Flux and massflux: Return Empty Vector for Inactive Phases

This commit introduces a new (private) predicate function

  ECLFluxCalc::phaseIsActive(const ECLPhaseIndex phase) const

that identifies whether or not 'phase' is active in the current
simulation model/result set.  This enables returning an empty result
vector from flux() and/or masssflux() in the case of the caller
requesting fluxes for inactive phases.  That, in turn, mirrors the
behaviour of ECLGraph::flux() on inactive phases and promotes
uniform phase treatment in calling code irrespective of using stored
or calculated flux values.
This commit is contained in:
Bård Skaflestad 2018-11-13 00:34:02 +01:00
parent 3b9cdf5a92
commit 78dfbfea6b
2 changed files with 25 additions and 0 deletions

View File

@ -208,6 +208,11 @@ namespace Opm
ECLFluxCalc::flux(const ECLRestartData& rstrt,
const ECLPhaseIndex phase) const
{
if (! this->phaseIsActive(phase)) {
// Inactive phase. Return empty flux vector.
return {};
}
// Obtain dynamic data.
const auto dyn_data = this->phaseProperties(rstrt, phase);
@ -225,6 +230,11 @@ namespace Opm
ECLFluxCalc::massflux(const ECLRestartData& rstrt,
const ECLPhaseIndex phase) const
{
if (! this->phaseIsActive(phase)) {
// Inactive phase. Return empty (mass) flux vector.
return {};
}
// Obtain dynamic data.
const auto dyn_data = this->phaseProperties(rstrt, phase);
@ -297,6 +307,19 @@ namespace Opm
}
bool ECLFluxCalc::phaseIsActive(const ECLPhaseIndex phase) const
{
switch (phase) {
case ECLPhaseIndex::Aqua: return this->pvtWat_ != nullptr;
case ECLPhaseIndex::Liquid: return this->pvtOil_ != nullptr;
case ECLPhaseIndex::Vapour: return this->pvtGas_ != nullptr;
}
throw std::invalid_argument {
"phaseIsActive(): Invalid Phase Identifier"
};
}
ECLFluxCalc::DynamicData
ECLFluxCalc::phaseProperties(const ECLRestartData& rstrt,

View File

@ -131,6 +131,8 @@ namespace Opm
const DynamicData& dyn_data) const;
bool phaseIsActive(const ECLPhaseIndex phase) const;
DynamicData gasPVT(const ECLRestartData& rstrt,
DynamicData&& dyn_data) const;