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
+12 -7
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");
}
}
}