Throw exception instead of using assert

Throw an exception if two-phase gas lift optimization is used for
other phases than oil and water.
This commit is contained in:
Håkon Hægland 2022-03-07 15:58:11 +01:00
parent 438a712e54
commit 3cf181b2ee
2 changed files with 23 additions and 13 deletions

View File

@ -156,11 +156,7 @@ setupPhaseVariables_()
{
const auto& pu = this->phase_usage_;
bool num_phases_ok = (pu.num_phases == 3);
if (pu.num_phases == 2
&& pu.phase_used[BlackoilPhases::Aqua] == 1
&& pu.phase_used[BlackoilPhases::Liquid] == 1
&& pu.phase_used[BlackoilPhases::Vapour] == 0)
{
if (pu.num_phases == 2) {
// NOTE: We support two-phase oil-water flow, by setting the gas flow rate
// to zero. This is done by initializing the potential vector to zero:
//
@ -171,7 +167,16 @@ setupPhaseVariables_()
// has been adapted to the two-phase oil-water case, see the comment
// in WellInterfaceGeneric.cpp for the method adaptRatesForVFP() for
// more information.
num_phases_ok = true; // two-phase oil-water is also supported
if ( pu.phase_used[BlackoilPhases::Aqua] == 1
&& pu.phase_used[BlackoilPhases::Liquid] == 1
&& pu.phase_used[BlackoilPhases::Vapour] == 0)
{
num_phases_ok = true; // two-phase oil-water is also supported
}
else {
throw std::logic_error("Two-phase gas lift optimization only supported"
" for oil and water");
}
}
assert(num_phases_ok);
this->oil_pos_ = pu.phase_pos[Oil];

View File

@ -109,13 +109,18 @@ WellInterfaceGeneric::WellInterfaceGeneric(const Well& well,
void WellInterfaceGeneric::adaptRatesForVFP(std::vector<double>& rates) const
{
const auto& pu = this->phaseUsage();
if (pu.num_phases == 2
&& pu.phase_used[BlackoilPhases::Aqua] == 1
&& pu.phase_used[BlackoilPhases::Liquid] == 1
&& pu.phase_used[BlackoilPhases::Vapour] == 0)
{
assert(rates.size() == 2);
rates.push_back(0.0); // set gas rate to zero
if (pu.num_phases == 2) {
if ( pu.phase_used[BlackoilPhases::Aqua] == 1
&& pu.phase_used[BlackoilPhases::Liquid] == 1
&& pu.phase_used[BlackoilPhases::Vapour] == 0)
{
assert(rates.size() == 2);
rates.push_back(0.0); // set gas rate to zero
}
else {
throw std::logic_error("Two-phase VFP calculation only "
"supported for oil and water");
}
}
}