Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- changed assert to throw #829

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 42 additions & 13 deletions opm/models/blackoil/blackoilintensivequantities.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "blackoilmicpmodules.hh"

#include <opm/common/TimingMacros.hpp>
#include <opm/common/Exceptions.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>

#include <opm/input/eclipse/EclipseState/Grid/FaceDir.hpp>
Expand Down Expand Up @@ -156,8 +157,8 @@ public:
if (compositionSwitchEnabled) {
fluidState_.setRs(0.0);
fluidState_.setRv(0.0);
}
if (enableEvaporation) {
}
if (enableEvaporation) {
fluidState_.setRvw(0.0);
}
if (has_disgas_in_water) {
Expand Down Expand Up @@ -472,22 +473,50 @@ public:

// update the diffusion specific quantities of the intensive quantities
DiffusionIntensiveQuantities::update_(fluidState_, paramCache, elemCtx, dofIdx, timeIdx);

#ifndef NDEBUG
// some safety checks in debug mode
#ifndef NOT_CHECK_STATE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the new name (that nobody knows)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Becase NDEBUG is on in production code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Becase NDEBUG is on in production code.

I think you meant NDEBUG is off in production code with default -DWITH_NDEBUG=0

-O3 -DNDEBUG -mtune=native -UNDEBUG

bool is_ok = true;
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
if (!FluidSystem::phaseIsActive(phaseIdx))
continue;
if(fluidState_.density(phaseIdx)< 0){
is_ok = false;
}
if(fluidState_.temperature(phaseIdx) < 0){
is_ok = false;
}
if(fluidState_.viscosity(phaseIdx) < 0.0){
is_ok = false;
}
if(this->mobility(phaseIdx) < 0.0){
is_ok = false;
}
if(this->porosity() < 0.0){
is_ok = false;
}
if(this->rockCompTransMultiplier() < 0.0){
is_ok = false;
}
if(this->referencePorosity() < 0.0){
is_ok = false;
}
if(fluidState_.invB(phaseIdx) < 0.0){
is_ok = false;
}

assert(isfinite(fluidState_.density(phaseIdx)));
assert(isfinite(fluidState_.saturation(phaseIdx)));
assert(isfinite(fluidState_.temperature(phaseIdx)));
assert(isfinite(fluidState_.pressure(phaseIdx)));
assert(isfinite(fluidState_.invB(phaseIdx)));
}
assert(isfinite(fluidState_.Rs()));
assert(isfinite(fluidState_.Rv()));
is_ok = true;
is_ok = is_ok && isfinite(fluidState_.density(phaseIdx));
is_ok = is_ok && isfinite(fluidState_.saturation(phaseIdx));
is_ok = is_ok && isfinite(fluidState_.temperature(phaseIdx));
is_ok = is_ok && isfinite(fluidState_.pressure(phaseIdx));
is_ok = is_ok && isfinite(fluidState_.invB(phaseIdx));
is_ok = is_ok && isfinite(fluidState_.viscosity(phaseIdx));

}
is_ok = is_ok && isfinite(fluidState_.Rs());
is_ok = is_ok && isfinite(fluidState_.Rv());
if( !is_ok ){
throw MaterialLawProblem("Non valid fluid state: infinite values, negative none valid values");
}
#endif
}

Expand Down