From 404164417138849b3500b58ce7d6cd88cc7f707e Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 5 May 2023 09:55:26 +0200 Subject: [PATCH] changed: put calculation of foam connection rate in separate method --- opm/simulators/wells/StandardWell.hpp | 4 ++ opm/simulators/wells/StandardWell_impl.hpp | 66 +++++++++++++--------- 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/opm/simulators/wells/StandardWell.hpp b/opm/simulators/wells/StandardWell.hpp index 98dd4037c..b2174453b 100644 --- a/opm/simulators/wells/StandardWell.hpp +++ b/opm/simulators/wells/StandardWell.hpp @@ -443,6 +443,10 @@ namespace Opm const std::vector& cq_s, const IntensiveQuantities& intQuants) const; + Eval connectionRateFoam(const std::vector& cq_s, + const IntensiveQuantities& intQuants, + DeferredLogger& deferred_logger) const; + std::tuple connectionRatesMICP(const std::vector& cq_s, const IntensiveQuantities& intQuants) const; diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index 1e29292bb..97dabdef9 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -715,33 +715,8 @@ namespace Opm } if constexpr (has_foam) { - // TODO: the application of well efficiency factor has not been tested with an example yet - auto getFoamTransportIdx = [&deferred_logger] { - switch (FoamModule::transportPhase()) { - case Phase::WATER: { - return Indices::canonicalToActiveComponentIndex(FluidSystem::waterCompIdx); - } - case Phase::GAS: { - return Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx); - } - case Phase::SOLVENT: { - if constexpr (has_solvent) - return (unsigned)Indices::contiSolventEqIdx; - else - OPM_DEFLOG_THROW(std::runtime_error, "Foam transport phase is SOLVENT but SOLVENT is not activated.", deferred_logger); - } - default: { - OPM_DEFLOG_THROW(std::runtime_error, "Foam transport phase must be GAS/WATER/SOLVENT.", deferred_logger); - } - } - }; - EvalWell cq_s_foam = cq_s[getFoamTransportIdx()] * this->well_efficiency_factor_; - if (this->isInjector()) { - cq_s_foam *= this->wfoam(); - } else { - cq_s_foam *= this->extendEval(intQuants.foamConcentration()); - } - connectionRates[perf][Indices::contiFoamEqIdx] = Base::restrictEval(cq_s_foam); + connectionRates[perf][Indices::contiFoamEqIdx] = + connectionRateFoam(cq_s, intQuants, deferred_logger); } if constexpr (has_zFraction) { @@ -2365,6 +2340,43 @@ namespace Opm } + template + typename StandardWell::Eval + StandardWell:: + connectionRateFoam(const std::vector& cq_s, + const IntensiveQuantities& intQuants, + DeferredLogger& deferred_logger) const + { + // TODO: the application of well efficiency factor has not been tested with an example yet + auto getFoamTransportIdx = [&deferred_logger] { + switch (FoamModule::transportPhase()) { + case Phase::WATER: { + return Indices::canonicalToActiveComponentIndex(FluidSystem::waterCompIdx); + } + case Phase::GAS: { + return Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx); + } + case Phase::SOLVENT: { + if constexpr (has_solvent) + return static_cast(Indices::contiSolventEqIdx); + else + OPM_DEFLOG_THROW(std::runtime_error, "Foam transport phase is SOLVENT but SOLVENT is not activated.", deferred_logger); + } + default: { + OPM_DEFLOG_THROW(std::runtime_error, "Foam transport phase must be GAS/WATER/SOLVENT.", deferred_logger); + } + } + }; + EvalWell cq_s_foam = cq_s[getFoamTransportIdx()] * this->well_efficiency_factor_; + if (this->isInjector()) { + cq_s_foam *= this->wfoam(); + } else { + cq_s_foam *= this->extendEval(intQuants.foamConcentration()); + } + return Base::restrictEval(cq_s_foam); + } + + template std::tuple::Eval, typename StandardWell::Eval,