From 930e6c8adf864c72ddb9061f4420e6e6148b9c16 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 5 Jul 2024 17:49:51 +0200 Subject: [PATCH] move NewtonTargetIterations to TypeTag-free parameter system --- examples/problems/co2ptflashproblem.hh | 8 +------ examples/problems/richardslensproblem.hh | 7 +------ opm/models/nonlinear/newtonmethod.hh | 8 ++----- .../nonlinear/newtonmethodparameters.hh | 21 +++++++++---------- 4 files changed, 14 insertions(+), 30 deletions(-) diff --git a/examples/problems/co2ptflashproblem.hh b/examples/problems/co2ptflashproblem.hh index 0e0e23bdd..c4f8873c2 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 NewtonTargetIterations -{ - using type = GetPropType; - static constexpr type value = 6; -}; - template struct NewtonMaxIterations { static constexpr int value = 30; }; @@ -374,6 +367,7 @@ public: Parameters::SetDefault>(60. * 60.); Parameters::SetDefault>(0.1 * 60. * 60.); Parameters::SetDefault>(1e-3); + Parameters::SetDefault(6); } /*! diff --git a/examples/problems/richardslensproblem.hh b/examples/problems/richardslensproblem.hh index 65f863191..a33e42856 100644 --- a/examples/problems/richardslensproblem.hh +++ b/examples/problems/richardslensproblem.hh @@ -108,12 +108,6 @@ template struct EnableGravity { static constexpr bool value = true; }; -// Set the "desireable" number of newton iterations of a time step -template -struct NewtonTargetIterations -{ static constexpr int value = 18; }; - -// Set the maximum number of newton iterations of a time step template struct NewtonMaxIterations { static constexpr int value = 28; }; @@ -254,6 +248,7 @@ public: Parameters::SetDefault>(3000.0); Parameters::SetDefault>(100.0); + Parameters::SetDefault(18); } /*! diff --git a/opm/models/nonlinear/newtonmethod.hh b/opm/models/nonlinear/newtonmethod.hh index 8cf451283..a73877b1e 100644 --- a/opm/models/nonlinear/newtonmethod.hh +++ b/opm/models/nonlinear/newtonmethod.hh @@ -81,10 +81,6 @@ struct NewtonConvergenceWriter { using type = NullC namespace Opm::Parameters { -template -struct NewtonTargetIterations -{ static constexpr int value = 10; }; - template struct NewtonMaxIterations { static constexpr int value = 20; }; @@ -148,7 +144,7 @@ public: Parameters::Register ("Write the convergence behaviour of the Newton " "method to a VTK file"); - Parameters::registerParam + Parameters::Register ("The 'optimum' number of Newton iterations per time step"); Parameters::registerParam ("The maximum number of Newton iterations per time step"); @@ -846,7 +842,7 @@ protected: // optimal number of iterations we want to achieve int targetIterations_() const - { return Parameters::get(); } + { return Parameters::Get(); } // maximum number of iterations we do before giving up int maxIterations_() const { return Parameters::get(); } diff --git a/opm/models/nonlinear/newtonmethodparameters.hh b/opm/models/nonlinear/newtonmethodparameters.hh index 742981c8c..e9385082b 100644 --- a/opm/models/nonlinear/newtonmethodparameters.hh +++ b/opm/models/nonlinear/newtonmethodparameters.hh @@ -32,6 +32,16 @@ namespace Opm::Parameters { template struct NewtonMaxError { static constexpr Scalar value = 1e100; }; +/*! + * \brief The number of iterations at which the Newton method + * should aim at. + * + * This is used to control the time-step size. The heuristic used + * is to scale the last time-step size by the deviation of the + * number of iterations used from the target steps. + */ +struct NewtonTargetIterations { static constexpr int value = 10; }; + /*! * \brief The value for the error below which convergence is declared * @@ -48,17 +58,6 @@ struct NewtonVerbose { static constexpr bool value = true; }; //! gets written out to disk for every Newton iteration struct NewtonWriteConvergence { static constexpr bool value = false; }; -/*! - * \brief The number of iterations at which the Newton method - * should aim at. - * - * This is used to control the time-step size. The heuristic used - * is to scale the last time-step size by the deviation of the - * number of iterations used from the target steps. - */ -template -struct NewtonTargetIterations { using type = Properties::UndefinedProperty; }; - //! Number of maximum iterations for the Newton method. template struct NewtonMaxIterations { using type = Properties::UndefinedProperty; };