changed: FlowExpNewton parameters moved to Opm::Parameters namespace

This commit is contained in:
Arne Morten Kvarving 2024-06-28 12:17:13 +02:00
parent 51e8bb7191
commit 04a9b0893e
3 changed files with 61 additions and 94 deletions

View File

@ -34,37 +34,22 @@
#include <opm/models/blackoil/blackoilnewtonmethod.hh> #include <opm/models/blackoil/blackoilnewtonmethod.hh>
#include <opm/models/utils/signum.hh> #include <opm/models/utils/signum.hh>
namespace Opm::Properties { namespace Opm::Parameters {
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct EclNewtonSumTolerance struct EclNewtonSumTolerance { using type = Properties::UndefinedProperty; };
{
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct EclNewtonStrictIterations struct EclNewtonStrictIterations { using type = Properties::UndefinedProperty; };
{
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct EclNewtonRelaxedVolumeFraction struct EclNewtonRelaxedVolumeFraction { using type = Properties::UndefinedProperty; };
{
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct EclNewtonSumToleranceExponent struct EclNewtonSumToleranceExponent { using type = Properties::UndefinedProperty; };
{
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct EclNewtonRelaxedTolerance struct EclNewtonRelaxedTolerance { using type = Properties::UndefinedProperty; };
{
using type = UndefinedProperty;
};
} // namespace Opm::Properties } // namespace Opm::Properties
@ -104,12 +89,12 @@ public:
explicit FlowExpNewtonMethod(Simulator& simulator) : ParentType(simulator) explicit FlowExpNewtonMethod(Simulator& simulator) : ParentType(simulator)
{ {
errorPvFraction_ = 1.0; errorPvFraction_ = 1.0;
relaxedMaxPvFraction_ = Parameters::get<TypeTag, Properties::EclNewtonRelaxedVolumeFraction>(); relaxedMaxPvFraction_ = Parameters::get<TypeTag, Parameters::EclNewtonRelaxedVolumeFraction>();
sumTolerance_ = 0.0; // this gets determined in the error calculation proceedure sumTolerance_ = 0.0; // this gets determined in the error calculation proceedure
relaxedTolerance_ = Parameters::get<TypeTag, Properties::EclNewtonRelaxedTolerance>(); relaxedTolerance_ = Parameters::get<TypeTag, Parameters::EclNewtonRelaxedTolerance>();
numStrictIterations_ = Parameters::get<TypeTag, Properties::EclNewtonStrictIterations>(); numStrictIterations_ = Parameters::get<TypeTag, Parameters::EclNewtonStrictIterations>();
} }
/*! /*!
@ -119,19 +104,19 @@ public:
{ {
ParentType::registerParameters(); ParentType::registerParameters();
Parameters::registerParam<TypeTag, Properties::EclNewtonSumTolerance> Parameters::registerParam<TypeTag, Parameters::EclNewtonSumTolerance>
("The maximum error tolerated by the Newton " ("The maximum error tolerated by the Newton "
"method for considering a solution to be converged"); "method for considering a solution to be converged");
Parameters::registerParam<TypeTag, Properties::EclNewtonStrictIterations> Parameters::registerParam<TypeTag, Parameters::EclNewtonStrictIterations>
("The number of Newton iterations where the " ("The number of Newton iterations where the "
"volumetric error is considered."); "volumetric error is considered.");
Parameters::registerParam<TypeTag, Properties::EclNewtonRelaxedVolumeFraction> Parameters::registerParam<TypeTag, Parameters::EclNewtonRelaxedVolumeFraction>
("The fraction of the pore volume of the reservoir " ("The fraction of the pore volume of the reservoir "
"where the volumetric error may be violated during strict Newton iterations."); "where the volumetric error may be violated during strict Newton iterations.");
Parameters::registerParam<TypeTag, Properties::EclNewtonSumToleranceExponent> Parameters::registerParam<TypeTag, Parameters::EclNewtonSumToleranceExponent>
("The the exponent used to scale the sum tolerance by " ("The the exponent used to scale the sum tolerance by "
"the total pore volume of the reservoir."); "the total pore volume of the reservoir.");
Parameters::registerParam<TypeTag, Properties::EclNewtonRelaxedTolerance> Parameters::registerParam<TypeTag, Parameters::EclNewtonRelaxedTolerance>
("The maximum error which the volumetric residual " ("The maximum error which the volumetric residual "
"may exhibit if it is in a 'relaxed' region during a strict iteration."); "may exhibit if it is in a 'relaxed' region during a strict iteration.");
} }
@ -234,8 +219,8 @@ public:
// scale the tolerance for the total error with the pore volume. by default, the // scale the tolerance for the total error with the pore volume. by default, the
// exponent is 1/3, i.e., cubic root. // exponent is 1/3, i.e., cubic root.
Scalar x = Parameters::get<TypeTag, Properties::EclNewtonSumTolerance>(); Scalar x = Parameters::get<TypeTag, Parameters::EclNewtonSumTolerance>();
Scalar y = Parameters::get<TypeTag, Properties::EclNewtonSumToleranceExponent>(); Scalar y = Parameters::get<TypeTag, Parameters::EclNewtonSumToleranceExponent>();
sumTolerance_ = x*std::pow(sumPv, y); sumTolerance_ = x*std::pow(sumPv, y);
this->endIterMsg() << " (max: " << this->tolerance_ this->endIterMsg() << " (max: " << this->tolerance_

View File

@ -130,36 +130,6 @@ struct LinearSolverBackend<TTag::FlowExpTypeTag, TTag::FlowIstlSolverParams> {
using type = ISTLSolver<TTag::FlowExpTypeTag>; using type = ISTLSolver<TTag::FlowExpTypeTag>;
}; };
// set fraction of the pore volume where the volumetric residual may be violated during
// strict Newton iterations
template<class TypeTag>
struct EclNewtonRelaxedVolumeFraction<TypeTag, TTag::FlowExpTypeTag> {
using type = GetPropType<TypeTag, Scalar>;
static constexpr type value = 0.05;
};
// 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 TypeTag>
struct EclNewtonSumTolerance<TypeTag, TTag::FlowExpTypeTag> {
using type = GetPropType<TypeTag, Scalar>;
static constexpr type value = 1e-5;
};
template<class TypeTag>
struct EclNewtonSumToleranceExponent<TypeTag, TTag::FlowExpTypeTag> {
using type = GetPropType<TypeTag, Scalar>;
static constexpr type value = 1./3.;
};
// 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.
template<class TypeTag>
struct EclNewtonStrictIterations<TypeTag, TTag::FlowExpTypeTag> {
static constexpr int value = 100;
};
template<class TypeTag> template<class TypeTag>
struct LinearSolverBackend<TypeTag, TTag::FlowExpTypeTag> { struct LinearSolverBackend<TypeTag, TTag::FlowExpTypeTag> {
using type = ISTLSolver<TypeTag>; using type = ISTLSolver<TypeTag>;
@ -199,13 +169,16 @@ struct NewtonMaxIterations<TypeTag, Properties::TTag::FlowExpTypeTag>
} // namespace Opm::Parameters } // namespace Opm::Parameters
namespace Opm::Properties { namespace Opm::Parameters {
// the maximum volumetric error of a cell in the relaxed region // the maximum volumetric error of a cell in the relaxed region
template<class TypeTag> template<class TypeTag>
struct EclNewtonRelaxedTolerance<TypeTag, TTag::FlowExpTypeTag> { struct EclNewtonRelaxedTolerance<TypeTag, Properties::TTag::FlowExpTypeTag> {
using type = GetPropType<TypeTag, Scalar>; using type = GetPropType<TypeTag, Properties::Scalar>;
static constexpr type value = 1e6*Parameters::NewtonTolerance<TypeTag, TTag::FlowExpTypeTag>::value; static constexpr auto baseValue =
Parameters::NewtonTolerance<TypeTag,
Properties::TTag::FlowExpTypeTag>::value;
static constexpr type value = 1e6 * baseValue;
}; };
} }

View File

@ -55,22 +55,6 @@ struct Problem<TypeTag, TTag::FlowExpProblemBlackOil>
using type = FlowExpProblem<TypeTag>; using type = FlowExpProblem<TypeTag>;
}; };
template<class TypeTag>
struct EclNewtonSumTolerance<TypeTag, TTag::FlowExpProblemBlackOil>
{
using type = GetPropType<TypeTag, Scalar>;
static constexpr type value = 1e-5;
};
// set fraction of the pore volume where the volumetric residual may be violated during
// strict Newton iterations
template<class TypeTag>
struct EclNewtonRelaxedVolumeFraction<TypeTag, TTag::FlowExpProblemBlackOil>
{
using type = GetPropType<TypeTag, Scalar>;
static constexpr type value = 0.0;
};
template<class TypeTag> template<class TypeTag>
struct EnableDiffusion<TypeTag, TTag::FlowExpProblemBlackOil> struct EnableDiffusion<TypeTag, TTag::FlowExpProblemBlackOil>
{ {
@ -93,14 +77,42 @@ struct Simulator<TypeTag, TTag::FlowExpProblemBlackOil>
namespace Opm::Parameters { namespace Opm::Parameters {
template<class TypeTag>
struct ThreadsPerProcess<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
{ static constexpr int value = 1; };
template<class TypeTag> template<class TypeTag>
struct ContinueOnConvergenceError<TypeTag, Properties::TTag::FlowExpProblemBlackOil> struct ContinueOnConvergenceError<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
{ static constexpr bool value = false; }; { static constexpr bool value = false; };
template<class TypeTag>
struct EclNewtonRelaxedTolerance<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
{
using type = GetPropType<TypeTag, Properties::Scalar>;
static constexpr auto baseValue =
Parameters::NewtonTolerance<TypeTag, Properties::TTag::FlowExpProblemBlackOil>::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;;
};
// the default for the allowed volumetric error for oil per second // the default for the allowed volumetric error for oil per second
template<class TypeTag> template<class TypeTag>
struct NewtonTolerance<TypeTag, Properties::TTag::FlowExpProblemBlackOil> struct NewtonTolerance<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
@ -109,18 +121,15 @@ struct NewtonTolerance<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
static constexpr type value = 1e-2; static constexpr type value = 1e-2;
}; };
} // namespace Opm::Parameters template<class TypeTag>
struct ThreadsPerProcess<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
namespace Opm::Properties { { static constexpr int value = 1; };
template<class TypeTag> template<class TypeTag>
struct EclNewtonRelaxedTolerance<TypeTag, TTag::FlowExpProblemBlackOil> struct EclNewtonStrictIterations<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
{ { static constexpr int value = 100; };
using type = GetPropType<TypeTag, Scalar>;
static constexpr type value = 10 * Parameters::NewtonTolerance<TypeTag,TTag::FlowExpProblemBlackOil>::value;
};
} // namespace Opm::Properties } // namespace Opm::Parameters
int main(int argc, char** argv) int main(int argc, char** argv)
{ {