changed: move the NumericDifferenceMethod parameter to Opm::Parameters

This commit is contained in:
Arne Morten Kvarving 2024-07-01 14:13:14 +02:00
parent 8869202680
commit c8f8b53733
6 changed files with 43 additions and 38 deletions

View File

@ -124,10 +124,6 @@ struct MaterialLaw<TypeTag, TTag::FingerBaseProblem>
using type = ParkerLenhard; using type = ParkerLenhard;
}; };
// Use forward differences instead of central differences
template<class TypeTag>
struct NumericDifferenceMethod<TypeTag, TTag::FingerBaseProblem> { static constexpr int value = +1; };
// Enable constraints // Enable constraints
template<class TypeTag> template<class TypeTag>
struct EnableConstraints<TypeTag, TTag::FingerBaseProblem> { static constexpr int value = true; }; struct EnableConstraints<TypeTag, TTag::FingerBaseProblem> { static constexpr int value = true; };
@ -202,6 +198,11 @@ template<class TypeTag>
struct NewtonWriteConvergence<TypeTag, Properties::TTag::FingerBaseProblem> struct NewtonWriteConvergence<TypeTag, Properties::TTag::FingerBaseProblem>
{ static constexpr bool value = false; }; { static constexpr bool value = false; };
// Use forward differences instead of central differences
template<class TypeTag>
struct NumericDifferenceMethod<TypeTag, Properties::TTag::FingerBaseProblem>
{ static constexpr int value = +1; };
} // namespace Opm::Parameters } // namespace Opm::Parameters
namespace Opm { namespace Opm {

View File

@ -74,10 +74,6 @@ struct FluidSystem<TypeTag, TTag::InfiltrationBaseProblem>
template<class TypeTag> template<class TypeTag>
struct EnableGravity<TypeTag, TTag::InfiltrationBaseProblem> { static constexpr bool value = true; }; struct EnableGravity<TypeTag, TTag::InfiltrationBaseProblem> { static constexpr bool value = true; };
// -1 backward differences, 0: central differences, +1: forward differences
template<class TypeTag>
struct NumericDifferenceMethod<TypeTag, TTag::InfiltrationBaseProblem> { static constexpr int value = 1; };
// Set the material Law // Set the material Law
template<class TypeTag> template<class TypeTag>
struct MaterialLaw<TypeTag, TTag::InfiltrationBaseProblem> struct MaterialLaw<TypeTag, TTag::InfiltrationBaseProblem>
@ -126,6 +122,11 @@ template<class TypeTag>
struct NewtonWriteConvergence<TypeTag, Properties::TTag::InfiltrationBaseProblem> struct NewtonWriteConvergence<TypeTag, Properties::TTag::InfiltrationBaseProblem>
{ static constexpr bool value = false; }; { static constexpr bool value = false; };
// -1 backward differences, 0: central differences, +1: forward differences
template<class TypeTag>
struct NumericDifferenceMethod<TypeTag, Properties::TTag::InfiltrationBaseProblem>
{ static constexpr int value = 1; };
} // namespace Opm::Parameters } // namespace Opm::Parameters
namespace Opm { namespace Opm {

View File

@ -129,9 +129,6 @@ public:
using type = Opm::EffToAbsLaw<EffectiveLaw>; using type = Opm::EffToAbsLaw<EffectiveLaw>;
}; };
// Use forward differences instead of central differences
template<class TypeTag>
struct NumericDifferenceMethod<TypeTag, TTag::LensBaseProblem> { static constexpr int value = +1; };
// Enable gravity // Enable gravity
template<class TypeTag> template<class TypeTag>
@ -243,11 +240,6 @@ template<class TypeTag>
struct NewtonWriteConvergence<TypeTag, Properties::TTag::LensBaseProblem> struct NewtonWriteConvergence<TypeTag, Properties::TTag::LensBaseProblem>
{ static constexpr bool value = false; }; { static constexpr bool value = false; };
// By default, include the intrinsic permeability tensor to the VTK output files
template<class TypeTag>
struct VtkWriteIntrinsicPermeabilities<TypeTag, Properties::TTag::LensBaseProblem>
{ static constexpr bool value = true; };
} // namespace Opm::Parameters } // namespace Opm::Parameters
namespace Opm { namespace Opm {

View File

@ -103,10 +103,6 @@ public:
template<class TypeTag> template<class TypeTag>
struct EnableGravity<TypeTag, TTag::RichardsLensProblem> { static constexpr bool value = true; }; struct EnableGravity<TypeTag, TTag::RichardsLensProblem> { static constexpr bool value = true; };
// Use central differences to approximate the Jacobian matrix
template<class TypeTag>
struct NumericDifferenceMethod<TypeTag, TTag::RichardsLensProblem> { static constexpr int value = 0; };
} // namespace Opm::Properties } // namespace Opm::Properties
namespace Opm::Parameters { namespace Opm::Parameters {
@ -147,6 +143,11 @@ template<class TypeTag>
struct NewtonMaxIterations<TypeTag, Properties::TTag::RichardsLensProblem> struct NewtonMaxIterations<TypeTag, Properties::TTag::RichardsLensProblem>
{ static constexpr int value = 28; }; { static constexpr int value = 28; };
// Use central differences to approximate the Jacobian matrix
template<class TypeTag>
struct NumericDifferenceMethod<TypeTag, Properties::TTag::RichardsLensProblem>
{ static constexpr int value = 0; };
} // namespace Opm::Parameters } // namespace Opm::Parameters
namespace Opm { namespace Opm {

View File

@ -119,10 +119,6 @@ struct FluidSystem<TypeTag, TTag::WaterAirBaseProblem>
template<class TypeTag> template<class TypeTag>
struct EnableGravity<TypeTag, TTag::WaterAirBaseProblem> { static constexpr bool value = true; }; struct EnableGravity<TypeTag, TTag::WaterAirBaseProblem> { static constexpr bool value = true; };
// Use forward differences instead of central differences
template<class TypeTag>
struct NumericDifferenceMethod<TypeTag, TTag::WaterAirBaseProblem> { static constexpr int value = +1; };
// Use the restarted GMRES linear solver with the ILU-2 preconditioner from dune-istl // Use the restarted GMRES linear solver with the ILU-2 preconditioner from dune-istl
template<class TypeTag> template<class TypeTag>
struct LinearSolverSplice<TypeTag, TTag::WaterAirBaseProblem> struct LinearSolverSplice<TypeTag, TTag::WaterAirBaseProblem>
@ -168,6 +164,11 @@ template<class TypeTag>
struct NewtonWriteConvergence<TypeTag, Properties::TTag::WaterAirBaseProblem> struct NewtonWriteConvergence<TypeTag, Properties::TTag::WaterAirBaseProblem>
{ static constexpr bool value = false; }; { static constexpr bool value = false; };
// Use forward differences instead of central differences
template<class TypeTag>
struct NumericDifferenceMethod<TypeTag, Properties::TTag::WaterAirBaseProblem>
{ static constexpr int value = +1; };
} // namespace Opm::Parameters } // namespace Opm::Parameters
namespace Opm { namespace Opm {

View File

@ -58,8 +58,6 @@ namespace TTag {
struct FiniteDifferenceLocalLinearizer {}; struct FiniteDifferenceLocalLinearizer {};
} // namespace TTag } // namespace TTag
template<class TypeTag, class MyTypeTag>
struct NumericDifferenceMethod { using type = UndefinedProperty; };
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct BaseEpsilon { using type = UndefinedProperty; }; struct BaseEpsilon { using type = UndefinedProperty; };
@ -72,16 +70,6 @@ template<class TypeTag>
struct Evaluation<TypeTag, TTag::FiniteDifferenceLocalLinearizer> struct Evaluation<TypeTag, TTag::FiniteDifferenceLocalLinearizer>
{ using type = GetPropType<TypeTag, Properties::Scalar>; }; { using type = GetPropType<TypeTag, Properties::Scalar>; };
/*!
* \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<class TypeTag>
struct NumericDifferenceMethod<TypeTag, TTag::FiniteDifferenceLocalLinearizer> { static constexpr int value = +1; };
//! The base epsilon value for finite difference calculations //! The base epsilon value for finite difference calculations
template<class TypeTag> template<class TypeTag>
struct BaseEpsilon<TypeTag, TTag::FiniteDifferenceLocalLinearizer> struct BaseEpsilon<TypeTag, TTag::FiniteDifferenceLocalLinearizer>
@ -92,6 +80,24 @@ struct BaseEpsilon<TypeTag, TTag::FiniteDifferenceLocalLinearizer>
} // namespace Opm::Properties } // namespace Opm::Properties
namespace Opm::Parameters {
template<class TypeTag, class MyTypeTag>
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<class TypeTag>
struct NumericDifferenceMethod<TypeTag, Properties::TTag::FiniteDifferenceLocalLinearizer>
{ static constexpr int value = +1; };
} // namespace Opm::Parameters
namespace Opm { namespace Opm {
/*! /*!
@ -182,7 +188,7 @@ public:
*/ */
static void registerParameters() static void registerParameters()
{ {
Parameters::registerParam<TypeTag, Properties::NumericDifferenceMethod> Parameters::registerParam<TypeTag, Parameters::NumericDifferenceMethod>
("The method used for numeric differentiation (-1: backward " ("The method used for numeric differentiation (-1: backward "
"differences, 0: central differences, 1: forward differences)"); "differences, 0: central differences, 1: forward differences)");
} }
@ -335,7 +341,10 @@ protected:
* \brief Returns the numeric difference method which is applied. * \brief Returns the numeric difference method which is applied.
*/ */
static int numericDifferenceMethod_() static int numericDifferenceMethod_()
{ return Parameters::get<TypeTag, Properties::NumericDifferenceMethod>(); } {
static int diff = Parameters::get<TypeTag, Parameters::NumericDifferenceMethod>();
return diff;
}
/*! /*!
* \brief Resize all internal attributes to the size of the * \brief Resize all internal attributes to the size of the