diff --git a/examples/co2injection_flash_ecfv.cpp b/examples/co2injection_flash_ecfv.cpp index ea7358d96..cce743128 100644 --- a/examples/co2injection_flash_ecfv.cpp +++ b/examples/co2injection_flash_ecfv.cpp @@ -75,21 +75,11 @@ struct Scalar } // namespace Opm::Properties -namespace Opm::Parameters { - -#if ! HAVE_QUAD -template -struct NewtonTolerance -{ - using type = GetPropType; - static constexpr type value = 1e-5; -}; -#endif - -} // namespace Opm::Parameters - int main(int argc, char **argv) { using EcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionFlashEcfvProblem; +#if ! HAVE_QUAD + Opm::Co2InjectionTolerance = 1e-5; +#endif return Opm::start(argc, argv); } diff --git a/examples/co2injection_flash_ni_ecfv.cpp b/examples/co2injection_flash_ni_ecfv.cpp index b5419ee75..36f0a8921 100644 --- a/examples/co2injection_flash_ni_ecfv.cpp +++ b/examples/co2injection_flash_ni_ecfv.cpp @@ -77,21 +77,11 @@ struct Scalar } // namespace Opm::Properties -namespace Opm::Parameters { - -#if ! HAVE_QUAD -template -struct NewtonTolerance -{ - using type = GetPropType; - static constexpr type value = 1e-5; -}; -#endif - -} // namespace Opm::Parameters - int main(int argc, char **argv) { using EcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionFlashNiEcfvProblem; +#if ! HAVE_QUAD + Opm::Co2InjectionTolerance = 1e-5; +#endif return Opm::start(argc, argv); } diff --git a/examples/co2injection_flash_ni_vcfv.cpp b/examples/co2injection_flash_ni_vcfv.cpp index 99ea4cfbf..f448a67fe 100644 --- a/examples/co2injection_flash_ni_vcfv.cpp +++ b/examples/co2injection_flash_ni_vcfv.cpp @@ -73,21 +73,11 @@ struct Scalar } // namespace Opm::Properties -namespace Opm::Parameters { - -#if ! HAVE_QUAD -template -struct NewtonTolerance -{ - using type = GetPropType; - static constexpr type value = 1e-5; -}; -#endif - -} // namespace Opm::Parameters - int main(int argc, char **argv) { using VcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionFlashNiVcfvProblem; +#if ! HAVE_QUAD + Opm::Co2InjectionTolerance = 1e-5; +#endif return Opm::start(argc, argv); } diff --git a/examples/co2injection_flash_vcfv.cpp b/examples/co2injection_flash_vcfv.cpp index 3c66fa159..d4a100e34 100644 --- a/examples/co2injection_flash_vcfv.cpp +++ b/examples/co2injection_flash_vcfv.cpp @@ -69,21 +69,11 @@ struct Scalar } // namespace Opm::Properties -namespace Opm::Parameters { - -#if ! HAVE_QUAD -template -struct NewtonTolerance -{ - using type = GetPropType; - static constexpr type value = 1e-5; -}; -#endif - -} // namespace Opm::Parameters - int main(int argc, char **argv) { using VcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionFlashVcfvProblem; +#if ! HAVE_QUAD + Opm::Co2InjectionTolerance = 1e-5; +#endif return Opm::start(argc, argv); } diff --git a/examples/problems/co2injectionproblem.hh b/examples/problems/co2injectionproblem.hh index e28414a05..aa174b44a 100644 --- a/examples/problems/co2injectionproblem.hh +++ b/examples/problems/co2injectionproblem.hh @@ -231,6 +231,9 @@ struct Temperature } // namespace Opm::Parameters namespace Opm { + +double Co2InjectionTolerance = 1e-8; + /*! * \ingroup TestProblems * @@ -393,6 +396,8 @@ public: Parameters::SetDefault("data/co2injection.dgf"); Parameters::SetDefault>(1e4); Parameters::SetDefault>(250); + + Parameters::SetDefault>(Scalar{Co2InjectionTolerance}); } /*! diff --git a/examples/problems/co2ptflashproblem.hh b/examples/problems/co2ptflashproblem.hh index 6116cc038..0e0e23bdd 100644 --- a/examples/problems/co2ptflashproblem.hh +++ b/examples/problems/co2ptflashproblem.hh @@ -190,13 +190,6 @@ struct LinearSolverTolerance static constexpr type value = 1e-3; }; -template -struct NewtonTolerance -{ - using type = GetPropType; - static constexpr type value = 1e-3; -}; - template struct NewtonTargetIterations { @@ -380,6 +373,7 @@ public: Parameters::SetDefault>(60. * 60.); Parameters::SetDefault>(0.1 * 60. * 60.); + Parameters::SetDefault>(1e-3); } /*! diff --git a/examples/problems/reservoirproblem.hh b/examples/problems/reservoirproblem.hh index c79c87adf..da41b8611 100644 --- a/examples/problems/reservoirproblem.hh +++ b/examples/problems/reservoirproblem.hh @@ -148,14 +148,6 @@ struct MaxDepth static constexpr type value = 2500; }; -// increase the tolerance for this problem to get larger time steps -template -struct NewtonTolerance -{ - using type = GetPropType; - static constexpr type value = 1e-6; -}; - template struct Temperature { @@ -431,6 +423,8 @@ public: Parameters::SetDefault(true); Parameters::SetDefault("data/reservoir.dgf"); Parameters::SetDefault>(100e3); + // increase the tolerance for this problem to get larger time steps + Parameters::SetDefault>(1e-6); } /*! diff --git a/opm/models/nonlinear/newtonmethod.hh b/opm/models/nonlinear/newtonmethod.hh index 81b5e12b2..26101dd51 100644 --- a/opm/models/nonlinear/newtonmethod.hh +++ b/opm/models/nonlinear/newtonmethod.hh @@ -81,13 +81,6 @@ struct NewtonConvergenceWriter { using type = NullC namespace Opm::Parameters { -template -struct NewtonTolerance -{ - using type = GetPropType; - static constexpr type value = 1e-8; -}; - // set the abortion tolerance to some very large value. if not // overwritten at run-time this basically disables abortions template @@ -146,7 +139,7 @@ public: { lastError_ = 1e100; error_ = 1e100; - tolerance_ = Parameters::get(); + tolerance_ = Parameters::Get>(); numIterations_ = 0; } @@ -168,7 +161,7 @@ public: ("The 'optimum' number of Newton iterations per time step"); Parameters::registerParam ("The maximum number of Newton iterations per time step"); - Parameters::registerParam + Parameters::Register> ("The maximum raw error tolerated by the Newton" "method for considering a solution to be converged"); Parameters::registerParam diff --git a/opm/models/nonlinear/newtonmethodparameters.hh b/opm/models/nonlinear/newtonmethodparameters.hh index 80b1f098e..35c16379c 100644 --- a/opm/models/nonlinear/newtonmethodparameters.hh +++ b/opm/models/nonlinear/newtonmethodparameters.hh @@ -27,21 +27,21 @@ namespace Opm::Parameters { -//! Specifies whether the Newton method should print messages or not -struct NewtonVerbose { static constexpr bool value = true; }; - -//! Specifies whether the convergence rate and the global residual -//! gets written out to disk for every Newton iteration -struct NewtonWriteConvergence { static constexpr bool value = false; }; - /*! * \brief The value for the error below which convergence is declared * * This value can (and for the porous media models will) be changed to account for grid * scaling and other effects. */ -template -struct NewtonTolerance { using type = Properties::UndefinedProperty; }; +template +struct NewtonTolerance { static constexpr Scalar value = 1e-8; }; + +//! Specifies whether the Newton method should print messages or not +struct NewtonVerbose { static constexpr bool value = true; }; + +//! Specifies whether the convergence rate and the global residual +//! 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