changed: move the LinearSolverAbsTolerance parameter to Opm::Parameters

This commit is contained in:
Arne Morten Kvarving 2024-07-01 14:13:14 +02:00
parent b9615ea29a
commit ffdbd2f127
7 changed files with 31 additions and 24 deletions

View File

@ -157,12 +157,6 @@ struct SimulationName<TypeTag, TTag::CO2PTBaseProblem> {
static constexpr auto value = "co2_ptflash"; static constexpr auto value = "co2_ptflash";
}; };
template <class TypeTag>
struct LinearSolverAbsTolerance<TypeTag, TTag::CO2PTBaseProblem> {
using type = GetPropType<TypeTag, Scalar>;
static constexpr type value = 0.;
};
// this is kinds of telling the report step length // this is kinds of telling the report step length
template <class TypeTag> template <class TypeTag>
struct EpisodeLength<TypeTag, TTag::CO2PTBaseProblem> { struct EpisodeLength<TypeTag, TTag::CO2PTBaseProblem> {
@ -244,6 +238,13 @@ struct InitialTimeStepSize<TypeTag, Properties::TTag::CO2PTBaseProblem>
static constexpr type value = 0.1 * 60. * 60.; static constexpr type value = 0.1 * 60. * 60.;
}; };
template <class TypeTag>
struct LinearSolverAbsTolerance<TypeTag, Properties::TTag::CO2PTBaseProblem>
{
using type = GetPropType<TypeTag, Properties::Scalar>;
static constexpr type value = 0.;
};
template <class TypeTag> template <class TypeTag>
struct LinearSolverTolerance<TypeTag, Properties::TTag::CO2PTBaseProblem> struct LinearSolverTolerance<TypeTag, Properties::TTag::CO2PTBaseProblem>
{ {

View File

@ -242,14 +242,6 @@ template<class TypeTag>
struct EnableConstraints<TypeTag, TTag::FvBaseDiscretization> struct EnableConstraints<TypeTag, TTag::FvBaseDiscretization>
{ static constexpr bool value = false; }; { static constexpr bool value = false; };
// use default initialization based on rule-of-thumb of Newton tolerance
template<class TypeTag>
struct LinearSolverAbsTolerance<TypeTag, TTag::FvBaseDiscretization>
{
using type = GetPropType<TypeTag, Scalar>;
static constexpr type value = -1.;
};
//! Set the history size of the time discretization to 2 (for implicit euler) //! Set the history size of the time discretization to 2 (for implicit euler)
template<class TypeTag> template<class TypeTag>
struct TimeDiscHistorySize<TypeTag, TTag::FvBaseDiscretization> struct TimeDiscHistorySize<TypeTag, TTag::FvBaseDiscretization>
@ -335,6 +327,14 @@ template<class TypeTag>
struct EnableThermodynamicHints<TypeTag, Properties::TTag::FvBaseDiscretization> struct EnableThermodynamicHints<TypeTag, Properties::TTag::FvBaseDiscretization>
{ static constexpr bool value = false; }; { static constexpr bool value = false; };
// use default initialization based on rule-of-thumb of Newton tolerance
template<class TypeTag>
struct LinearSolverAbsTolerance<TypeTag, Properties::TTag::FvBaseDiscretization>
{
using type = GetPropType<TypeTag, Properties::Scalar>;
static constexpr type value = -1.;
};
// if the deflection of the newton method is large, we do not need to solve the linear // if the deflection of the newton method is large, we do not need to solve the linear
// approximation accurately. Assuming that the value for the current solution is quite // approximation accurately. Assuming that the value for the current solution is quite
// close to the final value, a reduction of 3 orders of magnitude in the defect should be // close to the final value, a reduction of 3 orders of magnitude in the defect should be

View File

@ -33,6 +33,12 @@
namespace Opm::Parameters { namespace Opm::Parameters {
/*!
* \brief Maximum accepted error of the norm of the residual.
*/
template<class TypeTag, class MyTypeTag>
struct LinearSolverAbsTolerance { using type = Properties::UndefinedProperty; };
/*! /*!
* \brief The size of the algebraic overlap of the linear solver. * \brief The size of the algebraic overlap of the linear solver.
* *

View File

@ -41,17 +41,10 @@ struct LinearSolverBackend { using type = UndefinedProperty; };
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct PreconditionerWrapper { using type = UndefinedProperty; }; struct PreconditionerWrapper { using type = UndefinedProperty; };
//! The floating point type used internally by the linear solver //! The floating point type used internally by the linear solver
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct LinearSolverScalar { using type = UndefinedProperty; }; struct LinearSolverScalar { using type = UndefinedProperty; };
/*!
* \brief Maximum accepted error of the norm of the residual.
*/
template<class TypeTag, class MyTypeTag>
struct LinearSolverAbsTolerance { using type = UndefinedProperty; };
/*! /*!
* \brief Specifies the verbosity of the linear solver * \brief Specifies the verbosity of the linear solver
* *
@ -88,18 +81,25 @@ struct GlobalEqVector { using type = UndefinedProperty; };
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct AmgCoarsenTarget { using type = UndefinedProperty; }; struct AmgCoarsenTarget { using type = UndefinedProperty; };
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct LinearSolverMaxError { using type = UndefinedProperty; }; struct LinearSolverMaxError { using type = UndefinedProperty; };
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct LinearSolverWrapper { using type = UndefinedProperty; }; struct LinearSolverWrapper { using type = UndefinedProperty; };
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct Overlap { using type = UndefinedProperty; }; struct Overlap { using type = UndefinedProperty; };
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct OverlappingLinearOperator { using type = UndefinedProperty; }; struct OverlappingLinearOperator { using type = UndefinedProperty; };
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct OverlappingMatrix { using type = UndefinedProperty; }; struct OverlappingMatrix { using type = UndefinedProperty; };
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct OverlappingScalarProduct { using type = UndefinedProperty; }; struct OverlappingScalarProduct { using type = UndefinedProperty; };
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct OverlappingVector { using type = UndefinedProperty; }; struct OverlappingVector { using type = UndefinedProperty; };

View File

@ -194,7 +194,7 @@ protected:
using CCC = CombinedCriterion<OverlappingVector, decltype(gridView.comm())>; using CCC = CombinedCriterion<OverlappingVector, decltype(gridView.comm())>;
Scalar linearSolverTolerance = Parameters::get<TypeTag, Parameters::LinearSolverTolerance>(); Scalar linearSolverTolerance = Parameters::get<TypeTag, Parameters::LinearSolverTolerance>();
Scalar linearSolverAbsTolerance = Parameters::get<TypeTag, Properties::LinearSolverAbsTolerance>(); Scalar linearSolverAbsTolerance = Parameters::get<TypeTag, Parameters::LinearSolverAbsTolerance>();
if(linearSolverAbsTolerance < 0.0) if(linearSolverAbsTolerance < 0.0)
linearSolverAbsTolerance = this->simulator_.model().newtonMethod().tolerance()/100.0; linearSolverAbsTolerance = this->simulator_.model().newtonMethod().tolerance()/100.0;

View File

@ -154,7 +154,7 @@ public:
{ {
Parameters::registerParam<TypeTag, Parameters::LinearSolverTolerance> Parameters::registerParam<TypeTag, Parameters::LinearSolverTolerance>
("The maximum allowed error between of the linear solver"); ("The maximum allowed error between of the linear solver");
Parameters::registerParam<TypeTag, Properties::LinearSolverAbsTolerance> Parameters::registerParam<TypeTag, Parameters::LinearSolverAbsTolerance>
("The maximum accepted error of the norm of the residual"); ("The maximum accepted error of the norm of the residual");
Parameters::registerParam<TypeTag, Parameters::LinearSolverOverlapSize> Parameters::registerParam<TypeTag, Parameters::LinearSolverOverlapSize>
("The size of the algebraic overlap for the linear solver"); ("The size of the algebraic overlap for the linear solver");

View File

@ -138,7 +138,7 @@ protected:
using CCC = CombinedCriterion<OverlappingVector, decltype(gridView.comm())>; using CCC = CombinedCriterion<OverlappingVector, decltype(gridView.comm())>;
Scalar linearSolverTolerance = Parameters::get<TypeTag, Parameters::LinearSolverTolerance>(); Scalar linearSolverTolerance = Parameters::get<TypeTag, Parameters::LinearSolverTolerance>();
Scalar linearSolverAbsTolerance = Parameters::get<TypeTag, Properties::LinearSolverAbsTolerance>(); Scalar linearSolverAbsTolerance = Parameters::get<TypeTag, Parameters::LinearSolverAbsTolerance>();
if(linearSolverAbsTolerance < 0.0) if(linearSolverAbsTolerance < 0.0)
linearSolverAbsTolerance = this->simulator_.model().newtonMethod().tolerance() / 100.0; linearSolverAbsTolerance = this->simulator_.model().newtonMethod().tolerance() / 100.0;