mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
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:
parent
3b9cdf5a92
commit
78dfbfea6b
@ -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,
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user