From 8285d999e8fb79aec9d3e49c45e6f0c7e83716d1 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 5 Jul 2024 17:49:51 +0200 Subject: [PATCH] move NewtonMaxError parameter to TypeTag-free parameter system --- opm/models/ncp/ncpnewtonmethod.hh | 4 ++-- opm/models/nonlinear/newtonmethod.hh | 13 ++----------- opm/models/nonlinear/newtonmethodparameters.hh | 10 +++++----- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/opm/models/ncp/ncpnewtonmethod.hh b/opm/models/ncp/ncpnewtonmethod.hh index 3a9e16cc6..b21760c1f 100644 --- a/opm/models/ncp/ncpnewtonmethod.hh +++ b/opm/models/ncp/ncpnewtonmethod.hh @@ -117,10 +117,10 @@ protected: // make sure that the error never grows beyond the maximum // allowed one - if (this->error_ > Parameters::get()) + if (this->error_ > Parameters::Get>()) throw Opm::NumericalProblem("Newton: Error "+std::to_string(double(this->error_))+ + " is larger than maximum allowed error of " - + std::to_string(Parameters::get())); + + std::to_string(Parameters::Get>())); } /*! diff --git a/opm/models/nonlinear/newtonmethod.hh b/opm/models/nonlinear/newtonmethod.hh index 26101dd51..8cf451283 100644 --- a/opm/models/nonlinear/newtonmethod.hh +++ b/opm/models/nonlinear/newtonmethod.hh @@ -81,15 +81,6 @@ struct NewtonConvergenceWriter { using type = NullC namespace Opm::Parameters { -// set the abortion tolerance to some very large value. if not -// overwritten at run-time this basically disables abortions -template -struct NewtonMaxError -{ - using type = GetPropType; - static constexpr type value = 1e100; -}; - template struct NewtonTargetIterations { static constexpr int value = 10; }; @@ -164,7 +155,7 @@ public: Parameters::Register> ("The maximum raw error tolerated by the Newton" "method for considering a solution to be converged"); - Parameters::registerParam + Parameters::Register> ("The maximum error tolerated by the Newton " "method to which does not cause an abort"); } @@ -595,7 +586,7 @@ protected: { const auto& constraintsMap = model().linearizer().constraintsMap(); lastError_ = error_; - Scalar newtonMaxError = Parameters::get(); + Scalar newtonMaxError = Parameters::Get>(); // calculate the error as the maximum weighted tolerance of // the solution's residual diff --git a/opm/models/nonlinear/newtonmethodparameters.hh b/opm/models/nonlinear/newtonmethodparameters.hh index 35c16379c..742981c8c 100644 --- a/opm/models/nonlinear/newtonmethodparameters.hh +++ b/opm/models/nonlinear/newtonmethodparameters.hh @@ -27,6 +27,11 @@ namespace Opm::Parameters { +//! The maximum error which may occur in a simulation before the +//! Newton method for the time step is aborted +template +struct NewtonMaxError { static constexpr Scalar value = 1e100; }; + /*! * \brief The value for the error below which convergence is declared * @@ -43,11 +48,6 @@ struct NewtonVerbose { static constexpr bool value = true; }; //! gets written out to disk for every Newton iteration struct NewtonWriteConvergence { static constexpr bool value = false; }; -//! The maximum error which may occur in a simulation before the -//! Newton method for the time step is aborted -template -struct NewtonMaxError { using type = Properties::UndefinedProperty; }; - /*! * \brief The number of iterations at which the Newton method * should aim at.