diff --git a/examples/problems/co2injectionproblem.hh b/examples/problems/co2injectionproblem.hh index 7b5436b4e..404b934e7 100644 --- a/examples/problems/co2injectionproblem.hh +++ b/examples/problems/co2injectionproblem.hh @@ -174,14 +174,6 @@ template struct EnableGravity { static constexpr bool value = true; }; -// The default for the end time of the simulation -template -struct EndTime -{ - using type = GetPropType; - static constexpr type value = 1e4; -}; - template struct FluidSystemNumPressure { static constexpr unsigned value = 100; }; @@ -218,14 +210,6 @@ struct FluidSystemTemperatureLow -struct InitialTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 250; -}; - template struct MaxDepth { @@ -412,6 +396,8 @@ public: ("The name of the simulation used for the output files"); Parameters::SetDefault("data/co2injection.dgf"); + Parameters::SetDefault>(1e4); + Parameters::SetDefault>(250); } /*! diff --git a/examples/problems/co2ptflashproblem.hh b/examples/problems/co2ptflashproblem.hh index 5be7e7eed..0b99ed78d 100644 --- a/examples/problems/co2ptflashproblem.hh +++ b/examples/problems/co2ptflashproblem.hh @@ -161,14 +161,6 @@ template struct EnableGravity { static constexpr bool value = false; }; -// The default for the end time of the simulation -template -struct EndTime -{ - using type = GetPropType; - static constexpr type value = 60. * 60.; -}; - // this is kinds of telling the report step length template struct EpisodeLength @@ -184,14 +176,6 @@ struct Initialpressure static constexpr type value = 75.e5; }; -// convergence control -template -struct InitialTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 0.1 * 60. * 60.; -}; - template struct LinearSolverAbsTolerance { @@ -398,6 +382,9 @@ public: Parameters::SetDefault(1); Parameters::SetDefault>(1.0); } + + Parameters::SetDefault>(60. * 60.); + Parameters::SetDefault>(0.1 * 60. * 60.); } /*! diff --git a/examples/problems/cuvetteproblem.hh b/examples/problems/cuvetteproblem.hh index c504105d9..b8f248323 100644 --- a/examples/problems/cuvetteproblem.hh +++ b/examples/problems/cuvetteproblem.hh @@ -121,30 +121,6 @@ template struct EnableGravity { static constexpr bool value = true; }; -// The default for the end time of the simulation -template -struct EndTime -{ - using type = GetPropType; - static constexpr type value = 180; -}; - -// The default for the initial time step size of the simulation -template -struct InitialTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 1; -}; - -// Set the maximum time step -template -struct MaxTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 600.; -}; - } // namespace Opm::Parameters namespace Opm { @@ -312,6 +288,9 @@ public: ParentType::registerParameters(); Parameters::SetDefault("./data/cuvette_11x4.dgf"); + Parameters::SetDefault>(100.0); + Parameters::SetDefault>(1.0); + Parameters::SetDefault>(600.0); } /*! diff --git a/examples/problems/diffusionproblem.hh b/examples/problems/diffusionproblem.hh index 19b89674e..e4b480e89 100644 --- a/examples/problems/diffusionproblem.hh +++ b/examples/problems/diffusionproblem.hh @@ -115,22 +115,6 @@ template struct EnableGravity { static constexpr bool value = false; }; -// The default for the end time of the simulation -template -struct EndTime -{ - using type = GetPropType; - static constexpr type value = 1e6; -}; - -// The default for the initial time step size of the simulation -template -struct InitialTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 1000; -}; - } // namespace Opm::Parameters namespace Opm { @@ -223,10 +207,12 @@ public: if constexpr (dim > 1) { Parameters::SetDefault(1); } - if constexpr (dim == 3) { Parameters::SetDefault(1); } + + Parameters::SetDefault>(1e6); + Parameters::SetDefault>(1000); } /*! diff --git a/examples/problems/fingerproblem.hh b/examples/problems/fingerproblem.hh index 98b5c24fb..7431e90b8 100644 --- a/examples/problems/fingerproblem.hh +++ b/examples/problems/fingerproblem.hh @@ -136,22 +136,6 @@ template struct EnableGravity { static constexpr bool value = true; }; -// The default for the end time of the simulation -template -struct EndTime -{ - using type = GetPropType; - static constexpr type value = 215; -}; - -// The default for the initial time step size of the simulation -template -struct InitialTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 10; -}; - template struct InitialWaterSaturation { @@ -296,6 +280,9 @@ public: // Use forward differences Parameters::SetDefault(+1); + + Parameters::SetDefault>(215); + Parameters::SetDefault>(10); } /*! diff --git a/examples/problems/fractureproblem.hh b/examples/problems/fractureproblem.hh index 9ac3b1bd5..83ba3986e 100644 --- a/examples/problems/fractureproblem.hh +++ b/examples/problems/fractureproblem.hh @@ -165,22 +165,6 @@ template struct EnableGravity { static constexpr bool value = false; }; -// Set the default value for the end time -template -struct EndTime -{ - using type = GetPropType; - static constexpr type value = 3e3; -}; - -// Set the default value for the initial time step size -template -struct InitialTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 100; -}; - } // namespace Opm::Parameters namespace Opm { @@ -313,6 +297,8 @@ public: ParentType::registerParameters(); Parameters::SetDefault("data/fracture.art.dgf"); + Parameters::SetDefault>(3e3); + Parameters::SetDefault>(100); } /*! diff --git a/examples/problems/groundwaterproblem.hh b/examples/problems/groundwaterproblem.hh index dc1e28b16..5e37f3e12 100644 --- a/examples/problems/groundwaterproblem.hh +++ b/examples/problems/groundwaterproblem.hh @@ -117,22 +117,6 @@ template struct EnableGravity { static constexpr bool value = true; }; -// The default for the end time of the simulation -template -struct EndTime -{ - using type = GetPropType; - static constexpr type value = 1; -}; - -// The default for the initial time step size of the simulation -template -struct InitialTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 1; -}; - template struct LensLowerLeftX { @@ -303,6 +287,8 @@ public: ("The intrinsic permeability [m^2] of the lens."); Parameters::SetDefault("./data/groundwater_2d.dgf"); + Parameters::SetDefault>(1.0); + Parameters::SetDefault>(1.0); } /*! diff --git a/examples/problems/infiltrationproblem.hh b/examples/problems/infiltrationproblem.hh index 7063f1479..64c2175ed 100644 --- a/examples/problems/infiltrationproblem.hh +++ b/examples/problems/infiltrationproblem.hh @@ -97,22 +97,6 @@ template struct EnableGravity { static constexpr bool value = true; }; -// The default for the end time of the simulation -template -struct EndTime -{ - using type = GetPropType; - static constexpr type value = 6e3; -}; - -// The default for the initial time step size of the simulation -template -struct InitialTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 60; -}; - // Write newton convergence? template struct NewtonWriteConvergence @@ -243,6 +227,8 @@ public: Parameters::SetDefault("./data/infiltration_50x3.dgf"); Parameters::SetDefault(1); + Parameters::SetDefault>(6e3); + Parameters::SetDefault>(60.0); } /*! diff --git a/examples/problems/lensproblem.hh b/examples/problems/lensproblem.hh index f5de2d98a..22409c556 100644 --- a/examples/problems/lensproblem.hh +++ b/examples/problems/lensproblem.hh @@ -143,32 +143,6 @@ template struct EnableGravity { static constexpr bool value = true; }; -// enable the cache for intensive quantities by default for this problem -template -struct EnableIntensiveQuantityCache -{ static constexpr bool value = true; }; - -// enable the storage cache by default for this problem -template -struct EnableStorageCache -{ static constexpr bool value = true; }; - -// The default for the end time of the simulation -template -struct EndTime -{ - using type = GetPropType; - static constexpr type value = 30e3; -}; - -// The default for the initial time step size of the simulation -template -struct InitialTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 250; -}; - // define the properties specific for the lens problem template struct LensLowerLeftX @@ -378,6 +352,11 @@ public: if constexpr (useFD) { Parameters::SetDefault(+1); } + + Parameters::SetDefault>(30e3); + Parameters::SetDefault(true); + Parameters::SetDefault(true); + Parameters::SetDefault>(250.0); } /*! diff --git a/examples/problems/obstacleproblem.hh b/examples/problems/obstacleproblem.hh index 312f06d8f..eb299f702 100644 --- a/examples/problems/obstacleproblem.hh +++ b/examples/problems/obstacleproblem.hh @@ -120,22 +120,6 @@ template struct EnableGravity { static constexpr bool value = true; }; -// The default for the end time of the simulation -template -struct EndTime -{ - using type = GetPropType; - static constexpr type value = 1e4; -}; - -// The default for the initial time step size of the simulation -template -struct InitialTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 250; -}; - } // namespace Opm::Parameters namespace Opm { @@ -282,6 +266,8 @@ public: ParentType::registerParameters(); Parameters::SetDefault("./data/obstacle_24x16.dgf"); + Parameters::SetDefault>(1e4); + Parameters::SetDefault>(250); } /*! diff --git a/examples/problems/outflowproblem.hh b/examples/problems/outflowproblem.hh index e9b157465..f1eeaf232 100644 --- a/examples/problems/outflowproblem.hh +++ b/examples/problems/outflowproblem.hh @@ -81,22 +81,6 @@ template struct EnableGravity { static constexpr bool value = false; }; -// The default for the end time of the simulation -template -struct EndTime -{ - using type = GetPropType; - static constexpr type value = 100; -}; - -// The default for the initial time step size of the simulation -template -struct InitialTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 1; -}; - // Also write mass fractions to the output template struct VtkWriteMassFractions @@ -190,6 +174,8 @@ public: ParentType::registerParameters(); Parameters::SetDefault("./data/outflow.dgf"); + Parameters::SetDefault>(100.0); + Parameters::SetDefault>(1.0); } /*! diff --git a/examples/problems/powerinjectionproblem.hh b/examples/problems/powerinjectionproblem.hh index 7d2d39642..71d245b44 100644 --- a/examples/problems/powerinjectionproblem.hh +++ b/examples/problems/powerinjectionproblem.hh @@ -128,22 +128,6 @@ template struct EnableGravity { static constexpr bool value = false; }; -// The default for the end time of the simulation -template -struct EndTime -{ - using type = GetPropType; - static constexpr type value = 100; -}; - -// The default for the initial time step size of the simulation -template -struct InitialTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 1e-3; -}; - // Write out the filter velocities for this problem template struct VtkWriteFilterVelocities @@ -254,6 +238,9 @@ public: Parameters::SetDefault(1); Parameters::SetDefault>(1.0); } + + Parameters::SetDefault>(100.0); + Parameters::SetDefault>(1e-3); } /*! diff --git a/examples/problems/reservoirproblem.hh b/examples/problems/reservoirproblem.hh index c65aafca7..e6f44df83 100644 --- a/examples/problems/reservoirproblem.hh +++ b/examples/problems/reservoirproblem.hh @@ -46,6 +46,7 @@ #include +#include #include #include @@ -139,25 +140,6 @@ template struct EnableGravity { static constexpr bool value = true; }; -//! The default for the end time of the simulation [s]. -//! -//! By default this problem spans 1000 days (100 "settle down" days and 900 days of -//! production) -template -struct EndTime -{ - using type = GetPropType; - static constexpr type value = 1000.0*24*60*60; -}; - -// The default for the initial time step size of the simulation [s] -template -struct InitialTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 100e3; -}; - // set the defaults for some problem specific properties template struct MaxDepth @@ -445,8 +427,15 @@ public: ("The width of producer/injector wells as a fraction of the width" " of the spatial domain"); - Parameters::SetDefault("data/reservoir.dgf"); + + //! By default this problem spans 1000 days (100 "settle down" days and 900 days of + //! production) + Parameters::SetDefault>(1000.0*24*60*60); + + Parameters::SetDefault(true); + Parameters::SetDefault("data/reservoir.dgf"); + Parameters::SetDefault>(100e3); } /*! diff --git a/examples/problems/richardslensproblem.hh b/examples/problems/richardslensproblem.hh index 2e423d85a..44dee3c30 100644 --- a/examples/problems/richardslensproblem.hh +++ b/examples/problems/richardslensproblem.hh @@ -108,22 +108,6 @@ template struct EnableGravity { static constexpr bool value = true; }; -// The default for the end time of the simulation -template -struct EndTime -{ - using type = GetPropType; - static constexpr type value = 3000; -}; - -// The default for the initial time step size of the simulation -template -struct InitialTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 100; -}; - // Do not write the intermediate results of the newton method template struct NewtonWriteConvergence @@ -272,6 +256,9 @@ public: if constexpr (useFD) { Parameters::SetDefault(0); } + + Parameters::SetDefault>(3000.0); + Parameters::SetDefault>(100.0); } /*! diff --git a/examples/problems/waterairproblem.hh b/examples/problems/waterairproblem.hh index 058b934c5..18716c10d 100644 --- a/examples/problems/waterairproblem.hh +++ b/examples/problems/waterairproblem.hh @@ -140,22 +140,6 @@ template struct EnableGravity { static constexpr bool value = true; }; -// The default for the end time of the simulation (1 year) -template -struct EndTime -{ - using type = GetPropType; - static constexpr type value = 1.0 * 365 * 24 * 60 * 60; -}; - -// The default for the initial time step size of the simulation -template -struct InitialTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 250; -}; - // Write newton convergence template struct NewtonWriteConvergence @@ -316,6 +300,9 @@ public: // Use forward differences Parameters::SetDefault(+1); + + Parameters::SetDefault>(1.0 * 365 * 24 * 60 * 60); + Parameters::SetDefault>(250.0); } /*! diff --git a/examples/reservoir_ncp_vcfv.cpp b/examples/reservoir_ncp_vcfv.cpp index 1ad4f9650..e573238de 100644 --- a/examples/reservoir_ncp_vcfv.cpp +++ b/examples/reservoir_ncp_vcfv.cpp @@ -62,16 +62,6 @@ struct BaseEpsilon } // namespace Opm::Properties -namespace Opm::Parameters { - -// enable the storage cache for this problem so that the storage cache receives wider -// testing -template -struct EnableStorageCache -{ static constexpr bool value = true; }; - -} // namespace Opm::Parameters - int main(int argc, char **argv) { using ProblemTypeTag = Opm::Properties::TTag::ReservoirNcpVcfvProblem; diff --git a/examples/tutorial1problem.hh b/examples/tutorial1problem.hh index 697156b3c..e58b0ce14 100644 --- a/examples/tutorial1problem.hh +++ b/examples/tutorial1problem.hh @@ -129,22 +129,6 @@ template struct EnableGravity { static constexpr bool value = false; }; /*@\label{tutorial1:gravity}@*/ -// define how long the simulation should run [s] -template -struct EndTime -{ - using type = GetPropType; - static constexpr type value = 100e3; -}; /*@\label{tutorial1:default-params-begin}@*/ - -// define the size of the initial time step [s] -template -struct InitialTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 125.0; -}; - } // namespace Opm::Parameters namespace Opm { @@ -231,6 +215,9 @@ public: Parameters::SetDefault(1); Parameters::SetDefault>(0.0); } + + Parameters::SetDefault>(100e3); + Parameters::SetDefault>(125.0); } //! Specifies the problem name. This is used for files generated by the simulation. diff --git a/opm/models/discretefracture/discretefracturemodel.hh b/opm/models/discretefracture/discretefracturemodel.hh index d82a720f9..7c0cc8ac1 100644 --- a/opm/models/discretefracture/discretefracturemodel.hh +++ b/opm/models/discretefracture/discretefracturemodel.hh @@ -95,19 +95,6 @@ struct UseTwoPointGradients { static const } // namespace Opm::Properties -namespace Opm::Parameters { - -// The intensive quantity cache cannot be used by the discrete fracture model, because -// the intensive quantities of a control degree of freedom are not identical to the -// intensive quantities of the other intensive quantities of the same of the same degree -// of freedom. This is because the fracture properties (volume, permeability, etc) are -// specific for each... -template -struct EnableIntensiveQuantityCache -{ static constexpr bool value = false; }; - -} // namespace Opm::Parameters - namespace Opm { /*! @@ -137,7 +124,7 @@ public: DiscreteFractureModel(Simulator& simulator) : ParentType(simulator) { - if (Parameters::get()) { + if (Parameters::Get()) { throw std::runtime_error("The discrete fracture model does not work in conjunction " "with intensive quantities caching"); } @@ -152,6 +139,13 @@ public: // register runtime parameters of the VTK output modules Opm::VtkDiscreteFractureModule::registerParameters(); + + // The intensive quantity cache cannot be used by the discrete fracture model, because + // the intensive quantities of a control degree of freedom are not identical to the + // intensive quantities of the other intensive quantities of the same of the same degree + // of freedom. This is because the fracture properties (volume, permeability, etc) are + // specific for each... + Parameters::SetDefault(false); } /*! diff --git a/opm/models/discretization/common/fvbasediscretization.hh b/opm/models/discretization/common/fvbasediscretization.hh index 3eaa52123..135ef828b 100644 --- a/opm/models/discretization/common/fvbasediscretization.hh +++ b/opm/models/discretization/common/fvbasediscretization.hh @@ -284,42 +284,6 @@ struct DiscreteFunction namespace Opm::Parameters { -//! By default, do not continue with a non-converged solution instead of giving up -//! if we encounter a time step size smaller than the minimum time -//! step size. -template -struct ContinueOnConvergenceError -{ static constexpr bool value = false; }; - -//! Disable grid adaptation by default -template -struct EnableGridAdaptation -{ static constexpr bool value = false; }; - -//! by default, disable the intensive quantity cache. If the intensive quantities are -//! relatively cheap to calculate, the cache basically does not yield any performance -//! impact because of the intensive quantity cache will cause additional pressure on the -//! CPU caches... -template -struct EnableIntensiveQuantityCache -{ static constexpr bool value = false; }; - -// disable caching the storage term by default -template -struct EnableStorageCache -{ static constexpr bool value = false; }; - -//! Enable the VTK output by default -template -struct EnableVtkOutput -{ static constexpr bool value = true; }; - -// do not use thermodynamic hints by default. If you enable this, make sure to also -// enable the intensive quantity cache above to avoid getting an exception... -template -struct EnableThermodynamicHints -{ static constexpr bool value = false; }; - // use default initialization based on rule-of-thumb of Newton tolerance template struct LinearSolverAbsTolerance @@ -339,38 +303,6 @@ struct LinearSolverTolerance static constexpr type value = 1e-3; }; -//! use an unlimited time step size by default -template -struct MaxTimeStepSize -{ - using type = GetPropType; - static constexpr type value = std::numeric_limits::infinity(); -}; - -//! The maximum allowed number of timestep divisions for the -//! Newton solver -template -struct MaxTimeStepDivisions -{ static constexpr unsigned value = 10; }; - -//! By default, accept any time step larger than zero -template -struct MinTimeStepSize -{ - using type = GetPropType; - static constexpr type value = 0.0; -}; - -//! By default, write the simulation output to the current working directory -template -struct OutputDir -{ static constexpr auto value = "."; }; - - -template -struct ThreadsPerProcess -{ static constexpr int value = 1; }; - } // namespace Opm::Parameters namespace Opm { @@ -489,10 +421,10 @@ public: , newtonMethod_(simulator) , localLinearizer_(ThreadManager::maxThreads()) , linearizer_(new Linearizer()) - , enableGridAdaptation_(Parameters::get() ) - , enableIntensiveQuantityCache_(Parameters::get()) - , enableStorageCache_(Parameters::get()) - , enableThermodynamicHints_(Parameters::get()) + , enableGridAdaptation_(Parameters::Get() ) + , enableIntensiveQuantityCache_(Parameters::Get()) + , enableStorageCache_(Parameters::Get()) + , enableThermodynamicHints_(Parameters::Get()) { bool isEcfv = std::is_same >::value; if (enableGridAdaptation_ && !isEcfv) @@ -500,8 +432,6 @@ public: "element-centered finite volume discretization (is: " +Dune::className()+")"); - enableStorageCache_ = Parameters::get(); - PrimaryVariables::init(); size_t numDof = asImp_().numGridDof(); for (unsigned timeIdx = 0; timeIdx < historySize; ++timeIdx) { @@ -546,17 +476,17 @@ public: // register runtime parameters of the output modules VtkPrimaryVarsModule::registerParameters(); - Parameters::registerParam + Parameters::Register ("Enable adaptive grid refinement/coarsening"); - Parameters::registerParam + Parameters::Register ("Global switch for turning on writing VTK files"); - Parameters::registerParam + Parameters::Register ("Enable thermodynamic hints"); - Parameters::registerParam + Parameters::Register ("Turn on caching of intensive quantities"); - Parameters::registerParam + Parameters::Register ("Store previous storage terms and avoid re-calculating them."); - Parameters::registerParam + Parameters::Register ("The directory to which result files are written"); } diff --git a/opm/models/discretization/common/fvbaseelementcontext.hh b/opm/models/discretization/common/fvbaseelementcontext.hh index 8d36126fe..5f552ae9f 100644 --- a/opm/models/discretization/common/fvbaseelementcontext.hh +++ b/opm/models/discretization/common/fvbaseelementcontext.hh @@ -97,7 +97,7 @@ public: { // remember the simulator object simulatorPtr_ = &simulator; - enableStorageCache_ = Parameters::get(); + enableStorageCache_ = Parameters::Get(); stashedDofIdx_ = -1; focusDofIdx_ = -1; } diff --git a/opm/models/discretization/common/fvbaseparameters.hh b/opm/models/discretization/common/fvbaseparameters.hh index a3fb320fe..ee6e37681 100644 --- a/opm/models/discretization/common/fvbaseparameters.hh +++ b/opm/models/discretization/common/fvbaseparameters.hh @@ -30,12 +30,16 @@ #ifndef EWOMS_FV_BASE_PARAMETERS_HH #define EWOMS_FV_BASE_PARAMETERS_HH -#include +#include namespace Opm::Parameters { -template -struct ThreadsPerProcess { using type = Properties::UndefinedProperty; }; +/*! + * \brief Continue with a non-converged solution instead of giving up + * if we encounter a time step size smaller than the minimum time + * step size. + */ +struct ContinueOnConvergenceError { static constexpr bool value = false; }; /*! * \brief Determines if the VTK output is written to disk asynchronously @@ -54,54 +58,7 @@ struct EnableAsyncVtkOutput { static constexpr bool value = true; }; * Currently grid adaptation requires the presence of the dune-FEM module. If it is not * available and grid adaptation is enabled, an exception is thrown. */ -template -struct EnableGridAdaptation { using type = Properties::UndefinedProperty; }; - -/*! - * \brief The directory to which simulation output ought to be written to. - */ -template -struct OutputDir { using type = Properties::UndefinedProperty; }; - -/*! - * \brief Global switch to enable or disable the writing of VTK output files - * - * If writing VTK files is disabled, then the WriteVtk$FOO options do - * not have any effect... - */ -template -struct EnableVtkOutput { using type = Properties::UndefinedProperty; }; - -/*! - * \brief Specify the maximum size of a time integration [s]. - * - * The default is to not limit the step size. - */ -template -struct MaxTimeStepSize { using type = Properties::UndefinedProperty; }; - -/*! - * \brief Specify the minimal size of a time integration [s]. - * - * The default is to not limit the step size. - */ -template -struct MinTimeStepSize { using type = Properties::UndefinedProperty; }; - -/*! - * \brief The maximum allowed number of timestep divisions for the - * Newton solver. - */ -template -struct MaxTimeStepDivisions { using type = Properties::UndefinedProperty; }; - -/*! - * \brief Continue with a non-converged solution instead of giving up - * if we encounter a time step size smaller than the minimum time - * step size. - */ -template -struct ContinueOnConvergenceError { using type = Properties::UndefinedProperty; }; +struct EnableGridAdaptation { static constexpr bool value = false; }; /*! * \brief Specify whether all intensive quantities for the grid should be @@ -112,8 +69,7 @@ struct ContinueOnConvergenceError { using type = Properties::UndefinedProperty; * may cause the simulation to exhibit worse cache coherence behavior * which eats some of the computational benefits again. */ -template -struct EnableIntensiveQuantityCache { using type = Properties::UndefinedProperty; }; +struct EnableIntensiveQuantityCache { static constexpr bool value = false; }; /*! * \brief Specify whether the storage terms for previous solutions should be cached. @@ -121,8 +77,7 @@ struct EnableIntensiveQuantityCache { using type = Properties::UndefinedProperty * This potentially reduces the CPU time, but comes at the cost of higher memory * consumption. */ -template -struct EnableStorageCache { using type = Properties::UndefinedProperty; }; +struct EnableStorageCache { static constexpr bool value = false; }; /*! * \brief Specify whether to use the already calculated solutions as @@ -132,8 +87,45 @@ struct EnableStorageCache { using type = Properties::UndefinedProperty; }; * very expensive (e.g. for non-linear fugacity functions where the * solver converges faster). */ -template -struct EnableThermodynamicHints { using type = Properties::UndefinedProperty; }; +struct EnableThermodynamicHints { static constexpr bool value = false; }; + +/*! + * \brief Global switch to enable or disable the writing of VTK output files + * + * If writing VTK files is disabled, then the WriteVtk$FOO options do + * not have any effect... + */ +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 +struct MaxTimeStepSize { static constexpr Scalar value = std::numeric_limits::infinity(); }; + +/*! + * \brief The maximum allowed number of timestep divisions for the + * Newton solver. + */ +struct MaxTimeStepDivisions { static constexpr unsigned value = 10; }; + +/*! + * \brief Specify the minimal size of a time integration [s]. + * + * The default is to not limit the step size. + */ +template +struct MinTimeStepSize { static constexpr Scalar value = 0.0; }; + +/*! + * \brief The directory to which simulation output ought to be written to. + */ +struct OutputDir { static constexpr auto value = ""; }; + +//! \brief Number of threads per process. +struct ThreadsPerProcess { static constexpr int value = 1; }; } // namespace Opm::Parameters diff --git a/opm/models/discretization/common/fvbaseproblem.hh b/opm/models/discretization/common/fvbaseproblem.hh index 09aed8cf9..76701c007 100644 --- a/opm/models/discretization/common/fvbaseproblem.hh +++ b/opm/models/discretization/common/fvbaseproblem.hh @@ -147,7 +147,7 @@ public: // asynchonous VTK output currently does not work in conjunction with grid // adaptivity because the async-IO code assumes that the grid stays // constant. complain about that case. - bool enableGridAdaptation = Parameters::get(); + bool enableGridAdaptation = Parameters::Get(); if (asyncVtkOutput && enableGridAdaptation) throw std::runtime_error("Asynchronous VTK output currently cannot be used " "at the same time as grid adaptivity"); @@ -169,16 +169,16 @@ public: static void registerParameters() { Model::registerParameters(); - Parameters::registerParam + Parameters::Register> ("The maximum size to which all time steps are limited to [s]"); - Parameters::registerParam + Parameters::Register> ("The minimum size to which all time steps are limited to [s]"); - Parameters::registerParam + Parameters::Register ("The maximum number of divisions by two of the timestep size " "before the simulation bails out"); Parameters::Register ("Dispatch a separate thread to write the VTK output"); - Parameters::registerParam + Parameters::Register ("Continue with a non-converged solution instead of giving up " "if we encounter a time step size smaller than the minimum time " "step size."); @@ -204,7 +204,7 @@ public: */ std::string outputDir() const { - std::string outputDir = Parameters::get(); + std::string outputDir = Parameters::Get(); if (outputDir.empty()) outputDir = "."; @@ -560,14 +560,14 @@ public: * \brief Returns the minimum allowable size of a time step. */ Scalar minTimeStepSize() const - { return Parameters::get(); } + { return Parameters::Get>(); } /*! * \brief Returns the maximum number of subsequent failures for the time integration * before giving up. */ unsigned maxTimeIntegrationFailures() const - { return Parameters::get(); } + { return Parameters::Get(); } /*! * \brief Returns if we should continue with a non-converged solution instead of @@ -575,7 +575,7 @@ public: * step size. */ bool continueOnConvergenceError() const - { return Parameters::get(); } + { return Parameters::Get(); } /*! * \brief Impose the next time step size to be used externally. @@ -593,7 +593,7 @@ public: if (nextTimeStepSize_ > 0.0) return nextTimeStepSize_; - Scalar dtNext = std::min(Parameters::get(), + Scalar dtNext = std::min(Parameters::Get>(), newtonMethod().suggestTimeStepSize(simulator().timeStepSize())); if (dtNext < simulator().maxTimeStepSize() @@ -812,7 +812,7 @@ protected: private: bool enableVtkOutput_() const - { return Parameters::get(); } + { return Parameters::Get(); } //! Returns the implementation of the problem (i.e. static polymorphism) Implementation& asImp_() diff --git a/opm/models/flash/flashmodel.hh b/opm/models/flash/flashmodel.hh index 38f4d615a..b0d7db9fd 100644 --- a/opm/models/flash/flashmodel.hh +++ b/opm/models/flash/flashmodel.hh @@ -118,23 +118,6 @@ struct EnableEnergy { static constexpr bool value = f } // namespace Opm::Properties -namespace Opm::Parameters { - -// The updates of intensive quantities tend to be _very_ expensive for this -// model, so let's try to minimize the number of required ones -template -struct EnableIntensiveQuantityCache -{ static constexpr bool value = true; }; - -// since thermodynamic hints are basically free if the cache for intensive quantities is -// enabled, and this model usually shows quite a performance improvment if they are -// enabled, let's enable them by default. -template -struct EnableThermodynamicHints -{ static constexpr bool value = true; }; - -} // namespace Opm::Parameters - namespace Opm { /*! @@ -239,6 +222,15 @@ public: Parameters::Register> ("The maximum tolerance for the flash solver to " "consider the solution converged"); + + // The updates of intensive quantities tend to be _very_ expensive for this + // model, so let's try to minimize the number of required ones + Parameters::SetDefault(true); + + // since thermodynamic hints are basically free if the cache for intensive quantities is + // enabled, and this model usually shows quite a performance improvment if they are + // enabled, let's enable them by default. + Parameters::SetDefault(true); } /*! diff --git a/opm/models/io/vtkblackoilenergymodule.hh b/opm/models/io/vtkblackoilenergymodule.hh index 0ce68f4ad..a72a100c2 100644 --- a/opm/models/io/vtkblackoilenergymodule.hh +++ b/opm/models/io/vtkblackoilenergymodule.hh @@ -141,8 +141,9 @@ public: */ void allocBuffers() { - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } if (!enableEnergy) return; @@ -163,8 +164,9 @@ public: */ void processElement(const ElementContext& elemCtx) { - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } if (!enableEnergy) return; diff --git a/opm/models/io/vtkblackoilmicpmodule.hh b/opm/models/io/vtkblackoilmicpmodule.hh index ebb95e54a..9c22e96e6 100644 --- a/opm/models/io/vtkblackoilmicpmodule.hh +++ b/opm/models/io/vtkblackoilmicpmodule.hh @@ -148,8 +148,9 @@ public: */ void allocBuffers() { - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } if (!enableMICP) return; @@ -172,8 +173,9 @@ public: */ void processElement(const ElementContext& elemCtx) { - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } if (!enableMICP) return; diff --git a/opm/models/io/vtkblackoilmodule.hh b/opm/models/io/vtkblackoilmodule.hh index 75ed870cd..6ec841f12 100644 --- a/opm/models/io/vtkblackoilmodule.hh +++ b/opm/models/io/vtkblackoilmodule.hh @@ -249,8 +249,9 @@ public: */ void processElement(const ElementContext& elemCtx) { - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++dofIdx) { const auto& fs = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0).fluidState(); diff --git a/opm/models/io/vtkblackoilpolymermodule.hh b/opm/models/io/vtkblackoilpolymermodule.hh index 96024d089..31942f59f 100644 --- a/opm/models/io/vtkblackoilpolymermodule.hh +++ b/opm/models/io/vtkblackoilpolymermodule.hh @@ -160,8 +160,9 @@ public: */ void allocBuffers() { - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } if (!enablePolymer) return; @@ -186,8 +187,9 @@ public: */ void processElement(const ElementContext& elemCtx) { - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } if (!enablePolymer) return; diff --git a/opm/models/io/vtkblackoilsolventmodule.hh b/opm/models/io/vtkblackoilsolventmodule.hh index 6707c2ddc..3b4c5adea 100644 --- a/opm/models/io/vtkblackoilsolventmodule.hh +++ b/opm/models/io/vtkblackoilsolventmodule.hh @@ -150,8 +150,9 @@ public: */ void allocBuffers() { - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } if (!enableSolvent) return; @@ -174,8 +175,9 @@ public: */ void processElement(const ElementContext& elemCtx) { - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } if (!enableSolvent) return; diff --git a/opm/models/io/vtkcompositionmodule.hh b/opm/models/io/vtkcompositionmodule.hh index ce92e7913..f062032a3 100644 --- a/opm/models/io/vtkcompositionmodule.hh +++ b/opm/models/io/vtkcompositionmodule.hh @@ -191,8 +191,9 @@ public: { using Toolbox = MathToolbox; - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } for (unsigned i = 0; i < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++i) { unsigned I = elemCtx.globalSpaceIndex(i, /*timeIdx=*/0); diff --git a/opm/models/io/vtkdiffusionmodule.hh b/opm/models/io/vtkdiffusionmodule.hh index 0515e285c..023fd8a27 100644 --- a/opm/models/io/vtkdiffusionmodule.hh +++ b/opm/models/io/vtkdiffusionmodule.hh @@ -147,8 +147,9 @@ public: */ void processElement(const ElementContext& elemCtx) { - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } for (unsigned i = 0; i < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++i) { unsigned I = elemCtx.globalSpaceIndex(i, /*timeIdx=*/0); diff --git a/opm/models/io/vtkdiscretefracturemodule.hh b/opm/models/io/vtkdiscretefracturemodule.hh index 1d8f2e5a9..785e2715e 100644 --- a/opm/models/io/vtkdiscretefracturemodule.hh +++ b/opm/models/io/vtkdiscretefracturemodule.hh @@ -210,8 +210,9 @@ public: */ void processElement(const ElementContext& elemCtx) { - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } const auto& fractureMapper = elemCtx.simulator().vanguard().fractureMapper(); diff --git a/opm/models/io/vtkenergymodule.hh b/opm/models/io/vtkenergymodule.hh index 868dc873d..411c12798 100644 --- a/opm/models/io/vtkenergymodule.hh +++ b/opm/models/io/vtkenergymodule.hh @@ -162,8 +162,9 @@ public: */ void processElement(const ElementContext& elemCtx) { - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } for (unsigned i = 0; i < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++i) { unsigned I = elemCtx.globalSpaceIndex(i, /*timeIdx=*/0); diff --git a/opm/models/io/vtkmultiphasemodule.hh b/opm/models/io/vtkmultiphasemodule.hh index 5417b19e4..881135211 100644 --- a/opm/models/io/vtkmultiphasemodule.hh +++ b/opm/models/io/vtkmultiphasemodule.hh @@ -273,8 +273,9 @@ public: */ void processElement(const ElementContext& elemCtx) { - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } const auto& problem = elemCtx.problem(); for (unsigned i = 0; i < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++i) { diff --git a/opm/models/io/vtkphasepresencemodule.hh b/opm/models/io/vtkphasepresencemodule.hh index 9a62eaf4c..37bec49a3 100644 --- a/opm/models/io/vtkphasepresencemodule.hh +++ b/opm/models/io/vtkphasepresencemodule.hh @@ -106,8 +106,9 @@ public: */ void processElement(const ElementContext& elemCtx) { - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } for (unsigned i = 0; i < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++i) { // calculate the phase presence diff --git a/opm/models/io/vtkprimaryvarsmodule.hh b/opm/models/io/vtkprimaryvarsmodule.hh index 4c06212e1..1bc02d2d7 100644 --- a/opm/models/io/vtkprimaryvarsmodule.hh +++ b/opm/models/io/vtkprimaryvarsmodule.hh @@ -131,8 +131,9 @@ public: */ void processElement(const ElementContext& elemCtx) { - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } const auto& elementMapper = elemCtx.model().elementMapper(); unsigned elemIdx = static_cast(elementMapper.index(elemCtx.element())); diff --git a/opm/models/io/vtkptflashmodule.hh b/opm/models/io/vtkptflashmodule.hh index c0baad6e5..f8b9758c1 100644 --- a/opm/models/io/vtkptflashmodule.hh +++ b/opm/models/io/vtkptflashmodule.hh @@ -131,8 +131,9 @@ public: { using Toolbox = MathToolbox; - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } for (unsigned i = 0; i < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++i) { unsigned I = elemCtx.globalSpaceIndex(i, /*timeIdx=*/0); diff --git a/opm/models/io/vtktemperaturemodule.hh b/opm/models/io/vtktemperaturemodule.hh index 28ff584d3..d001569ed 100644 --- a/opm/models/io/vtktemperaturemodule.hh +++ b/opm/models/io/vtktemperaturemodule.hh @@ -112,8 +112,9 @@ public: { using Toolbox = MathToolbox; - if (!Parameters::get()) + if (!Parameters::Get()) { return; + } for (unsigned i = 0; i < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++i) { unsigned I = elemCtx.globalSpaceIndex(i, /*timeIdx=*/0); diff --git a/opm/models/parallel/threadmanager.hh b/opm/models/parallel/threadmanager.hh index fda9689ab..2aa83d8fc 100644 --- a/opm/models/parallel/threadmanager.hh +++ b/opm/models/parallel/threadmanager.hh @@ -60,7 +60,7 @@ public: */ static void registerParameters() { - Parameters::registerParam + Parameters::Register ("The maximum number of threads to be instantiated per process " "('-1' means 'automatic')"); } @@ -78,7 +78,7 @@ public: { if (queryCommandLineParameter) { - numThreads_ = Parameters::get(); + numThreads_ = Parameters::Get(); // some safety checks. This is pretty ugly macro-magic, but so what? #if !defined(_OPENMP) diff --git a/opm/models/ptflash/flashmodel.hh b/opm/models/ptflash/flashmodel.hh index d03a1af66..279be8d06 100644 --- a/opm/models/ptflash/flashmodel.hh +++ b/opm/models/ptflash/flashmodel.hh @@ -141,23 +141,6 @@ struct EnableEnergy } // namespace Opm::Properties -namespace Opm::Parameters { - -// The updates of intensive quantities tend to be _very_ expensive for this -// model, so let's try to minimize the number of required ones -template -struct EnableIntensiveQuantityCache -{ static constexpr bool value = true; }; - -// since thermodynamic hints are basically free if the cache for intensive quantities is -// enabled, and this model usually shows quite a performance improvment if they are -// enabled, let's enable them by default. -template -struct EnableThermodynamicHints -{ static constexpr bool value = true; }; - -} // namespace Opm::Parameters - namespace Opm { /*! @@ -253,6 +236,12 @@ public: "ssi, newton, ssi+newton"); Parameters::SetDefault>(1e-12); + Parameters::SetDefault(true); + + // since thermodynamic hints are basically free if the cache for intensive quantities is + // enabled, and this model usually shows quite a performance improvment if they are + // enabled, let's enable them by default. + Parameters::SetDefault(true); } /*! diff --git a/opm/models/utils/basicparameters.hh b/opm/models/utils/basicparameters.hh index 0e8be2bb3..6b9ff8565 100644 --- a/opm/models/utils/basicparameters.hh +++ b/opm/models/utils/basicparameters.hh @@ -28,8 +28,6 @@ #ifndef EWOMS_BASIC_PARAMETERS_HH #define EWOMS_BASIC_PARAMETERS_HH -#include - namespace Opm::Parameters { //! grid resolution @@ -48,8 +46,8 @@ template struct DomainSizeZ { static constexpr Scalar value = 1.0; }; //! The default value for the simulation's end time -template -struct EndTime { using type = Properties::UndefinedProperty; }; +template +struct EndTime { static constexpr Scalar value = -1e35; }; //! Name of the grid file struct GridFile { static constexpr auto value = ""; }; @@ -59,15 +57,14 @@ struct GridFile { static constexpr auto value = ""; }; struct GridGlobalRefinements { static constexpr unsigned value = 0; }; //! The default value for the simulation's initial time step size -template -struct InitialTimeStepSize { using type = Properties::UndefinedProperty; }; +template +struct InitialTimeStepSize { static constexpr Scalar value = -1e35; }; //! Set a value for the ParameterFile property struct ParameterFile { static constexpr auto value = ""; }; -//! The name of the file with a number of forced time step lengths -template -struct PredeterminedTimeStepsFile { using type = Properties::UndefinedProperty; }; +//! By default, do not force any time steps +struct PredeterminedTimeStepsFile { static constexpr auto value = ""; }; /*! * \brief Print all parameters on startup? @@ -75,12 +72,11 @@ struct PredeterminedTimeStepsFile { using type = Properties::UndefinedProperty; * 0 means 'no', 1 means 'yes', 2 means 'print only to logfiles'. The * default is 2. */ -template -struct PrintParameters { using type = Properties::UndefinedProperty; }; +struct PrintParameters { static constexpr int value = 2; }; //! The default value for the simulation's restart time -template -struct RestartTime { using type = Properties::UndefinedProperty; }; +template +struct RestartTime { static constexpr Scalar value = -1e35; }; } // namespace Opm:Parameters diff --git a/opm/models/utils/basicproperties.hh b/opm/models/utils/basicproperties.hh index cc3e7962c..9d751ba9c 100644 --- a/opm/models/utils/basicproperties.hh +++ b/opm/models/utils/basicproperties.hh @@ -177,42 +177,4 @@ struct Vanguard } // namespace Opm::Properties -namespace Opm::Parameters { - -//! The default value for the simulation's end time -template -struct EndTime -{ - using type = GetPropType; - static constexpr type value = -1e35; -}; - -//! The default value for the simulation's initial time step size -template -struct InitialTimeStepSize -{ - using type = GetPropType; - static constexpr type value = -1e35; -}; - -//! By default, do not force any time steps -template -struct PredeterminedTimeStepsFile -{ static constexpr auto value = ""; }; - -//! By default, print the values of the run-time parameters on startup -template -struct PrintParameters -{ static constexpr int value = 2; }; - -//! The default value for the simulation's restart time -template -struct RestartTime -{ - using type = GetPropType; - static constexpr type value = -1e35; -}; - -} // namespace Opm::Parameters - #endif diff --git a/opm/models/utils/simulator.hh b/opm/models/utils/simulator.hh index 65bd2198e..116da39c6 100644 --- a/opm/models/utils/simulator.hh +++ b/opm/models/utils/simulator.hh @@ -129,11 +129,11 @@ public: timeStepIdx_ = 0; startTime_ = 0.0; time_ = 0.0; - endTime_ = Parameters::get(); - timeStepSize_ = Parameters::get(); + endTime_ = Parameters::Get>(); + timeStepSize_ = Parameters::Get>(); assert(timeStepSize_ > 0); const std::string& predetTimeStepFile = - Parameters::get(); + Parameters::Get(); if (!predetTimeStepFile.empty()) { std::ifstream is(predetTimeStepFile); while (!is.eof()) { @@ -254,13 +254,13 @@ public: */ static void registerParameters() { - Parameters::registerParam + Parameters::Register> ("The simulation time at which the simulation is finished [s]"); - Parameters::registerParam + Parameters::Register> ("The size of the initial time step [s]"); - Parameters::registerParam + Parameters::Register> ("The simulation time at which a restart should be attempted [s]"); - Parameters::registerParam + Parameters::Register ("A file with a list of predetermined time step sizes (one " "time step per line)"); @@ -649,7 +649,7 @@ public: TimerGuard writeTimerGuard(writeTimer_); setupTimer_.start(); - Scalar restartTime = Parameters::get(); + Scalar restartTime = Parameters::Get>(); if (restartTime > -1e30) { // try to restart a previous simulation time_ = restartTime; diff --git a/opm/models/utils/start.hh b/opm/models/utils/start.hh index ac6712602..62604c471 100644 --- a/opm/models/utils/start.hh +++ b/opm/models/utils/start.hh @@ -80,12 +80,12 @@ static inline void registerAllParameters_(bool finalizeRegistration = true) Parameters::Register ("An .ini file which contains a set of run-time parameters"); - Parameters::registerParam + Parameters::Register ("Print the values of the run-time parameters at the " "start of the simulation"); - Simulator::registerParameters(); ThreadManager::registerParameters(); + Simulator::registerParameters(); if (finalizeRegistration) { Parameters::endRegistration(); @@ -315,7 +315,7 @@ static inline int start(int argc, char **argv, bool registerParams=true) #endif // read the initial time step and the end time - Scalar endTime = Parameters::get(); + Scalar endTime = Parameters::Get>(); if (endTime < -1e50) { if (myRank == 0) Parameters::printUsage(argv[0], @@ -323,7 +323,7 @@ static inline int start(int argc, char **argv, bool registerParams=true) return 1; } - Scalar initialTimeStepSize = Parameters::get(); + Scalar initialTimeStepSize = Parameters::Get>(); if (initialTimeStepSize < -1e50) { if (myRank == 0) Parameters::printUsage(argv[0], @@ -351,7 +351,7 @@ static inline int start(int argc, char **argv, bool registerParams=true) } // print the parameters if requested - int printParams = Parameters::get(); + int printParams = Parameters::Get(); if (myRank == 0) { std::string endParametersSeparator("# [end of parameters]\n"); if (printParams) {