move MaxTimestepSize to TypeTag-free parameter system

This commit is contained in:
Arne Morten Kvarving 2024-07-05 17:49:51 +02:00
parent c979eae201
commit 08002caa53
4 changed files with 13 additions and 26 deletions

View File

@ -121,14 +121,6 @@ template<class TypeTag>
struct EnableGravity<TypeTag, Properties::TTag::CuvetteBaseProblem> struct EnableGravity<TypeTag, Properties::TTag::CuvetteBaseProblem>
{ static constexpr bool value = true; }; { static constexpr bool value = true; };
// Set the maximum time step
template<class TypeTag>
struct MaxTimeStepSize<TypeTag, Properties::TTag::CuvetteBaseProblem>
{
using type = GetPropType<TypeTag, Properties::Scalar>;
static constexpr type value = 600.;
};
} // namespace Opm::Parameters } // namespace Opm::Parameters
namespace Opm { namespace Opm {
@ -298,6 +290,7 @@ public:
Parameters::SetDefault<Parameters::GridFile>("./data/cuvette_11x4.dgf"); Parameters::SetDefault<Parameters::GridFile>("./data/cuvette_11x4.dgf");
Parameters::SetDefault<Parameters::EndTime<Scalar>>(100.0); Parameters::SetDefault<Parameters::EndTime<Scalar>>(100.0);
Parameters::SetDefault<Parameters::InitialTimeStepSize<Scalar>>(1.0); Parameters::SetDefault<Parameters::InitialTimeStepSize<Scalar>>(1.0);
Parameters::SetDefault<Parameters::MaxTimeStepSize<Scalar>>(600.0);
} }
/*! /*!

View File

@ -329,14 +329,6 @@ struct LinearSolverTolerance<TypeTag, Properties::TTag::FvBaseDiscretization>
static constexpr type value = 1e-3; static constexpr type value = 1e-3;
}; };
//! use an unlimited time step size by default
template<class TypeTag>
struct MaxTimeStepSize<TypeTag, Properties::TTag::FvBaseDiscretization>
{
using type = GetPropType<TypeTag, Properties::Scalar>;
static constexpr type value = std::numeric_limits<type>::infinity();
};
//! The maximum allowed number of timestep divisions for the //! The maximum allowed number of timestep divisions for the
//! Newton solver //! Newton solver
template<class TypeTag> template<class TypeTag>

View File

@ -32,6 +32,8 @@
#include <opm/models/utils/propertysystem.hh> #include <opm/models/utils/propertysystem.hh>
#include <limits>
namespace Opm::Parameters { namespace Opm::Parameters {
/*! /*!
@ -61,6 +63,14 @@ struct EnableGridAdaptation { static constexpr bool value = false; };
*/ */
struct EnableVtkOutput { static constexpr bool value = true; }; struct EnableVtkOutput { static constexpr bool value = true; };
/*!
* \brief Specify the maximum size of a time integration [s].
*
* The default is to not limit the step size.
*/
template<class Scalar>
struct MaxTimeStepSize { static constexpr Scalar value = std::numeric_limits<Scalar>::infinity(); };
/*! /*!
* \brief The directory to which simulation output ought to be written to. * \brief The directory to which simulation output ought to be written to.
*/ */
@ -69,14 +79,6 @@ struct OutputDir { static constexpr auto value = ""; };
//! \brief Number of threads per process. //! \brief Number of threads per process.
struct ThreadsPerProcess { static constexpr int value = 1; }; struct ThreadsPerProcess { static constexpr int value = 1; };
/*!
* \brief Specify the maximum size of a time integration [s].
*
* The default is to not limit the step size.
*/
template<class TypeTag, class MyTypeTag>
struct MaxTimeStepSize { using type = Properties::UndefinedProperty; };
/*! /*!
* \brief Specify the minimal size of a time integration [s]. * \brief Specify the minimal size of a time integration [s].
* *

View File

@ -169,7 +169,7 @@ public:
static void registerParameters() static void registerParameters()
{ {
Model::registerParameters(); Model::registerParameters();
Parameters::registerParam<TypeTag, Parameters::MaxTimeStepSize> Parameters::Register<Parameters::MaxTimeStepSize<Scalar>>
("The maximum size to which all time steps are limited to [s]"); ("The maximum size to which all time steps are limited to [s]");
Parameters::registerParam<TypeTag, Parameters::MinTimeStepSize> Parameters::registerParam<TypeTag, Parameters::MinTimeStepSize>
("The minimum size to which all time steps are limited to [s]"); ("The minimum size to which all time steps are limited to [s]");
@ -593,7 +593,7 @@ public:
if (nextTimeStepSize_ > 0.0) if (nextTimeStepSize_ > 0.0)
return nextTimeStepSize_; return nextTimeStepSize_;
Scalar dtNext = std::min(Parameters::get<TypeTag, Parameters::MaxTimeStepSize>(), Scalar dtNext = std::min(Parameters::Get<Parameters::MaxTimeStepSize<Scalar>>(),
newtonMethod().suggestTimeStepSize(simulator().timeStepSize())); newtonMethod().suggestTimeStepSize(simulator().timeStepSize()));
if (dtNext < simulator().maxTimeStepSize() if (dtNext < simulator().maxTimeStepSize()