From 2a133b615e5c3428bf6a203ade05fed2e8b08b34 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 1 Jul 2024 10:20:05 +0200 Subject: [PATCH] changed: move the NewtonTolerance parameter to Opm::Parameters --- examples/co2injection_flash_ecfv.cpp | 14 ++++++++++---- examples/co2injection_flash_ni_ecfv.cpp | 14 ++++++++++---- examples/co2injection_flash_ni_vcfv.cpp | 14 ++++++++++---- examples/co2injection_flash_vcfv.cpp | 14 ++++++++++---- examples/problems/co2ptflashproblem.hh | 13 +++++++------ examples/problems/reservoirproblem.hh | 16 ++++++++-------- opm/models/nonlinear/newtonmethod.hh | 17 +++++++++-------- opm/models/nonlinear/newtonmethodparameters.hh | 9 +++++++++ opm/models/nonlinear/newtonmethodproperties.hh | 9 --------- 9 files changed, 73 insertions(+), 47 deletions(-) diff --git a/examples/co2injection_flash_ecfv.cpp b/examples/co2injection_flash_ecfv.cpp index ef41d8c8c..ea7358d96 100644 --- a/examples/co2injection_flash_ecfv.cpp +++ b/examples/co2injection_flash_ecfv.cpp @@ -71,16 +71,22 @@ struct FlashSolver template struct Scalar { using type = quad; }; -#else +#endif + +} // namespace Opm::Properties + +namespace Opm::Parameters { + +#if ! HAVE_QUAD template -struct NewtonTolerance +struct NewtonTolerance { - using type = GetPropType; + using type = GetPropType; static constexpr type value = 1e-5; }; #endif -} // namespace Opm::Properties +} // namespace Opm::Parameters int main(int argc, char **argv) { diff --git a/examples/co2injection_flash_ni_ecfv.cpp b/examples/co2injection_flash_ni_ecfv.cpp index 73966e1e2..b5419ee75 100644 --- a/examples/co2injection_flash_ni_ecfv.cpp +++ b/examples/co2injection_flash_ni_ecfv.cpp @@ -73,16 +73,22 @@ struct FlashSolver template struct Scalar { using type = quad; }; -#else +#endif + +} // namespace Opm::Properties + +namespace Opm::Parameters { + +#if ! HAVE_QUAD template -struct NewtonTolerance +struct NewtonTolerance { - using type = GetPropType; + using type = GetPropType; static constexpr type value = 1e-5; }; #endif -} // namespace Opm::Properties +} // namespace Opm::Parameters int main(int argc, char **argv) { diff --git a/examples/co2injection_flash_ni_vcfv.cpp b/examples/co2injection_flash_ni_vcfv.cpp index bfb8bd18f..99ea4cfbf 100644 --- a/examples/co2injection_flash_ni_vcfv.cpp +++ b/examples/co2injection_flash_ni_vcfv.cpp @@ -69,16 +69,22 @@ struct FlashSolver template struct Scalar { using type = quad; }; -#else +#endif + +} // namespace Opm::Properties + +namespace Opm::Parameters { + +#if ! HAVE_QUAD template -struct NewtonTolerance +struct NewtonTolerance { - using type = GetPropType; + using type = GetPropType; static constexpr type value = 1e-5; }; #endif -} // namespace Opm::Properties +} // namespace Opm::Parameters int main(int argc, char **argv) { diff --git a/examples/co2injection_flash_vcfv.cpp b/examples/co2injection_flash_vcfv.cpp index e29bda604..3c66fa159 100644 --- a/examples/co2injection_flash_vcfv.cpp +++ b/examples/co2injection_flash_vcfv.cpp @@ -65,16 +65,22 @@ struct FlashSolver template struct Scalar { using type = quad; }; -#else +#endif + +} // namespace Opm::Properties + +namespace Opm::Parameters { + +#if ! HAVE_QUAD template -struct NewtonTolerance +struct NewtonTolerance { - using type = GetPropType; + using type = GetPropType; static constexpr type value = 1e-5; }; #endif -} // namespace Opm::Properties +} // namespace Opm::Parameters int main(int argc, char **argv) { diff --git a/examples/problems/co2ptflashproblem.hh b/examples/problems/co2ptflashproblem.hh index 07d07f4a1..ee54d0234 100644 --- a/examples/problems/co2ptflashproblem.hh +++ b/examples/problems/co2ptflashproblem.hh @@ -189,12 +189,6 @@ struct LinearSolverAbsTolerance { static constexpr type value = 0.; }; -template -struct NewtonTolerance { - using type = GetPropType; - static constexpr type value = 1e-3; -}; - template struct NewtonMaxIterations { static constexpr int value = 30; @@ -299,6 +293,13 @@ template struct NewtonWriteConvergence { static constexpr bool value = false; }; +template +struct NewtonTolerance +{ + using type = GetPropType; + static constexpr type value = 1e-3; +}; + } // namespace Opm::Parameters namespace Opm { diff --git a/examples/problems/reservoirproblem.hh b/examples/problems/reservoirproblem.hh index 14a0a2cb5..38c695115 100644 --- a/examples/problems/reservoirproblem.hh +++ b/examples/problems/reservoirproblem.hh @@ -171,14 +171,6 @@ public: template struct GridFile { static constexpr auto value = "data/reservoir.dgf"; }; -// increase the tolerance for this problem to get larger time steps -template -struct NewtonTolerance -{ - using type = GetPropType; - static constexpr type value = 1e-6; -}; - } // namespace Opm::Properties namespace Opm::Parameters { @@ -188,6 +180,14 @@ template struct NewtonWriteConvergence { static constexpr bool value = false; }; +// increase the tolerance for this problem to get larger time steps +template +struct NewtonTolerance +{ + using type = GetPropType; + static constexpr type value = 1e-6; +}; + } // namespace Opm::Parameters namespace Opm { diff --git a/opm/models/nonlinear/newtonmethod.hh b/opm/models/nonlinear/newtonmethod.hh index e86a68fbb..22c82900e 100644 --- a/opm/models/nonlinear/newtonmethod.hh +++ b/opm/models/nonlinear/newtonmethod.hh @@ -76,12 +76,6 @@ template struct NewtonMethod { using type = ::Opm::NewtonMethod; }; template struct NewtonConvergenceWriter { using type = NullConvergenceWriter; }; -template -struct NewtonTolerance -{ - using type = GetPropType; - static constexpr type value = 1e-8; -}; // set the abortion tolerace to some very large value. if not // overwritten at run-time this basically disables abortions template @@ -107,6 +101,13 @@ template struct NewtonWriteConvergence { static constexpr bool value = false; }; +template +struct NewtonTolerance +{ + using type = GetPropType; + static constexpr type value = 1e-8; +}; + } // namespace Opm::Parameters namespace Opm { @@ -148,7 +149,7 @@ public: { lastError_ = 1e100; error_ = 1e100; - tolerance_ = Parameters::get(); + tolerance_ = Parameters::get(); numIterations_ = 0; } @@ -170,7 +171,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::registerParam ("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 91f2cd95e..d402f6031 100644 --- a/opm/models/nonlinear/newtonmethodparameters.hh +++ b/opm/models/nonlinear/newtonmethodparameters.hh @@ -36,6 +36,15 @@ struct NewtonVerbose { using type = Properties::UndefinedProperty; }; template struct NewtonWriteConvergence { using type = Properties::UndefinedProperty; }; +/*! + * \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; }; + } // end namespace Opm::Parameters #endif diff --git a/opm/models/nonlinear/newtonmethodproperties.hh b/opm/models/nonlinear/newtonmethodproperties.hh index 402c33d4f..5475acda6 100644 --- a/opm/models/nonlinear/newtonmethodproperties.hh +++ b/opm/models/nonlinear/newtonmethodproperties.hh @@ -44,15 +44,6 @@ struct NewtonConvergenceWriter { using type = UndefinedProperty; }; template struct ConvergenceWriter { using type = UndefinedProperty; }; -/*! - * \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 = UndefinedProperty; }; - //! The maximum error which may occur in a simulation before the //! Newton method for the time step is aborted template