diff --git a/opm/simulators/wells/StandardWell.hpp b/opm/simulators/wells/StandardWell.hpp index ff635f275..7a1528412 100644 --- a/opm/simulators/wells/StandardWell.hpp +++ b/opm/simulators/wells/StandardWell.hpp @@ -475,9 +475,15 @@ namespace Opm virtual void updateWaterThroughput(const double dt, WellState& well_state) const override; + // checking the convergence of the well control equations void checkConvergenceControlEq(ConvergenceReport& report, DeferredLogger& deferred_logger) const; + // checking convergence of extra equations, if there are any + void checkConvergenceExtraEqs(const std::vector& res, + ConvergenceReport& report, + DeferredLogger& deferred_logger) const; + }; } diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index 4713b1ebf..d78704943 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -2032,36 +2032,7 @@ namespace Opm checkConvergenceControlEq(report, deferred_logger); - if (this->has_polymermw && well_type_ == INJECTOR) { - // checking the convergence of the perforation rates - const double wat_vel_tol = 1.e-8; - const int dummy_component = -1; - const auto wat_vel_failure_type = CR::WellFailure::Type::MassBalance; - for (int perf = 0; perf < number_of_perforations_; ++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, name()}); - } else if (wat_vel_residual > maxResidualAllowed * 10.) { - report.setWellFailed({wat_vel_failure_type, CR::Severity::TooLarge, dummy_component, name()}); - } else if (wat_vel_residual > wat_vel_tol) { - report.setWellFailed({wat_vel_failure_type, CR::Severity::Normal, dummy_component, 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 < number_of_perforations_; ++perf) { - const double pskin_residual = res[Bhp + 1 + perf + number_of_perforations_]; - if (std::isnan(pskin_residual)) { - report.setWellFailed({pskin_failure_type, CR::Severity::NotANumber, dummy_component, name()}); - } else if (pskin_residual > maxResidualAllowed * 10.) { - report.setWellFailed({pskin_failure_type, CR::Severity::TooLarge, dummy_component, name()}); - } else if (pskin_residual > pskin_tol) { - report.setWellFailed({pskin_failure_type, CR::Severity::Normal, dummy_component, name()}); - } - } - } + checkConvergenceExtraEqs(res, report, deferred_logger); return report; } @@ -3186,4 +3157,52 @@ namespace Opm report.setWellFailed({ctrltype, CR::Severity::Normal, dummy_component, name()}); } } + + + + + + template + void + StandardWell:: + checkConvergenceExtraEqs(const std::vector& res, + ConvergenceReport& report, + DeferredLogger& deferred_logger) const + { + // if different types of extra equations are involved, this function needs to be refactored further + + // checking the convergence of the extra equations related to polymer injectivity + if (this->has_polymermw && well_type_ == INJECTOR) { + // checking the convergence of the perforation rates + const double wat_vel_tol = 1.e-8; + const int dummy_component = -1; + const double maxResidualAllowed = param_.max_residual_allowed_; + using CR = ConvergenceReport; + const auto wat_vel_failure_type = CR::WellFailure::Type::MassBalance; + for (int perf = 0; perf < number_of_perforations_; ++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, name()}); + } else if (wat_vel_residual > maxResidualAllowed * 10.) { + report.setWellFailed({wat_vel_failure_type, CR::Severity::TooLarge, dummy_component, name()}); + } else if (wat_vel_residual > wat_vel_tol) { + report.setWellFailed({wat_vel_failure_type, CR::Severity::Normal, dummy_component, 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 < number_of_perforations_; ++perf) { + const double pskin_residual = res[Bhp + 1 + perf + number_of_perforations_]; + if (std::isnan(pskin_residual)) { + report.setWellFailed({pskin_failure_type, CR::Severity::NotANumber, dummy_component, name()}); + } else if (pskin_residual > maxResidualAllowed * 10.) { + report.setWellFailed({pskin_failure_type, CR::Severity::TooLarge, dummy_component, name()}); + } else if (pskin_residual > pskin_tol) { + report.setWellFailed({pskin_failure_type, CR::Severity::Normal, dummy_component, name()}); + } + } + } + } }