From 45a968fe462ff1789fcee516e7756726cd156bf9 Mon Sep 17 00:00:00 2001 From: Paul Egberts Date: Mon, 22 Aug 2022 17:48:43 +0200 Subject: [PATCH 1/3] fix for gaswater system with water evaporation --- .../blackoil/blackoilprimaryvariables.hh | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/opm/models/blackoil/blackoilprimaryvariables.hh b/opm/models/blackoil/blackoilprimaryvariables.hh index 5cb26f10f..8014b3c64 100644 --- a/opm/models/blackoil/blackoilprimaryvariables.hh +++ b/opm/models/blackoil/blackoilprimaryvariables.hh @@ -498,14 +498,23 @@ public: Scalar So = 1.0 - Sw - Sg - solventSaturation_(); Scalar So3 = 1.0 - Sg - solventSaturation_(); + //water disappears - if(Sw < -eps && So3 > 0.0 && Sg > 0.0 && FluidSystem::enableVaporizedWater()) { - Scalar po = (*this)[Indices::pressureSwitchIdx]; + if(Sw < -eps && FluidSystem::enableVaporizedWater()) { + Scalar pg = 0.0; Scalar T = asImp_().temperature_(); - std::array pC = { 0.0 }; - const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx); - computeCapillaryPressures_(pC, So3, Sg + solventSaturation_(), /*Sw=*/ 0.0, matParams); - Scalar pg = po + (pC[gasPhaseIdx] - pC[oilPhaseIdx]); + if constexpr (waterEnabled && gasEnabled && !oilEnabled) { + // twophase water-gas system + pg = (*this)[Indices::pressureSwitchIdx]; + } + else if (So3 > 0.0 && Sg > 0.0) { + // threephase case + std::array pC = { 0.0 }; + const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx); + computeCapillaryPressures_(pC, So3, Sg + solventSaturation_(), /*Sw=*/ 0.0, matParams); + Scalar po = (*this)[Indices::pressureSwitchIdx]; + pg = po + (pC[gasPhaseIdx] - pC[oilPhaseIdx]); + } Scalar RvwSat = FluidSystem::gasPvt().saturatedWaterVaporizationFactor(pvtRegionIdx_, T, pg); From 38fb8e114bfba4ba35cb6cc4909a478978093aab Mon Sep 17 00:00:00 2001 From: Paul Egberts Date: Tue, 23 Aug 2022 11:56:50 +0200 Subject: [PATCH 2/3] removed constexpr in if - else construction --- opm/models/blackoil/blackoilprimaryvariables.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/models/blackoil/blackoilprimaryvariables.hh b/opm/models/blackoil/blackoilprimaryvariables.hh index 8014b3c64..286af02b0 100644 --- a/opm/models/blackoil/blackoilprimaryvariables.hh +++ b/opm/models/blackoil/blackoilprimaryvariables.hh @@ -503,7 +503,7 @@ public: if(Sw < -eps && FluidSystem::enableVaporizedWater()) { Scalar pg = 0.0; Scalar T = asImp_().temperature_(); - if constexpr (waterEnabled && gasEnabled && !oilEnabled) { + if (waterEnabled && gasEnabled && !oilEnabled) { // twophase water-gas system pg = (*this)[Indices::pressureSwitchIdx]; } From 23c385d3d87a3bc8f9c8e9a6071cf48e12f36641 Mon Sep 17 00:00:00 2001 From: Paul Egberts Date: Tue, 23 Aug 2022 14:24:47 +0200 Subject: [PATCH 3/3] reverted back constexpr nested the if --- .../blackoil/blackoilprimaryvariables.hh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/opm/models/blackoil/blackoilprimaryvariables.hh b/opm/models/blackoil/blackoilprimaryvariables.hh index 286af02b0..99f71efc3 100644 --- a/opm/models/blackoil/blackoilprimaryvariables.hh +++ b/opm/models/blackoil/blackoilprimaryvariables.hh @@ -503,17 +503,19 @@ public: if(Sw < -eps && FluidSystem::enableVaporizedWater()) { Scalar pg = 0.0; Scalar T = asImp_().temperature_(); - if (waterEnabled && gasEnabled && !oilEnabled) { + if constexpr (waterEnabled && gasEnabled && !oilEnabled) { // twophase water-gas system pg = (*this)[Indices::pressureSwitchIdx]; } - else if (So3 > 0.0 && Sg > 0.0) { - // threephase case - std::array pC = { 0.0 }; - const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx); - computeCapillaryPressures_(pC, So3, Sg + solventSaturation_(), /*Sw=*/ 0.0, matParams); - Scalar po = (*this)[Indices::pressureSwitchIdx]; - pg = po + (pC[gasPhaseIdx] - pC[oilPhaseIdx]); + else { + if (So3 > 0.0 && Sg > 0.0) { + // threephase case + std::array pC = { 0.0 }; + const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx); + computeCapillaryPressures_(pC, So3, Sg + solventSaturation_(), /*Sw=*/ 0.0, matParams); + Scalar po = (*this)[Indices::pressureSwitchIdx]; + pg = po + (pC[gasPhaseIdx] - pC[oilPhaseIdx]); + } } Scalar RvwSat = FluidSystem::gasPvt().saturatedWaterVaporizationFactor(pvtRegionIdx_, T,