From 296c8ef73d746eccb2b1a6494f44086eca4d26c8 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sat, 6 Jul 2024 10:22:47 +0200 Subject: [PATCH 01/15] move FlowExpNewtonMethod parameters to TypeTag-free parameter system --- flowexperimental/FlowExpNewtonMethod.hpp | 50 ++++++++++++++---------- flowexperimental/flowexp.hpp | 13 ++---- flowexperimental/flowexp_blackoil.cpp | 40 ------------------- 3 files changed, 32 insertions(+), 71 deletions(-) diff --git a/flowexperimental/FlowExpNewtonMethod.hpp b/flowexperimental/FlowExpNewtonMethod.hpp index e2107836f..6e9753d75 100644 --- a/flowexperimental/FlowExpNewtonMethod.hpp +++ b/flowexperimental/FlowExpNewtonMethod.hpp @@ -36,22 +36,30 @@ namespace Opm::Parameters { -template -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 +struct EclNewtonSumTolerance { static constexpr Scalar value = 1e-5; }; -template -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 -struct EclNewtonRelaxedVolumeFraction { using type = Properties::UndefinedProperty; }; +// set fraction of the pore volume where the volumetric residual may be violated during +// strict Newton iterations +template +struct EclNewtonRelaxedVolumeFraction { static constexpr Scalar value = 0.05; }; -template -struct EclNewtonSumToleranceExponent { using type = Properties::UndefinedProperty; }; +template +struct EclNewtonSumToleranceExponent { static constexpr Scalar value = 1.0 / 3.0; }; -template -struct EclNewtonRelaxedTolerance { using type = Properties::UndefinedProperty; }; +// the maximum volumetric error of a cell in the relaxed region +template +struct EclNewtonRelaxedTolerance { static constexpr Scalar value = NewtonTolerance::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(); + relaxedMaxPvFraction_ = Parameters::Get>(); sumTolerance_ = 0.0; // this gets determined in the error calculation proceedure - relaxedTolerance_ = Parameters::get(); + relaxedTolerance_ = Parameters::Get>(); - numStrictIterations_ = Parameters::get(); + numStrictIterations_ = Parameters::Get(); } /*! @@ -104,19 +112,19 @@ public: { ParentType::registerParameters(); - Parameters::registerParam + Parameters::Register> ("The maximum error tolerated by the Newton " "method for considering a solution to be converged"); - Parameters::registerParam + Parameters::Register ("The number of Newton iterations where the " "volumetric error is considered."); - Parameters::registerParam + Parameters::Register> ("The fraction of the pore volume of the reservoir " "where the volumetric error may be violated during strict Newton iterations."); - Parameters::registerParam + Parameters::Register> ("The the exponent used to scale the sum tolerance by " "the total pore volume of the reservoir."); - Parameters::registerParam + Parameters::Register> ("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(); - Scalar y = Parameters::get(); + Scalar x = Parameters::Get>(); + Scalar y = Parameters::Get>(); sumTolerance_ = x*std::pow(sumPv, y); this->endIterMsg() << " (max: " << this->tolerance_ diff --git a/flowexperimental/flowexp.hpp b/flowexperimental/flowexp.hpp index a9ab269e0..2f13f969a 100644 --- a/flowexperimental/flowexp.hpp +++ b/flowexperimental/flowexp.hpp @@ -126,16 +126,6 @@ template struct EnableTerminalOutput { static constexpr bool value = false; }; -// the maximum volumetric error of a cell in the relaxed region -template -struct EclNewtonRelaxedTolerance -{ - using type = GetPropType; - static constexpr auto baseValue = - Parameters::NewtonTolerance::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(8); Parameters::SetDefault>(1e-2); + Parameters::SetDefault>(1e-1); + Parameters::SetDefault>(0.0); + Parameters::SetDefault>(1e-5); } // inherit the constructors diff --git a/flowexperimental/flowexp_blackoil.cpp b/flowexperimental/flowexp_blackoil.cpp index fe1507926..616e4956c 100644 --- a/flowexperimental/flowexp_blackoil.cpp +++ b/flowexperimental/flowexp_blackoil.cpp @@ -75,46 +75,6 @@ struct Simulator } // namespace Opm::Properties -namespace Opm::Parameters { - -template -struct EclNewtonRelaxedTolerance -{ - using type = GetPropType; - static constexpr auto baseValue = - Parameters::NewtonTolerance::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 -struct EclNewtonRelaxedVolumeFraction -{ - using type = GetPropType; - static constexpr type value = 0.0; -}; - -template -struct EclNewtonSumTolerance -{ - using type = GetPropType; - static constexpr type value = 1e-5; -}; - -template -struct EclNewtonSumToleranceExponent -{ - using type = GetPropType; - static constexpr type value = 1.0 / 3.0;; -}; - -template -struct EclNewtonStrictIterations -{ static constexpr int value = 100; }; - -} // namespace Opm::Parameters - int main(int argc, char** argv) { using TypeTag = Opm::Properties::TTag::FlowExpProblemBlackOil; From aab40a32e2a518c40880e2faa7bd26548ba4350d Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sat, 6 Jul 2024 10:22:47 +0200 Subject: [PATCH 02/15] move EnableTerminalOutput parameter to TypeTag-free parameter system --- flowexperimental/flowexp.hpp | 9 +++------ opm/simulators/flow/Main.hpp | 2 +- .../flow/SimulatorFullyImplicitBlackoil.hpp | 8 ++------ opm/simulators/wells/BlackoilWellModel.hpp | 3 +-- opm/simulators/wells/BlackoilWellModel_impl.hpp | 2 +- tests/TestTypeTag.hpp | 4 ---- tests/test_RestartSerialization.cpp | 2 +- tests/test_equil.cpp | 12 +----------- tests/test_glift1.cpp | 2 +- 9 files changed, 11 insertions(+), 33 deletions(-) diff --git a/flowexperimental/flowexp.hpp b/flowexperimental/flowexp.hpp index 2f13f969a..2ea1528c7 100644 --- a/flowexperimental/flowexp.hpp +++ b/flowexperimental/flowexp.hpp @@ -122,10 +122,6 @@ struct LinearSolverBackend { namespace Opm::Parameters { -template -struct EnableTerminalOutput -{ static constexpr bool value = false; }; - // 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. @@ -168,7 +164,7 @@ public: ParentType::registerParameters(); BlackoilModelParameters::registerParameters(); - Parameters::registerParam("Do *NOT* use!"); + Parameters::Register("Do *NOT* use!"); Parameters::hideParam(); Parameters::hideParam(); Parameters::hideParam(); @@ -192,7 +188,7 @@ public: Parameters::hideParam(); Parameters::hideParam(); Parameters::hideParam(); - Parameters::hideParam(); + Parameters::Hide(); // if openMP is available, set the default the number of threads per process for the main // simulation to 2 (instead of grabbing everything that is available). @@ -209,6 +205,7 @@ public: Parameters::SetDefault>(1e-1); Parameters::SetDefault>(0.0); Parameters::SetDefault>(1e-5); + Parameters::SetDefault(false); } // inherit the constructors diff --git a/opm/simulators/flow/Main.hpp b/opm/simulators/flow/Main.hpp index c7fb18392..4c48e54be 100644 --- a/opm/simulators/flow/Main.hpp +++ b/opm/simulators/flow/Main.hpp @@ -378,7 +378,7 @@ private: int mpiRank = FlowGenericVanguard::comm().rank(); outputCout_ = false; if (mpiRank == 0) - outputCout_ = Parameters::get(); + outputCout_ = Parameters::Get(); if (deckFilename.empty()) { if (mpiRank == 0) { diff --git a/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp b/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp index 6913552f8..93f4d5610 100644 --- a/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp +++ b/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp @@ -85,10 +85,6 @@ template struct OutputExtraConvergenceInfo { static constexpr auto* value = "none"; }; -template -struct EnableTerminalOutput -{ static constexpr bool value = true; }; - template struct SaveStep { static constexpr auto* value = ""; }; @@ -171,7 +167,7 @@ public: // Only rank 0 does print to std::cout, and only if specifically requested. this->terminalOutput_ = false; if (this->grid().comm().rank() == 0) { - this->terminalOutput_ = Parameters::get(); + this->terminalOutput_ = Parameters::Get(); this->startConvergenceOutputThread(Parameters::get(), R"(OutputExtraConvergenceInfo (--output-extra-convergence-info))"); @@ -190,7 +186,7 @@ public: SolverParameters::registerParameters(); TimeStepper::registerParameters(); - Parameters::registerParam + Parameters::Register ("Print high-level information about the simulation's progress to the terminal"); Parameters::registerParam ("Use adaptive time stepping between report steps"); diff --git a/opm/simulators/wells/BlackoilWellModel.hpp b/opm/simulators/wells/BlackoilWellModel.hpp index 6470f8286..4d9282889 100644 --- a/opm/simulators/wells/BlackoilWellModel.hpp +++ b/opm/simulators/wells/BlackoilWellModel.hpp @@ -80,8 +80,7 @@ namespace Opm::Parameters { -template -struct EnableTerminalOutput { using type = Properties::UndefinedProperty; }; +struct EnableTerminalOutput { static constexpr bool value = true; }; } // namespace Opm::Parameters diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 7416c2ea9..c6a249358 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -77,7 +77,7 @@ namespace Opm { , simulator_(simulator) { this->terminal_output_ = ((simulator.gridView().comm().rank() == 0) && - Parameters::get()); + Parameters::Get()); local_num_cells_ = simulator_.gridView().size(0); diff --git a/tests/TestTypeTag.hpp b/tests/TestTypeTag.hpp index 5d8b1040b..53064e07c 100644 --- a/tests/TestTypeTag.hpp +++ b/tests/TestTypeTag.hpp @@ -97,10 +97,6 @@ struct LinearSolverBackend { namespace Opm::Parameters { -template -struct EnableTerminalOutput -{ static constexpr bool value = false; }; - // set some parameters that are only required by the well model template struct MatrixAddWellContributions diff --git a/tests/test_RestartSerialization.cpp b/tests/test_RestartSerialization.cpp index b2126bc2c..e6967b1ff 100644 --- a/tests/test_RestartSerialization.cpp +++ b/tests/test_RestartSerialization.cpp @@ -514,7 +514,7 @@ struct AquiferFixture { Opm::ThreadManager::registerParameters(); AdaptiveTimeStepping::registerParameters(); BlackoilModelParameters::registerParameters(); - Parameters::registerParam("Do *NOT* use!"); + Parameters::Register("Do *NOT* use!"); setupParameters_(2, argv, /*registerParams=*/true); Opm::FlowGenericVanguard::setCommunication(std::make_unique()); } diff --git a/tests/test_equil.cpp b/tests/test_equil.cpp index a256b50f7..06f023acf 100644 --- a/tests/test_equil.cpp +++ b/tests/test_equil.cpp @@ -98,15 +98,6 @@ struct EnableVapwat { } // namespace Opm::Properties -namespace Opm::Parameters { - -template -struct EnableTerminalOutput { - static constexpr bool value = true; -}; - -} // namespace Opm::Parameters - template std::unique_ptr> initSimulator(const char *filename) @@ -242,8 +233,7 @@ struct EquilFixture { Opm::ThreadManager::registerParameters(); BlackoilModelParameters::registerParameters(); AdaptiveTimeStepping::registerParameters(); - Parameters::registerParam("Dummy added for the well model to compile."); + Parameters::Register("Dummy added for the well model to compile."); registerAllParameters_(); } diff --git a/tests/test_glift1.cpp b/tests/test_glift1.cpp index b02dcebdf..ae11d5932 100644 --- a/tests/test_glift1.cpp +++ b/tests/test_glift1.cpp @@ -89,7 +89,7 @@ initSimulator(const char *filename) registerAllParameters_(false); registerEclTimeSteppingParameters(); BlackoilModelParameters::registerParameters(); - Parameters::registerParam("Do *NOT* use!"); + Parameters::Register("Do *NOT* use!"); Opm::Parameters::SetDefault(2); Parameters::endRegistration(); setupParameters_(/*argc=*/sizeof(argv) / sizeof(argv[0]), From febb359951225908c5c4ba7717751ba1ea757682 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sat, 6 Jul 2024 10:22:47 +0200 Subject: [PATCH 03/15] move VtkTracerModule parameters to TypeTag-free parameter system --- opm/simulators/flow/FlowMain.hpp | 2 +- opm/simulators/flow/FlowProblemProperties.hpp | 2 +- opm/simulators/flow/VtkTracerModule.hpp | 19 +++---------------- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/opm/simulators/flow/FlowMain.hpp b/opm/simulators/flow/FlowMain.hpp index 6451ccdfa..a8714aed7 100644 --- a/opm/simulators/flow/FlowMain.hpp +++ b/opm/simulators/flow/FlowMain.hpp @@ -169,7 +169,7 @@ namespace Opm { Parameters::Hide(); Parameters::Hide(); Parameters::Hide(); - Parameters::hideParam(); + Parameters::Hide(); Parameters::Hide(); Parameters::Hide(); Parameters::Hide(); diff --git a/opm/simulators/flow/FlowProblemProperties.hpp b/opm/simulators/flow/FlowProblemProperties.hpp index 7f831f8f2..81c4b1b14 100644 --- a/opm/simulators/flow/FlowProblemProperties.hpp +++ b/opm/simulators/flow/FlowProblemProperties.hpp @@ -62,7 +62,7 @@ namespace Opm::Properties { namespace TTag { struct FlowBaseProblem { - using InheritsFrom = std::tuple; + using InheritsFrom = std::tuple; }; } diff --git a/opm/simulators/flow/VtkTracerModule.hpp b/opm/simulators/flow/VtkTracerModule.hpp index d67a5404e..f7b9060ad 100644 --- a/opm/simulators/flow/VtkTracerModule.hpp +++ b/opm/simulators/flow/VtkTracerModule.hpp @@ -39,23 +39,10 @@ #include #include -namespace Opm::Properties::TTag { - -// create new type tag for the VTK tracer output -struct VtkTracer {}; - -} - namespace Opm::Parameters { -// create the property tags needed for the tracer model -template -struct VtkWriteTracerConcentration { using type = Properties::UndefinedProperty; }; - // set default values for what quantities to output -template -struct VtkWriteTracerConcentration -{ static constexpr bool value = false; }; +struct VtkWriteTracerConcentration { static constexpr bool value = false; }; } // namespace Opm::Parameters @@ -95,7 +82,7 @@ namespace Opm { */ static void registerParameters() { - Parameters::registerParam + Parameters::Register ("Include the tracer concentration in the VTK output files"); } @@ -178,7 +165,7 @@ namespace Opm { private: static bool eclTracerConcentrationOutput_() { - static bool val = Parameters::get(); + static bool val = Parameters::Get(); return val; } From 3716ee664dabeba32e04d7d12a110476194b4357 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sat, 6 Jul 2024 10:22:47 +0200 Subject: [PATCH 04/15] move BlackoilModel parameters to TypeTag-free parameter system --- flowexperimental/flowexp.hpp | 77 +- opm/simulators/flow/BlackoilModel.hpp | 2 +- .../flow/BlackoilModelParameters.hpp | 664 +++++------------- opm/simulators/flow/FlowBaseVanguard.hpp | 19 +- opm/simulators/flow/FlowMain.hpp | 4 +- opm/simulators/flow/Main.hpp | 2 +- opm/simulators/linalg/ISTLSolver.hpp | 4 +- .../wells/BlackoilWellModel_impl.hpp | 2 +- tests/TestTypeTag.hpp | 24 +- tests/test_equil.cpp | 7 +- 10 files changed, 230 insertions(+), 575 deletions(-) diff --git a/flowexperimental/flowexp.hpp b/flowexperimental/flowexp.hpp index 2ea1528c7..db2bc616f 100644 --- a/flowexperimental/flowexp.hpp +++ b/flowexperimental/flowexp.hpp @@ -54,9 +54,12 @@ class FlowExpProblem; namespace Opm::Properties { namespace TTag { -struct FlowExpTypeTag { - using InheritsFrom = std::tuple; + +struct FlowExpTypeTag +{ + using InheritsFrom = std::tuple; }; + } // Set the problem class @@ -120,22 +123,6 @@ struct LinearSolverBackend { } // namespace Opm::Properties -namespace Opm::Parameters { - -// 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. -template -struct UseMultisegmentWell -{ static constexpr bool value = false; }; - -// set some properties that are only required by the well model -template -struct MatrixAddWellContributions -{ static constexpr bool value = false; }; - -} // namespace Opm::Parameters - namespace Opm { template class FlowExpProblem : public FlowProblem //, public FvBaseProblem @@ -165,33 +152,33 @@ public: BlackoilModelParameters::registerParameters(); Parameters::Register("Do *NOT* use!"); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); - Parameters::hideParam(); + Parameters::Hide>(); + Parameters::Hide>(); + Parameters::Hide>(); + Parameters::Hide>(); + Parameters::Hide>(); + Parameters::Hide>(); + Parameters::Hide>(); + Parameters::Hide>(); + Parameters::Hide>(); + Parameters::Hide(); + Parameters::Hide(); + Parameters::Hide>(); + Parameters::Hide>(); + Parameters::Hide(); + Parameters::Hide(); + Parameters::Hide(); + Parameters::Hide>(); + Parameters::Hide(); + Parameters::Hide(); + Parameters::Hide(); + Parameters::Hide(); + Parameters::Hide(); + Parameters::Hide(); Parameters::Hide(); // if openMP is available, set the default the number of threads per process for the main - // simulation to 2 (instead of grabbing everything that is available). + // simulation to 1 (instead of grabbing everything that is available). #if _OPENMP Parameters::SetDefault(2); #endif @@ -206,6 +193,12 @@ public: Parameters::SetDefault>(0.0); Parameters::SetDefault>(1e-5); Parameters::SetDefault(false); + + // 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. + Parameters::SetDefault(false); + Parameters::SetDefault(false); } // inherit the constructors diff --git a/opm/simulators/flow/BlackoilModel.hpp b/opm/simulators/flow/BlackoilModel.hpp index dd1607091..328c30c9f 100644 --- a/opm/simulators/flow/BlackoilModel.hpp +++ b/opm/simulators/flow/BlackoilModel.hpp @@ -75,7 +75,7 @@ namespace Opm::Properties { namespace TTag { struct FlowProblem { - using InheritsFrom = std::tuple; }; } diff --git a/opm/simulators/flow/BlackoilModelParameters.hpp b/opm/simulators/flow/BlackoilModelParameters.hpp index 977e27a7a..c7e3737cf 100644 --- a/opm/simulators/flow/BlackoilModelParameters.hpp +++ b/opm/simulators/flow/BlackoilModelParameters.hpp @@ -25,7 +25,6 @@ #include #include -#include #include @@ -33,427 +32,106 @@ #include #include -namespace Opm::Properties::TTag { - -struct FlowModelParameters {}; - -} - namespace Opm::Parameters { -template -struct EclDeckFileName { using type = Properties::UndefinedProperty; }; +template +struct DbhpMaxRel { static constexpr Scalar value = 1.0; }; -template -struct DbhpMaxRel { using type = Properties::UndefinedProperty; }; +template +struct DwellFractionMax { static constexpr Scalar value = 0.2; }; -template -struct DwellFractionMax { using type = Properties::UndefinedProperty; }; +struct EclDeckFileName { static constexpr auto value = ""; }; -template -struct MaxResidualAllowed { using type = Properties::UndefinedProperty; }; +template +struct MaxResidualAllowed { static constexpr Scalar value = 1e7; }; -template -struct RelaxedMaxPvFraction { using type = Properties::UndefinedProperty; }; +template +struct RelaxedMaxPvFraction { static constexpr Scalar value = 0.03; }; -template -struct ToleranceMb { using type = Properties::UndefinedProperty; }; +template +struct ToleranceMb { static constexpr Scalar value = 1e-7; }; -template -struct ToleranceMbRelaxed { using type = Properties::UndefinedProperty; }; +template +struct ToleranceMbRelaxed { static constexpr Scalar value = 1e-6; }; -template -struct ToleranceCnv { using type = Properties::UndefinedProperty; }; +template +struct ToleranceCnv { static constexpr Scalar value = 1e-2; }; -template -struct ToleranceCnvRelaxed { using type = Properties::UndefinedProperty; }; +template +struct ToleranceCnvRelaxed { static constexpr Scalar value = 1.0; }; -template -struct ToleranceWells { using type = Properties::UndefinedProperty; }; +template +struct ToleranceWells { static constexpr Scalar value = 1e-4; }; -template -struct ToleranceWellControl { using type = Properties::UndefinedProperty; }; +template +struct ToleranceWellControl { static constexpr Scalar value = 1e-7; }; -template -struct MaxWelleqIter { using type = Properties::UndefinedProperty; }; +struct MaxWelleqIter { static constexpr int value = 30; }; -template -struct UseMultisegmentWell { using type = Properties::UndefinedProperty; }; +template +struct MaxSinglePrecisionDays { static constexpr Scalar value = 20.0; }; -template -struct MaxSinglePrecisionDays { using type = Properties::UndefinedProperty; }; +struct MinStrictCnvIter { static constexpr int value = -1; }; +struct MinStrictMbIter { static constexpr int value = -1; }; +struct SolveWelleqInitially { static constexpr bool value = true; }; +struct UpdateEquationsScaling { static constexpr bool value = false; }; +struct UseUpdateStabilization { static constexpr bool value = true; }; +struct MatrixAddWellContributions { static constexpr bool value = false; }; -template -struct MinStrictCnvIter { using type = Properties::UndefinedProperty; }; +struct UseMultisegmentWell { static constexpr bool value = true; }; -template -struct MinStrictMbIter { using type = Properties::UndefinedProperty; }; +template +struct TolerancePressureMsWells { static constexpr Scalar value = 0.01*1e5; }; -template -struct SolveWelleqInitially { using type = Properties::UndefinedProperty; }; +template +struct MaxPressureChangeMsWells { static constexpr Scalar value = 10*1e5; }; -template -struct UpdateEquationsScaling { using type = Properties::UndefinedProperty; }; +struct MaxNewtonIterationsWithInnerWellIterations { static constexpr int value = 8; }; +struct MaxInnerIterMsWells { static constexpr int value = 100; }; +struct MaxInnerIterWells { static constexpr int value = 50; }; +struct ShutUnsolvableWells { static constexpr bool value = true; }; +struct AlternativeWellRateInit { static constexpr bool value = true; }; +struct StrictOuterIterWells { static constexpr int value = 6; }; +struct StrictInnerIterWells { static constexpr int value = 40; }; -template -struct UseUpdateStabilization { using type = Properties::UndefinedProperty; }; +template +struct RegularizationFactorWells { static constexpr Scalar value = 100.0; }; -template -struct MatrixAddWellContributions { using type = Properties::UndefinedProperty; }; +struct EnableWellOperabilityCheck { static constexpr bool value = true; }; +struct EnableWellOperabilityCheckIter { static constexpr bool value = false; }; +struct DebugEmitCellPartition { static constexpr bool value = false; }; -template -struct EnableWellOperabilityCheck { using type = Properties::UndefinedProperty; }; +template +struct RelaxedWellFlowTol { static constexpr Scalar value = 1e-3; }; -template -struct EnableWellOperabilityCheckIter { using type = Properties::UndefinedProperty; }; +template +struct RelaxedPressureTolMsw { static constexpr Scalar value = 1e4; }; -template -struct DebugEmitCellPartition { using type = Properties::UndefinedProperty; }; - -// parameters for multisegment wells -template -struct TolerancePressureMsWells { using type = Properties::UndefinedProperty; }; - -template -struct MaxPressureChangeMsWells { using type = Properties::UndefinedProperty; }; - -template -struct MaxInnerIterMsWells { using type = Properties::UndefinedProperty; }; - -template -struct StrictInnerIterWells { using type = Properties::UndefinedProperty; }; - -template -struct RelaxedWellFlowTol { using type = Properties::UndefinedProperty; }; - -template -struct StrictOuterIterWells { using type = Properties::UndefinedProperty; }; - -template -struct RelaxedPressureTolMsw { using type = Properties::UndefinedProperty; }; - -template -struct RegularizationFactorWells { using type = Properties::UndefinedProperty; }; - -template -struct MaxNewtonIterationsWithInnerWellIterations { using type = Properties::UndefinedProperty; }; - -template -struct ShutUnsolvableWells { using type = Properties::UndefinedProperty; }; - -template -struct MaxInnerIterWells { using type = Properties::UndefinedProperty; }; - -template -struct AlternativeWellRateInit { using type = Properties::UndefinedProperty; }; - -template -struct MaximumNumberOfWellSwitches { using type = Properties::UndefinedProperty; }; - -template -struct UseAverageDensityMsWells { using type = Properties::UndefinedProperty; }; - -template -struct LocalWellSolveControlSwitching { using type = Properties::UndefinedProperty; }; - -template -struct UseImplicitIpr { using type = Properties::UndefinedProperty; }; +struct MaximumNumberOfWellSwitches { static constexpr int value = 3; }; +struct UseAverageDensityMsWells { static constexpr bool value = false; }; +struct LocalWellSolveControlSwitching { static constexpr bool value = true; }; +struct UseImplicitIpr { static constexpr bool value = true; }; // Network solver parameters -template -struct NetworkMaxStrictIterations { using type = Properties::UndefinedProperty; }; +struct NetworkMaxStrictIterations { static constexpr int value = 100; }; +struct NetworkMaxIterations { static constexpr int value = 200; }; +struct NonlinearSolver { static constexpr auto value = "newton"; }; +struct LocalSolveApproach { static constexpr auto value = "gauss-seidel"; }; +struct MaxLocalSolveIterations { static constexpr int value = 20; }; -template -struct NetworkMaxIterations { using type = Properties::UndefinedProperty; }; +template +struct LocalToleranceScalingMb { static constexpr Scalar value = 1.0; }; -template -struct NonlinearSolver { using type = Properties::UndefinedProperty; }; +template +struct LocalToleranceScalingCnv { static constexpr Scalar value = 0.1; }; +struct NlddNumInitialNewtonIter { static constexpr int value = 1; }; +struct NumLocalDomains { static constexpr int value = 0; }; -template -struct LocalSolveApproach { using type = Properties::UndefinedProperty; }; +template +struct LocalDomainsPartitioningImbalance { static constexpr Scalar value = 1.03; }; -template -struct MaxLocalSolveIterations { using type = Properties::UndefinedProperty; }; - -template -struct LocalToleranceScalingMb { using type = Properties::UndefinedProperty; }; - -template -struct LocalToleranceScalingCnv { using type = Properties::UndefinedProperty; }; - -template -struct NlddNumInitialNewtonIter { using type = Properties::UndefinedProperty; }; - -template -struct NumLocalDomains { using type = Properties::UndefinedProperty; }; - -template -struct LocalDomainsPartitioningImbalance { using type = Properties::UndefinedProperty; }; - -template -struct LocalDomainsPartitioningMethod { using type = Properties::UndefinedProperty; }; - -template -struct LocalDomainsOrderingMeasure { using type = Properties::UndefinedProperty; }; - -template -struct DbhpMaxRel -{ - using type = GetPropType; - static constexpr type value = 1.0; -}; - -template -struct DwellFractionMax -{ - using type = GetPropType; - static constexpr type value = 0.2; -}; - -template -struct MaxResidualAllowed -{ - using type = GetPropType; - static constexpr type value = 1e7; -}; - -template -struct RelaxedMaxPvFraction -{ - using type = GetPropType; - static constexpr type value = 0.03; -}; - -template -struct ToleranceMb -{ - using type = GetPropType; - static constexpr type value = 1e-7; -}; - -template -struct ToleranceMbRelaxed -{ - using type = GetPropType; - static constexpr type value = 1e-6; -}; - -template -struct ToleranceCnv -{ - using type = GetPropType; - static constexpr type value = 1e-2; -}; - -template -struct ToleranceCnvRelaxed -{ - using type = GetPropType; - static constexpr type value = 1; -}; - -template -struct ToleranceWells -{ - using type = GetPropType; - static constexpr type value = 1e-4; -}; - -template -struct ToleranceWellControl -{ - using type = GetPropType; - static constexpr type value = 1e-7; -}; - -template -struct MaxWelleqIter -{ static constexpr int value = 30; }; - -template -struct UseMultisegmentWell -{ static constexpr bool value = true; }; - -template -struct MaxSinglePrecisionDays -{ - using type = GetPropType; - static constexpr type value = 20.0; -}; - -template -struct MinStrictCnvIter -{ static constexpr int value = -1; }; - -template -struct MinStrictMbIter -{ static constexpr int value = -1; }; - -template -struct SolveWelleqInitially -{ static constexpr bool value = true; }; - -template -struct UpdateEquationsScaling -{ static constexpr bool value = false; }; - -template -struct UseUpdateStabilization -{ static constexpr bool value = true; }; - -template -struct MatrixAddWellContributions -{ static constexpr bool value = false; }; - -template -struct TolerancePressureMsWells -{ - using type = GetPropType; - static constexpr type value = 0.01*1e5; -}; - -template -struct MaxPressureChangeMsWells -{ - using type = GetPropType; - static constexpr type value = 10*1e5; -}; - -template -struct MaxNewtonIterationsWithInnerWellIterations -{ static constexpr int value = 8; }; - -template -struct MaxInnerIterMsWells -{ static constexpr int value = 100; }; - -template -struct MaxInnerIterWells -{ static constexpr int value = 50; }; - -template -struct ShutUnsolvableWells -{ static constexpr bool value = true; }; - -template -struct AlternativeWellRateInit -{ static constexpr bool value = true; }; - -template -struct StrictOuterIterWells -{ static constexpr int value = 6; }; - -template -struct StrictInnerIterWells -{ static constexpr int value = 40; }; - -template -struct RegularizationFactorWells -{ - using type = GetPropType; - static constexpr type value = 100; -}; - -template -struct EnableWellOperabilityCheck -{ static constexpr bool value = true; }; - -template -struct EnableWellOperabilityCheckIter -{ static constexpr bool value = false; }; - -template -struct DebugEmitCellPartition -{ static constexpr bool value = false; }; - -template -struct RelaxedWellFlowTol -{ - using type = GetPropType; - static constexpr type value = 1e-3; -}; - -template -struct RelaxedPressureTolMsw -{ - using type = GetPropType; - static constexpr type value = 1.0e4; -}; - -template -struct MaximumNumberOfWellSwitches -{ static constexpr int value = 3; }; - -template -struct UseAverageDensityMsWells -{ static constexpr bool value = false; }; - -template -struct LocalWellSolveControlSwitching -{ static constexpr bool value = true; }; - -template -struct UseImplicitIpr -{ static constexpr bool value = true; }; - -// Network solver parameters -template -struct NetworkMaxStrictIterations -{ static constexpr int value = 100; }; - -template -struct NetworkMaxIterations -{ static constexpr int value = 200; }; - -template -struct NonlinearSolver -{ static constexpr auto value = "newton"; }; - -template -struct LocalSolveApproach -{ static constexpr auto value = "gauss-seidel"; }; - -template -struct MaxLocalSolveIterations -{ static constexpr int value = 20; }; - -template -struct LocalToleranceScalingMb -{ - using type = GetPropType; - static constexpr type value = 1.0; -}; - -template -struct LocalToleranceScalingCnv -{ - using type = GetPropType; - static constexpr type value = 0.1; -}; - -template -struct NlddNumInitialNewtonIter -{ static constexpr int value = 1; -}; - -template -struct NumLocalDomains -{ static constexpr int value = 0; }; - -template -struct LocalDomainsPartitioningImbalance -{ - using type = GetPropType; - static constexpr auto value = type{1.03}; -}; - -template -struct LocalDomainsPartitioningMethod -{ static constexpr auto value = "zoltan"; }; - -template -struct LocalDomainsOrderingMeasure -{ static constexpr auto value = "maxpressure"; }; +struct LocalDomainsPartitioningMethod { static constexpr auto value = "zoltan"; }; +struct LocalDomainsOrderingMeasure { static constexpr auto value = "maxpressure"; }; } // namespace Opm::Parameters @@ -600,44 +278,44 @@ public: /// Construct from user parameters or defaults. BlackoilModelParameters() { - dbhp_max_rel_= Parameters::get(); - dwell_fraction_max_ = Parameters::get(); - max_residual_allowed_ = Parameters::get(); - relaxed_max_pv_fraction_ = Parameters::get(); - tolerance_mb_ = Parameters::get(); - tolerance_mb_relaxed_ = std::max(tolerance_mb_, Parameters::get()); - tolerance_cnv_ = Parameters::get(); - tolerance_cnv_relaxed_ = std::max(tolerance_cnv_, Parameters::get()); - tolerance_wells_ = Parameters::get(); - tolerance_well_control_ = Parameters::get(); - max_welleq_iter_ = Parameters::get(); - use_multisegment_well_ = Parameters::get(); - tolerance_pressure_ms_wells_ = Parameters::get(); - relaxed_tolerance_flow_well_ = Parameters::get(); - relaxed_tolerance_pressure_ms_well_ = Parameters::get(); - max_pressure_change_ms_wells_ = Parameters::get(); - max_inner_iter_ms_wells_ = Parameters::get(); - strict_inner_iter_wells_ = Parameters::get(); - strict_outer_iter_wells_ = Parameters::get(); - regularization_factor_wells_ = Parameters::get(); - max_niter_inner_well_iter_ = Parameters::get(); - shut_unsolvable_wells_ = Parameters::get(); - max_inner_iter_wells_ = Parameters::get(); - maxSinglePrecisionTimeStep_ = Parameters::get() * 24 * 60 * 60; - min_strict_cnv_iter_ = Parameters::get(); - min_strict_mb_iter_ = Parameters::get(); - solve_welleq_initially_ = Parameters::get(); - update_equations_scaling_ = Parameters::get(); - use_update_stabilization_ = Parameters::get(); - matrix_add_well_contributions_ = Parameters::get(); - check_well_operability_ = Parameters::get(); - check_well_operability_iter_ = Parameters::get(); - max_number_of_well_switches_ = Parameters::get(); - use_average_density_ms_wells_ = Parameters::get(); - local_well_solver_control_switching_ = Parameters::get(); - use_implicit_ipr_ = Parameters::get(); - nonlinear_solver_ = Parameters::get(); - const auto approach = Parameters::get(); + dbhp_max_rel_ = Parameters::Get>(); + dwell_fraction_max_ = Parameters::Get>(); + max_residual_allowed_ = Parameters::Get>(); + relaxed_max_pv_fraction_ = Parameters::Get>(); + tolerance_mb_ = Parameters::Get>(); + tolerance_mb_relaxed_ = std::max(tolerance_mb_, Parameters::Get>()); + tolerance_cnv_ = Parameters::Get>(); + tolerance_cnv_relaxed_ = std::max(tolerance_cnv_, Parameters::Get>()); + tolerance_wells_ = Parameters::Get>(); + tolerance_well_control_ = Parameters::Get>(); + max_welleq_iter_ = Parameters::Get(); + use_multisegment_well_ = Parameters::Get(); + tolerance_pressure_ms_wells_ = Parameters::Get>(); + relaxed_tolerance_flow_well_ = Parameters::Get>(); + relaxed_tolerance_pressure_ms_well_ = Parameters::Get>(); + max_pressure_change_ms_wells_ = Parameters::Get>(); + max_inner_iter_ms_wells_ = Parameters::Get(); + strict_inner_iter_wells_ = Parameters::Get(); + strict_outer_iter_wells_ = Parameters::Get(); + regularization_factor_wells_ = Parameters::Get>(); + max_niter_inner_well_iter_ = Parameters::Get(); + shut_unsolvable_wells_ = Parameters::Get(); + max_inner_iter_wells_ = Parameters::Get(); + maxSinglePrecisionTimeStep_ = Parameters::Get>() * 24 * 60 * 60; + min_strict_cnv_iter_ = Parameters::Get(); + min_strict_mb_iter_ = Parameters::Get(); + solve_welleq_initially_ = Parameters::Get(); + update_equations_scaling_ = Parameters::Get(); + use_update_stabilization_ = Parameters::Get(); + matrix_add_well_contributions_ = Parameters::Get(); + check_well_operability_ = Parameters::Get(); + check_well_operability_iter_ = Parameters::Get(); + max_number_of_well_switches_ = Parameters::Get(); + use_average_density_ms_wells_ = Parameters::Get(); + local_well_solver_control_switching_ = Parameters::Get(); + use_implicit_ipr_ = Parameters::Get(); + nonlinear_solver_ = Parameters::Get(); + const auto approach = Parameters::Get(); if (approach == "jacobi") { local_solve_approach_ = DomainSolveApproach::Jacobi; } else if (approach == "gauss-seidel") { @@ -646,143 +324,143 @@ public: throw std::runtime_error("Invalid domain solver approach '" + approach + "' specified."); } - max_local_solve_iterations_ = Parameters::get(); - local_tolerance_scaling_mb_ = Parameters::get(); - local_tolerance_scaling_cnv_ = Parameters::get(); - nldd_num_initial_newton_iter_ = Parameters::get(); - num_local_domains_ = Parameters::get(); - local_domain_partition_imbalance_ = std::max(Scalar{1.0}, Parameters::get()); - local_domain_partition_method_ = Parameters::get(); - deck_file_name_ = Parameters::get(); - network_max_strict_iterations_ = Parameters::get(); - network_max_iterations_ = Parameters::get(); - local_domain_ordering_ = domainOrderingMeasureFromString(Parameters::get()); - write_partitions_ = Parameters::get(); + max_local_solve_iterations_ = Parameters::Get(); + local_tolerance_scaling_mb_ = Parameters::Get>(); + local_tolerance_scaling_cnv_ = Parameters::Get>(); + nldd_num_initial_newton_iter_ = Parameters::Get(); + num_local_domains_ = Parameters::Get(); + local_domain_partition_imbalance_ = std::max(Scalar{1.0}, Parameters::Get>()); + local_domain_partition_method_ = Parameters::Get(); + deck_file_name_ = Parameters::Get(); + network_max_strict_iterations_ = Parameters::Get(); + network_max_iterations_ = Parameters::Get(); + local_domain_ordering_ = domainOrderingMeasureFromString(Parameters::Get()); + write_partitions_ = Parameters::Get(); } static void registerParameters() { - Parameters::registerParam + Parameters::Register> ("Maximum relative change of the bottom-hole pressure in a single iteration"); - Parameters::registerParam + Parameters::Register> ("Maximum absolute change of a well's volume fraction in a single iteration"); - Parameters::registerParam + Parameters::Register> ("Absolute maximum tolerated for residuals without cutting the time step size"); - Parameters::registerParam + Parameters::Register> ("The fraction of the pore volume of the reservoir " "where the volumetric error (CNV) may be voilated " "during strict Newton iterations."); - Parameters::registerParam + Parameters::Register> ("Tolerated mass balance error relative to total mass present"); - Parameters::registerParam + Parameters::Register> ("Relaxed tolerated mass balance error that applies for iterations " "after the iterations with the strict tolerance"); - Parameters::registerParam + Parameters::Register> ("Local convergence tolerance (Maximum of local saturation errors)"); - Parameters::registerParam + Parameters::Register> ("Relaxed local convergence tolerance that applies for iterations " "after the iterations with the strict tolerance"); - Parameters::registerParam + Parameters::Register> ("Well convergence tolerance"); - Parameters::registerParam + Parameters::Register> ("Tolerance for the well control equations"); - Parameters::registerParam + Parameters::Register ("Maximum number of iterations to determine solution the well equations"); - Parameters::registerParam + Parameters::Register ("Use the well model for multi-segment wells instead of the " "one for single-segment wells"); - Parameters::registerParam + Parameters::Register> ("Tolerance for the pressure equations for multi-segment wells"); - Parameters::registerParam + Parameters::Register> ("Relaxed tolerance for the well flow residual"); - Parameters::registerParam + Parameters::Register> ("Relaxed tolerance for the MSW pressure solution"); - Parameters::registerParam + Parameters::Register> ("Maximum relative pressure change for a single iteration " "of the multi-segment well model"); - Parameters::registerParam + Parameters::Register ("Maximum number of inner iterations for multi-segment wells"); - Parameters::registerParam + Parameters::Register ("Number of inner well iterations with strict tolerance"); - Parameters::registerParam + Parameters::Register ("Number of newton iterations for which wells are checked with strict tolerance"); - Parameters::registerParam + Parameters::Register ("Maximum newton iterations with inner well iterations"); - Parameters::registerParam + Parameters::Register ("Shut unsolvable wells"); - Parameters::registerParam + Parameters::Register ("Maximum number of inner iterations for standard wells"); - Parameters::registerParam + Parameters::Register ("Use alternative well rate initialization procedure"); - Parameters::registerParam + Parameters::Register> ("Regularization factor for wells"); - Parameters::registerParam + Parameters::Register> ("Maximum time step size where single precision floating point " "arithmetic can be used solving for the linear systems of equations"); - Parameters::registerParam + Parameters::Register ("Minimum number of Newton iterations before relaxed tolerances " "can be used for the CNV convergence criterion"); - Parameters::registerParam + Parameters::Register ("Minimum number of Newton iterations before relaxed tolerances " "can be used for the MB convergence criterion. " "Default -1 means that the relaxed tolerance is used when maximum " "number of Newton iterations are reached."); - Parameters::registerParam + Parameters::Register ("Fully solve the well equations before each iteration of the reservoir model"); - Parameters::registerParam + Parameters::Register ("Update scaling factors for mass balance equations during the run"); - Parameters::registerParam + Parameters::Register ("Try to detect and correct oscillations or stagnation during the Newton method"); - Parameters::registerParam + Parameters::Register ("Explicitly specify the influences of wells between cells in " "the Jacobian and preconditioner matrices"); - Parameters::registerParam + Parameters::Register ("Enable the well operability checking"); - Parameters::registerParam + Parameters::Register ("Enable the well operability checking during iterations"); - Parameters::registerParam + Parameters::Register ("Maximum number of times a well can switch to the same control"); - Parameters::registerParam + Parameters::Register ("Approximate segment densitities by averaging over segment and its outlet"); - Parameters::registerParam + Parameters::Register ("Allow control switching during local well solutions"); - Parameters::registerParam + Parameters::Register ("Compute implict IPR for stability checks and stable solution search"); - Parameters::registerParam + Parameters::Register ("Maximum iterations in network solver before relaxing tolerance"); - Parameters::registerParam + Parameters::Register ("Maximum number of iterations in the network solver before giving up"); - Parameters::registerParam + Parameters::Register ("Choose nonlinear solver. Valid choices are newton or nldd."); - Parameters::registerParam + Parameters::Register ("Choose local solve approach. Valid choices are jacobi and gauss-seidel"); - Parameters::registerParam + Parameters::Register ("Max iterations for local solves with NLDD nonlinear solver."); - Parameters::registerParam + Parameters::Register> ("Set lower than 1.0 to use stricter convergence tolerance for local solves."); - Parameters::registerParam + Parameters::Register> ("Set lower than 1.0 to use stricter convergence tolerance for local solves."); - Parameters::registerParam + Parameters::Register ("Number of initial global Newton iterations when running the NLDD nonlinear solver."); - Parameters::registerParam + Parameters::Register ("Number of local domains for NLDD nonlinear solver."); - Parameters::registerParam + Parameters::Register> ("Subdomain partitioning imbalance tolerance. 1.03 is 3 percent imbalance."); - Parameters::registerParam + Parameters::Register ("Subdomain partitioning method. Allowed values are " "'zoltan', " "'simple', " "and the name of a partition file ending with '.partition'."); - Parameters::registerParam + Parameters::Register ("Subdomain ordering measure. Allowed values are " "'maxpressure', " "'averagepressure' " "and 'residual'."); - Parameters::registerParam + Parameters::Register ("Whether or not to emit cell partitions as a debugging aid."); - Parameters::hideParam(); + Parameters::Hide(); // if openMP is available, determine the number threads per process automatically. #if _OPENMP diff --git a/opm/simulators/flow/FlowBaseVanguard.hpp b/opm/simulators/flow/FlowBaseVanguard.hpp index 6fdbbf884..b07901eb0 100644 --- a/opm/simulators/flow/FlowBaseVanguard.hpp +++ b/opm/simulators/flow/FlowBaseVanguard.hpp @@ -27,6 +27,8 @@ #ifndef OPM_FLOW_BASE_VANGUARD_HPP #define OPM_FLOW_BASE_VANGUARD_HPP +#include + #include #include #include @@ -69,10 +71,6 @@ struct EquilGrid { using type = UndefinedProperty; }; namespace Opm::Parameters { -template -struct EclDeckFileName -{ static constexpr auto value = ""; }; - // TODO: enumeration parameters. we use strings for now. template struct EnableDryRun { using type = Properties::UndefinedProperty; }; @@ -115,11 +113,6 @@ struct PartitionMethod { using type = Properties::UndefinedProperty; }; template struct SerialPartitioning { using type = Properties::UndefinedProperty; }; -// Same as in BlackoilModelParameters.hpp but for here. -template -struct UseMultisegmentWell -{ static constexpr bool value = true; }; - template struct ZoltanImbalanceTol { using type = Properties::UndefinedProperty; }; @@ -247,7 +240,7 @@ public: */ static void registerParameters() { - Parameters::registerParam + Parameters::Register ("The name of the file which contains the ECL deck to be simulated"); Parameters::registerParam ("The number of report steps that ought to be skipped between two writes of ECL results"); @@ -316,7 +309,7 @@ public: Parameters::registerParam ("Allow the perforations of a well to be distributed to interior of multiple processes"); // register here for the use in the tests without BlackoilModelParameters - Parameters::registerParam + Parameters::Register ("Use the well model for multi-segment wells instead of the one for single-segment wells"); } @@ -329,7 +322,7 @@ public: FlowBaseVanguard(Simulator& simulator) : ParentType(simulator) { - fileName_ = Parameters::get(); + fileName_ = Parameters::Get(); edgeWeightsMethod_ = Dune::EdgeWeightMethod(Parameters::get()); #if HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA @@ -355,7 +348,7 @@ public: int output_param = Parameters::get(); if (output_param >= 0) outputInterval_ = output_param; - useMultisegmentWell_ = Parameters::get(); + useMultisegmentWell_ = Parameters::Get(); enableExperiments_ = enableExperiments; init(); diff --git a/opm/simulators/flow/FlowMain.hpp b/opm/simulators/flow/FlowMain.hpp index a8714aed7..54733a5f6 100644 --- a/opm/simulators/flow/FlowMain.hpp +++ b/opm/simulators/flow/FlowMain.hpp @@ -190,7 +190,7 @@ namespace Opm { Parameters::Hide(); // hide average density option - Parameters::hideParam(); + Parameters::Hide(); Parameters::endRegistration(); @@ -402,7 +402,7 @@ namespace Opm { } detail::mergeParallelLogFiles(eclState().getIOConfig().getOutputDir(), - Parameters::get(), + Parameters::Get(), Parameters::get()); } diff --git a/opm/simulators/flow/Main.hpp b/opm/simulators/flow/Main.hpp index 4c48e54be..df8dbd75c 100644 --- a/opm/simulators/flow/Main.hpp +++ b/opm/simulators/flow/Main.hpp @@ -337,7 +337,7 @@ private: outputDir = eclipseState_->getIOConfig().getOutputDir(); } else { - deckFilename = Parameters::get(); + deckFilename = Parameters::Get(); outputDir = Parameters::Get(); } diff --git a/opm/simulators/linalg/ISTLSolver.hpp b/opm/simulators/linalg/ISTLSolver.hpp index 166b0eea9..e88c6ceea 100644 --- a/opm/simulators/linalg/ISTLSolver.hpp +++ b/opm/simulators/linalg/ISTLSolver.hpp @@ -258,7 +258,7 @@ std::unique_ptr blockJacobiAdjacency(const Grid& grid, // Set it up manually ElementMapper elemMapper(simulator_.vanguard().gridView(), Dune::mcmgElementLayout()); detail::findOverlapAndInterior(simulator_.vanguard().grid(), elemMapper, overlapRows_, interiorRows_); - useWellConn_ = Parameters::get(); + useWellConn_ = Parameters::Get(); const bool ownersFirst = Parameters::get(); if (!ownersFirst) { const std::string msg = "The linear solver no longer supports --owner-cells-first=false."; @@ -324,7 +324,7 @@ std::unique_ptr blockJacobiAdjacency(const Grid& grid, // Outch! We need to be able to scale the linear system! Hence const_cast matrix_ = const_cast(&M); - useWellConn_ = Parameters::get(); + useWellConn_ = Parameters::Get(); // setup sparsity pattern for jacobi matrix for preconditioner (only used for openclSolver) } else { // Pointers should not change diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index c6a249358..31d6c8689 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -94,7 +94,7 @@ namespace Opm { } this->alternative_well_rate_init_ = - Parameters::get(); + Parameters::Get(); using SourceDataSpan = typename PAvgDynamicSourceData::template SourceDataSpan; diff --git a/tests/TestTypeTag.hpp b/tests/TestTypeTag.hpp index 53064e07c..5bd026043 100644 --- a/tests/TestTypeTag.hpp +++ b/tests/TestTypeTag.hpp @@ -39,8 +39,12 @@ namespace Opm::Properties { namespace TTag { -struct TestTypeTag { - using InheritsFrom = std::tuple; + +struct TestTypeTag +{ + using InheritsFrom = std::tuple; }; } @@ -95,20 +99,4 @@ struct LinearSolverBackend { } // namespace Opm::Properties -namespace Opm::Parameters { - -// set some parameters that are only required by the well model -template -struct MatrixAddWellContributions -{ static constexpr bool value = true; }; - -// currently, ebos uses the non-multisegment well model by default to avoid -// regressions. the --use-multisegment-well=true|false command line parameter is still -// available in ebos, but hidden from view. -template -struct UseMultisegmentWell -{ static constexpr bool value = false; }; - -} // namespace Opm::Parameters - #endif // OPM_TEST_TYPETAG_HPP diff --git a/tests/test_equil.cpp b/tests/test_equil.cpp index 06f023acf..495311d42 100644 --- a/tests/test_equil.cpp +++ b/tests/test_equil.cpp @@ -72,10 +72,13 @@ namespace TTag { struct TestEquilTypeTag { - using InheritsFrom = std::tuple; + using InheritsFrom = std::tuple; }; struct TestEquilVapwatTypeTag { - using InheritsFrom = std::tuple; + using InheritsFrom = std::tuple; }; } From bfe6f47d58554414a55a38572721bca2c8ae7a75 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sat, 6 Jul 2024 10:22:47 +0200 Subject: [PATCH 05/15] move FlowMain parameters to TypeTag-free parameter system --- opm/simulators/flow/FlowMain.hpp | 20 +++++--------------- opm/simulators/flow/Main.hpp | 2 +- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/opm/simulators/flow/FlowMain.hpp b/opm/simulators/flow/FlowMain.hpp index 54733a5f6..58bc4d16d 100644 --- a/opm/simulators/flow/FlowMain.hpp +++ b/opm/simulators/flow/FlowMain.hpp @@ -44,20 +44,10 @@ namespace Opm::Parameters { -template -struct OutputInterval { using type = Properties::UndefinedProperty; }; - -template -struct EnableLoggingFalloutWarning { using type = Properties::UndefinedProperty; }; - // Do not merge parallel output files or warn about them -template -struct EnableLoggingFalloutWarning -{ static constexpr bool value = false; }; +struct EnableLoggingFalloutWarning { static constexpr bool value = false; }; -template -struct OutputInterval -{ static constexpr int value = 1; }; +struct OutputInterval { static constexpr int value = 1; }; } // namespace Opm::Parameters @@ -101,9 +91,9 @@ namespace Opm { return EXIT_SUCCESS; } // register the flow specific parameters - Parameters::registerParam + Parameters::Register ("Specify the number of report steps between two consecutive writes of restart data"); - Parameters::registerParam + Parameters::Register ("Developer option to see whether logging was on non-root processors. " "In that case it will be appended to the *.DBG or *.PRT files"); @@ -403,7 +393,7 @@ namespace Opm { detail::mergeParallelLogFiles(eclState().getIOConfig().getOutputDir(), Parameters::Get(), - Parameters::get()); + Parameters::Get()); } void setupModelSimulator() diff --git a/opm/simulators/flow/Main.hpp b/opm/simulators/flow/Main.hpp index df8dbd75c..d005daa99 100644 --- a/opm/simulators/flow/Main.hpp +++ b/opm/simulators/flow/Main.hpp @@ -419,7 +419,7 @@ private: outputDir, Parameters::get(), !Parameters::get(), - Parameters::get(), + Parameters::Get(), Parameters::get(), Parameters::get(), getNumThreads(), From dd1bc8d75b1dd4faec1514320024cf383650fb7a Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sat, 6 Jul 2024 10:22:47 +0200 Subject: [PATCH 06/15] move FlowBaseVanguard parameters to TypeTag-free parameter system --- opm/simulators/flow/EclWriter.hpp | 2 +- opm/simulators/flow/FlowBaseVanguard.hpp | 216 +++++-------------- opm/simulators/flow/Main.hpp | 8 +- opm/simulators/flow/OutputBlackoilModule.hpp | 2 +- opm/simulators/linalg/ISTLSolver.hpp | 2 +- opm/simulators/linalg/ISTLSolverBda.hpp | 2 +- 6 files changed, 66 insertions(+), 166 deletions(-) diff --git a/opm/simulators/flow/EclWriter.hpp b/opm/simulators/flow/EclWriter.hpp index acff0f301..af4de1f57 100644 --- a/opm/simulators/flow/EclWriter.hpp +++ b/opm/simulators/flow/EclWriter.hpp @@ -484,7 +484,7 @@ public: bool gasActive = FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx); bool waterActive = FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx); bool enableSwatinit = simulator_.vanguard().eclState().fieldProps().has_double("SWATINIT"); - bool opm_rst_file = Parameters::get(); + bool opm_rst_file = Parameters::Get(); bool read_temp = enableEnergy || (opm_rst_file && enableTemperature); std::vector solutionKeys{ {"PRESSURE", UnitSystem::measure::pressure}, diff --git a/opm/simulators/flow/FlowBaseVanguard.hpp b/opm/simulators/flow/FlowBaseVanguard.hpp index b07901eb0..3b8c4424d 100644 --- a/opm/simulators/flow/FlowBaseVanguard.hpp +++ b/opm/simulators/flow/FlowBaseVanguard.hpp @@ -71,137 +71,37 @@ struct EquilGrid { using type = UndefinedProperty; }; namespace Opm::Parameters { -// TODO: enumeration parameters. we use strings for now. -template -struct EnableDryRun { using type = Properties::UndefinedProperty; }; +struct AllowDistributedWells { static constexpr bool value = false; }; +struct EclOutputInterval { static constexpr int value = -1; }; +struct EdgeWeightsMethod { static constexpr int value = 1; }; +struct EnableDryRun { static constexpr auto value = "auto"; }; +struct EnableOpmRstFile { static constexpr bool value = false; }; +struct ExternalPartition { static constexpr auto* value = ""; }; -template -struct EnableOpmRstFile { using type = Properties::UndefinedProperty; }; +template +struct ImbalanceTol { static constexpr Scalar value = 1.1; }; -template -struct ParsingStrictness { using type = Properties::UndefinedProperty; }; - -template -struct InputSkipMode { using type = Properties::UndefinedProperty; }; - -template -struct SchedRestart { using type = Properties::UndefinedProperty; }; - -template -struct EclOutputInterval { using type = Properties::UndefinedProperty; }; - -template -struct IgnoreKeywords { using type = Properties::UndefinedProperty; }; - -template -struct EdgeWeightsMethod { using type = Properties::UndefinedProperty; }; +struct IgnoreKeywords { static constexpr auto value = ""; }; +struct InputSkipMode { static constexpr auto value = "100"; }; +struct MetisParams { static constexpr auto value = "default"; }; #if HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA -template -struct NumJacobiBlocks { using type = Properties::UndefinedProperty; }; +struct NumJacobiBlocks { static constexpr int value = 0; }; #endif -template -struct OwnerCellsFirst { using type = Properties::UndefinedProperty; }; +struct OwnerCellsFirst { static constexpr bool value = true; }; +struct ParsingStrictness { static constexpr auto value = "normal"; }; -template -struct ImbalanceTol { using type = Properties::UndefinedProperty; }; + // 0: simple, 1: Zoltan, 2: METIS, see GridEnums.hpp +struct PartitionMethod { static constexpr int value = 1; }; -template -struct PartitionMethod { using type = Properties::UndefinedProperty; }; +struct SchedRestart{ static constexpr bool value = false; }; +struct SerialPartitioning{ static constexpr bool value = false; }; -template -struct SerialPartitioning { using type = Properties::UndefinedProperty; }; +template +struct ZoltanImbalanceTol { static constexpr Scalar value = 1.1; }; -template -struct ZoltanImbalanceTol { using type = Properties::UndefinedProperty; }; - -template -struct ZoltanParams { using type = Properties::UndefinedProperty; }; - -template -struct MetisParams { using type = Properties::UndefinedProperty; }; - -template -struct ExternalPartition { using type = Properties::UndefinedProperty; }; - -template -struct AllowDistributedWells { using type = Properties::UndefinedProperty; }; - -template -struct IgnoreKeywords -{ static constexpr auto value = ""; }; - -template -struct EclOutputInterval -{ static constexpr int value = -1; }; - -// TODO: enumeration parameters. we use strings for now. -template -struct EnableDryRun -{ static constexpr auto value = "auto"; }; - -template -struct EnableOpmRstFile -{ static constexpr bool value = false; }; - -template -struct ParsingStrictness -{ static constexpr auto value = "normal"; }; - -template -struct InputSkipMode -{ static constexpr auto value = "100"; }; - -template -struct SchedRestart -{ static constexpr bool value = false; }; - -template -struct EdgeWeightsMethod -{ static constexpr int value = 1; }; - -template -struct ImbalanceTol -{ static constexpr double value = 1.1; }; - -#if HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA -template -struct NumJacobiBlocks -{ static constexpr int value = 0; }; -#endif - -template -struct OwnerCellsFirst -{ static constexpr bool value = true; }; - -template -struct PartitionMethod -{ static constexpr int value = 1; }; // 0: simple, 1: Zoltan, 2: METIS, see GridEnums.hpp - -template -struct SerialPartitioning -{ static constexpr bool value = false; }; - -template -struct ZoltanImbalanceTol -{ static constexpr double value = 1.1; }; - -template -struct ZoltanParams -{ static constexpr auto value = "graph"; }; - -template -struct MetisParams -{ static constexpr auto value = "default"; }; - -template -struct ExternalPartition -{ static constexpr auto* value = ""; }; - -template -struct AllowDistributedWells -{ static constexpr bool value = false; }; +struct ZoltanParams { static constexpr auto value = "graph"; }; } // namespace Opm::Parameters @@ -242,71 +142,71 @@ public: { Parameters::Register ("The name of the file which contains the ECL deck to be simulated"); - Parameters::registerParam + Parameters::Register ("The number of report steps that ought to be skipped between two writes of ECL results"); - Parameters::registerParam + Parameters::Register ("Specify if the simulation ought to be actually run, or just pretended to be"); - Parameters::registerParam + Parameters::Register ("Include OPM-specific keywords in the ECL restart file to " "enable restart of OPM simulators from these files"); - Parameters::registerParam + Parameters::Register ("List of Eclipse keywords which should be ignored. As a ':' separated string."); - Parameters::registerParam + Parameters::Register ("Set strictness of parsing process. Available options are " "normal (stop for critical errors), " "high (stop for all errors) and " "low (as normal, except do not stop due to unsupported " "keywords even if marked critical"); - Parameters::registerParam + Parameters::Register ("Set compatibility mode for the SKIP100/SKIP300 keywords. Options are " "100 (skip SKIP100..ENDSKIP, keep SKIP300..ENDSKIP) [default], " "300 (skip SKIP300..ENDSKIP, keep SKIP100..ENDSKIP) and " "all (skip both SKIP100..ENDSKIP and SKIP300..ENDSKIP) "); - Parameters::registerParam + Parameters::Register ("When restarting: should we try to initialize wells and " "groups from historical SCHEDULE section."); - Parameters::registerParam + Parameters::Register ("Choose edge-weighing strategy: 0=uniform, 1=trans, 2=log(trans)."); #if HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA - Parameters::registerParam + Parameters::Register ("Number of blocks to be created for the Block-Jacobi preconditioner."); #endif - Parameters::registerParam + Parameters::Register ("Order cells owned by rank before ghost/overlap cells."); #if HAVE_MPI - Parameters::registerParam + Parameters::Register ("Choose partitioning strategy: 0=simple, 1=Zoltan, 2=METIS."); - Parameters::registerParam + Parameters::Register ("Perform partitioning for parallel runs on a single process."); - Parameters::registerParam + Parameters::Register> ("Tolerable imbalance of the loadbalancing provided by Zoltan. DEPRECATED: Use --imbalance-tol instead"); - Parameters::hideParam(); - Parameters::registerParam + Parameters::Hide>(); + Parameters::Register ("Configuration of Zoltan partitioner. " "Valid options are: graph, hypergraph or scotch. " "Alternatively, you can request a configuration to be read " "from a JSON file by giving the filename here, ending with '.json.' " "See https://sandialabs.github.io/Zoltan/ug_html/ug.html " "for available Zoltan options."); - Parameters::hideParam(); - Parameters::registerParam + Parameters::Hide(); + Parameters::Register> ("Tolerable imbalance of the loadbalancing (default: 1.1)."); - Parameters::registerParam + Parameters::Register ("Configuration of Metis partitioner. " "You can request a configuration to be read " "from a JSON file by giving the filename here, ending with '.json.' " "See http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/manual.pdf" "for available METIS options."); - Parameters::registerParam + Parameters::Register ("Name of file from which to load an externally generated " "partitioning of the model's active cells for MPI " "distribution purposes. If empty, the built-in partitioning " "method will be employed."); - Parameters::hideParam(); + Parameters::Hide(); #endif - Parameters::registerParam + Parameters::Register ("Allow the perforations of a well to be distributed to interior of multiple processes"); // register here for the use in the tests without BlackoilModelParameters Parameters::Register @@ -323,29 +223,29 @@ public: : ParentType(simulator) { fileName_ = Parameters::Get(); - edgeWeightsMethod_ = Dune::EdgeWeightMethod(Parameters::get()); + edgeWeightsMethod_ = Dune::EdgeWeightMethod(Parameters::Get()); #if HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA - numJacobiBlocks_ = Parameters::get(); + numJacobiBlocks_ = Parameters::Get(); #endif - ownersFirst_ = Parameters::get(); + ownersFirst_ = Parameters::Get(); #if HAVE_MPI - partitionMethod_ = Dune::PartitionMethod(Parameters::get()); - serialPartitioning_ = Parameters::get(); - imbalanceTol_ = Parameters::get(); + partitionMethod_ = Dune::PartitionMethod(Parameters::Get()); + serialPartitioning_ = Parameters::Get(); + imbalanceTol_ = Parameters::Get>(); - zoltanImbalanceTolSet_ = Parameters::isSet(); - zoltanImbalanceTol_ = Parameters::get(); - zoltanParams_ = Parameters::get(); + zoltanImbalanceTolSet_ = Parameters::IsSet>(); + zoltanImbalanceTol_ = Parameters::Get>(); + zoltanParams_ = Parameters::Get(); - metisParams_ = Parameters::get(); + metisParams_ = Parameters::Get(); - externalPartitionFile_ = Parameters::get(); + externalPartitionFile_ = Parameters::Get(); #endif - enableDistributedWells_ = Parameters::get(); - ignoredKeywords_ = Parameters::get(); - int output_param = Parameters::get(); + enableDistributedWells_ = Parameters::Get(); + ignoredKeywords_ = Parameters::Get(); + int output_param = Parameters::Get(); if (output_param >= 0) outputInterval_ = output_param; useMultisegmentWell_ = Parameters::Get(); @@ -545,9 +445,9 @@ protected: asImp_().createGrids_(); asImp_().filterConnections_(); std::string outputDir = Parameters::Get(); - bool enableEclCompatFile = !Parameters::get(); + bool enableEclCompatFile = !Parameters::Get(); asImp_().updateOutputDir_(outputDir, enableEclCompatFile); - const std::string& dryRunString = Parameters::get(); + const std::string& dryRunString = Parameters::Get(); asImp_().updateNOSIM_(dryRunString); asImp_().finalizeInit_(); } diff --git a/opm/simulators/flow/Main.hpp b/opm/simulators/flow/Main.hpp index d005daa99..2d9c57bbf 100644 --- a/opm/simulators/flow/Main.hpp +++ b/opm/simulators/flow/Main.hpp @@ -418,12 +418,12 @@ private: this->readDeck(deckFilename, outputDir, Parameters::get(), - !Parameters::get(), + !Parameters::Get(), Parameters::Get(), - Parameters::get(), - Parameters::get(), + Parameters::Get(), + Parameters::Get(), getNumThreads(), - Parameters::get(), + Parameters::Get(), cmdline_params, Opm::moduleVersion(), Opm::compileTimestamp()); diff --git a/opm/simulators/flow/OutputBlackoilModule.hpp b/opm/simulators/flow/OutputBlackoilModule.hpp index 84209ec9b..57829ab8b 100644 --- a/opm/simulators/flow/OutputBlackoilModule.hpp +++ b/opm/simulators/flow/OutputBlackoilModule.hpp @@ -170,7 +170,7 @@ public: this->forceDisableFipresvOutput_ = Parameters::get(); - if (! Parameters::get()) { + if (! Parameters::Get()) { const std::string msg = "The output code does not support --owner-cells-first=false."; if (collectToIORank.isIORank()) { OpmLog::error(msg); diff --git a/opm/simulators/linalg/ISTLSolver.hpp b/opm/simulators/linalg/ISTLSolver.hpp index e88c6ceea..b65607267 100644 --- a/opm/simulators/linalg/ISTLSolver.hpp +++ b/opm/simulators/linalg/ISTLSolver.hpp @@ -259,7 +259,7 @@ std::unique_ptr blockJacobiAdjacency(const Grid& grid, ElementMapper elemMapper(simulator_.vanguard().gridView(), Dune::mcmgElementLayout()); detail::findOverlapAndInterior(simulator_.vanguard().grid(), elemMapper, overlapRows_, interiorRows_); useWellConn_ = Parameters::Get(); - const bool ownersFirst = Parameters::get(); + const bool ownersFirst = Parameters::Get(); if (!ownersFirst) { const std::string msg = "The linear solver no longer supports --owner-cells-first=false."; if (on_io_rank) { diff --git a/opm/simulators/linalg/ISTLSolverBda.hpp b/opm/simulators/linalg/ISTLSolverBda.hpp index 74e898df0..91691c75a 100644 --- a/opm/simulators/linalg/ISTLSolverBda.hpp +++ b/opm/simulators/linalg/ISTLSolverBda.hpp @@ -204,7 +204,7 @@ public: // to the original one with a deleter that does nothing. // Outch! We need to be able to scale the linear system! Hence const_cast // setup sparsity pattern for jacobi matrix for preconditioner (only used for openclSolver) - bdaBridge_->numJacobiBlocks_ = Parameters::get(); + bdaBridge_->numJacobiBlocks_ = Parameters::Get(); bdaBridge_->prepare(this->simulator_.vanguard().grid(), this->simulator_.vanguard().cartesianIndexMapper(), this->simulator_.vanguard().schedule().getWellsatEnd(), From 94c30a74b8a9bc1c5a83d26c0bf409894779493c Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sat, 6 Jul 2024 10:22:47 +0200 Subject: [PATCH 07/15] move NonLinearSolver parameters to TypeTag-free parameter system --- opm/simulators/flow/BlackoilModel.hpp | 2 +- opm/simulators/flow/NonlinearSolver.hpp | 47 ++++++------------------- 2 files changed, 11 insertions(+), 38 deletions(-) diff --git a/opm/simulators/flow/BlackoilModel.hpp b/opm/simulators/flow/BlackoilModel.hpp index 328c30c9f..e590e8f46 100644 --- a/opm/simulators/flow/BlackoilModel.hpp +++ b/opm/simulators/flow/BlackoilModel.hpp @@ -76,7 +76,7 @@ namespace Opm::Properties { namespace TTag { struct FlowProblem { using InheritsFrom = std::tuple; + FlowBaseProblem, BlackOilModel>; }; } // default in flow is to formulate the equations in surface volumes diff --git a/opm/simulators/flow/NonlinearSolver.hpp b/opm/simulators/flow/NonlinearSolver.hpp index ae242137c..731a05ccb 100644 --- a/opm/simulators/flow/NonlinearSolver.hpp +++ b/opm/simulators/flow/NonlinearSolver.hpp @@ -39,40 +39,13 @@ #include -namespace Opm::Properties::TTag { - -struct FlowNonLinearSolver {}; - -} - namespace Opm::Parameters { -template -struct NewtonMaxRelax { using type = Properties::UndefinedProperty; }; +template +struct NewtonMaxRelax { static constexpr Scalar value = 0.5; }; -// we are reusing NewtonMaxIterations from opm-models -// See opm/models/nonlinear/newtonmethodproperties.hh - -template -struct NewtonMinIterations { using type = Properties::UndefinedProperty; }; - -template -struct NewtonRelaxationType { using type = Properties::UndefinedProperty; }; - -template -struct NewtonMaxRelax -{ - using type = GetPropType; - static constexpr type value = 0.5; -}; - -template -struct NewtonMinIterations -{ static constexpr int value = 2; }; - -template -struct NewtonRelaxationType -{ static constexpr auto value = "dampen"; }; +struct NewtonMinIterations { static constexpr int value = 2; }; +struct NewtonRelaxationType { static constexpr auto value = "dampen"; }; } // namespace Opm::Parameters @@ -125,11 +98,11 @@ void stabilizeNonlinearUpdate(BVector& dx, BVector& dxOld, reset(); // overload with given parameters - relaxMax_ = Parameters::get(); + relaxMax_ = Parameters::Get>(); maxIter_ = Parameters::Get(); - minIter_ = Parameters::get(); + minIter_ = Parameters::Get(); - const auto& relaxationTypeString = Parameters::get(); + const auto& relaxationTypeString = Parameters::Get(); if (relaxationTypeString == "dampen") { relaxType_ = NonlinearRelaxType::Dampen; } else if (relaxationTypeString == "sor") { @@ -142,13 +115,13 @@ void stabilizeNonlinearUpdate(BVector& dx, BVector& dxOld, static void registerParameters() { - Parameters::registerParam + Parameters::Register> ("The maximum relaxation factor of a Newton iteration"); Parameters::Register ("The maximum number of Newton iterations per time step"); - Parameters::registerParam + Parameters::Register ("The minimum number of Newton iterations per time step"); - Parameters::registerParam + Parameters::Register ("The type of relaxation used by Newton method"); Parameters::SetDefault(20); From 9141f2c2d58863c8ab57ccb186bbbf6b491e56e1 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sat, 6 Jul 2024 10:22:47 +0200 Subject: [PATCH 08/15] move Damaris parameters to TypeTag-free parameter system --- opm/simulators/flow/DamarisParameters.hpp | 57 ++++--------- opm/simulators/flow/DamarisWriter.hpp | 29 +++---- opm/simulators/flow/FlowProblem.hpp | 4 +- opm/simulators/flow/FlowProblemProperties.hpp | 83 ------------------- opm/simulators/flow/Main.hpp | 2 +- opm/simulators/utils/DamarisKeywords.hpp | 26 +++--- 6 files changed, 45 insertions(+), 156 deletions(-) diff --git a/opm/simulators/flow/DamarisParameters.hpp b/opm/simulators/flow/DamarisParameters.hpp index 48ec3f6e8..d1ba555fb 100644 --- a/opm/simulators/flow/DamarisParameters.hpp +++ b/opm/simulators/flow/DamarisParameters.hpp @@ -31,51 +31,22 @@ #ifndef OPM_DAMARIS_PARAMETERS_HPP #define OPM_DAMARIS_PARAMETERS_HPP -#include - namespace Opm::Parameters { -template -struct EnableDamarisOutput { using type = Properties::UndefinedProperty; }; - -template -struct DamarisOutputHdfCollective { using type = Properties::UndefinedProperty; }; - -template -struct DamarisSaveMeshToHdf { using type = Properties::UndefinedProperty; }; - -template -struct DamarisSaveToHdf { using type = Properties::UndefinedProperty; }; - -template -struct DamarisPythonScript { using type = Properties::UndefinedProperty; }; - -template -struct DamarisPythonParaviewScript { using type = Properties::UndefinedProperty; }; - -template -struct DamarisSimName { using type = Properties::UndefinedProperty; }; - -template -struct DamarisDedicatedCores { using type = Properties::UndefinedProperty; }; - -template -struct DamarisDedicatedNodes { using type = Properties::UndefinedProperty; }; - -template -struct DamarisSharedMemoryName { using type = Properties::UndefinedProperty; }; - -template -struct DamarisSharedMemorySizeBytes { using type = Properties::UndefinedProperty; }; - -template -struct DamarisLogLevel { using type = Properties::UndefinedProperty; }; - -template -struct DamarisDaskFile { using type = Properties::UndefinedProperty; }; - -template -struct DamarisLimitVariables { using type = Properties::UndefinedProperty; }; +struct EnableDamarisOutput { static constexpr bool value = false; }; +struct DamarisOutputHdfCollective { static constexpr bool value = true; }; +struct DamarisSaveMeshToHdf { static constexpr bool value = false; }; +struct DamarisSaveToHdf { static constexpr bool value = true; }; +struct DamarisPythonScript { static constexpr auto value = ""; }; +struct DamarisPythonParaviewScript { static constexpr auto value = ""; }; +struct DamarisSimName { static constexpr auto value = ""; }; +struct DamarisDedicatedCores { static constexpr int value = 1; }; +struct DamarisDedicatedNodes { static constexpr int value = 0; }; +struct DamarisSharedMemoryName { static constexpr auto value = "" ; }; +struct DamarisSharedMemorySizeBytes { static constexpr long value = 536870912; }; // 512 MB +struct DamarisLogLevel { static constexpr auto value = "info"; }; +struct DamarisDaskFile { static constexpr auto value = ""; }; +struct DamarisLimitVariables { static constexpr auto value = ""; }; } // namespace Opm::Parameters diff --git a/opm/simulators/flow/DamarisWriter.hpp b/opm/simulators/flow/DamarisWriter.hpp index 1b7315d8b..c54971ff6 100644 --- a/opm/simulators/flow/DamarisWriter.hpp +++ b/opm/simulators/flow/DamarisWriter.hpp @@ -105,58 +105,58 @@ class DamarisWriter : public EclGenericWriter + Parameters::Register ("Write output via Damaris using parallel HDF5 to " "get single file and dataset per timestep instead " "of one per Damaris core with multiple datasets."); - Parameters::registerParam + Parameters::Register ("Set to false to prevent output to HDF5. " "Uses collective output by default or " "set --enable-damaris-collective=false to" "use file per core (file per Damaris server)."); - Parameters::registerParam + Parameters::Register ("Saves the mesh data to the HDF5 file (1st iteration only). " "Will set --damaris-output-hdf-collective to false " "so will use file per core (file per Damaris server) output " "(global sizes and offset values of mesh variables are not being provided as yet)."); - Parameters::registerParam + Parameters::Register ("Set to the path and filename of a Python script to run on " "Damaris server resources with access to OPM flow data."); - Parameters::registerParam + Parameters::Register ("Set to the path and filename of a Paraview Python script " "to run on Paraview Catalyst (1 or 2) on Damaris server " "resources with access to OPM flow data."); - Parameters::registerParam + Parameters::Register ("The name of the simulation to be used by Damaris. " "If empty (the default) then Damaris uses \"opm-sim-\". " "This name is used for the Damaris HDF5 file name prefix. " "Make unique if writing to the same output directory."); - Parameters::registerParam + Parameters::Register ("The log level for the Damaris logging system (boost log based). " "Levels are: [trace, debug, info, warning, error, fatal]. " "Currently debug and info are useful. "); - Parameters::registerParam + Parameters::Register ("The name of a Dask json configuration file (if using Dask for processing)."); - Parameters::registerParam + Parameters::Register ("Set the number of dedicated cores (MPI processes) " "that should be used for Damaris processing (per node). " "Must divide evenly into the number of simulation ranks (client ranks)."); - Parameters::registerParam + Parameters::Register ("Set the number of dedicated nodes (full nodes) " "that should be used for Damaris processing (per simulation). " "Must divide evenly into the number of simulation nodes."); - Parameters::registerParam + Parameters::Register ("Set the size of the shared memory buffer used for IPC " "between the simulation and the Damaris resources. " "Needs to hold all the variables published, possibly over " "multiple simulation iterations."); - Parameters::registerParam + Parameters::Register ("The name of the shared memory area to be used by Damaris for the current. " "If empty (the default) then Damaris uses \"opm-damaris-\". " "This name should be unique if multiple simulations are running on " "the same node/server as it is used for the Damaris shmem name and by " "the Python Dask library to locate sections of variables."); - Parameters::registerParam + Parameters::Register ("A comma separated list of variable names that a user wants to pass " "through via DamarisOutput::DamarisWriter::writeOutput)() to the " "damaris_write() call. This can be used to limit the number of " @@ -351,7 +351,8 @@ private: static bool enableDamarisOutput_() { - return Parameters::get(); + static bool enable = Parameters::Get(); + return enable; } void setGlobalIndexForDamaris () diff --git a/opm/simulators/flow/FlowProblem.hpp b/opm/simulators/flow/FlowProblem.hpp index 0de1390a7..b7e7c597e 100644 --- a/opm/simulators/flow/FlowProblem.hpp +++ b/opm/simulators/flow/FlowProblem.hpp @@ -228,7 +228,7 @@ public: ("Write binary output which is compatible with the commercial " "Eclipse simulator"); #if HAVE_DAMARIS - Parameters::registerParam + Parameters::Register ("Write a specific variable using Damaris in a separate core"); #endif Parameters::registerParam @@ -331,7 +331,7 @@ public: #if HAVE_DAMARIS // create Damaris writer damarisWriter_ = std::make_unique(simulator); - enableDamarisOutput_ = Parameters::get(); + enableDamarisOutput_ = Parameters::Get(); #endif enableDriftCompensation_ = Parameters::get(); diff --git a/opm/simulators/flow/FlowProblemProperties.hpp b/opm/simulators/flow/FlowProblemProperties.hpp index 81c4b1b14..c73e3d66b 100644 --- a/opm/simulators/flow/FlowProblemProperties.hpp +++ b/opm/simulators/flow/FlowProblemProperties.hpp @@ -268,89 +268,6 @@ struct EnableExperiments namespace Opm::Parameters { -#ifdef HAVE_DAMARIS -//! Disable the Damaris HDF5 output by default -template -struct EnableDamarisOutput -{ static constexpr bool value = false; }; - -// If Damaris is available, write specific variable output in parallel -template -struct DamarisOutputHdfCollective -{ static constexpr bool value = true; }; - -// Save the reservoir model mesh data to the HDF5 file -// (even if field data HDF5 output is disabled) -template -struct DamarisSaveMeshToHdf -{ static constexpr bool value = false; }; - -// Save the simulation fields (currently only PRESSURE) variables to HDF5 file -template -struct DamarisSaveToHdf -{ static constexpr bool value = true; }; - -// Specify path and filename of a Python script to run on each end of iteration output -template -struct DamarisPythonScript -{ static constexpr auto value = ""; }; - -// Specifiy a Paraview Catalyst in situ visualisation script -// (if Paraview is enabled in Damaris) -template -struct DamarisPythonParaviewScript -{ static constexpr auto value = ""; }; - -// Specify a unique name for the Damaris simulation (used as prefix to HDF5 filenames) -template -struct DamarisSimName -{ static constexpr auto value = ""; }; - -// Specify the number of Damaris cores (dc) to create (per-node). -// Must divide into the remaining ranks -// equally, e.g. mpirun -np 16 ... -> (if running on one node) -// The following are allowed: -// 1 dc + 15 sim ranks -// or 2 dc + 14 sim -// or 4 dc + 12 sim -// *not* 3 dc + 13 sim ranks -template -struct DamarisDedicatedCores -{ static constexpr int value = 1; }; - -// Specify the number of Damaris nodes to create -template -struct DamarisDedicatedNodes -{ static constexpr int value = 0; }; - -// Specify a name for the Damaris shared memory file -// (a unique name will be created by default) -template -struct DamarisSharedMemoryName -{ static constexpr auto value = "" ; }; - -// Specify the shared memory file size -template -struct DamarisSharedMemorySizeBytes -{ static constexpr long value = 536870912; }; // 512 MB - -// Specify the Damaris log level - if set to debug then log is flushed regularly -template -struct DamarisLogLevel -{ static constexpr auto value = "info"; }; - -// Specify the dask file jason file that specifies the Dask scheduler etc. -template -struct DamarisDaskFile -{ static constexpr auto value = ""; }; - -// Specify the the exact variables to be passed through -// to Damaris (must exist in the XML file / intiDamarisXmlFile.cpp) -template -struct DamarisLimitVariables -{ static constexpr auto value = ""; }; -#endif - // By default, use single precision for the ECL formated results template struct EclOutputDoublePrecision diff --git a/opm/simulators/flow/Main.hpp b/opm/simulators/flow/Main.hpp index 2d9c57bbf..8036f14a9 100644 --- a/opm/simulators/flow/Main.hpp +++ b/opm/simulators/flow/Main.hpp @@ -342,7 +342,7 @@ private: } #if HAVE_DAMARIS - enableDamarisOutput_ = Parameters::get(); + enableDamarisOutput_ = Parameters::Get(); // Reset to false as we cannot use Damaris if there is only one rank. if ((enableDamarisOutput_ == true) && (FlowGenericVanguard::comm().size() == 1)) { diff --git a/opm/simulators/utils/DamarisKeywords.hpp b/opm/simulators/utils/DamarisKeywords.hpp index 89874f962..600865cee 100644 --- a/opm/simulators/utils/DamarisKeywords.hpp +++ b/opm/simulators/utils/DamarisKeywords.hpp @@ -97,18 +97,18 @@ getDamarisKeywords(const Parallel::Communication& comm, const std::string& Outpu // which is used in simulators/flow/Main.hpp) // These command line arguments are defined in opm/simulators/flow/DamarisWriter.hpp and // defaults are set in opm/simulators/flow/FlowProblemProperties.hpp - settings.enableDamarisOutputCollective_ = Parameters::get(); - settings.saveMeshToHDF5_ = Parameters::get(); - settings.saveToDamarisHDF5_ = Parameters::get(); - settings.pythonFilename_ = Parameters::get(); - settings.paraviewPythonFilename_ = Parameters::get(); - settings.damarisSimName_ = Parameters::get(); - settings.nDamarisCores_ = Parameters::get(); - settings.nDamarisNodes_ = Parameters::get(); - settings.shmemSizeBytes_ = Parameters::get(); - settings.shmemName_ = Parameters::get(); - settings.damarisLogLevel_ = Parameters::get(); - settings.damarisDaskFile_ = Parameters::get(); + settings.enableDamarisOutputCollective_ = Parameters::Get(); + settings.saveMeshToHDF5_ = Parameters::Get(); + settings.saveToDamarisHDF5_ = Parameters::Get(); + settings.pythonFilename_ = Parameters::Get(); + settings.paraviewPythonFilename_ = Parameters::Get(); + settings.damarisSimName_ = Parameters::Get(); + settings.nDamarisCores_ = Parameters::Get(); + settings.nDamarisNodes_ = Parameters::Get(); + settings.shmemSizeBytes_ = Parameters::Get(); + settings.shmemName_ = Parameters::Get(); + settings.damarisLogLevel_ = Parameters::Get(); + settings.damarisDaskFile_ = Parameters::Get(); return settings.getKeywords(comm, OutputDir); } @@ -120,7 +120,7 @@ getSetOfIncludedVariables(void) std::unordered_set resuset ; std::string tstr; // The --damaris-limit-variables command line option (defaults to empty string) - std::string damarisLimitVars = Parameters::get(); + std::string damarisLimitVars = Parameters::Get(); std::stringstream ss(damarisLimitVars); // Use while loop to check the getline() function condition. From fdcc9a0fb20c3839f03edcd7f14c09155ba692d0 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 14 Aug 2024 14:05:43 +0200 Subject: [PATCH 09/15] fixed: EnableDebuggingChecks is a property, not a parameter --- opm/simulators/flow/BlackoilModel.hpp | 8 ++------ opm/simulators/flow/FlowProblem.hpp | 2 +- opm/simulators/flow/FlowProblemParameters.hpp | 6 ------ opm/simulators/flow/FlowProblemProperties.hpp | 16 +++++++++++----- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/opm/simulators/flow/BlackoilModel.hpp b/opm/simulators/flow/BlackoilModel.hpp index e590e8f46..78134dd17 100644 --- a/opm/simulators/flow/BlackoilModel.hpp +++ b/opm/simulators/flow/BlackoilModel.hpp @@ -142,15 +142,11 @@ template struct LinearSolverSplice { using type = TTag::FlowIstlSolver; }; -} // namespace Opm::Properties - -namespace Opm::Parameters { - template -struct EnableDebuggingChecks +struct EnableDebuggingChecks { static constexpr bool value = false; }; -} +} // namespace Opm::Properties namespace Opm { diff --git a/opm/simulators/flow/FlowProblem.hpp b/opm/simulators/flow/FlowProblem.hpp index b7e7c597e..7006d12a8 100644 --- a/opm/simulators/flow/FlowProblem.hpp +++ b/opm/simulators/flow/FlowProblem.hpp @@ -679,7 +679,7 @@ public: OPM_TIMEBLOCK(endTimeStep); #ifndef NDEBUG - if constexpr (getPropValue()) { + if constexpr (getPropValue()) { // in debug mode, we don't care about performance, so we check // if the model does the right thing (i.e., the mass change // inside the whole reservoir must be equivalent to the fluxes diff --git a/opm/simulators/flow/FlowProblemParameters.hpp b/opm/simulators/flow/FlowProblemParameters.hpp index ab3f80099..bd2607f66 100644 --- a/opm/simulators/flow/FlowProblemParameters.hpp +++ b/opm/simulators/flow/FlowProblemParameters.hpp @@ -32,12 +32,6 @@ namespace Opm::Parameters { -// Enable the additional checks even if compiled in debug mode (i.e., with the NDEBUG -// macro undefined). Next to a slightly better performance, this also eliminates some -// print statements in debug mode. -template -struct EnableDebuggingChecks { using type = Properties::UndefinedProperty; }; - // Enable partial compensation of systematic mass losses via the source term of the next time // step template diff --git a/opm/simulators/flow/FlowProblemProperties.hpp b/opm/simulators/flow/FlowProblemProperties.hpp index c73e3d66b..604259a8e 100644 --- a/opm/simulators/flow/FlowProblemProperties.hpp +++ b/opm/simulators/flow/FlowProblemProperties.hpp @@ -76,6 +76,12 @@ struct AquiferModel { using type = UndefinedProperty; }; template struct EnableApiTracking { using type = UndefinedProperty; }; +// Enable the additional checks even if compiled in debug mode (i.e., with the NDEBUG +// macro undefined). Next to a slightly better performance, this also eliminates some +// print statements in debug mode. +template +struct EnableDebuggingChecks { using type = Properties::UndefinedProperty; }; + // if thermal flux boundaries are enabled an effort is made to preserve the initial // thermal gradient specified via the TEMPVD keyword template @@ -264,6 +270,11 @@ template struct EnableExperiments { static constexpr bool value = false; }; +// By default, we enable the debugging checks if we're compiled in debug mode +template +struct EnableDebuggingChecks +{ static constexpr bool value = true; }; + } // namespace Opm::Properties namespace Opm::Parameters { @@ -278,11 +289,6 @@ template struct EnableAsyncEclOutput { static constexpr bool value = true; }; -// By default, we enable the debugging checks if we're compiled in debug mode -template -struct EnableDebuggingChecks -{ static constexpr bool value = true; }; - // Drift compensation is an experimental feature, i.e., systematic errors in the // conservation quantities are only compensated for // as default if experimental mode is enabled. From 414f313d2ab54903eb53a0d4ec52f55b60c8f3e1 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sat, 6 Jul 2024 10:22:47 +0200 Subject: [PATCH 10/15] move FlowProblem parameters to TypeTag-free parameter system --- opm/simulators/flow/BlackoilModel.hpp | 1 + opm/simulators/flow/FlowMain.hpp | 2 +- opm/simulators/flow/FlowProblem.hpp | 22 ++++++++-------- opm/simulators/flow/FlowProblemParameters.hpp | 26 +++++++++---------- opm/simulators/flow/FlowProblemProperties.hpp | 22 ---------------- opm/simulators/flow/Main.hpp | 7 +++-- 6 files changed, 28 insertions(+), 52 deletions(-) diff --git a/opm/simulators/flow/BlackoilModel.hpp b/opm/simulators/flow/BlackoilModel.hpp index 78134dd17..1d064677d 100644 --- a/opm/simulators/flow/BlackoilModel.hpp +++ b/opm/simulators/flow/BlackoilModel.hpp @@ -1310,6 +1310,7 @@ namespace Opm { public: std::vector wasSwitched_; }; + } // namespace Opm #endif // OPM_BLACKOILMODEL_HEADER_INCLUDED diff --git a/opm/simulators/flow/FlowMain.hpp b/opm/simulators/flow/FlowMain.hpp index 58bc4d16d..c8ca2ef82 100644 --- a/opm/simulators/flow/FlowMain.hpp +++ b/opm/simulators/flow/FlowMain.hpp @@ -135,7 +135,7 @@ namespace Opm { // the default eWoms checkpoint/restart mechanism does not work with flow Parameters::Hide>(); - Parameters::hideParam(); + Parameters::Hide(); // hide all vtk related it is not currently possible to do this dependet on if the vtk writing is used //if(not(Parameters::get())){ Parameters::Hide(); diff --git a/opm/simulators/flow/FlowProblem.hpp b/opm/simulators/flow/FlowProblem.hpp index 7006d12a8..76e200e1b 100644 --- a/opm/simulators/flow/FlowProblem.hpp +++ b/opm/simulators/flow/FlowProblem.hpp @@ -233,20 +233,20 @@ public: #endif Parameters::registerParam ("Tell the output writer to use double precision. Useful for 'perfect' restarts"); - Parameters::registerParam + Parameters::Register ("The frequencies of which time steps are serialized to disk"); - Parameters::registerParam + Parameters::Register ("Enable partial compensation of systematic mass losses via " "the source term of the next time step"); - Parameters::registerParam + Parameters::Register ("Specify which messages are going to be printed. " "Valid values are: none, log, all (default)"); - Parameters::registerParam + Parameters::Register ("Number of pressure points (in each direction) in tables used for equilibration"); - Parameters::hideParam(); // Users will typically not need to modify this parameter.. - Parameters::registerParam + Parameters::Hide(); // Users will typically not need to modify this parameter.. + Parameters::Register ("Use pressure from end of the last time step when evaluating rock compaction"); - Parameters::hideParam(); // Users will typically not need to modify this parameter.. + Parameters::Hide(); // Users will typically not need to modify this parameter.. // By default, stop it after the universe will probably have stopped // to exist. (the ECL problem will finish the simulation explicitly @@ -333,7 +333,7 @@ public: damarisWriter_ = std::make_unique(simulator); enableDamarisOutput_ = Parameters::Get(); #endif - enableDriftCompensation_ = Parameters::get(); + enableDriftCompensation_ = Parameters::Get(); enableEclOutput_ = Parameters::get(); enableVtkOutput_ = Parameters::Get(); @@ -346,14 +346,14 @@ public: // 1. Command line value (--num-pressure-points-equil=N) // 2. EQLDIMS item 2 // Default value is defined in opm-common/src/opm/input/eclipse/share/keywords/000_Eclipse100/E/EQLDIMS - if (Parameters::isSet()) + if (Parameters::IsSet()) { - this->numPressurePointsEquil_ = Parameters::get(); + this->numPressurePointsEquil_ = Parameters::Get(); } else { this->numPressurePointsEquil_ = simulator.vanguard().eclState().getTableManager().getEqldims().getNumDepthNodesP(); } - explicitRockCompaction_ = Parameters::get(); + explicitRockCompaction_ = Parameters::Get(); RelpermDiagnostics relpermDiagnostics; diff --git a/opm/simulators/flow/FlowProblemParameters.hpp b/opm/simulators/flow/FlowProblemParameters.hpp index bd2607f66..ba615e980 100644 --- a/opm/simulators/flow/FlowProblemParameters.hpp +++ b/opm/simulators/flow/FlowProblemParameters.hpp @@ -28,29 +28,27 @@ #ifndef OPM_FLOW_PROBLEM_PARAMETERS_HPP #define OPM_FLOW_PROBLEM_PARAMETERS_HPP -#include +#include namespace Opm::Parameters { -// Enable partial compensation of systematic mass losses via the source term of the next time -// step -template -struct EnableDriftCompensation { using type = Properties::UndefinedProperty; }; + +// Enable partial compensation of systematic mass losses via +// the source term of the next time step +struct EnableDriftCompensation { static constexpr bool value = true; }; // implicit or explicit pressure in rock compaction -template -struct ExplicitRockCompaction { using type = Properties::UndefinedProperty; }; +struct ExplicitRockCompaction { static constexpr bool value = false; }; // Parameterize equilibration accuracy -template -struct NumPressurePointsEquil { using type = Properties::UndefinedProperty; }; +struct NumPressurePointsEquil +{ static constexpr int value = ParserKeywords::EQLDIMS::DEPTH_NODES_P::defaultValue; }; -template -struct OutputMode { using type = Properties::UndefinedProperty; }; +struct OutputMode { static constexpr auto value = "all"; }; -// The number of time steps skipped between writing two consequtive restart files -template -struct RestartWritingInterval { using type = Properties::UndefinedProperty; }; +// The frequency of writing restart (*.ers) files. This is the number of time steps +// between writing restart files +struct RestartWritingInterval { static constexpr int value = 0xffffff; }; // disable } // namespace Opm::Parameters diff --git a/opm/simulators/flow/FlowProblemProperties.hpp b/opm/simulators/flow/FlowProblemProperties.hpp index 604259a8e..ae3083210 100644 --- a/opm/simulators/flow/FlowProblemProperties.hpp +++ b/opm/simulators/flow/FlowProblemProperties.hpp @@ -28,8 +28,6 @@ #ifndef OPM_FLOW_PROBLEM_PROPERTIES_HPP #define OPM_FLOW_PROBLEM_PROPERTIES_HPP -#include - #include #include @@ -311,26 +309,6 @@ template struct EnableWriteAllSolutions { static constexpr bool value = false; }; -// By default, use implicit pressure in rock compaction -template -struct ExplicitRockCompaction -{ static constexpr bool value = false; }; - -// Parameterize equilibration accuracy -template -struct NumPressurePointsEquil -{ static constexpr int value = ParserKeywords::EQLDIMS::DEPTH_NODES_P::defaultValue; }; - -template -struct OutputMode -{ static constexpr auto value = "all"; }; - -// The frequency of writing restart (*.ers) files. This is the number of time steps -// between writing restart files -template -struct RestartWritingInterval -{ static constexpr int value = 0xffffff; }; // disable - } // namespace Opm::Parameters #endif // OPM_FLOW_PROBLEM_PROPERTIES_HPP diff --git a/opm/simulators/flow/Main.hpp b/opm/simulators/flow/Main.hpp index 8036f14a9..bc4288f59 100644 --- a/opm/simulators/flow/Main.hpp +++ b/opm/simulators/flow/Main.hpp @@ -406,7 +406,7 @@ private: std::string cmdline_params; if (outputCout_) { printFlowBanner(FlowGenericVanguard::comm().size(), - getNumThreads(), + getNumThreads(), Opm::moduleVersionName()); std::ostringstream str; Parameters::printValues(str); @@ -417,12 +417,12 @@ private: try { this->readDeck(deckFilename, outputDir, - Parameters::get(), + Parameters::Get(), !Parameters::Get(), Parameters::Get(), Parameters::Get(), Parameters::Get(), - getNumThreads(), + getNumThreads(), Parameters::Get(), cmdline_params, Opm::moduleVersion(), @@ -705,7 +705,6 @@ private: void setupVanguard(); - template static int getNumThreads() { From 8111d2eaa0dd6af7d4403e0791afcb3e14385363 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sat, 6 Jul 2024 10:22:47 +0200 Subject: [PATCH 11/15] move EclWriter parameters to TypeTag-free parameter system --- flowexperimental/flowexp.hpp | 2 +- opm/simulators/flow/EclWriter.hpp | 41 ++++++++++--------- opm/simulators/flow/FlowMain.hpp | 2 +- opm/simulators/flow/FlowProblem.hpp | 10 ++--- opm/simulators/flow/FlowProblemParameters.hpp | 2 +- opm/simulators/flow/FlowProblemProperties.hpp | 36 ---------------- 6 files changed, 30 insertions(+), 63 deletions(-) diff --git a/flowexperimental/flowexp.hpp b/flowexperimental/flowexp.hpp index db2bc616f..21a6d29a0 100644 --- a/flowexperimental/flowexp.hpp +++ b/flowexperimental/flowexp.hpp @@ -137,7 +137,7 @@ public: OPM_TIMEBLOCK(problemWriteOutput); // use the generic code to prepare the output fields and to // write the desired VTK files. - if (Parameters::get() || + if (Parameters::Get() || this->simulator().episodeWillBeOver()) { // \Note: the SimulatorTimer does not carry any useful information, so PRT file (if it gets output) will contain wrong diff --git a/opm/simulators/flow/EclWriter.hpp b/opm/simulators/flow/EclWriter.hpp index af4de1f57..19f345523 100644 --- a/opm/simulators/flow/EclWriter.hpp +++ b/opm/simulators/flow/EclWriter.hpp @@ -52,22 +52,21 @@ namespace Opm::Parameters { -template -struct EnableEclOutput { using type = Properties::UndefinedProperty; }; +// enable the ECL output by default +struct EnableEclOutput { static constexpr bool value = true; }; -template -struct EnableAsyncEclOutput { using type = Properties::UndefinedProperty; }; +// If available, write the ECL output in a non-blocking manner +struct EnableAsyncEclOutput { static constexpr bool value = true; }; -template -struct EclOutputDoublePrecision { using type = Properties::UndefinedProperty; }; +// By default, use single precision for the ECL formated results +struct EclOutputDoublePrecision { static constexpr bool value = false; }; // Write all solutions for visualization, not just the ones for the // report steps... -template -struct EnableWriteAllSolutions { using type = Properties::UndefinedProperty; }; +struct EnableWriteAllSolutions { static constexpr bool value = false; }; -template -struct EnableEsmry { using type = Properties::UndefinedProperty; }; +// Write ESMRY file for fast loading of summary data +struct EnableEsmry { static constexpr bool value = false; }; } // namespace Opm::Parameters @@ -125,10 +124,10 @@ public: { OutputBlackOilModule::registerParameters(); - Parameters::registerParam + Parameters::Register ("Write the ECL-formated results in a non-blocking way " "(i.e., using a separate thread)."); - Parameters::registerParam + Parameters::Register ("Write ESMRY file for fast loading of summary data."); } @@ -148,8 +147,8 @@ public: ((simulator.vanguard().grid().comm().rank() == 0) ? &simulator.vanguard().equilCartesianIndexMapper() : nullptr), - Parameters::get(), - Parameters::get()) + Parameters::Get(), + Parameters::Get()) , simulator_(simulator) { #if HAVE_MPI @@ -399,7 +398,7 @@ public: auto floresn = this->outputModule_->getFloresn(); // data::Solution localCellData = {}; - if (! isSubStep || Parameters::get()) { + if (! isSubStep || Parameters::Get()) { auto rstep = timer.reportStepNum(); @@ -455,7 +454,7 @@ public: const Scalar curTime = simulator_.time() + simulator_.timeStepSize(); const Scalar nextStepSize = simulator_.problem().nextTimeStepSize(); std::optional timeStepIdx; - if (Parameters::get()) { + if (Parameters::Get()) { timeStepIdx = simulator_.timeStepIndex(); } this->doWriteOutput(reportStepNum, timeStepIdx, isSubStep, @@ -469,7 +468,7 @@ public: this->summaryState(), this->simulator_.problem().thresholdPressure().getRestartVector(), curTime, nextStepSize, - Parameters::get(), + Parameters::Get(), isFlowsn, std::move(flowsn), isFloresn, std::move(floresn)); } @@ -604,7 +603,10 @@ public: private: static bool enableEclOutput_() - { return Parameters::get(); } + { + static bool enable = Parameters::Get(); + return enable; + } const EclipseState& eclState() const { return simulator_.vanguard().eclState(); } @@ -637,7 +639,8 @@ private: countLocalInteriorCellsGridView(gridView); this->outputModule_-> allocBuffers(num_interior, reportStepNum, - isSubStep && !Parameters::get(), log, /*isRestart*/ false); + isSubStep && !Parameters::Get(), + log, /*isRestart*/ false); ElementContext elemCtx(simulator_); diff --git a/opm/simulators/flow/FlowMain.hpp b/opm/simulators/flow/FlowMain.hpp index c8ca2ef82..d4bacfb6e 100644 --- a/opm/simulators/flow/FlowMain.hpp +++ b/opm/simulators/flow/FlowMain.hpp @@ -137,7 +137,7 @@ namespace Opm { Parameters::Hide>(); Parameters::Hide(); // hide all vtk related it is not currently possible to do this dependet on if the vtk writing is used - //if(not(Parameters::get())){ + //if(not(Parameters::Get())){ Parameters::Hide(); Parameters::Hide(); Parameters::Hide(); diff --git a/opm/simulators/flow/FlowProblem.hpp b/opm/simulators/flow/FlowProblem.hpp index 76e200e1b..379a94383 100644 --- a/opm/simulators/flow/FlowProblem.hpp +++ b/opm/simulators/flow/FlowProblem.hpp @@ -221,17 +221,17 @@ public: VtkTracerModule::registerParameters(); - Parameters::registerParam + Parameters::Register ("Write all solutions to disk instead of only the ones for the " "report steps"); - Parameters::registerParam + Parameters::Register ("Write binary output which is compatible with the commercial " "Eclipse simulator"); #if HAVE_DAMARIS Parameters::Register ("Write a specific variable using Damaris in a separate core"); #endif - Parameters::registerParam + Parameters::Register ("Tell the output writer to use double precision. Useful for 'perfect' restarts"); Parameters::Register ("The frequencies of which time steps are serialized to disk"); @@ -335,7 +335,7 @@ public: #endif enableDriftCompensation_ = Parameters::Get(); - enableEclOutput_ = Parameters::get(); + enableEclOutput_ = Parameters::Get(); enableVtkOutput_ = Parameters::Get(); this->enableTuning_ = Parameters::get(); @@ -810,7 +810,7 @@ public: OPM_TIMEBLOCK(problemWriteOutput); // use the generic code to prepare the output fields and to // write the desired VTK files. - if (Parameters::get() || + if (Parameters::Get() || this->simulator().episodeWillBeOver()) { ParentType::writeOutput(verbose); } diff --git a/opm/simulators/flow/FlowProblemParameters.hpp b/opm/simulators/flow/FlowProblemParameters.hpp index ba615e980..9278ea4b3 100644 --- a/opm/simulators/flow/FlowProblemParameters.hpp +++ b/opm/simulators/flow/FlowProblemParameters.hpp @@ -35,7 +35,7 @@ namespace Opm::Parameters { // Enable partial compensation of systematic mass losses via // the source term of the next time step -struct EnableDriftCompensation { static constexpr bool value = true; }; +struct EnableDriftCompensation { static constexpr bool value = false; }; // implicit or explicit pressure in rock compaction struct ExplicitRockCompaction { static constexpr bool value = false; }; diff --git a/opm/simulators/flow/FlowProblemProperties.hpp b/opm/simulators/flow/FlowProblemProperties.hpp index ae3083210..859d92ea5 100644 --- a/opm/simulators/flow/FlowProblemProperties.hpp +++ b/opm/simulators/flow/FlowProblemProperties.hpp @@ -275,40 +275,4 @@ struct EnableDebuggingChecks } // namespace Opm::Properties -namespace Opm::Parameters { - -// By default, use single precision for the ECL formated results -template -struct EclOutputDoublePrecision -{ static constexpr bool value = false; }; - -// If available, write the ECL output in a non-blocking manner -template -struct EnableAsyncEclOutput -{ static constexpr bool value = true; }; - -// Drift compensation is an experimental feature, i.e., systematic errors in the -// conservation quantities are only compensated for -// as default if experimental mode is enabled. -template -struct EnableDriftCompensation -{ static constexpr bool value = false; }; - -// enable the ECL output by default -template -struct EnableEclOutput -{ static constexpr bool value = true; }; - -// Write ESMRY file for fast loading of summary data -template -struct EnableEsmry -{ static constexpr bool value = false; }; - -// only write the solutions for the report steps to disk -template -struct EnableWriteAllSolutions -{ static constexpr bool value = false; }; - -} // namespace Opm::Parameters - #endif // OPM_FLOW_PROBLEM_PROPERTIES_HPP From 707afc79eb6d6c4968ec29553f022920b3db19fa Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sat, 6 Jul 2024 10:22:47 +0200 Subject: [PATCH 12/15] move SimulatorFullyImplicitBlackoil parameters to TypeTag-free parameter system --- opm/simulators/flow/FlowMain.hpp | 2 +- .../flow/SimulatorFullyImplicitBlackoil.hpp | 75 +++++-------------- 2 files changed, 21 insertions(+), 56 deletions(-) diff --git a/opm/simulators/flow/FlowMain.hpp b/opm/simulators/flow/FlowMain.hpp index d4bacfb6e..c1287724d 100644 --- a/opm/simulators/flow/FlowMain.hpp +++ b/opm/simulators/flow/FlowMain.hpp @@ -456,7 +456,7 @@ namespace Opm { printFlowTrailer(mpi_size_, threads, total_setup_time_, deck_read_time_, report, simulator_->model().localAccumulatedReports()); detail::handleExtraConvergenceOutput(report, - Parameters::get(), + Parameters::Get(), R"(OutputExtraConvergenceInfo (--output-extra-convergence-info))", eclState().getIOConfig().getOutputDir(), eclState().getIOConfig().getBaseName()); diff --git a/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp b/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp index 93f4d5610..f25ce2584 100644 --- a/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp +++ b/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp @@ -59,47 +59,12 @@ namespace Opm::Parameters { -template -struct EnableAdaptiveTimeStepping { using type = Properties::UndefinedProperty; }; - -template -struct OutputExtraConvergenceInfo { using type = Properties::UndefinedProperty; }; - -template -struct SaveStep { using type = Properties::UndefinedProperty; }; - -template -struct LoadStep { using type = Properties::UndefinedProperty; }; - -template -struct SaveFile { using type = Properties::UndefinedProperty; }; - -template -struct LoadFile { using type = Properties::UndefinedProperty; }; - -template -struct EnableAdaptiveTimeStepping -{ static constexpr bool value = true; }; - -template -struct OutputExtraConvergenceInfo -{ static constexpr auto* value = "none"; }; - -template -struct SaveStep -{ static constexpr auto* value = ""; }; - -template -struct SaveFile -{ static constexpr auto* value = ""; }; - -template -struct LoadFile -{ static constexpr auto* value = ""; }; - -template -struct LoadStep -{ static constexpr int value = -1; }; +struct EnableAdaptiveTimeStepping { static constexpr bool value = true; }; +struct OutputExtraConvergenceInfo { static constexpr auto* value = "none"; }; +struct SaveStep { static constexpr auto* value = ""; }; +struct SaveFile { static constexpr auto* value = ""; }; +struct LoadFile { static constexpr auto* value = ""; }; +struct LoadStep { static constexpr int value = -1; }; } // namespace Opm::Parameters @@ -157,10 +122,10 @@ public: , serializer_(*this, FlowGenericVanguard::comm(), simulator_.vanguard().eclState().getIOConfig(), - Parameters::get(), - Parameters::get(), - Parameters::get(), - Parameters::get()) + Parameters::Get(), + Parameters::Get(), + Parameters::Get(), + Parameters::Get()) { phaseUsage_ = phaseUsageFromDeck(eclState()); @@ -169,7 +134,7 @@ public: if (this->grid().comm().rank() == 0) { this->terminalOutput_ = Parameters::Get(); - this->startConvergenceOutputThread(Parameters::get(), + this->startConvergenceOutputThread(Parameters::Get(), R"(OutputExtraConvergenceInfo (--output-extra-convergence-info))"); } } @@ -188,9 +153,9 @@ public: Parameters::Register ("Print high-level information about the simulation's progress to the terminal"); - Parameters::registerParam + Parameters::Register ("Use adaptive time stepping between report steps"); - Parameters::registerParam + Parameters::Register ("Provide additional convergence output " "files for diagnostic purposes. " "\"none\" gives no extra output and " @@ -199,25 +164,25 @@ public: "\"iterations\" generates an INFOITER file. " "Combine options with commas, e.g., " "\"steps,iterations\" for multiple outputs."); - Parameters::registerParam + Parameters::Register ("Save serialized state to .OPMRST file. " "Either a specific report step, \"all\" to save " "all report steps or \":x\" to save every x'th step." "Use negative values of \"x\" to keep only the last " "written step, or \"last\" to save every step, keeping " "only the last."); - Parameters::registerParam + Parameters::Register ("Load serialized state from .OPMRST file. " "Either a specific report step, or 0 to load last " "stored report step."); - Parameters::registerParam + Parameters::Register ("FileName for .OPMRST file used for saving serialized state. " "If empty, CASENAME.OPMRST is used."); - Parameters::hideParam(); - Parameters::registerParam + Parameters::Hide(); + Parameters::Register ("FileName for .OPMRST file used to load serialized state. " "If empty, CASENAME.OPMRST is used."); - Parameters::hideParam(); + Parameters::Hide(); } /// Run the simulation. @@ -249,7 +214,7 @@ public: totalTimer_->start(); // adaptive time stepping - bool enableAdaptive = Parameters::get(); + bool enableAdaptive = Parameters::Get(); bool enableTUNING = Parameters::get(); if (enableAdaptive) { const UnitSystem& unitSystem = this->simulator_.vanguard().eclState().getUnits(); From e2b8715b42680c23b457e9f02d6088810da541cd Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sat, 6 Jul 2024 10:22:47 +0200 Subject: [PATCH 13/15] move EclTimeStepping parameters to TypeTag-free parameter system --- flowexperimental/flowexp.hpp | 2 +- flowexperimental/flowexp_blackoil.cpp | 2 +- opm/simulators/flow/FlowProblem.hpp | 6 +- opm/simulators/flow/FlowProblemProperties.hpp | 2 +- opm/simulators/flow/OutputBlackoilModule.hpp | 30 ++---- .../flow/SimulatorFullyImplicitBlackoil.hpp | 4 +- .../timestepping/AdaptiveTimeStepping.hpp | 19 ++-- .../timestepping/EclTimeSteppingParams.hpp | 97 ++++--------------- tests/TestTypeTag.hpp | 4 +- tests/test_glift1.cpp | 2 +- 10 files changed, 47 insertions(+), 121 deletions(-) diff --git a/flowexperimental/flowexp.hpp b/flowexperimental/flowexp.hpp index 21a6d29a0..6efef55fd 100644 --- a/flowexperimental/flowexp.hpp +++ b/flowexperimental/flowexp.hpp @@ -57,7 +57,7 @@ namespace TTag { struct FlowExpTypeTag { - using InheritsFrom = std::tuple; + using InheritsFrom = std::tuple; }; } diff --git a/flowexperimental/flowexp_blackoil.cpp b/flowexperimental/flowexp_blackoil.cpp index 616e4956c..8f9025b96 100644 --- a/flowexperimental/flowexp_blackoil.cpp +++ b/flowexperimental/flowexp_blackoil.cpp @@ -78,6 +78,6 @@ struct Simulator int main(int argc, char** argv) { using TypeTag = Opm::Properties::TTag::FlowExpProblemBlackOil; - Opm::registerEclTimeSteppingParameters(); + Opm::registerEclTimeSteppingParameters(); return Opm::start(argc, argv); } diff --git a/opm/simulators/flow/FlowProblem.hpp b/opm/simulators/flow/FlowProblem.hpp index 379a94383..1ab0fd1f2 100644 --- a/opm/simulators/flow/FlowProblem.hpp +++ b/opm/simulators/flow/FlowProblem.hpp @@ -338,9 +338,9 @@ public: enableEclOutput_ = Parameters::Get(); enableVtkOutput_ = Parameters::Get(); - this->enableTuning_ = Parameters::get(); + this->enableTuning_ = Parameters::Get(); this->initialTimeStepSize_ = Parameters::Get>(); - this->maxTimeStepAfterWellEvent_ = Parameters::get() * 24 * 60 * 60; + this->maxTimeStepAfterWellEvent_ = Parameters::Get>() * 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() * 24 * 60 * 60; + Scalar maxTimeStepSize = Parameters::Get>() * 24 * 60 * 60; int reportStepIdx = std::max(episodeIdx, 0); if (this->enableTuning_) { const auto& tuning = schedule[reportStepIdx].tuning(); diff --git a/opm/simulators/flow/FlowProblemProperties.hpp b/opm/simulators/flow/FlowProblemProperties.hpp index 859d92ea5..391c787e5 100644 --- a/opm/simulators/flow/FlowProblemProperties.hpp +++ b/opm/simulators/flow/FlowProblemProperties.hpp @@ -60,7 +60,7 @@ namespace Opm::Properties { namespace TTag { struct FlowBaseProblem { - using InheritsFrom = std::tuple; + using InheritsFrom = std::tuple; }; } diff --git a/opm/simulators/flow/OutputBlackoilModule.hpp b/opm/simulators/flow/OutputBlackoilModule.hpp index 57829ab8b..555540a8d 100644 --- a/opm/simulators/flow/OutputBlackoilModule.hpp +++ b/opm/simulators/flow/OutputBlackoilModule.hpp @@ -65,28 +65,10 @@ #include #include -namespace Opm::Properties::TTag { - -// create new type tag for the Ecl-output -struct OutputBlackOil {}; - -} // namespace Opm::Properties::TTag - namespace Opm::Parameters { -template -struct ForceDisableFluidInPlaceOutput { using type = Properties::UndefinedProperty; }; - -template -struct ForceDisableResvFluidInPlaceOutput { using type = Properties::UndefinedProperty; }; - -template -struct ForceDisableFluidInPlaceOutput -{ static constexpr bool value = false; }; - -template -struct ForceDisableResvFluidInPlaceOutput -{ 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(); + Parameters::Get(); this->forceDisableFipresvOutput_ = - Parameters::get(); + Parameters::Get(); if (! Parameters::Get()) { const std::string msg = "The output code does not support --owner-cells-first=false."; @@ -199,10 +181,10 @@ public: */ static void registerParameters() { - Parameters::registerParam + Parameters::Register ("Do not print fluid-in-place values after each report step " "even if requested by the deck."); - Parameters::registerParam + Parameters::Register ("Do not print reservoir volumes values after each report step " "even if requested by the deck."); } diff --git a/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp b/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp index f25ce2584..7a9b7a5c9 100644 --- a/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp +++ b/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp @@ -215,7 +215,7 @@ public: // adaptive time stepping bool enableAdaptive = Parameters::Get(); - bool enableTUNING = Parameters::get(); + bool enableTUNING = Parameters::Get(); 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(); + const bool enableTUNING = Parameters::Get(); // If sub stepping is enabled allow the solver to sub cycle // in case the report steps are too large for the solver to converge diff --git a/opm/simulators/timestepping/AdaptiveTimeStepping.hpp b/opm/simulators/timestepping/AdaptiveTimeStepping.hpp index 0a24d3019..2d08b398b 100644 --- a/opm/simulators/timestepping/AdaptiveTimeStepping.hpp +++ b/opm/simulators/timestepping/AdaptiveTimeStepping.hpp @@ -49,9 +49,7 @@ namespace Opm::Properties::TTag { -struct FlowTimeSteppingParameters { - using InheritsFrom = std::tuple; -}; +struct FlowTimeSteppingParameters {}; } @@ -219,6 +217,7 @@ std::set consistentlyFailingWells(const std::vector& sr template class AdaptiveTimeStepping { + using Scalar = GetPropType; template class SolutionTimeErrorSolverWrapper : public RelativeChangeInterface { @@ -252,18 +251,18 @@ std::set consistentlyFailingWells(const std::vector& sr const double max_next_tstep = -1.0, const bool terminalOutput = true) : timeStepControl_() - , restartFactor_(Parameters::get()) // 0.33 - , growthFactor_(Parameters::get()) // 2.0 - , maxGrowth_(Parameters::get()) // 3.0 - , maxTimeStep_(Parameters::get() * 24 * 60 * 60) // 365.25 - , minTimeStep_(unitSystem.to_si(UnitSystem::measure::time, Parameters::get())) // 1e-12; + , restartFactor_(Parameters::Get>()) // 0.33 + , growthFactor_(Parameters::Get>()) // 2.0 + , maxGrowth_(Parameters::Get>()) // 3.0 + , maxTimeStep_(Parameters::Get>() * 24 * 60 * 60) // 365.25 + , minTimeStep_(unitSystem.to_si(UnitSystem::measure::time, Parameters::Get>())) // 1e-12; , ignoreConvergenceFailure_(Parameters::get()) // false; , solverRestartMax_(Parameters::get()) // 10 , solverVerbose_(Parameters::get() > 0 && terminalOutput) // 2 , timestepVerbose_(Parameters::get() > 0 && terminalOutput) // 2 , suggestedNextTimestep_((max_next_tstep <= 0 ? Parameters::get() : max_next_tstep) * 24 * 60 * 60) // 1.0 , fullTimestepInitially_(Parameters::get()) // false - , timestepAfterEvent_(Parameters::get() * 24 * 60 * 60) // 1e30 + , timestepAfterEvent_(Parameters::Get>() * 24 * 60 * 60) // 1e30 , useNewtonIteration_(false) , minTimeStepBeforeShuttingProblematicWells_(Parameters::get() * unit::day) @@ -301,7 +300,7 @@ std::set consistentlyFailingWells(const std::vector& sr static void registerParameters() { - registerEclTimeSteppingParameters(); + registerEclTimeSteppingParameters(); // TODO: make sure the help messages are correct (and useful) Parameters::registerParam ("Continue instead of stop when minimum solver time step is reached"); diff --git a/opm/simulators/timestepping/EclTimeSteppingParams.hpp b/opm/simulators/timestepping/EclTimeSteppingParams.hpp index 41bd9efc1..136207644 100644 --- a/opm/simulators/timestepping/EclTimeSteppingParams.hpp +++ b/opm/simulators/timestepping/EclTimeSteppingParams.hpp @@ -26,104 +26,49 @@ #include #include - -namespace Opm::Properties::TTag { - -struct EclTimeSteppingParameters {}; - -} - namespace Opm::Parameters { -template -struct EnableTuning { using type = Properties::UndefinedProperty; }; +struct EnableTuning { static constexpr bool value = false; }; +template +struct SolverGrowthFactor { static constexpr Scalar value = 2.0; }; -template -struct SolverGrowthFactor { using type = Properties::UndefinedProperty; }; +template +struct SolverMaxGrowth { static constexpr Scalar value = 3.0; }; -template -struct SolverMaxGrowth { using type = Properties::UndefinedProperty; }; +template +struct SolverMinTimeStep { static constexpr Scalar value = 1e-12; }; -template -struct SolverMaxTimeStepInDays { using type = Properties::UndefinedProperty; }; +template +struct SolverMaxTimeStepInDays { static constexpr Scalar value = 365.0; }; -template -struct SolverMinTimeStep { using type = Properties::UndefinedProperty; }; +template +struct SolverRestartFactor { static constexpr Scalar value = 0.33; }; -template -struct SolverRestartFactor { using type = Properties::UndefinedProperty; }; - -template -struct TimeStepAfterEventInDays { using type = Properties::UndefinedProperty; }; - -template -struct EnableTuning -{ static constexpr bool value = false; }; - -template -struct SolverGrowthFactor -{ - using type = GetPropType; - static constexpr type value = 2.0; -}; - -template -struct SolverMaxGrowth -{ - using type = GetPropType; - static constexpr type value = 3.0; -}; - -template -struct SolverMinTimeStep -{ - using type = GetPropType; - static constexpr type value = 1.0e-12; -}; - -template -struct SolverMaxTimeStepInDays -{ - using type = GetPropType; - static constexpr type value = 365.0; -}; - -template -struct SolverRestartFactor -{ - using type = GetPropType; - static constexpr type value = 0.33; -}; - -template -struct TimeStepAfterEventInDays -{ - using type = GetPropType; - static constexpr type value = -1.0; -}; +template +struct TimeStepAfterEventInDays { static constexpr Scalar value = -1.0; }; } // namespace Opm::Properties namespace Opm { -template +template void registerEclTimeSteppingParameters() { - Parameters::registerParam + Parameters::Register ("Honor some aspects of the TUNING keyword."); - Parameters::registerParam + Parameters::Register> ("The factor time steps are elongated after a successful substep"); - Parameters::registerParam + Parameters::Register> ("The maximum factor time steps are elongated after a report step"); - Parameters::registerParam + Parameters::Register> ("The maximum size of a time step in days"); - Parameters::registerParam + Parameters::Register> ("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 + Parameters::Register> ("The factor time steps are elongated after restarts"); - Parameters::registerParam + Parameters::Register> ("Time step size of the first time step after an event " "occurs during the simulation in days"); } diff --git a/tests/TestTypeTag.hpp b/tests/TestTypeTag.hpp index 5bd026043..4fb69fc84 100644 --- a/tests/TestTypeTag.hpp +++ b/tests/TestTypeTag.hpp @@ -43,9 +43,9 @@ namespace TTag { struct TestTypeTag { using InheritsFrom = std::tuple; + BlackOilModel>; }; + } // Set the problem class diff --git a/tests/test_glift1.cpp b/tests/test_glift1.cpp index ae11d5932..08d4454f6 100644 --- a/tests/test_glift1.cpp +++ b/tests/test_glift1.cpp @@ -87,7 +87,7 @@ initSimulator(const char *filename) Parameters::reset(); registerAllParameters_(false); - registerEclTimeSteppingParameters(); + registerEclTimeSteppingParameters(); BlackoilModelParameters::registerParameters(); Parameters::Register("Do *NOT* use!"); Opm::Parameters::SetDefault(2); From 280704e2e072900afb59fc531e1579e094e8c8ec Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sat, 6 Jul 2024 10:22:47 +0200 Subject: [PATCH 14/15] move AdaptiveTimeStepping parameters to TypeTag-free parameter system --- opm/simulators/flow/BlackoilModel.hpp | 8 +- .../timestepping/AdaptiveTimeStepping.hpp | 257 +++++------------- tests/test_RestartSerialization.cpp | 2 +- tests/test_equil.cpp | 3 +- 4 files changed, 69 insertions(+), 201 deletions(-) diff --git a/opm/simulators/flow/BlackoilModel.hpp b/opm/simulators/flow/BlackoilModel.hpp index 1d064677d..3a246154a 100644 --- a/opm/simulators/flow/BlackoilModel.hpp +++ b/opm/simulators/flow/BlackoilModel.hpp @@ -74,11 +74,11 @@ namespace Opm::Properties { namespace TTag { -struct FlowProblem { - using InheritsFrom = std::tuple; -}; + +struct FlowProblem { using InheritsFrom = std::tuple; }; + } + // default in flow is to formulate the equations in surface volumes template struct BlackoilConserveSurfaceVolume diff --git a/opm/simulators/timestepping/AdaptiveTimeStepping.hpp b/opm/simulators/timestepping/AdaptiveTimeStepping.hpp index 2d08b398b..39bfbf992 100644 --- a/opm/simulators/timestepping/AdaptiveTimeStepping.hpp +++ b/opm/simulators/timestepping/AdaptiveTimeStepping.hpp @@ -47,156 +47,25 @@ #include #include -namespace Opm::Properties::TTag { - -struct FlowTimeSteppingParameters {}; - -} - namespace Opm::Parameters { -template -struct SolverContinueOnConvergenceFailure { using type = Properties::UndefinedProperty; }; - -template -struct SolverMaxRestarts { using type = Properties::UndefinedProperty; }; -template - -struct SolverVerbosity { using type = Properties::UndefinedProperty; }; - -template -struct TimeStepVerbosity { using type = Properties::UndefinedProperty; }; - -template -struct InitialTimeStepInDays { using type = Properties::UndefinedProperty; }; - -template -struct FullTimeStepInitially { using type = Properties::UndefinedProperty; }; - -template -struct TimeStepControl { using type = Properties::UndefinedProperty; }; - -template -struct TimeStepControlTolerance { using type = Properties::UndefinedProperty; }; - -template -struct TimeStepControlTargetIterations { using type = Properties::UndefinedProperty; }; - -template -struct TimeStepControlTargetNewtonIterations { using type = Properties::UndefinedProperty; }; - -template -struct TimeStepControlDecayRate { using type = Properties::UndefinedProperty; }; - -template -struct TimeStepControlGrowthRate { using type = Properties::UndefinedProperty; }; - -template -struct TimeStepControlDecayDampingFactor { using type = Properties::UndefinedProperty; }; - -template -struct TimeStepControlGrowthDampingFactor { using type = Properties::UndefinedProperty; }; - -template -struct TimeStepControlFileName { using type = Properties::UndefinedProperty; }; - -template -struct MinTimeStepBeforeShuttingProblematicWellsInDays { using type = Properties::UndefinedProperty; }; - -template -struct MinTimeStepBasedOnNewtonIterations { using type = Properties::UndefinedProperty; }; - -template -struct SolverContinueOnConvergenceFailure -{ static constexpr bool value = false; }; - -template -struct SolverMaxRestarts -{ static constexpr int value = 10; }; - -template -struct SolverVerbosity -{ static constexpr int value = 1; }; - -template -struct TimeStepVerbosity -{ static constexpr int value = 1; }; - -template -struct InitialTimeStepInDays -{ - using type = GetPropType; - static constexpr type value = 1.0; -}; - -template -struct FullTimeStepInitially -{ static constexpr bool value = false; }; - -template -struct TimeStepControl -{ static constexpr auto value = "pid+newtoniteration"; }; - -template -struct TimeStepControlTolerance -{ - using type = GetPropType; - static constexpr type value = 1e-1; -}; - -template -struct TimeStepControlTargetIterations -{ static constexpr int value = 30; }; - -template -struct TimeStepControlTargetNewtonIterations -{ static constexpr int value = 8; }; - -template -struct TimeStepControlDecayRate -{ - using type = GetPropType; - static constexpr type value = 0.75; -}; - -template -struct TimeStepControlGrowthRate -{ - using type = GetPropType; - static constexpr type value = 1.25; -}; - -template -struct TimeStepControlDecayDampingFactor -{ - using type = GetPropType; - static constexpr type value = 1.0; -}; - -template -struct TimeStepControlGrowthDampingFactor -{ - using type = GetPropType; - static constexpr type value = 3.2; -}; - -template -struct TimeStepControlFileName -{ static constexpr auto value = "timesteps"; }; - -template -struct MinTimeStepBeforeShuttingProblematicWellsInDays -{ - using type = GetPropType; - static constexpr type value = 0.01; -}; - -template -struct MinTimeStepBasedOnNewtonIterations -{ - using type = GetPropType; - static constexpr type value = 0.0; -}; +struct SolverContinueOnConvergenceFailure { static constexpr bool value = false; }; +struct SolverMaxRestarts { static constexpr int value = 10; }; +struct SolverVerbosity { static constexpr int value = 1; }; +struct TimeStepVerbosity { static constexpr int value = 1; }; +struct InitialTimeStepInDays { static constexpr double value = 1.0; }; +struct FullTimeStepInitially { static constexpr bool value = false; }; +struct TimeStepControl { static constexpr auto value = "pid+newtoniteration"; }; +struct TimeStepControlTolerance { static constexpr double value = 1e-1; }; +struct TimeStepControlTargetIterations { static constexpr int value = 30; }; +struct TimeStepControlTargetNewtonIterations { static constexpr int value = 8; }; +struct TimeStepControlDecayRate { static constexpr double value = 0.75; }; +struct TimeStepControlGrowthRate { static constexpr double value = 1.25; }; +struct TimeStepControlDecayDampingFactor { static constexpr double value = 1.0; }; +struct TimeStepControlGrowthDampingFactor { static constexpr double value = 3.2; }; +struct TimeStepControlFileName { static constexpr auto value = "timesteps"; }; +struct MinTimeStepBeforeShuttingProblematicWellsInDays { static constexpr double value = 0.01; }; +struct MinTimeStepBasedOnNewtonIterations { static constexpr double value = 0.0; }; } // namespace Opm::Parameters @@ -256,15 +125,15 @@ std::set consistentlyFailingWells(const std::vector& sr , maxGrowth_(Parameters::Get>()) // 3.0 , maxTimeStep_(Parameters::Get>() * 24 * 60 * 60) // 365.25 , minTimeStep_(unitSystem.to_si(UnitSystem::measure::time, Parameters::Get>())) // 1e-12; - , ignoreConvergenceFailure_(Parameters::get()) // false; - , solverRestartMax_(Parameters::get()) // 10 - , solverVerbose_(Parameters::get() > 0 && terminalOutput) // 2 - , timestepVerbose_(Parameters::get() > 0 && terminalOutput) // 2 - , suggestedNextTimestep_((max_next_tstep <= 0 ? Parameters::get() : max_next_tstep) * 24 * 60 * 60) // 1.0 - , fullTimestepInitially_(Parameters::get()) // false + , ignoreConvergenceFailure_(Parameters::Get()) // false; + , solverRestartMax_(Parameters::Get()) // 10 + , solverVerbose_(Parameters::Get() > 0 && terminalOutput) // 2 + , timestepVerbose_(Parameters::Get() > 0 && terminalOutput) // 2 + , suggestedNextTimestep_((max_next_tstep <= 0 ? Parameters::Get() : max_next_tstep) * 24 * 60 * 60) // 1.0 + , fullTimestepInitially_(Parameters::Get()) // false , timestepAfterEvent_(Parameters::Get>() * 24 * 60 * 60) // 1e30 , useNewtonIteration_(false) - , minTimeStepBeforeShuttingProblematicWells_(Parameters::get() * unit::day) + , minTimeStepBeforeShuttingProblematicWells_(Parameters::Get() * unit::day) { init_(unitSystem); @@ -286,14 +155,14 @@ std::set consistentlyFailingWells(const std::vector& sr , maxTimeStep_(tuning.TSMAXZ) // 365.25 , minTimeStep_(tuning.TSFMIN) // 0.1; , ignoreConvergenceFailure_(true) - , solverRestartMax_(Parameters::get()) // 10 - , solverVerbose_(Parameters::get() > 0 && terminalOutput) // 2 - , timestepVerbose_(Parameters::get() > 0 && terminalOutput) // 2 - , suggestedNextTimestep_(max_next_tstep <= 0 ? Parameters::get() * 24 * 60 * 60 : max_next_tstep) // 1.0 - , fullTimestepInitially_(Parameters::get()) // false + , solverRestartMax_(Parameters::Get()) // 10 + , solverVerbose_(Parameters::Get() > 0 && terminalOutput) // 2 + , timestepVerbose_(Parameters::Get() > 0 && terminalOutput) // 2 + , suggestedNextTimestep_(max_next_tstep <= 0 ? Parameters::Get() * 24 * 60 * 60 : max_next_tstep) // 1.0 + , fullTimestepInitially_(Parameters::Get()) // false , timestepAfterEvent_(tuning.TMAXWC) // 1e30 , useNewtonIteration_(false) - , minTimeStepBeforeShuttingProblematicWells_(Parameters::get() * unit::day) + , minTimeStepBeforeShuttingProblematicWells_(Parameters::Get() * unit::day) { init_(unitSystem); } @@ -302,20 +171,20 @@ std::set consistentlyFailingWells(const std::vector& sr { registerEclTimeSteppingParameters(); // TODO: make sure the help messages are correct (and useful) - Parameters::registerParam + Parameters::Register ("Continue instead of stop when minimum solver time step is reached"); - Parameters::registerParam + Parameters::Register ("The maximum number of breakdowns before a substep is given up and " "the simulator is terminated"); - Parameters::registerParam + Parameters::Register ("Specify the \"chattiness\" of the non-linear solver itself"); - Parameters::registerParam + Parameters::Register ("Specify the \"chattiness\" during the time integration"); - Parameters::registerParam + Parameters::Register ("The size of the initial time step in days"); - Parameters::registerParam + Parameters::Register ("Always attempt to finish a report step using a single substep"); - Parameters::registerParam + Parameters::Register ("The algorithm used to determine time-step sizes. " "Valid options are: " "'pid' (default), " @@ -324,31 +193,31 @@ std::set consistentlyFailingWells(const std::vector& sr "'iterationcount', " "'newtoniterationcount' " "and 'hardcoded'"); - Parameters::registerParam + Parameters::Register ("The tolerance used by the time step size control algorithm"); - Parameters::registerParam + Parameters::Register ("The number of linear iterations which the time step control scheme " "should aim for (if applicable)"); - Parameters::registerParam + Parameters::Register ("The number of Newton iterations which the time step control scheme " "should aim for (if applicable)"); - Parameters::registerParam + Parameters::Register ("The decay rate of the time step size of the number of " "target iterations is exceeded"); - Parameters::registerParam + Parameters::Register ("The growth rate of the time step size of the number of " "target iterations is undercut"); - Parameters::registerParam + Parameters::Register ("The decay rate of the time step decrease when the " "target iterations is exceeded"); - Parameters::registerParam + Parameters::Register ("The growth rate of the time step increase when the " "target iterations is undercut"); - Parameters::registerParam + Parameters::Register ("The name of the file which contains the hardcoded time steps sizes"); - Parameters::registerParam + Parameters::Register ("The minimum time step size in days for which problematic wells are not shut"); - Parameters::registerParam + Parameters::Register ("The minimum time step size (in days for field and metric unit and hours for lab unit) " "can be reduced to based on newton iteration counts"); } @@ -812,25 +681,25 @@ std::set consistentlyFailingWells(const std::vector& sr void init_(const UnitSystem& unitSystem) { // valid are "pid" and "pid+iteration" - std::string control = Parameters::get(); // "pid" + std::string control = Parameters::Get(); // "pid" - const double tol = Parameters::get(); // 1e-1 + const double tol = Parameters::Get(); // 1e-1 if (control == "pid") { timeStepControl_ = std::make_unique(tol); timeStepControlType_ = TimeStepControlType::PID; } else if (control == "pid+iteration") { - const int iterations = Parameters::get(); // 30 - const double decayDampingFactor = Parameters::get(); // 1.0 - const double growthDampingFactor = Parameters::get(); // 3.2 + const int iterations = Parameters::Get(); // 30 + const double decayDampingFactor = Parameters::Get(); // 1.0 + const double growthDampingFactor = Parameters::Get(); // 3.2 timeStepControl_ = std::make_unique(iterations, decayDampingFactor, growthDampingFactor, tol); timeStepControlType_ = TimeStepControlType::PIDAndIterationCount; } else if (control == "pid+newtoniteration") { - const int iterations = Parameters::get(); // 8 - const double decayDampingFactor = Parameters::get(); // 1.0 - const double growthDampingFactor = Parameters::get(); // 3.2 - const double nonDimensionalMinTimeStepIterations = Parameters::get(); // 0.0 by default + const int iterations = Parameters::Get(); // 8 + const double decayDampingFactor = Parameters::Get(); // 1.0 + const double growthDampingFactor = Parameters::Get(); // 3.2 + const double nonDimensionalMinTimeStepIterations = Parameters::Get(); // 0.0 by default // the min time step can be reduced by the newton iteration numbers double minTimeStepReducedByIterations = unitSystem.to_si(UnitSystem::measure::time, nonDimensionalMinTimeStepIterations); timeStepControl_ = std::make_unique(iterations, decayDampingFactor, @@ -839,22 +708,22 @@ std::set consistentlyFailingWells(const std::vector& sr useNewtonIteration_ = true; } else if (control == "iterationcount") { - const int iterations = Parameters::get(); // 30 - const double decayrate = Parameters::get(); // 0.75 - const double growthrate = Parameters::get(); // 1.25 + const int iterations = Parameters::Get(); // 30 + const double decayrate = Parameters::Get(); // 0.75 + const double growthrate = Parameters::Get(); // 1.25 timeStepControl_ = std::make_unique(iterations, decayrate, growthrate); timeStepControlType_ = TimeStepControlType::SimpleIterationCount; } else if (control == "newtoniterationcount") { - const int iterations = Parameters::get(); // 8 - const double decayrate = Parameters::get(); // 0.75 - const double growthrate = Parameters::get(); // 1.25 + const int iterations = Parameters::Get(); // 8 + const double decayrate = Parameters::Get(); // 0.75 + const double growthrate = Parameters::Get(); // 1.25 timeStepControl_ = std::make_unique(iterations, decayrate, growthrate); useNewtonIteration_ = true; timeStepControlType_ = TimeStepControlType::SimpleIterationCount; } else if (control == "hardcoded") { - const std::string filename = Parameters::get(); // "timesteps" + const std::string filename = Parameters::Get(); // "timesteps" timeStepControl_ = std::make_unique(filename); timeStepControlType_ = TimeStepControlType::HardCodedTimeStep; } diff --git a/tests/test_RestartSerialization.cpp b/tests/test_RestartSerialization.cpp index e6967b1ff..9c480b4f6 100644 --- a/tests/test_RestartSerialization.cpp +++ b/tests/test_RestartSerialization.cpp @@ -62,7 +62,7 @@ namespace Opm::Properties { namespace TTag { struct TestRestartTypeTag { - using InheritsFrom = std::tuple; + using InheritsFrom = std::tuple; }; } diff --git a/tests/test_equil.cpp b/tests/test_equil.cpp index 495311d42..205bfac55 100644 --- a/tests/test_equil.cpp +++ b/tests/test_equil.cpp @@ -72,8 +72,7 @@ namespace TTag { struct TestEquilTypeTag { - using InheritsFrom = std::tuple; }; struct TestEquilVapwatTypeTag { From 3751ca6be45d19baa931b4b843ea6b820b3c653f Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sat, 6 Jul 2024 10:22:47 +0200 Subject: [PATCH 15/15] move FlowLinearSolver parameters to TypeTag-free parameter system --- opm/simulators/flow/BlackoilModelNldd.hpp | 2 +- .../linalg/FlowLinearSolverParameters.hpp | 254 +++++------------- opm/simulators/linalg/ISTLSolver.hpp | 20 +- opm/simulators/linalg/ISTLSolverBda.hpp | 14 +- 4 files changed, 80 insertions(+), 210 deletions(-) diff --git a/opm/simulators/flow/BlackoilModelNldd.hpp b/opm/simulators/flow/BlackoilModelNldd.hpp index 4fc9a0923..ef4786017 100644 --- a/opm/simulators/flow/BlackoilModelNldd.hpp +++ b/opm/simulators/flow/BlackoilModelNldd.hpp @@ -160,7 +160,7 @@ public: // only. This must be addressed before going parallel. const auto& eclState = model_.simulator().vanguard().eclState(); FlowLinearSolverParameters loc_param; - loc_param.template init(eclState.getSimulationConfig().useCPR()); + loc_param.init(eclState.getSimulationConfig().useCPR()); // Override solver type with umfpack if small domain. // Otherwise hardcode to ILU0 if (domains_[index].cells.size() < 200) { diff --git a/opm/simulators/linalg/FlowLinearSolverParameters.hpp b/opm/simulators/linalg/FlowLinearSolverParameters.hpp index 78414de08..8a56e9278 100644 --- a/opm/simulators/linalg/FlowLinearSolverParameters.hpp +++ b/opm/simulators/linalg/FlowLinearSolverParameters.hpp @@ -63,154 +63,26 @@ struct LinearSolverBackend namespace Opm::Parameters { -template -struct LinearSolverReduction { using type = Properties::UndefinedProperty; }; - -template -struct RelaxedLinearSolverReduction { using type = Properties::UndefinedProperty; }; - -template -struct LinearSolverMaxIter { using type = Properties::UndefinedProperty; }; - -template -struct LinearSolverRestart { using type = Properties::UndefinedProperty; }; - -template -struct IluRelaxation { using type = Properties::UndefinedProperty; }; - -template -struct IluFillinLevel { using type = Properties::UndefinedProperty; }; - -template -struct MiluVariant { using type = Properties::UndefinedProperty; }; - -template -struct IluRedblack { using type = Properties::UndefinedProperty; }; - -template -struct IluReorderSpheres { using type = Properties::UndefinedProperty; }; - -template -struct UseGmres { using type = Properties::UndefinedProperty; }; - -template -struct LinearSolverIgnoreConvergenceFailure { using type = Properties::UndefinedProperty; }; - -template -struct ScaleLinearSystem { using type = Properties::UndefinedProperty; }; - -template -struct LinearSolver { using type = Properties::UndefinedProperty; }; - -template -struct LinearSolverPrintJsonDefinition { using type = Properties::UndefinedProperty; }; - -template -struct CprReuseSetup { using type = Properties::UndefinedProperty; }; - -template -struct CprReuseInterval { using type = Properties::UndefinedProperty; }; - -template -struct AcceleratorMode { using type = Properties::UndefinedProperty; }; - -template -struct BdaDeviceId { using type = Properties::UndefinedProperty; }; - -template -struct OpenclPlatformId { using type = Properties::UndefinedProperty; }; - -template -struct OpenclIluParallel { using type = Properties::UndefinedProperty; }; - -template -struct LinearSolverReduction -{ - using type = GetPropType; - static constexpr type value = 1e-2; -}; - -template -struct RelaxedLinearSolverReduction -{ - using type = GetPropType; - static constexpr type value = 1e-2; -}; - -template -struct LinearSolverMaxIter -{ static constexpr int value = 200; }; - -template -struct LinearSolverRestart -{ static constexpr int value = 40; }; - -template -struct IluRelaxation -{ - using type = GetPropType; - static constexpr type value = 0.9; -}; - -template -struct IluFillinLevel -{ static constexpr int value = 0; }; - -template -struct MiluVariant -{ static constexpr auto value = "ILU"; }; - -template -struct IluRedblack -{ static constexpr bool value = false; }; - -template -struct IluReorderSpheres -{ static constexpr bool value = false; }; - -template -struct UseGmres -{ static constexpr bool value = false; }; - -template -struct LinearSolverIgnoreConvergenceFailure -{ static constexpr bool value = false; }; - -template -struct ScaleLinearSystem -{ static constexpr bool value = false; }; - -template -struct LinearSolver -{ static constexpr auto value = "cprw"; }; - -template -struct LinearSolverPrintJsonDefinition -{ static constexpr auto value = true; }; - -template -struct CprReuseSetup -{ static constexpr int value = 4; }; - -template -struct CprReuseInterval -{ static constexpr int value = 30; }; - -template -struct AcceleratorMode -{ static constexpr auto value = "none"; }; - -template -struct BdaDeviceId -{ static constexpr int value = 0; }; - -template -struct OpenclPlatformId -{ static constexpr int value = 0; }; - -template -struct OpenclIluParallel -{ static constexpr bool value = true; }; // note: false should only be used in debug +struct LinearSolverReduction { static constexpr double value = 1e-2; }; +struct RelaxedLinearSolverReduction { static constexpr double value = 1e-2; }; +struct IluRelaxation { static constexpr double value = 0.9; }; +struct LinearSolverMaxIter { static constexpr int value = 200; }; +struct LinearSolverRestart { static constexpr int value = 40; }; +struct IluFillinLevel { static constexpr int value = 0; }; +struct MiluVariant { static constexpr auto value = "ILU"; }; +struct IluRedblack { static constexpr bool value = false; }; +struct IluReorderSpheres { static constexpr bool value = false; }; +struct UseGmres { static constexpr bool value = false; }; +struct LinearSolverIgnoreConvergenceFailure { static constexpr bool value = false; }; +struct ScaleLinearSystem { static constexpr bool value = false; }; +struct LinearSolver { static constexpr auto value = "cprw"; }; +struct LinearSolverPrintJsonDefinition { static constexpr auto value = true; }; +struct CprReuseSetup { static constexpr int value = 4; }; +struct CprReuseInterval { static constexpr int value = 30; }; +struct AcceleratorMode { static constexpr auto value = "none"; }; +struct BdaDeviceId { static constexpr int value = 0; }; +struct OpenclPlatformId { static constexpr int value = 0; }; +struct OpenclIluParallel { static constexpr bool value = true; }; // note: false should only be used in debug } // namespace Opm::Parameters @@ -241,109 +113,107 @@ struct FlowLinearSolverParameters int opencl_platform_id_; bool opencl_ilu_parallel_; - template void init(bool cprRequestedInDataFile) { // TODO: these parameters have undocumented non-trivial dependencies - linear_solver_reduction_ = Parameters::get(); - relaxed_linear_solver_reduction_ = Parameters::get(); - linear_solver_maxiter_ = Parameters::get(); - linear_solver_restart_ = Parameters::get(); + linear_solver_reduction_ = Parameters::Get(); + relaxed_linear_solver_reduction_ = Parameters::Get(); + linear_solver_maxiter_ = Parameters::Get(); + linear_solver_restart_ = Parameters::Get(); linear_solver_verbosity_ = Parameters::Get(); - ilu_relaxation_ = Parameters::get(); - ilu_fillin_level_ = Parameters::get(); - ilu_milu_ = convertString2Milu(Parameters::get()); - ilu_redblack_ = Parameters::get(); - ilu_reorder_sphere_ = Parameters::get(); - newton_use_gmres_ = Parameters::get(); - ignoreConvergenceFailure_ = Parameters::get(); - scale_linear_system_ = Parameters::get(); - linsolver_ = Parameters::get(); - linear_solver_print_json_definition_ = Parameters::get(); - cpr_reuse_setup_ = Parameters::get(); - cpr_reuse_interval_ = Parameters::get(); + ilu_relaxation_ = Parameters::Get(); + ilu_fillin_level_ = Parameters::Get(); + ilu_milu_ = convertString2Milu(Parameters::Get()); + ilu_redblack_ = Parameters::Get(); + ilu_reorder_sphere_ = Parameters::Get(); + newton_use_gmres_ = Parameters::Get(); + ignoreConvergenceFailure_ = Parameters::Get(); + scale_linear_system_ = Parameters::Get(); + linsolver_ = Parameters::Get(); + linear_solver_print_json_definition_ = Parameters::Get(); + cpr_reuse_setup_ = Parameters::Get(); + cpr_reuse_interval_ = Parameters::Get(); - if (!Parameters::isSet() && cprRequestedInDataFile) { + if (!Parameters::IsSet() && cprRequestedInDataFile) { linsolver_ = "cpr"; } else { - linsolver_ = Parameters::get(); + linsolver_ = Parameters::Get(); } - accelerator_mode_ = Parameters::get(); - bda_device_id_ = Parameters::get(); - opencl_platform_id_ = Parameters::get(); - opencl_ilu_parallel_ = Parameters::get(); + accelerator_mode_ = Parameters::Get(); + bda_device_id_ = Parameters::Get(); + opencl_platform_id_ = Parameters::Get(); + opencl_ilu_parallel_ = Parameters::Get(); } - template static void registerParameters() { - Parameters::registerParam + Parameters::Register ("The minimum reduction of the residual which the linear solver must achieve"); - Parameters::registerParam + Parameters::Register ("The minimum reduction of the residual which the linear solver need to " "achieve for the solution to be accepted"); - Parameters::registerParam + Parameters::Register ("The maximum number of iterations of the linear solver"); - Parameters::registerParam + Parameters::Register ("The number of iterations after which GMRES is restarted"); Parameters::Register ("The verbosity level of the linear solver (0: off, 2: all)"); - Parameters::registerParam + Parameters::Register ("The relaxation factor of the linear solver's ILU preconditioner"); - Parameters::registerParam + Parameters::Register ("The fill-in level of the linear solver's ILU preconditioner"); - Parameters::registerParam + Parameters::Register ("Specify which variant of the modified-ILU preconditioner ought to be used. " "Possible variants are: ILU (default, plain ILU), " "MILU_1 (lump diagonal with dropped row entries), " "MILU_2 (lump diagonal with the sum of the absolute values of the dropped row entries), " "MILU_3 (if diagonal is positive add sum of dropped row entries, otherwise subtract them), " "MILU_4 (if diagonal is positive add sum of dropped row entries, otherwise do nothing"); - Parameters::registerParam + Parameters::Register ("Use red-black partitioning for the ILU preconditioner"); - Parameters::registerParam + Parameters::Register ("Whether to reorder the entries of the matrix in the red-black " "ILU preconditioner in spheres starting at an edge. " "If false the original ordering is preserved in each color. " "Otherwise why try to ensure D4 ordering (in a 2D structured grid, " "the diagonal elements are consecutive)."); - Parameters::registerParam + Parameters::Register ("Use GMRES as the linear solver"); - Parameters::registerParam + Parameters::Register ("Continue with the simulation like nothing happened " "after the linear solver did not converge"); - Parameters::registerParam + Parameters::Register ("Scale linear system according to equation scale and primary variable types"); - Parameters::registerParam + Parameters::Register ("Configuration of solver. Valid options are: ilu0 (default), " "dilu, cprw, cpr (an alias for cprw), cpr_quasiimpes, " "cpr_trueimpes, cpr_trueimpesanalytic, amg or hybrid (experimental). " "Alternatively, you can request a configuration to be read from a " "JSON file by giving the filename here, ending with '.json.'"); - Parameters::registerParam + Parameters::Register ("Write the JSON definition of the linear solver setup to the DBG file."); - Parameters::registerParam + Parameters::Register ("Reuse preconditioner setup. Valid options are " "0: recreate the preconditioner for every linear solve, " "1: recreate once every timestep, " "2: recreate if last linear solve took more than 10 iterations, " "3: never recreate, " "4: recreated every CprReuseInterval"); - Parameters::registerParam + Parameters::Register ("Reuse preconditioner interval. Used when CprReuseSetup is set to 4, " "then the preconditioner will be fully recreated instead of reused " "every N linear solve, where N is this parameter."); - Parameters::registerParam + Parameters::Register ("Choose a linear solver, usage: " "'--accelerator-mode=[none|cusparse|opencl|amgcl|rocalution|rocsparse]'"); - Parameters::registerParam + Parameters::Register ("Choose device ID for cusparseSolver or openclSolver, " "use 'nvidia-smi' or 'clinfo' to determine valid IDs"); - Parameters::registerParam + Parameters::Register ("Choose platform ID for openclSolver, use 'clinfo' " "to determine valid platform IDs"); - Parameters::registerParam + Parameters::Register ("Parallelize ILU decomposition and application on GPU"); Parameters::SetDefault(0); diff --git a/opm/simulators/linalg/ISTLSolver.hpp b/opm/simulators/linalg/ISTLSolver.hpp index b65607267..cecf0aec2 100644 --- a/opm/simulators/linalg/ISTLSolver.hpp +++ b/opm/simulators/linalg/ISTLSolver.hpp @@ -170,7 +170,7 @@ std::unique_ptr blockJacobiAdjacency(const Grid& grid, static void registerParameters() { - FlowLinearSolverParameters::registerParameters(); + FlowLinearSolverParameters::registerParameters(); } /// Construct a system solver. @@ -203,7 +203,7 @@ std::unique_ptr blockJacobiAdjacency(const Grid& grid, matrix_(nullptr) { parameters_.resize(1); - parameters_[0].template init(simulator_.vanguard().eclState().getSimulationConfig().useCPR()); + parameters_[0].init(simulator_.vanguard().eclState().getSimulationConfig().useCPR()); initialize(); } @@ -220,21 +220,21 @@ std::unique_ptr blockJacobiAdjacency(const Grid& grid, parameters_.clear(); { FlowLinearSolverParameters para; - para.init(false); + para.init(false); para.linsolver_ = "cprw"; parameters_.push_back(para); prm_.push_back(setupPropertyTree(parameters_[0], - Parameters::isSet(), - Parameters::isSet())); + Parameters::IsSet(), + Parameters::IsSet())); } { FlowLinearSolverParameters para; - para.init(false); + para.init(false); para.linsolver_ = "ilu0"; parameters_.push_back(para); prm_.push_back(setupPropertyTree(parameters_[1], - Parameters::isSet(), - Parameters::isSet())); + Parameters::IsSet(), + Parameters::IsSet())); } // ------------ } else { @@ -242,8 +242,8 @@ std::unique_ptr blockJacobiAdjacency(const Grid& grid, assert(parameters_.size() == 1); assert(prm_.empty()); prm_.push_back(setupPropertyTree(parameters_[0], - Parameters::isSet(), - Parameters::isSet())); + Parameters::IsSet(), + Parameters::IsSet())); } flexibleSolver_.resize(prm_.size()); diff --git a/opm/simulators/linalg/ISTLSolverBda.hpp b/opm/simulators/linalg/ISTLSolverBda.hpp index 91691c75a..61cd95d06 100644 --- a/opm/simulators/linalg/ISTLSolverBda.hpp +++ b/opm/simulators/linalg/ISTLSolverBda.hpp @@ -152,7 +152,7 @@ public: { OPM_TIMEBLOCK(initializeBda); - std::string accelerator_mode = Parameters::get(); + std::string accelerator_mode = Parameters::Get(); // Force accelerator mode to none if using MPI. if ((this->simulator_.vanguard().grid().comm().size() > 1) && (accelerator_mode != "none")) { const bool on_io_rank = (this->simulator_.gridView().comm().rank() == 0); @@ -167,13 +167,13 @@ public: } // Initialize the BdaBridge - const int platformID = Parameters::get(); - const int deviceID = Parameters::get(); - const int maxit = Parameters::get(); - const double tolerance = Parameters::get(); - const bool opencl_ilu_parallel = Parameters::get(); + const int platformID = Parameters::Get(); + const int deviceID = Parameters::Get(); + const int maxit = Parameters::Get(); + const double tolerance = Parameters::Get(); + const bool opencl_ilu_parallel = Parameters::Get(); const int linear_solver_verbosity = this->parameters_[0].linear_solver_verbosity_; - std::string linsolver = Parameters::get(); + std::string linsolver = Parameters::Get(); bdaBridge_ = std::make_unique>(accelerator_mode, linear_solver_verbosity, maxit,