move EclTimeStepping parameters to TypeTag-free parameter system

This commit is contained in:
Arne Morten Kvarving
2024-07-06 10:22:47 +02:00
parent 707afc79eb
commit e2b8715b42
10 changed files with 47 additions and 121 deletions

View File

@@ -57,7 +57,7 @@ namespace TTag {
struct FlowExpTypeTag
{
using InheritsFrom = std::tuple<FlowBaseProblem, BlackOilModel, EclTimeSteppingParameters>;
using InheritsFrom = std::tuple<FlowBaseProblem, BlackOilModel>;
};
}

View File

@@ -78,6 +78,6 @@ struct Simulator<TypeTag, TTag::FlowExpProblemBlackOil>
int main(int argc, char** argv)
{
using TypeTag = Opm::Properties::TTag::FlowExpProblemBlackOil;
Opm::registerEclTimeSteppingParameters<TypeTag>();
Opm::registerEclTimeSteppingParameters<double>();
return Opm::start<TypeTag>(argc, argv);
}

View File

@@ -338,9 +338,9 @@ public:
enableEclOutput_ = Parameters::Get<Parameters::EnableEclOutput>();
enableVtkOutput_ = Parameters::Get<Parameters::EnableVtkOutput>();
this->enableTuning_ = Parameters::get<TypeTag, Parameters::EnableTuning>();
this->enableTuning_ = Parameters::Get<Parameters::EnableTuning>();
this->initialTimeStepSize_ = Parameters::Get<Parameters::InitialTimeStepSize<Scalar>>();
this->maxTimeStepAfterWellEvent_ = Parameters::get<TypeTag, Parameters::TimeStepAfterEventInDays>() * 24 * 60 * 60;
this->maxTimeStepAfterWellEvent_ = Parameters::Get<Parameters::TimeStepAfterEventInDays<Scalar>>() * 24 * 60 * 60;
// The value N for this parameter is defined in the following order of presedence:
// 1. Command line value (--num-pressure-points-equil=N)
@@ -2723,7 +2723,7 @@ private:
int episodeIdx = simulator.episodeIndex();
// first thing in the morning, limit the time step size to the maximum size
Scalar maxTimeStepSize = Parameters::get<TypeTag, Parameters::SolverMaxTimeStepInDays>() * 24 * 60 * 60;
Scalar maxTimeStepSize = Parameters::Get<Parameters::SolverMaxTimeStepInDays<Scalar>>() * 24 * 60 * 60;
int reportStepIdx = std::max(episodeIdx, 0);
if (this->enableTuning_) {
const auto& tuning = schedule[reportStepIdx].tuning();

View File

@@ -60,7 +60,7 @@ namespace Opm::Properties {
namespace TTag {
struct FlowBaseProblem {
using InheritsFrom = std::tuple<OutputBlackOil, CpGridVanguard>;
using InheritsFrom = std::tuple<CpGridVanguard>;
};
}

View File

@@ -65,28 +65,10 @@
#include <utility>
#include <vector>
namespace Opm::Properties::TTag {
// create new type tag for the Ecl-output
struct OutputBlackOil {};
} // namespace Opm::Properties::TTag
namespace Opm::Parameters {
template <class TypeTag, class MyTypeTag>
struct ForceDisableFluidInPlaceOutput { using type = Properties::UndefinedProperty; };
template <class TypeTag, class MyTypeTag>
struct ForceDisableResvFluidInPlaceOutput { using type = Properties::UndefinedProperty; };
template <class TypeTag>
struct ForceDisableFluidInPlaceOutput<TypeTag, Properties::TTag::OutputBlackOil>
{ static constexpr bool value = false; };
template <class TypeTag>
struct ForceDisableResvFluidInPlaceOutput<TypeTag, Properties::TTag::OutputBlackOil>
{ static constexpr bool value = false; };
struct ForceDisableFluidInPlaceOutput { static constexpr bool value = false; };
struct ForceDisableResvFluidInPlaceOutput { static constexpr bool value = false; };
} // namespace Opm::Parameters
@@ -165,10 +147,10 @@ public:
this->setupBlockData(isCartIdxOnThisRank);
this->forceDisableFipOutput_ =
Parameters::get<TypeTag, Parameters::ForceDisableFluidInPlaceOutput>();
Parameters::Get<Parameters::ForceDisableFluidInPlaceOutput>();
this->forceDisableFipresvOutput_ =
Parameters::get<TypeTag, Parameters::ForceDisableResvFluidInPlaceOutput>();
Parameters::Get<Parameters::ForceDisableResvFluidInPlaceOutput>();
if (! Parameters::Get<Parameters::OwnerCellsFirst>()) {
const std::string msg = "The output code does not support --owner-cells-first=false.";
@@ -199,10 +181,10 @@ public:
*/
static void registerParameters()
{
Parameters::registerParam<TypeTag, Parameters::ForceDisableFluidInPlaceOutput>
Parameters::Register<Parameters::ForceDisableFluidInPlaceOutput>
("Do not print fluid-in-place values after each report step "
"even if requested by the deck.");
Parameters::registerParam<TypeTag, Parameters::ForceDisableResvFluidInPlaceOutput>
Parameters::Register<Parameters::ForceDisableResvFluidInPlaceOutput>
("Do not print reservoir volumes values after each report step "
"even if requested by the deck.");
}

View File

@@ -215,7 +215,7 @@ public:
// adaptive time stepping
bool enableAdaptive = Parameters::Get<Parameters::EnableAdaptiveTimeStepping>();
bool enableTUNING = Parameters::get<TypeTag, Parameters::EnableTuning>();
bool enableTUNING = Parameters::Get<Parameters::EnableTuning>();
if (enableAdaptive) {
const UnitSystem& unitSystem = this->simulator_.vanguard().eclState().getUnits();
const auto& sched_state = schedule()[timer.currentStepNum()];
@@ -305,7 +305,7 @@ public:
this->solver_->model().beginReportStep();
const bool enableTUNING = Parameters::get<TypeTag, Parameters::EnableTuning>();
const bool enableTUNING = Parameters::Get<Parameters::EnableTuning>();
// If sub stepping is enabled allow the solver to sub cycle
// in case the report steps are too large for the solver to converge

View File

@@ -49,9 +49,7 @@
namespace Opm::Properties::TTag {
struct FlowTimeSteppingParameters {
using InheritsFrom = std::tuple<EclTimeSteppingParameters>;
};
struct FlowTimeSteppingParameters {};
}
@@ -219,6 +217,7 @@ std::set<std::string> consistentlyFailingWells(const std::vector<StepReport>& sr
template<class TypeTag>
class AdaptiveTimeStepping
{
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
template <class Solver>
class SolutionTimeErrorSolverWrapper : public RelativeChangeInterface
{
@@ -252,18 +251,18 @@ std::set<std::string> consistentlyFailingWells(const std::vector<StepReport>& sr
const double max_next_tstep = -1.0,
const bool terminalOutput = true)
: timeStepControl_()
, restartFactor_(Parameters::get<TypeTag, Parameters::SolverRestartFactor>()) // 0.33
, growthFactor_(Parameters::get<TypeTag, Parameters::SolverGrowthFactor>()) // 2.0
, maxGrowth_(Parameters::get<TypeTag, Parameters::SolverMaxGrowth>()) // 3.0
, maxTimeStep_(Parameters::get<TypeTag, Parameters::SolverMaxTimeStepInDays>() * 24 * 60 * 60) // 365.25
, minTimeStep_(unitSystem.to_si(UnitSystem::measure::time, Parameters::get<TypeTag, Parameters::SolverMinTimeStep>())) // 1e-12;
, restartFactor_(Parameters::Get<Parameters::SolverRestartFactor<Scalar>>()) // 0.33
, growthFactor_(Parameters::Get<Parameters::SolverGrowthFactor<Scalar>>()) // 2.0
, maxGrowth_(Parameters::Get<Parameters::SolverMaxGrowth<Scalar>>()) // 3.0
, maxTimeStep_(Parameters::Get<Parameters::SolverMaxTimeStepInDays<Scalar>>() * 24 * 60 * 60) // 365.25
, minTimeStep_(unitSystem.to_si(UnitSystem::measure::time, Parameters::Get<Parameters::SolverMinTimeStep<Scalar>>())) // 1e-12;
, ignoreConvergenceFailure_(Parameters::get<TypeTag, Parameters::SolverContinueOnConvergenceFailure>()) // false;
, solverRestartMax_(Parameters::get<TypeTag, Parameters::SolverMaxRestarts>()) // 10
, solverVerbose_(Parameters::get<TypeTag, Parameters::SolverVerbosity>() > 0 && terminalOutput) // 2
, timestepVerbose_(Parameters::get<TypeTag, Parameters::TimeStepVerbosity>() > 0 && terminalOutput) // 2
, suggestedNextTimestep_((max_next_tstep <= 0 ? Parameters::get<TypeTag, Parameters::InitialTimeStepInDays>() : max_next_tstep) * 24 * 60 * 60) // 1.0
, fullTimestepInitially_(Parameters::get<TypeTag, Parameters::FullTimeStepInitially>()) // false
, timestepAfterEvent_(Parameters::get<TypeTag, Parameters::TimeStepAfterEventInDays>() * 24 * 60 * 60) // 1e30
, timestepAfterEvent_(Parameters::Get<Parameters::TimeStepAfterEventInDays<Scalar>>() * 24 * 60 * 60) // 1e30
, useNewtonIteration_(false)
, minTimeStepBeforeShuttingProblematicWells_(Parameters::get<TypeTag, Parameters::MinTimeStepBeforeShuttingProblematicWellsInDays>() * unit::day)
@@ -301,7 +300,7 @@ std::set<std::string> consistentlyFailingWells(const std::vector<StepReport>& sr
static void registerParameters()
{
registerEclTimeSteppingParameters<TypeTag>();
registerEclTimeSteppingParameters<Scalar>();
// TODO: make sure the help messages are correct (and useful)
Parameters::registerParam<TypeTag, Parameters::SolverContinueOnConvergenceFailure>
("Continue instead of stop when minimum solver time step is reached");

View File

@@ -26,104 +26,49 @@
#include <opm/models/utils/basicproperties.hh>
#include <opm/models/utils/propertysystem.hh>
namespace Opm::Properties::TTag {
struct EclTimeSteppingParameters {};
}
namespace Opm::Parameters {
template<class TypeTag, class MyTypeTag>
struct EnableTuning { using type = Properties::UndefinedProperty; };
struct EnableTuning { static constexpr bool value = false; };
template<class Scalar>
struct SolverGrowthFactor { static constexpr Scalar value = 2.0; };
template<class TypeTag, class MyTypeTag>
struct SolverGrowthFactor { using type = Properties::UndefinedProperty; };
template<class Scalar>
struct SolverMaxGrowth { static constexpr Scalar value = 3.0; };
template<class TypeTag, class MyTypeTag>
struct SolverMaxGrowth { using type = Properties::UndefinedProperty; };
template<class Scalar>
struct SolverMinTimeStep { static constexpr Scalar value = 1e-12; };
template<class TypeTag, class MyTypeTag>
struct SolverMaxTimeStepInDays { using type = Properties::UndefinedProperty; };
template<class Scalar>
struct SolverMaxTimeStepInDays { static constexpr Scalar value = 365.0; };
template<class TypeTag, class MyTypeTag>
struct SolverMinTimeStep { using type = Properties::UndefinedProperty; };
template<class Scalar>
struct SolverRestartFactor { static constexpr Scalar value = 0.33; };
template<class TypeTag, class MyTypeTag>
struct SolverRestartFactor { using type = Properties::UndefinedProperty; };
template<class TypeTag, class MyTypeTag>
struct TimeStepAfterEventInDays { using type = Properties::UndefinedProperty; };
template<class TypeTag>
struct EnableTuning<TypeTag, Properties::TTag::EclTimeSteppingParameters>
{ static constexpr bool value = false; };
template<class TypeTag>
struct SolverGrowthFactor<TypeTag, Properties::TTag::EclTimeSteppingParameters>
{
using type = GetPropType<TypeTag, Properties::Scalar>;
static constexpr type value = 2.0;
};
template<class TypeTag>
struct SolverMaxGrowth<TypeTag, Properties::TTag::EclTimeSteppingParameters>
{
using type = GetPropType<TypeTag, Properties::Scalar>;
static constexpr type value = 3.0;
};
template<class TypeTag>
struct SolverMinTimeStep<TypeTag, Properties::TTag::EclTimeSteppingParameters>
{
using type = GetPropType<TypeTag, Properties::Scalar>;
static constexpr type value = 1.0e-12;
};
template<class TypeTag>
struct SolverMaxTimeStepInDays<TypeTag, Properties::TTag::EclTimeSteppingParameters>
{
using type = GetPropType<TypeTag, Properties::Scalar>;
static constexpr type value = 365.0;
};
template<class TypeTag>
struct SolverRestartFactor<TypeTag, Properties::TTag::EclTimeSteppingParameters>
{
using type = GetPropType<TypeTag, Properties::Scalar>;
static constexpr type value = 0.33;
};
template<class TypeTag>
struct TimeStepAfterEventInDays<TypeTag, Properties::TTag::EclTimeSteppingParameters>
{
using type = GetPropType<TypeTag, Properties::Scalar>;
static constexpr type value = -1.0;
};
template<class Scalar>
struct TimeStepAfterEventInDays { static constexpr Scalar value = -1.0; };
} // namespace Opm::Properties
namespace Opm {
template<class TypeTag>
template<class Scalar>
void registerEclTimeSteppingParameters()
{
Parameters::registerParam<TypeTag, Parameters::EnableTuning>
Parameters::Register<Parameters::EnableTuning>
("Honor some aspects of the TUNING keyword.");
Parameters::registerParam<TypeTag, Parameters::SolverGrowthFactor>
Parameters::Register<Parameters::SolverGrowthFactor<Scalar>>
("The factor time steps are elongated after a successful substep");
Parameters::registerParam<TypeTag, Parameters::SolverMaxGrowth>
Parameters::Register<Parameters::SolverMaxGrowth<Scalar>>
("The maximum factor time steps are elongated after a report step");
Parameters::registerParam<TypeTag, Parameters::SolverMaxTimeStepInDays>
Parameters::Register<Parameters::SolverMaxTimeStepInDays<Scalar>>
("The maximum size of a time step in days");
Parameters::registerParam<TypeTag, Parameters::SolverMinTimeStep>
Parameters::Register<Parameters::SolverMinTimeStep<Scalar>>
("The minimum size of a time step in days for field and "
"metric and hours for lab. If a step cannot converge without "
"getting cut below this step size the simulator will stop");
Parameters::registerParam<TypeTag, Parameters::SolverRestartFactor>
Parameters::Register<Parameters::SolverRestartFactor<Scalar>>
("The factor time steps are elongated after restarts");
Parameters::registerParam<TypeTag, Parameters::TimeStepAfterEventInDays>
Parameters::Register<Parameters::TimeStepAfterEventInDays<Scalar>>
("Time step size of the first time step after an event "
"occurs during the simulation in days");
}

View File

@@ -43,9 +43,9 @@ namespace TTag {
struct TestTypeTag
{
using InheritsFrom = std::tuple<FlowBaseProblem,
BlackOilModel,
EclTimeSteppingParameters>;
BlackOilModel>;
};
}
// Set the problem class

View File

@@ -87,7 +87,7 @@ initSimulator(const char *filename)
Parameters::reset();
registerAllParameters_<TypeTag>(false);
registerEclTimeSteppingParameters<TypeTag>();
registerEclTimeSteppingParameters<double>();
BlackoilModelParameters<TypeTag>::registerParameters();
Parameters::Register<Parameters::EnableTerminalOutput>("Do *NOT* use!");
Opm::Parameters::SetDefault<Opm::Parameters::ThreadsPerProcess>(2);