From 8603935aad8498aee8b3bec9db6f7e0ce7a07788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 13 Nov 2018 00:36:51 +0100 Subject: [PATCH] Capillary Pressure: Truly Fall Back to Scaled Connate Saturations This commit ensures that we use the scaled connate water/gas saturations (SWL/SGL) in place of the scaled capillary pressure saturations (SWLPC/SGLPC) when the latter are undefined (set to a sentinel value; -1.0E+20). We would previously fall directly back to the connate saturations from the input table in this case and this would lead to inconsistent curves for the scaled capillary pressure functions. --- .../opm/utility/ECLEndPointScaling.cpp | 42 ++++++++++++++----- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.cpp index 91522e8c59..a6166196ef 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.cpp @@ -107,10 +107,14 @@ namespace { const ::Opm::ECLInitFileData& init, const std::string& vector, const std::vector& dflt, - CvrtVal&& cvrt) + CvrtVal&& cvrt, + const std::vector& fallback + = std::vector{}) { auto ret = std::vector(G.numCells()); + const auto sentinel = 1.0e20; + assert (! dflt.empty() && "Internal Error"); auto cellID = std::vector::size_type{0}; @@ -126,8 +130,20 @@ namespace { : std::vector(nc, -1.0e21); for (auto c = 0*nc; c < nc; ++c, ++cellID) { - ret[cellID] = (std::abs(val[c]) < 1.0e20) - ? cvrt(val[c]) : dflt[snum[c] - 1]; + const auto fb = fallback.empty() + ? -sentinel : fallback[c]; + + auto& r = ret[cellID]; + + if (std::abs(val[c]) < sentinel) { + r = cvrt(val[c]); + } + else if (std::abs(fb) < sentinel) { + r = cvrt(fb); + } + else { + r = dflt[snum[c] - 1]; + } } } @@ -1049,10 +1065,12 @@ Create::TwoPoint::Pc::GO(const ::Opm::ECLGraph& G, // Use dedicated scaled Sg_conn for Pc if defined in at least one // subgrid. Use SGL otherwise. Same default value (i.e., table's // connate gas saturation) for both vectors. - auto sgl = haveKeywordData(G, init, "SGLPC") + const auto sgl = ::Opm::SatFunc::scaledConnateGas(G, init, tep); + + auto sglpc = haveKeywordData(G, init, "SGLPC") ? gridDefaultedVector(G, init, "SGLPC", tep.conn.gas, - [](const double s) { return s; }) - : ::Opm::SatFunc::scaledConnateGas(G, init, tep); + [](const double s) { return s; }, sgl) + : sgl; auto sgu = sgMax(G, init, tep); @@ -1066,7 +1084,7 @@ Create::TwoPoint::Pc::GO(const ::Opm::ECLGraph& G, } return EPSPtr { - new EPS { std::move(sgl), std::move(sgu) } + new EPS { std::move(sglpc), std::move(sgu) } }; } @@ -1078,10 +1096,12 @@ Create::TwoPoint::Pc::OW(const ::Opm::ECLGraph& G, // Use dedicated scaled Sw_conn for Pc if defined in at least one // subgrid. Use SWL otherwise. Same default value (i.e., table's // connate water saturation) for both vectors. - auto swl = haveKeywordData(G, init, "SWLPC") + const auto swl = ::Opm::SatFunc::scaledConnateWater(G, init, tep); + + auto swlpc = haveKeywordData(G, init, "SWLPC") ? gridDefaultedVector(G, init, "SWLPC", tep.conn.water, - [](const double s) { return s; }) - : ::Opm::SatFunc::scaledConnateWater(G, init, tep); + [](const double s) { return s; }, swl) + : swl; auto swu = swMax(G, init, tep); @@ -1095,7 +1115,7 @@ Create::TwoPoint::Pc::OW(const ::Opm::ECLGraph& G, } return EPSPtr { - new EPS { std::move(swl), std::move(swu) } + new EPS { std::move(swlpc), std::move(swu) } }; }