From dd04eb128afd8e61b388c3b9fad94ad303385fce Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 14 May 2021 21:38:47 +0200 Subject: [PATCH] use if constexpr to eliminate some zFraction code --- opm/simulators/wells/StandardWell_impl.hpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index cf54f0ec4..cc2176184 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -394,10 +394,12 @@ namespace Opm b_perfcells_dense[contiSolventEqIdx] = extendEval(intQuants.solventInverseFormationVolumeFactor()); } - if (has_zFraction && this->isInjector()) { - const unsigned gasCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx); - b_perfcells_dense[gasCompIdx] *= (1.0 - wsolvent()); - b_perfcells_dense[gasCompIdx] += wsolvent()*intQuants.zPureInvFormationVolumeFactor().value(); + if constexpr (has_zFraction) { + if (this->isInjector()) { + const unsigned gasCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx); + b_perfcells_dense[gasCompIdx] *= (1.0 - wsolvent()); + b_perfcells_dense[gasCompIdx] += wsolvent()*intQuants.zPureInvFormationVolumeFactor().value(); + } } // Pressure drawdown (also used to determine direction of flow) @@ -626,7 +628,7 @@ namespace Opm } } - if (has_zFraction) { + if constexpr (has_zFraction) { for (int pvIdx = 0; pvIdx < numWellEq_; ++pvIdx) { duneC_[0][cell_idx][pvIdx][contiZfracEqIdx] -= cq_s_zfrac_effective.derivative(pvIdx+numEq); } @@ -805,7 +807,7 @@ namespace Opm connectionRates[perf][contiFoamEqIdx] = Base::restrictEval(cq_s_foam); } - if (has_zFraction) { + if constexpr (has_zFraction) { // TODO: the application of well efficiency factor has not been tested with an example yet const unsigned gasCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx); cq_s_zfrac_effective = cq_s[gasCompIdx];