mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-10-25 23:20:12 -05:00
Use if constexpr to handle conditionally stored members.
Also added some more convenience enums to avoid repeated getPropValue() clutter.
This commit is contained in:
1 parent
4a5d5a001e
commit
521a252300
6 files changed
+144
-111
No files matched your search
@@ -146,11 +146,11 @@ public:
|
||||
|
||||
BlackOilIntensiveQuantitiesGlobalIndex()
|
||||
{
|
||||
if (compositionSwitchEnabled) {
|
||||
if constexpr (compositionSwitchEnabled) {
|
||||
fluidState_.setRs(0.0);
|
||||
fluidState_.setRv(0.0);
|
||||
}
|
||||
if (enableVapwat) {
|
||||
if constexpr (enableVapwat) {
|
||||
fluidState_.setRvw(0.0);
|
||||
}
|
||||
}
|
||||
@@ -301,17 +301,19 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if (priVars.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Rvw) {
|
||||
const auto& Rvw = priVars.makeEvaluation(Indices::waterSwitchIdx, timeIdx);
|
||||
fluidState_.setRvw(Rvw);
|
||||
} else {
|
||||
//NB! should save the indexing for later evaluation
|
||||
if (FluidSystem::enableVaporizedWater()) { // Add Sg > 0? i.e. if only water set rv = 0)
|
||||
OPM_TIMEBLOCK_LOCAL(UpdateSaturatedRv);
|
||||
const Evaluation& RvwSat = FluidSystem::saturatedVaporizationFactor(fluidState_,
|
||||
gasPhaseIdx,
|
||||
pvtRegionIdx);
|
||||
fluidState_.setRvw(RvwSat);
|
||||
if constexpr (enableVapwat) {
|
||||
if (priVars.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Rvw) {
|
||||
const auto& Rvw = priVars.makeEvaluation(Indices::waterSwitchIdx, timeIdx);
|
||||
fluidState_.setRvw(Rvw);
|
||||
} else {
|
||||
//NB! should save the indexing for later evaluation
|
||||
if (FluidSystem::enableVaporizedWater()) { // Add Sg > 0? i.e. if only water set rv = 0)
|
||||
OPM_TIMEBLOCK_LOCAL(UpdateSaturatedRv);
|
||||
const Evaluation& RvwSat = FluidSystem::saturatedVaporizationFactor(fluidState_,
|
||||
gasPhaseIdx,
|
||||
pvtRegionIdx);
|
||||
fluidState_.setRvw(RvwSat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ class BlackOilIntensiveQuantities
|
||||
enum { enableFoam = getPropValue<TypeTag, Properties::EnableFoam>() };
|
||||
enum { enableBrine = getPropValue<TypeTag, Properties::EnableBrine>() };
|
||||
enum { enableVapwat = getPropValue<TypeTag, Properties::EnableVapwat>() };
|
||||
enum { has_disgas_in_water = getPropValue<TypeTag, Properties::EnableDisgasInWater>() };
|
||||
enum { enableDisgasInWater = getPropValue<TypeTag, Properties::EnableDisgasInWater>() };
|
||||
enum { enableSaltPrecipitation = getPropValue<TypeTag, Properties::EnableSaltPrecipitation>() };
|
||||
enum { enableTemperature = getPropValue<TypeTag, Properties::EnableTemperature>() };
|
||||
enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
enableVapwat,
|
||||
enableBrine,
|
||||
enableSaltPrecipitation,
|
||||
has_disgas_in_water,
|
||||
enableDisgasInWater,
|
||||
Indices::numPhases>;
|
||||
using ScalarFluidState = BlackOilFluidState<Scalar,
|
||||
FluidSystem,
|
||||
@@ -157,7 +157,7 @@ public:
|
||||
enableVapwat,
|
||||
enableBrine,
|
||||
enableSaltPrecipitation,
|
||||
has_disgas_in_water,
|
||||
enableDisgasInWater,
|
||||
Indices::numPhases>;
|
||||
using Problem = GetPropType<TypeTag, Properties::Problem>;
|
||||
|
||||
@@ -166,11 +166,11 @@ public:
|
||||
if constexpr (compositionSwitchEnabled) {
|
||||
fluidState_.setRs(0.0);
|
||||
fluidState_.setRv(0.0);
|
||||
}
|
||||
}
|
||||
if constexpr (enableVapwat) {
|
||||
fluidState_.setRvw(0.0);
|
||||
}
|
||||
if constexpr (has_disgas_in_water) {
|
||||
if constexpr (enableDisgasInWater) {
|
||||
fluidState_.setRsw(0.0);
|
||||
}
|
||||
}
|
||||
@@ -361,69 +361,72 @@ public:
|
||||
|
||||
// take the meaning of the switching primary variable into account for the gas
|
||||
// and oil phase compositions
|
||||
if (priVars.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Rs) {
|
||||
const auto& Rs = priVars.makeEvaluation(Indices::compositionSwitchIdx, timeIdx);
|
||||
fluidState_.setRs(Rs);
|
||||
}
|
||||
else {
|
||||
if (FluidSystem::enableDissolvedGas()) { // Add So > 0? i.e. if only water set rs = 0)
|
||||
const Evaluation& RsSat = enableExtbo ? asImp_().rs() :
|
||||
FluidSystem::saturatedDissolutionFactor(fluidState_,
|
||||
oilPhaseIdx,
|
||||
pvtRegionIdx,
|
||||
SoMax);
|
||||
fluidState_.setRs(min(RsMax, RsSat));
|
||||
|
||||
if constexpr (compositionSwitchEnabled) {
|
||||
if (priVars.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Rs) {
|
||||
const auto& Rs = priVars.makeEvaluation(Indices::compositionSwitchIdx, timeIdx);
|
||||
fluidState_.setRs(Rs);
|
||||
}
|
||||
else {
|
||||
if constexpr (compositionSwitchEnabled) {
|
||||
if (FluidSystem::enableDissolvedGas()) { // Add So > 0? i.e. if only water set rs = 0)
|
||||
const Evaluation& RsSat = enableExtbo ? asImp_().rs() :
|
||||
FluidSystem::saturatedDissolutionFactor(fluidState_,
|
||||
oilPhaseIdx,
|
||||
pvtRegionIdx,
|
||||
SoMax);
|
||||
fluidState_.setRs(min(RsMax, RsSat));
|
||||
}
|
||||
else {
|
||||
fluidState_.setRs(0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (priVars.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Rv) {
|
||||
const auto& Rv = priVars.makeEvaluation(Indices::compositionSwitchIdx, timeIdx);
|
||||
fluidState_.setRv(Rv);
|
||||
}
|
||||
else {
|
||||
if (FluidSystem::enableVaporizedOil() ) { // Add Sg > 0? i.e. if only water set rv = 0)
|
||||
const Evaluation& RvSat = enableExtbo ? asImp_().rv() :
|
||||
FluidSystem::saturatedDissolutionFactor(fluidState_,
|
||||
gasPhaseIdx,
|
||||
pvtRegionIdx,
|
||||
SoMax);
|
||||
fluidState_.setRv(min(RvMax, RvSat));
|
||||
if (priVars.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Rv) {
|
||||
const auto& Rv = priVars.makeEvaluation(Indices::compositionSwitchIdx, timeIdx);
|
||||
fluidState_.setRv(Rv);
|
||||
}
|
||||
else {
|
||||
if constexpr (compositionSwitchEnabled) {
|
||||
if (FluidSystem::enableVaporizedOil() ) { // Add Sg > 0? i.e. if only water set rv = 0)
|
||||
const Evaluation& RvSat = enableExtbo ? asImp_().rv() :
|
||||
FluidSystem::saturatedDissolutionFactor(fluidState_,
|
||||
gasPhaseIdx,
|
||||
pvtRegionIdx,
|
||||
SoMax);
|
||||
fluidState_.setRv(min(RvMax, RvSat));
|
||||
}
|
||||
else {
|
||||
fluidState_.setRv(0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (priVars.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Rvw) {
|
||||
const auto& Rvw = priVars.makeEvaluation(Indices::waterSwitchIdx, timeIdx);
|
||||
fluidState_.setRvw(Rvw);
|
||||
}
|
||||
else {
|
||||
if (FluidSystem::enableVaporizedWater()) { // Add Sg > 0? i.e. if only water set rv = 0)
|
||||
const Evaluation& RvwSat = FluidSystem::saturatedVaporizationFactor(fluidState_,
|
||||
gasPhaseIdx,
|
||||
pvtRegionIdx);
|
||||
fluidState_.setRvw(RvwSat);
|
||||
if constexpr (enableVapwat) {
|
||||
if (priVars.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Rvw) {
|
||||
const auto& Rvw = priVars.makeEvaluation(Indices::waterSwitchIdx, timeIdx);
|
||||
fluidState_.setRvw(Rvw);
|
||||
}
|
||||
else {
|
||||
if (FluidSystem::enableVaporizedWater()) { // Add Sg > 0? i.e. if only water set rv = 0)
|
||||
const Evaluation& RvwSat = FluidSystem::saturatedVaporizationFactor(fluidState_,
|
||||
gasPhaseIdx,
|
||||
pvtRegionIdx);
|
||||
fluidState_.setRvw(RvwSat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (priVars.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Rsw) {
|
||||
const auto& Rsw = priVars.makeEvaluation(Indices::waterSwitchIdx, timeIdx);
|
||||
fluidState_.setRsw(Rsw);
|
||||
}
|
||||
else {
|
||||
if (FluidSystem::enableDissolvedGasInWater()) {
|
||||
const Evaluation& RswSat = FluidSystem::saturatedDissolutionFactor(fluidState_,
|
||||
waterPhaseIdx,
|
||||
pvtRegionIdx);
|
||||
fluidState_.setRsw(min(RswMax, RswSat));
|
||||
if constexpr (enableDisgasInWater) {
|
||||
if (priVars.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Rsw) {
|
||||
const auto& Rsw = priVars.makeEvaluation(Indices::waterSwitchIdx, timeIdx);
|
||||
fluidState_.setRsw(Rsw);
|
||||
}
|
||||
else {
|
||||
if (FluidSystem::enableDissolvedGasInWater()) {
|
||||
const Evaluation& RswSat = FluidSystem::saturatedDissolutionFactor(fluidState_,
|
||||
waterPhaseIdx,
|
||||
pvtRegionIdx);
|
||||
fluidState_.setRsw(min(RswMax, RswSat));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -159,11 +159,11 @@ public:
|
||||
{
|
||||
exteriorIdx_ = static_cast<unsigned short>(localNeighborIdx);
|
||||
|
||||
if (needNormal) {
|
||||
if constexpr (needNormal) {
|
||||
(*normal_) = intersection.centerUnitOuterNormal();
|
||||
}
|
||||
const auto& geometry = intersection.geometry();
|
||||
if (needIntegrationPos) {
|
||||
if constexpr (needIntegrationPos) {
|
||||
(*integrationPos_) = geometry.center();
|
||||
}
|
||||
area_ = geometry.volume();
|
||||
|
||||
@@ -80,8 +80,8 @@ class EquilInitializer
|
||||
enum { enableBrine = getPropValue<TypeTag, Properties::EnableBrine>() };
|
||||
enum { enableVapwat = getPropValue<TypeTag, Properties::EnableVapwat>() };
|
||||
enum { enableSaltPrecipitation = getPropValue<TypeTag, Properties::EnableSaltPrecipitation>() };
|
||||
enum { has_disgas_in_water = getPropValue<TypeTag, Properties::EnableDisgasInWater>() };
|
||||
|
||||
enum { enableDisgasInWater = getPropValue<TypeTag, Properties::EnableDisgasInWater>() };
|
||||
enum { enableDissolvedGas = Indices::compositionSwitchIdx >= 0 };
|
||||
|
||||
public:
|
||||
// NB: setting the enableEnergy argument to true enables storage of enthalpy and
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
enableVapwat,
|
||||
enableBrine,
|
||||
enableSaltPrecipitation,
|
||||
has_disgas_in_water,
|
||||
enableDisgasInWater,
|
||||
Indices::numPhases>;
|
||||
|
||||
|
||||
@@ -141,18 +141,21 @@ public:
|
||||
fluidState.setSaturation(phaseIdx, 0.0);
|
||||
}
|
||||
|
||||
if (FluidSystem::enableDissolvedGas())
|
||||
fluidState.setRs(initialState.rs()[elemIdx]);
|
||||
else if (Indices::gasEnabled && Indices::oilEnabled)
|
||||
fluidState.setRs(0.0);
|
||||
if constexpr (enableDissolvedGas) {
|
||||
if (FluidSystem::enableDissolvedGas())
|
||||
fluidState.setRs(initialState.rs()[elemIdx]);
|
||||
else if (Indices::gasEnabled && Indices::oilEnabled)
|
||||
fluidState.setRs(0.0);
|
||||
if (FluidSystem::enableVaporizedOil())
|
||||
fluidState.setRv(initialState.rv()[elemIdx]);
|
||||
else if (Indices::gasEnabled && Indices::oilEnabled)
|
||||
fluidState.setRv(0.0);
|
||||
}
|
||||
|
||||
if (FluidSystem::enableVaporizedOil())
|
||||
fluidState.setRv(initialState.rv()[elemIdx]);
|
||||
else if (Indices::gasEnabled && Indices::oilEnabled)
|
||||
fluidState.setRv(0.0);
|
||||
|
||||
if (FluidSystem::enableVaporizedWater())
|
||||
fluidState.setRvw(initialState.rvw()[elemIdx]);
|
||||
if constexpr (enableVapwat) {
|
||||
if (FluidSystem::enableVaporizedWater())
|
||||
fluidState.setRvw(initialState.rvw()[elemIdx]);
|
||||
}
|
||||
|
||||
// set the temperature.
|
||||
if (enableTemperature || enableEnergy)
|
||||
@@ -170,7 +173,7 @@ public:
|
||||
const auto& rho = FluidSystem::density(fluidState, phaseIdx, regionIdx);
|
||||
fluidState.setDensity(phaseIdx, rho);
|
||||
|
||||
if (enableEnergy) {
|
||||
if constexpr (enableEnergy) {
|
||||
const auto& h = FluidSystem::enthalpy(fluidState, phaseIdx, regionIdx);
|
||||
fluidState.setEnthalpy(phaseIdx, h);
|
||||
}
|
||||
|
||||
@@ -132,6 +132,10 @@ private:
|
||||
using typename FlowProblemType::MaterialLaw;
|
||||
using typename FlowProblemType::DimMatrix;
|
||||
|
||||
enum { enableDissolvedGas = Indices::compositionSwitchIdx >= 0 };
|
||||
enum { enableVapwat = getPropValue<TypeTag, Properties::EnableVapwat>() };
|
||||
enum { enableDisgasInWater = getPropValue<TypeTag, Properties::EnableDisgasInWater>() };
|
||||
|
||||
using SolventModule = BlackOilSolventModule<TypeTag>;
|
||||
using PolymerModule = BlackOilPolymerModule<TypeTag>;
|
||||
using FoamModule = BlackOilFoamModule<TypeTag>;
|
||||
@@ -797,15 +801,22 @@ public:
|
||||
temperature = *temperature_input;
|
||||
fluidState.setTemperature(temperature);
|
||||
|
||||
if (FluidSystem::enableDissolvedGas()) {
|
||||
fluidState.setRs(0.0);
|
||||
fluidState.setRv(0.0);
|
||||
if constexpr (enableDissolvedGas) {
|
||||
if (FluidSystem::enableDissolvedGas()) {
|
||||
fluidState.setRs(0.0);
|
||||
fluidState.setRv(0.0);
|
||||
}
|
||||
}
|
||||
if (FluidSystem::enableDissolvedGasInWater()) {
|
||||
fluidState.setRsw(0.0);
|
||||
if constexpr (enableDisgasInWater) {
|
||||
if (FluidSystem::enableDissolvedGasInWater()) {
|
||||
fluidState.setRsw(0.0);
|
||||
}
|
||||
}
|
||||
if constexpr (enableVapwat) {
|
||||
if (FluidSystem::enableVaporizedWater()) {
|
||||
fluidState.setRvw(0.0);
|
||||
}
|
||||
}
|
||||
if (FluidSystem::enableVaporizedWater())
|
||||
fluidState.setRvw(0.0);
|
||||
|
||||
for (unsigned activePhaseIdx = 0; activePhaseIdx < FluidSystem::numActivePhases(); ++activePhaseIdx) {
|
||||
const auto phaseIdx = FluidSystem::activeToCanonicalPhaseIdx(activePhaseIdx);
|
||||
@@ -815,7 +826,7 @@ public:
|
||||
|
||||
const auto& rho = FluidSystem::density(fluidState, phaseIdx, pvtRegionIdx);
|
||||
fluidState.setDensity(phaseIdx, rho);
|
||||
if (enableEnergy) {
|
||||
if constexpr (enableEnergy) {
|
||||
const auto& h = FluidSystem::enthalpy(fluidState, phaseIdx, pvtRegionIdx);
|
||||
fluidState.setEnthalpy(phaseIdx, h);
|
||||
}
|
||||
@@ -1424,21 +1435,26 @@ protected:
|
||||
dofFluidState.setPressure(phaseIdx, pressure);
|
||||
}
|
||||
|
||||
if (FluidSystem::enableDissolvedGas())
|
||||
dofFluidState.setRs(rsData[dofIdx]);
|
||||
else if (Indices::gasEnabled && Indices::oilEnabled)
|
||||
dofFluidState.setRs(0.0);
|
||||
if constexpr (enableDissolvedGas) {
|
||||
if (FluidSystem::enableDissolvedGas())
|
||||
dofFluidState.setRs(rsData[dofIdx]);
|
||||
else if (Indices::gasEnabled && Indices::oilEnabled)
|
||||
dofFluidState.setRs(0.0);
|
||||
if (FluidSystem::enableVaporizedOil())
|
||||
dofFluidState.setRv(rvData[dofIdx]);
|
||||
else if (Indices::gasEnabled && Indices::oilEnabled)
|
||||
dofFluidState.setRv(0.0);
|
||||
}
|
||||
|
||||
if (FluidSystem::enableDissolvedGasInWater() && has_rsw)
|
||||
dofFluidState.setRsw(rswData[dofIdx]);
|
||||
if constexpr (enableDisgasInWater) {
|
||||
if (FluidSystem::enableDissolvedGasInWater() && has_rsw)
|
||||
dofFluidState.setRsw(rswData[dofIdx]);
|
||||
}
|
||||
|
||||
if (FluidSystem::enableVaporizedOil())
|
||||
dofFluidState.setRv(rvData[dofIdx]);
|
||||
else if (Indices::gasEnabled && Indices::oilEnabled)
|
||||
dofFluidState.setRv(0.0);
|
||||
|
||||
if (FluidSystem::enableVaporizedWater())
|
||||
dofFluidState.setRvw(rvwData[dofIdx]);
|
||||
if constexpr (enableVapwat) {
|
||||
if (FluidSystem::enableVaporizedWater())
|
||||
dofFluidState.setRvw(rvwData[dofIdx]);
|
||||
}
|
||||
|
||||
//////
|
||||
// set invB_
|
||||
|
||||
@@ -115,6 +115,9 @@ class OutputBlackOilModule : public GenericOutputBlackoilModule<GetPropType<Type
|
||||
static constexpr int waterCompIdx = FluidSystem::waterCompIdx;
|
||||
enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
|
||||
enum { enableMICP = getPropValue<TypeTag, Properties::EnableMICP>() };
|
||||
enum { enableVapwat = getPropValue<TypeTag, Properties::EnableVapwat>() };
|
||||
enum { enableDisgasInWater = getPropValue<TypeTag, Properties::EnableDisgasInWater>() };
|
||||
enum { enableDissolvedGas = Indices::compositionSwitchIdx >= 0 };
|
||||
|
||||
template<int idx, class VectorType>
|
||||
static Scalar value_or_zero(const VectorType& v)
|
||||
@@ -533,14 +536,20 @@ public:
|
||||
|
||||
if (!this->temperature_.empty())
|
||||
fs.setTemperature(this->temperature_[elemIdx]);
|
||||
if (!this->rs_.empty())
|
||||
fs.setRs(this->rs_[elemIdx]);
|
||||
if (!this->rsw_.empty())
|
||||
fs.setRsw(this->rsw_[elemIdx]);
|
||||
if (!this->rv_.empty())
|
||||
fs.setRv(this->rv_[elemIdx]);
|
||||
if (!this->rvw_.empty())
|
||||
fs.setRvw(this->rvw_[elemIdx]);
|
||||
if constexpr (enableDissolvedGas) {
|
||||
if (!this->rs_.empty())
|
||||
fs.setRs(this->rs_[elemIdx]);
|
||||
if (!this->rv_.empty())
|
||||
fs.setRv(this->rv_[elemIdx]);
|
||||
}
|
||||
if constexpr (enableDisgasInWater) {
|
||||
if (!this->rsw_.empty())
|
||||
fs.setRsw(this->rsw_[elemIdx]);
|
||||
}
|
||||
if constexpr (enableVapwat) {
|
||||
if (!this->rvw_.empty())
|
||||
fs.setRvw(this->rvw_[elemIdx]);
|
||||
}
|
||||
}
|
||||
|
||||
void initHysteresisParams(Simulator& simulator, unsigned elemIdx) const
|
||||
|
||||
Reference in new issue
Block a user