From 2e2a49b935b54452891ff2801275e042a0c5eeea Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 19 Dec 2022 09:52:48 +0100 Subject: [PATCH] MultisegmentWell: move volumeFractionScaled to MultisegmentWellPrimaryVariables --- opm/simulators/wells/MultisegmentWellEval.cpp | 27 +++++-------------- opm/simulators/wells/MultisegmentWellEval.hpp | 4 --- .../MultisegmentWellPrimaryVariables.cpp | 17 ++++++++++++ .../MultisegmentWellPrimaryVariables.hpp | 11 +++++--- 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/opm/simulators/wells/MultisegmentWellEval.cpp b/opm/simulators/wells/MultisegmentWellEval.cpp index 0cf467fb7..333ad7991 100644 --- a/opm/simulators/wells/MultisegmentWellEval.cpp +++ b/opm/simulators/wells/MultisegmentWellEval.cpp @@ -171,23 +171,6 @@ getWellConvergence(const WellState& well_state, return report; } -template -typename MultisegmentWellEval::EvalWell -MultisegmentWellEval:: -volumeFractionScaled(const int seg, - const int comp_idx) const -{ - // For reservoir rate control, the distr in well control is used for the - // rate conversion coefficients. For the injection well, only the distr of the injection - // phase is not zero. - const double scale = baseif_.scalingFactor(baseif_.ebosCompIdxToFlowCompIdx(comp_idx)); - if (scale > 0.) { - return primary_variables_.volumeFraction(seg, comp_idx) / scale; - } - - return primary_variables_.volumeFraction(seg, comp_idx); -} - template typename MultisegmentWellEval::EvalWell MultisegmentWellEval:: @@ -196,12 +179,12 @@ surfaceVolumeFraction(const int seg, { EvalWell sum_volume_fraction_scaled = 0.; for (int idx = 0; idx < baseif_.numComponents(); ++idx) { - sum_volume_fraction_scaled += volumeFractionScaled(seg, idx); + sum_volume_fraction_scaled += primary_variables_.volumeFractionScaled(seg, idx); } assert(sum_volume_fraction_scaled.value() != 0.); - return volumeFractionScaled(seg, comp_idx) / sum_volume_fraction_scaled; + return primary_variables_.volumeFractionScaled(seg, comp_idx) / sum_volume_fraction_scaled; } template @@ -237,7 +220,8 @@ getSegmentRateUpwinding(const int seg, return 0.0; } - const EvalWell segment_rate = primary_variables_.evaluation_[seg][WQTotal] * volumeFractionScaled(seg_upwind, comp_idx); + const EvalWell segment_rate = primary_variables_.evaluation_[seg][WQTotal] * + primary_variables_.volumeFractionScaled(seg_upwind, comp_idx); assert(segment_rate.derivative(SPres + Indices::numEq) == 0.); @@ -452,7 +436,8 @@ MultisegmentWellEval:: getSegmentRate(const int seg, const int comp_idx) const { - return primary_variables_.evaluation_[seg][WQTotal] * volumeFractionScaled(seg, comp_idx); + return primary_variables_.evaluation_[seg][WQTotal] * + primary_variables_.volumeFractionScaled(seg, comp_idx); } template diff --git a/opm/simulators/wells/MultisegmentWellEval.hpp b/opm/simulators/wells/MultisegmentWellEval.hpp index e5c3012d4..dc506a2ce 100644 --- a/opm/simulators/wells/MultisegmentWellEval.hpp +++ b/opm/simulators/wells/MultisegmentWellEval.hpp @@ -186,10 +186,6 @@ protected: const double rho, DeferredLogger& deferred_logger) const; - // F_p / g_p, the basic usage of this value is because Q_p = G_t * F_p / G_p - EvalWell volumeFractionScaled(const int seg, - const int comp_idx) const; - // basically Q_p / \sigma_p Q_p EvalWell surfaceVolumeFraction(const int seg, const int comp_idx) const; diff --git a/opm/simulators/wells/MultisegmentWellPrimaryVariables.cpp b/opm/simulators/wells/MultisegmentWellPrimaryVariables.cpp index 31d0bd15f..af4959f43 100644 --- a/opm/simulators/wells/MultisegmentWellPrimaryVariables.cpp +++ b/opm/simulators/wells/MultisegmentWellPrimaryVariables.cpp @@ -288,6 +288,23 @@ volumeFraction(const int seg, return oil_fraction; } +template +typename MultisegmentWellPrimaryVariables::EvalWell +MultisegmentWellPrimaryVariables:: +volumeFractionScaled(const int seg, + const int comp_idx) const +{ + // For reservoir rate control, the distr in well control is used for the + // rate conversion coefficients. For the injection well, only the distr of the injection + // phase is not zero. + const double scale = well_.scalingFactor(well_.ebosCompIdxToFlowCompIdx(comp_idx)); + if (scale > 0.) { + return this->volumeFraction(seg, comp_idx) / scale; + } + + return this->volumeFraction(seg, comp_idx); +} + #define INSTANCE(...) \ template class MultisegmentWellPrimaryVariables,__VA_ARGS__,double>; diff --git a/opm/simulators/wells/MultisegmentWellPrimaryVariables.hpp b/opm/simulators/wells/MultisegmentWellPrimaryVariables.hpp index 5126756a5..4b0dd3e13 100644 --- a/opm/simulators/wells/MultisegmentWellPrimaryVariables.hpp +++ b/opm/simulators/wells/MultisegmentWellPrimaryVariables.hpp @@ -94,9 +94,10 @@ public: const double DFLimit, const double max_pressure_change); - //! \brief Returns volume fraction for component in a segment. - EvalWell volumeFraction(const int seg, - const unsigned compIdx) const; + //! \brief Returns scaled volume fraction for a component in a segment. + //! \details F_p / g_p, the basic usage of this value is because Q_p = G_t * F_p / G_p + EvalWell volumeFractionScaled(const int seg, + const int compIdx) const; // the values for the primary varibles // based on different solutioin strategies, the wells can have different primary variables @@ -109,6 +110,10 @@ private: //! \brief Handle non-reasonable fractions due to numerical overshoot. void processFractions(const int seg); + //! \brief Returns volume fraction for component in a segment. + EvalWell volumeFraction(const int seg, + const unsigned compIdx) const; + const WellInterfaceIndices& well_; //!< Reference to well interface };