mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
move FlowExpNewtonMethod parameters to TypeTag-free parameter system
This commit is contained in:
@@ -36,22 +36,30 @@
|
||||
|
||||
namespace Opm::Parameters {
|
||||
|
||||
template<class TypeTag, class MyTypeTag>
|
||||
struct EclNewtonSumTolerance { using type = Properties::UndefinedProperty; };
|
||||
// the tolerated amount of "incorrect" amount of oil per time step for the complete
|
||||
// reservoir. this is scaled by the pore volume of the reservoir, i.e., larger reservoirs
|
||||
// will tolerate larger residuals.
|
||||
template<class Scalar>
|
||||
struct EclNewtonSumTolerance { static constexpr Scalar value = 1e-5; };
|
||||
|
||||
template<class TypeTag, class MyTypeTag>
|
||||
struct EclNewtonStrictIterations { using type = Properties::UndefinedProperty; };
|
||||
// make all Newton iterations strict, i.e., the volumetric Newton tolerance must be
|
||||
// always be upheld in the majority of the spatial domain. In this context, "majority"
|
||||
// means 1 - EclNewtonRelaxedVolumeFraction.
|
||||
struct EclNewtonStrictIterations { static constexpr int value = 100; };
|
||||
|
||||
template<class TypeTag, class MyTypeTag>
|
||||
struct EclNewtonRelaxedVolumeFraction { using type = Properties::UndefinedProperty; };
|
||||
// set fraction of the pore volume where the volumetric residual may be violated during
|
||||
// strict Newton iterations
|
||||
template<class Scalar>
|
||||
struct EclNewtonRelaxedVolumeFraction { static constexpr Scalar value = 0.05; };
|
||||
|
||||
template<class TypeTag, class MyTypeTag>
|
||||
struct EclNewtonSumToleranceExponent { using type = Properties::UndefinedProperty; };
|
||||
template<class Scalar>
|
||||
struct EclNewtonSumToleranceExponent { static constexpr Scalar value = 1.0 / 3.0; };
|
||||
|
||||
template<class TypeTag, class MyTypeTag>
|
||||
struct EclNewtonRelaxedTolerance { using type = Properties::UndefinedProperty; };
|
||||
// the maximum volumetric error of a cell in the relaxed region
|
||||
template<class Scalar>
|
||||
struct EclNewtonRelaxedTolerance { static constexpr Scalar value = NewtonTolerance<Scalar>::value * 1e6; };
|
||||
|
||||
} // namespace Opm::Properties
|
||||
} // namespace Opm::Parameters
|
||||
|
||||
namespace Opm {
|
||||
|
||||
@@ -89,12 +97,12 @@ public:
|
||||
explicit FlowExpNewtonMethod(Simulator& simulator) : ParentType(simulator)
|
||||
{
|
||||
errorPvFraction_ = 1.0;
|
||||
relaxedMaxPvFraction_ = Parameters::get<TypeTag, Parameters::EclNewtonRelaxedVolumeFraction>();
|
||||
relaxedMaxPvFraction_ = Parameters::Get<Parameters::EclNewtonRelaxedVolumeFraction<Scalar>>();
|
||||
|
||||
sumTolerance_ = 0.0; // this gets determined in the error calculation proceedure
|
||||
relaxedTolerance_ = Parameters::get<TypeTag, Parameters::EclNewtonRelaxedTolerance>();
|
||||
relaxedTolerance_ = Parameters::Get<Parameters::EclNewtonRelaxedTolerance<Scalar>>();
|
||||
|
||||
numStrictIterations_ = Parameters::get<TypeTag, Parameters::EclNewtonStrictIterations>();
|
||||
numStrictIterations_ = Parameters::Get<Parameters::EclNewtonStrictIterations>();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -104,19 +112,19 @@ public:
|
||||
{
|
||||
ParentType::registerParameters();
|
||||
|
||||
Parameters::registerParam<TypeTag, Parameters::EclNewtonSumTolerance>
|
||||
Parameters::Register<Parameters::EclNewtonSumTolerance<Scalar>>
|
||||
("The maximum error tolerated by the Newton "
|
||||
"method for considering a solution to be converged");
|
||||
Parameters::registerParam<TypeTag, Parameters::EclNewtonStrictIterations>
|
||||
Parameters::Register<Parameters::EclNewtonStrictIterations>
|
||||
("The number of Newton iterations where the "
|
||||
"volumetric error is considered.");
|
||||
Parameters::registerParam<TypeTag, Parameters::EclNewtonRelaxedVolumeFraction>
|
||||
Parameters::Register<Parameters::EclNewtonRelaxedVolumeFraction<Scalar>>
|
||||
("The fraction of the pore volume of the reservoir "
|
||||
"where the volumetric error may be violated during strict Newton iterations.");
|
||||
Parameters::registerParam<TypeTag, Parameters::EclNewtonSumToleranceExponent>
|
||||
Parameters::Register<Parameters::EclNewtonSumToleranceExponent<Scalar>>
|
||||
("The the exponent used to scale the sum tolerance by "
|
||||
"the total pore volume of the reservoir.");
|
||||
Parameters::registerParam<TypeTag, Parameters::EclNewtonRelaxedTolerance>
|
||||
Parameters::Register<Parameters::EclNewtonRelaxedTolerance<Scalar>>
|
||||
("The maximum error which the volumetric residual "
|
||||
"may exhibit if it is in a 'relaxed' region during a strict iteration.");
|
||||
}
|
||||
@@ -219,8 +227,8 @@ public:
|
||||
|
||||
// scale the tolerance for the total error with the pore volume. by default, the
|
||||
// exponent is 1/3, i.e., cubic root.
|
||||
Scalar x = Parameters::get<TypeTag, Parameters::EclNewtonSumTolerance>();
|
||||
Scalar y = Parameters::get<TypeTag, Parameters::EclNewtonSumToleranceExponent>();
|
||||
Scalar x = Parameters::Get<Parameters::EclNewtonSumTolerance<Scalar>>();
|
||||
Scalar y = Parameters::Get<Parameters::EclNewtonSumToleranceExponent<Scalar>>();
|
||||
sumTolerance_ = x*std::pow(sumPv, y);
|
||||
|
||||
this->endIterMsg() << " (max: " << this->tolerance_
|
||||
|
||||
@@ -126,16 +126,6 @@ template<class TypeTag>
|
||||
struct EnableTerminalOutput<TypeTag, Properties::TTag::FlowExpTypeTag>
|
||||
{ static constexpr bool value = false; };
|
||||
|
||||
// the maximum volumetric error of a cell in the relaxed region
|
||||
template<class TypeTag>
|
||||
struct EclNewtonRelaxedTolerance<TypeTag, Properties::TTag::FlowExpTypeTag>
|
||||
{
|
||||
using type = GetPropType<TypeTag, Properties::Scalar>;
|
||||
static constexpr auto baseValue =
|
||||
Parameters::NewtonTolerance<type>::value;
|
||||
static constexpr type value = 1e6 * baseValue;
|
||||
};
|
||||
|
||||
// currently, flowexp uses the non-multisegment well model by default to avoid
|
||||
// regressions. the --use-multisegment-well=true|false command line parameter is still
|
||||
// available in flowexp, but hidden from view.
|
||||
@@ -216,6 +206,9 @@ public:
|
||||
|
||||
Parameters::SetDefault<Parameters::NewtonMaxIterations>(8);
|
||||
Parameters::SetDefault<Parameters::NewtonTolerance<Scalar>>(1e-2);
|
||||
Parameters::SetDefault<Parameters::EclNewtonRelaxedTolerance<Scalar>>(1e-1);
|
||||
Parameters::SetDefault<Parameters::EclNewtonRelaxedVolumeFraction<Scalar>>(0.0);
|
||||
Parameters::SetDefault<Parameters::EclNewtonSumTolerance<Scalar>>(1e-5);
|
||||
}
|
||||
|
||||
// inherit the constructors
|
||||
|
||||
@@ -75,46 +75,6 @@ struct Simulator<TypeTag, TTag::FlowExpProblemBlackOil>
|
||||
|
||||
} // namespace Opm::Properties
|
||||
|
||||
namespace Opm::Parameters {
|
||||
|
||||
template<class TypeTag>
|
||||
struct EclNewtonRelaxedTolerance<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
|
||||
{
|
||||
using type = GetPropType<TypeTag, Properties::Scalar>;
|
||||
static constexpr auto baseValue =
|
||||
Parameters::NewtonTolerance<type>::value;
|
||||
static constexpr type value = 10 * baseValue;
|
||||
};
|
||||
|
||||
// set fraction of the pore volume where the volumetric residual may be violated during
|
||||
// strict Newton iterations
|
||||
template<class TypeTag>
|
||||
struct EclNewtonRelaxedVolumeFraction<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
|
||||
{
|
||||
using type = GetPropType<TypeTag, Properties::Scalar>;
|
||||
static constexpr type value = 0.0;
|
||||
};
|
||||
|
||||
template<class TypeTag>
|
||||
struct EclNewtonSumTolerance<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
|
||||
{
|
||||
using type = GetPropType<TypeTag, Properties::Scalar>;
|
||||
static constexpr type value = 1e-5;
|
||||
};
|
||||
|
||||
template<class TypeTag>
|
||||
struct EclNewtonSumToleranceExponent<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
|
||||
{
|
||||
using type = GetPropType<TypeTag, Properties::Scalar>;
|
||||
static constexpr type value = 1.0 / 3.0;;
|
||||
};
|
||||
|
||||
template<class TypeTag>
|
||||
struct EclNewtonStrictIterations<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
|
||||
{ static constexpr int value = 100; };
|
||||
|
||||
} // namespace Opm::Parameters
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
using TypeTag = Opm::Properties::TTag::FlowExpProblemBlackOil;
|
||||
|
||||
Reference in New Issue
Block a user