From c8f8b53733bde83953568bb5ffa48e10a1ed971f Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 1 Jul 2024 14:13:14 +0200 Subject: [PATCH] changed: move the NumericDifferenceMethod parameter to Opm::Parameters --- examples/problems/fingerproblem.hh | 9 +++-- examples/problems/infiltrationproblem.hh | 9 +++-- examples/problems/lensproblem.hh | 8 ---- examples/problems/richardslensproblem.hh | 9 +++-- examples/problems/waterairproblem.hh | 9 +++-- .../common/fvbasefdlocallinearizer.hh | 37 ++++++++++++------- 6 files changed, 43 insertions(+), 38 deletions(-) diff --git a/examples/problems/fingerproblem.hh b/examples/problems/fingerproblem.hh index a07ca5746..3cec59c37 100644 --- a/examples/problems/fingerproblem.hh +++ b/examples/problems/fingerproblem.hh @@ -124,10 +124,6 @@ struct MaterialLaw using type = ParkerLenhard; }; -// Use forward differences instead of central differences -template -struct NumericDifferenceMethod { static constexpr int value = +1; }; - // Enable constraints template struct EnableConstraints { static constexpr int value = true; }; @@ -202,6 +198,11 @@ template struct NewtonWriteConvergence { static constexpr bool value = false; }; +// Use forward differences instead of central differences +template +struct NumericDifferenceMethod +{ static constexpr int value = +1; }; + } // namespace Opm::Parameters namespace Opm { diff --git a/examples/problems/infiltrationproblem.hh b/examples/problems/infiltrationproblem.hh index d7ce4899c..2c6c2756e 100644 --- a/examples/problems/infiltrationproblem.hh +++ b/examples/problems/infiltrationproblem.hh @@ -74,10 +74,6 @@ struct FluidSystem template struct EnableGravity { static constexpr bool value = true; }; -// -1 backward differences, 0: central differences, +1: forward differences -template -struct NumericDifferenceMethod { static constexpr int value = 1; }; - // Set the material Law template struct MaterialLaw @@ -126,6 +122,11 @@ template struct NewtonWriteConvergence { static constexpr bool value = false; }; +// -1 backward differences, 0: central differences, +1: forward differences +template +struct NumericDifferenceMethod +{ static constexpr int value = 1; }; + } // namespace Opm::Parameters namespace Opm { diff --git a/examples/problems/lensproblem.hh b/examples/problems/lensproblem.hh index d0a75925a..5f61addc3 100644 --- a/examples/problems/lensproblem.hh +++ b/examples/problems/lensproblem.hh @@ -129,9 +129,6 @@ public: using type = Opm::EffToAbsLaw; }; -// Use forward differences instead of central differences -template -struct NumericDifferenceMethod { static constexpr int value = +1; }; // Enable gravity template @@ -243,11 +240,6 @@ template struct NewtonWriteConvergence { static constexpr bool value = false; }; -// By default, include the intrinsic permeability tensor to the VTK output files -template -struct VtkWriteIntrinsicPermeabilities -{ static constexpr bool value = true; }; - } // namespace Opm::Parameters namespace Opm { diff --git a/examples/problems/richardslensproblem.hh b/examples/problems/richardslensproblem.hh index 2a3ffc45f..ba8164864 100644 --- a/examples/problems/richardslensproblem.hh +++ b/examples/problems/richardslensproblem.hh @@ -103,10 +103,6 @@ public: template struct EnableGravity { static constexpr bool value = true; }; -// Use central differences to approximate the Jacobian matrix -template -struct NumericDifferenceMethod { static constexpr int value = 0; }; - } // namespace Opm::Properties namespace Opm::Parameters { @@ -147,6 +143,11 @@ template struct NewtonMaxIterations { static constexpr int value = 28; }; +// Use central differences to approximate the Jacobian matrix +template +struct NumericDifferenceMethod +{ static constexpr int value = 0; }; + } // namespace Opm::Parameters namespace Opm { diff --git a/examples/problems/waterairproblem.hh b/examples/problems/waterairproblem.hh index 2774a7bb6..b42549822 100644 --- a/examples/problems/waterairproblem.hh +++ b/examples/problems/waterairproblem.hh @@ -119,10 +119,6 @@ struct FluidSystem template struct EnableGravity { static constexpr bool value = true; }; -// Use forward differences instead of central differences -template -struct NumericDifferenceMethod { static constexpr int value = +1; }; - // Use the restarted GMRES linear solver with the ILU-2 preconditioner from dune-istl template struct LinearSolverSplice @@ -168,6 +164,11 @@ template struct NewtonWriteConvergence { static constexpr bool value = false; }; +// Use forward differences instead of central differences +template +struct NumericDifferenceMethod +{ static constexpr int value = +1; }; + } // namespace Opm::Parameters namespace Opm { diff --git a/opm/models/discretization/common/fvbasefdlocallinearizer.hh b/opm/models/discretization/common/fvbasefdlocallinearizer.hh index bd818060f..fe9fd3ea2 100644 --- a/opm/models/discretization/common/fvbasefdlocallinearizer.hh +++ b/opm/models/discretization/common/fvbasefdlocallinearizer.hh @@ -58,8 +58,6 @@ namespace TTag { struct FiniteDifferenceLocalLinearizer {}; } // namespace TTag -template -struct NumericDifferenceMethod { using type = UndefinedProperty; }; template struct BaseEpsilon { using type = UndefinedProperty; }; @@ -72,16 +70,6 @@ template struct Evaluation { using type = GetPropType; }; -/*! - * \brief Specify which kind of method should be used to numerically - * calculate the partial derivatives of the residual. - * - * -1 means backward differences, 0 means central differences, 1 means - * forward differences. By default we use central differences. - */ -template -struct NumericDifferenceMethod { static constexpr int value = +1; }; - //! The base epsilon value for finite difference calculations template struct BaseEpsilon @@ -92,6 +80,24 @@ struct BaseEpsilon } // namespace Opm::Properties +namespace Opm::Parameters { + +template +struct NumericDifferenceMethod { using type = Properties::UndefinedProperty; }; + +/*! + * \brief Specify which kind of method should be used to numerically + * calculate the partial derivatives of the residual. + * + * -1 means backward differences, 0 means central differences, 1 means + * forward differences. By default we use forward differences. + */ +template +struct NumericDifferenceMethod +{ static constexpr int value = +1; }; + +} // namespace Opm::Parameters + namespace Opm { /*! @@ -182,7 +188,7 @@ public: */ static void registerParameters() { - Parameters::registerParam + Parameters::registerParam ("The method used for numeric differentiation (-1: backward " "differences, 0: central differences, 1: forward differences)"); } @@ -335,7 +341,10 @@ protected: * \brief Returns the numeric difference method which is applied. */ static int numericDifferenceMethod_() - { return Parameters::get(); } + { + static int diff = Parameters::get(); + return diff; + } /*! * \brief Resize all internal attributes to the size of the