From 84893437736cb8572b4579457e874d4e478b0046 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Fri, 20 Dec 2024 12:20:41 +0100 Subject: [PATCH 1/2] should not use phase index for canonicalToActiveComponentIndex() --- opm/simulators/wells/MultisegmentWellSegments.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/opm/simulators/wells/MultisegmentWellSegments.cpp b/opm/simulators/wells/MultisegmentWellSegments.cpp index f816f409115..cb49590cfe2 100644 --- a/opm/simulators/wells/MultisegmentWellSegments.cpp +++ b/opm/simulators/wells/MultisegmentWellSegments.cpp @@ -933,10 +933,10 @@ mixtureDensity(const int seg) const continue; } - const auto compIdx = Indices:: - canonicalToActiveComponentIndex(phIdx); + const auto active_comp_index = Indices:: + canonicalToActiveComponentIndex(FluidSystem::solventComponentIndex(phIdx)); - mixDens += q[compIdx].value() * rho[compIdx].value(); + mixDens += q[active_comp_index].value() * rho[active_comp_index].value(); } return mixDens; @@ -977,7 +977,7 @@ mixtureDensityWithExponents(const AutoICD& aicd, const int seg) const for (const auto& [fsPhaseIdx, densityExponent] : densityExponents) { if (FluidSystem::phaseIsActive(fsPhaseIdx)) { const auto compIdx = Indices:: - canonicalToActiveComponentIndex(fsPhaseIdx); + canonicalToActiveComponentIndex(FluidSystem::solventComponentIndex(fsPhaseIdx)); // exp = (aicd.*densityExponent)() in native syntax. const auto exp = std::invoke(densityExponent, aicd); From 343b98cab77ff0bf37197500d3422ffd856fdf04 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Fri, 20 Dec 2024 14:32:12 +0100 Subject: [PATCH 2/2] testing removing the extra parameter for assemblePressureEq() --- opm/simulators/wells/MultisegmentWellAssemble.cpp | 8 +++----- opm/simulators/wells/MultisegmentWellAssemble.hpp | 4 +--- opm/simulators/wells/MultisegmentWellEval.cpp | 4 +--- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/opm/simulators/wells/MultisegmentWellAssemble.cpp b/opm/simulators/wells/MultisegmentWellAssemble.cpp index 59c18ed1f29..f1eb0f275a3 100644 --- a/opm/simulators/wells/MultisegmentWellAssemble.cpp +++ b/opm/simulators/wells/MultisegmentWellAssemble.cpp @@ -279,9 +279,7 @@ assemblePressureEq(const int seg, const int outlet_segment_index, const EvalWell& pressure_equation, const EvalWell& outlet_pressure, - Equations& eqns1, - bool wfrac, - bool gfrac) const + Equations& eqns1) const { /* This method does *not* need communication. @@ -290,10 +288,10 @@ assemblePressureEq(const int seg, eqns.residual()[seg][SPres] += pressure_equation.value(); eqns.D()[seg][seg][SPres][SPres] += pressure_equation.derivative(SPres + Indices::numEq); eqns.D()[seg][seg][SPres][WQTotal] += pressure_equation.derivative(WQTotal + Indices::numEq); - if (wfrac) { + if (has_wfrac_variable) { eqns.D()[seg][seg_upwind][SPres][WFrac] += pressure_equation.derivative(WFrac + Indices::numEq); } - if (gfrac) { + if (has_gfrac_variable) { eqns.D()[seg][seg_upwind][SPres][GFrac] += pressure_equation.derivative(GFrac + Indices::numEq); } diff --git a/opm/simulators/wells/MultisegmentWellAssemble.hpp b/opm/simulators/wells/MultisegmentWellAssemble.hpp index 7340fa7dd71..e3fe97cbb36 100644 --- a/opm/simulators/wells/MultisegmentWellAssemble.hpp +++ b/opm/simulators/wells/MultisegmentWellAssemble.hpp @@ -107,9 +107,7 @@ class MultisegmentWellAssemble const int outlet_segment_index, const EvalWell& pressure_equation, const EvalWell& outlet_pressure, - Equations& eqns, - bool wfrac = has_wfrac_variable, - bool gfrac = has_gfrac_variable) const; + Equations& eqns) const; //! \brief Assembles a trivial equation. void assembleTrivialEq(const int seg, diff --git a/opm/simulators/wells/MultisegmentWellEval.cpp b/opm/simulators/wells/MultisegmentWellEval.cpp index aadf148108d..46762131429 100644 --- a/opm/simulators/wells/MultisegmentWellEval.cpp +++ b/opm/simulators/wells/MultisegmentWellEval.cpp @@ -368,9 +368,7 @@ assembleICDPressureEq(const int seg, MultisegmentWellAssemble(baseif_). assemblePressureEq(seg, seg_upwind, outlet_segment_index, pressure_equation, outlet_pressure, - linSys_, - FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx), - FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)); + linSys_); assembleAccelerationAndHydroPressureLosses(seg, well_state, use_average_density); }