From 5d4c7f49a2aef42b0411b9f7f1a03e17dddc99fd Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 27 Oct 2022 10:43:44 +0200 Subject: [PATCH] move checkConvergencePolyMW into WellConvergence --- opm/simulators/wells/StandardWellGeneric.cpp | 41 -------------------- opm/simulators/wells/StandardWellGeneric.hpp | 4 -- opm/simulators/wells/StandardWell_impl.hpp | 4 +- opm/simulators/wells/WellConvergence.cpp | 40 +++++++++++++++++++ opm/simulators/wells/WellConvergence.hpp | 5 +++ 5 files changed, 48 insertions(+), 46 deletions(-) diff --git a/opm/simulators/wells/StandardWellGeneric.cpp b/opm/simulators/wells/StandardWellGeneric.cpp index c3bda8bee..1072e10a8 100644 --- a/opm/simulators/wells/StandardWellGeneric.cpp +++ b/opm/simulators/wells/StandardWellGeneric.cpp @@ -393,47 +393,6 @@ computeBhpAtThpLimitInj(const std::function(const double)>& } } -template -void -StandardWellGeneric:: -checkConvergencePolyMW(const std::vector& res, - ConvergenceReport& report, - const double maxResidualAllowed) const -{ - if (baseif_.isInjector()) { - // checking the convergence of the perforation rates - const double wat_vel_tol = 1.e-8; - const int dummy_component = -1; - using CR = ConvergenceReport; - const auto wat_vel_failure_type = CR::WellFailure::Type::MassBalance; - for (int perf = 0; perf < baseif_.numPerfs(); ++perf) { - const double wat_vel_residual = res[Bhp_ + 1 + perf]; - if (std::isnan(wat_vel_residual)) { - report.setWellFailed({wat_vel_failure_type, CR::Severity::NotANumber, dummy_component, baseif_.name()}); - } else if (wat_vel_residual > maxResidualAllowed * 10.) { - report.setWellFailed({wat_vel_failure_type, CR::Severity::TooLarge, dummy_component, baseif_.name()}); - } else if (wat_vel_residual > wat_vel_tol) { - report.setWellFailed({wat_vel_failure_type, CR::Severity::Normal, dummy_component, baseif_.name()}); - } - } - - // checking the convergence of the skin pressure - const double pskin_tol = 1000.; // 1000 pascal - const auto pskin_failure_type = CR::WellFailure::Type::Pressure; - for (int perf = 0; perf < baseif_.numPerfs(); ++perf) { - const double pskin_residual = res[Bhp_ + 1 + perf + baseif_.numPerfs()]; - if (std::isnan(pskin_residual)) { - report.setWellFailed({pskin_failure_type, CR::Severity::NotANumber, dummy_component, baseif_.name()}); - } else if (pskin_residual > maxResidualAllowed * 10.) { - report.setWellFailed({pskin_failure_type, CR::Severity::TooLarge, dummy_component, baseif_.name()}); - } else if (pskin_residual > pskin_tol) { - report.setWellFailed({pskin_failure_type, CR::Severity::Normal, dummy_component, baseif_.name()}); - } - } - } -} - - template void StandardWellGeneric:: diff --git a/opm/simulators/wells/StandardWellGeneric.hpp b/opm/simulators/wells/StandardWellGeneric.hpp index de73cbff2..150edbf1f 100644 --- a/opm/simulators/wells/StandardWellGeneric.hpp +++ b/opm/simulators/wells/StandardWellGeneric.hpp @@ -85,10 +85,6 @@ protected: const double bhp, DeferredLogger& deferred_logger) const; - void checkConvergencePolyMW(const std::vector& res, - ConvergenceReport& report, - const double maxResidualAllowed) const; - void computeConnectionPressureDelta(); std::optional computeBhpAtThpLimitInj(const std::function(const double)>& frates, diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index be2edbe16..5aa155d60 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -2501,7 +2502,8 @@ namespace Opm // checking the convergence of the extra equations related to polymer injectivity if constexpr (Base::has_polymermw) { - this->checkConvergencePolyMW(res, report, this->param_.max_residual_allowed_); + WellConvergence(*this). + checkConvergencePolyMW(res, Bhp, this->param_.max_residual_allowed_, report); } } diff --git a/opm/simulators/wells/WellConvergence.cpp b/opm/simulators/wells/WellConvergence.cpp index be5c1195c..b922de0e8 100644 --- a/opm/simulators/wells/WellConvergence.cpp +++ b/opm/simulators/wells/WellConvergence.cpp @@ -115,4 +115,44 @@ checkConvergenceControlEq(const WellState& well_state, } } +void +WellConvergence:: +checkConvergencePolyMW(const std::vector& res, + const int Bhp, + const double maxResidualAllowed, + ConvergenceReport& report) const +{ + if (well_.isInjector()) { + // checking the convergence of the perforation rates + const double wat_vel_tol = 1.e-8; + const int dummy_component = -1; + using CR = ConvergenceReport; + const auto wat_vel_failure_type = CR::WellFailure::Type::MassBalance; + for (int perf = 0; perf < well_.numPerfs(); ++perf) { + const double wat_vel_residual = res[Bhp + 1 + perf]; + if (std::isnan(wat_vel_residual)) { + report.setWellFailed({wat_vel_failure_type, CR::Severity::NotANumber, dummy_component, well_.name()}); + } else if (wat_vel_residual > maxResidualAllowed * 10.) { + report.setWellFailed({wat_vel_failure_type, CR::Severity::TooLarge, dummy_component, well_.name()}); + } else if (wat_vel_residual > wat_vel_tol) { + report.setWellFailed({wat_vel_failure_type, CR::Severity::Normal, dummy_component, well_.name()}); + } + } + + // checking the convergence of the skin pressure + const double pskin_tol = 1000.; // 1000 pascal + const auto pskin_failure_type = CR::WellFailure::Type::Pressure; + for (int perf = 0; perf < well_.numPerfs(); ++perf) { + const double pskin_residual = res[Bhp + 1 + perf + well_.numPerfs()]; + if (std::isnan(pskin_residual)) { + report.setWellFailed({pskin_failure_type, CR::Severity::NotANumber, dummy_component, well_.name()}); + } else if (pskin_residual > maxResidualAllowed * 10.) { + report.setWellFailed({pskin_failure_type, CR::Severity::TooLarge, dummy_component, well_.name()}); + } else if (pskin_residual > pskin_tol) { + report.setWellFailed({pskin_failure_type, CR::Severity::Normal, dummy_component, well_.name()}); + } + } + } +} + } diff --git a/opm/simulators/wells/WellConvergence.hpp b/opm/simulators/wells/WellConvergence.hpp index 5d1d4a5d4..82f97aa99 100644 --- a/opm/simulators/wells/WellConvergence.hpp +++ b/opm/simulators/wells/WellConvergence.hpp @@ -55,6 +55,11 @@ public: ConvergenceReport& report, DeferredLogger& deferred_logger) const; + void checkConvergencePolyMW(const std::vector& res, + const int Bhp, + const double maxResidualAllowed, + ConvergenceReport& report) const; + private: const WellInterfaceGeneric& well_; };