From 62f654b52cbf156bae07141b33eebfb039478cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 29 Jul 2014 11:12:08 +0200 Subject: [PATCH 1/7] Don't use variable-length arrays We only support up to 'BlackoilPhases::MaxNumPhases' different phases (and components), so there's no need to pretend otherwise. --- opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp index f51dde88..1b22a97d 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp @@ -430,7 +430,7 @@ namespace Opm swat = eps_transf_[cell].wat.smax; } else { const int wpos = phase_usage_.phase_pos[BlackoilPhases::Aqua]; - const int np = phase_usage_.num_phases; + const int np = BlackoilPhases::MaxNumPhases; double s[np]; s[wpos] = swat; double pc[np]; From 6f75afc62bb1bb1394b45ad79517b2c8e4186688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 29 Jul 2014 11:15:08 +0200 Subject: [PATCH 2/7] Consistently refer to BlackoilPhases::Aqua This avoids confusion. --- opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp index 1b22a97d..def70e76 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp @@ -422,7 +422,7 @@ namespace Opm const double pcow, double & swat) { - if (phase_usage_.phase_used[Aqua]) { + if (phase_usage_.phase_used[BlackoilPhases::Aqua]) { // TODO: Mixed wettability systems - see ecl kw OPTIONS switch 74 if (swat <= eps_transf_[cell].wat.smin) { swat = eps_transf_[cell].wat.smin; From 4da2c5862d84b0e1fbb92d8ef8b5e541e8336009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 29 Jul 2014 11:34:57 +0200 Subject: [PATCH 3/7] Initialise saturation points for Pc scaling This gives predictable failure modes although the actual behaviour is (probably) unchanged. --- opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp index def70e76..7faa8526 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp @@ -431,9 +431,9 @@ namespace Opm } else { const int wpos = phase_usage_.phase_pos[BlackoilPhases::Aqua]; const int np = BlackoilPhases::MaxNumPhases; - double s[np]; + double s[np] = { 0.0 }; s[wpos] = swat; - double pc[np]; + double pc[np] = { 0.0 }; funcForCell(cell).evalPc(s, pc, &(eps_transf_[cell])); if (pc[wpos] > 1.0e-8) { eps_transf_[cell].wat.pcFactor *= pcow/pc[wpos]; From e8901775cd34a1241dcbeb726b562fcd13d94956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 4 Aug 2014 19:06:12 +0200 Subject: [PATCH 4/7] swatInitScaling(): Rename array size parameter This commit renames the 'np' parameter used to allocate small arrays for saturations and capillary pressures to 'max_np' to better reflect its purpose. Suggested by: [at] atgeirr --- opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp index 7faa8526..f9fb1052 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp @@ -430,10 +430,10 @@ namespace Opm swat = eps_transf_[cell].wat.smax; } else { const int wpos = phase_usage_.phase_pos[BlackoilPhases::Aqua]; - const int np = BlackoilPhases::MaxNumPhases; - double s[np] = { 0.0 }; + const int max_np = BlackoilPhases::MaxNumPhases; + double s[max_np] = { 0.0 }; s[wpos] = swat; - double pc[np] = { 0.0 }; + double pc[max_np] = { 0.0 }; funcForCell(cell).evalPc(s, pc, &(eps_transf_[cell])); if (pc[wpos] > 1.0e-8) { eps_transf_[cell].wat.pcFactor *= pcow/pc[wpos]; From f8492aeb643ece9d352c628b9d7e4b9d88097749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 4 Aug 2014 19:13:42 +0200 Subject: [PATCH 5/7] swatInitScaling(): Name magic constant The constant 1.0e-8 was used as a threshold to distinguish "low" from "high" capillary pressure values. Introduce acutual constant "pc_low_threshold" to clarify that role. Suggested by: [at] atgeirr --- opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp index f9fb1052..d64e48f3 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp @@ -423,10 +423,11 @@ namespace Opm double & swat) { if (phase_usage_.phase_used[BlackoilPhases::Aqua]) { + const double pc_low_threshold = 1.0e-8; // TODO: Mixed wettability systems - see ecl kw OPTIONS switch 74 if (swat <= eps_transf_[cell].wat.smin) { swat = eps_transf_[cell].wat.smin; - } else if (pcow < 1.0e-8) { + } else if (pcow < pc_low_threshold) { swat = eps_transf_[cell].wat.smax; } else { const int wpos = phase_usage_.phase_pos[BlackoilPhases::Aqua]; @@ -435,7 +436,7 @@ namespace Opm s[wpos] = swat; double pc[max_np] = { 0.0 }; funcForCell(cell).evalPc(s, pc, &(eps_transf_[cell])); - if (pc[wpos] > 1.0e-8) { + if (pc[wpos] > pc_low_threshold) { eps_transf_[cell].wat.pcFactor *= pcow/pc[wpos]; } } From c047a6c9dcd7ffdcdbfe0fc8b3b1f74c4ac04682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 4 Aug 2014 19:18:43 +0200 Subject: [PATCH 6/7] swatInitScaling(): Remove EOL whitespace This commit removes several instances of EOL whitespace in function 'swatInitScaling()'. Aesthetic only. No functional changes. Suggested by: [at] atgeirr --- .../props/satfunc/SaturationPropsFromDeck_impl.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp index d64e48f3..414ff031 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp @@ -414,12 +414,12 @@ namespace Opm /// Update capillary pressure scaling according to pressure diff. and initial water saturation. - /// \param[in] cell Cell index. + /// \param[in] cell Cell index. /// \param[in] pcow P_oil - P_water. - /// \param[in/out] swat Water saturation. / Possibly modified Water saturation. + /// \param[in/out] swat Water saturation. / Possibly modified Water saturation. template - void SaturationPropsFromDeck::swatInitScaling(const int cell, - const double pcow, + void SaturationPropsFromDeck::swatInitScaling(const int cell, + const double pcow, double & swat) { if (phase_usage_.phase_used[BlackoilPhases::Aqua]) { @@ -433,9 +433,9 @@ namespace Opm const int wpos = phase_usage_.phase_pos[BlackoilPhases::Aqua]; const int max_np = BlackoilPhases::MaxNumPhases; double s[max_np] = { 0.0 }; - s[wpos] = swat; + s[wpos] = swat; double pc[max_np] = { 0.0 }; - funcForCell(cell).evalPc(s, pc, &(eps_transf_[cell])); + funcForCell(cell).evalPc(s, pc, &(eps_transf_[cell])); if (pc[wpos] > pc_low_threshold) { eps_transf_[cell].wat.pcFactor *= pcow/pc[wpos]; } From 6b36dab2ee0fddeb69970bb6fafaf2994ad61723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 4 Aug 2014 19:23:03 +0200 Subject: [PATCH 7/7] swatInitScaling(): Abide by OPM coding conventions This commit attaches the reference-signifying ampersand to the type as is preferred in the OPM code base. Suggested by: [at] atgeirr --- opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp index 414ff031..64cb7eaa 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp @@ -420,7 +420,7 @@ namespace Opm template void SaturationPropsFromDeck::swatInitScaling(const int cell, const double pcow, - double & swat) + double& swat) { if (phase_usage_.phase_used[BlackoilPhases::Aqua]) { const double pc_low_threshold = 1.0e-8;