Merge pull request #5525 from akva2/typetag_free_params1

Move parameters to typetag-free parameter system
This commit is contained in:
Bård Skaflestad
2024-08-13 19:44:22 +02:00
committed by GitHub
15 changed files with 57 additions and 112 deletions

View File

@@ -122,20 +122,6 @@ struct LinearSolverBackend<TypeTag, TTag::FlowExpTypeTag> {
namespace Opm::Parameters {
// 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).
#if _OPENMP
template<class TypeTag>
struct ThreadsPerProcess<TypeTag, Properties::TTag::FlowExpTypeTag>
{ static constexpr int value = 2; };
#endif
// By default, flowexp accepts the result of the time integration unconditionally if the
// smallest time step size is reached.
template<class TypeTag>
struct ContinueOnConvergenceError<TypeTag, Properties::TTag::FlowExpTypeTag>
{ static constexpr bool value = true; };
template<class TypeTag>
struct EnableTerminalOutput<TypeTag, Properties::TTag::FlowExpTypeTag>
{ static constexpr bool value = false; };
@@ -230,6 +216,16 @@ public:
Parameters::hideParam<TypeTag, Parameters::UseUpdateStabilization>();
Parameters::hideParam<TypeTag, Parameters::MatrixAddWellContributions>();
Parameters::hideParam<TypeTag, Parameters::EnableTerminalOutput>();
// 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).
#if _OPENMP
Parameters::SetDefault<Parameters::ThreadsPerProcess>(2);
#endif
// By default, flowexp accepts the result of the time integration unconditionally if the
// smallest time step size is reached.
Parameters::SetDefault<Parameters::ContinueOnConvergenceError>(true);
}
// inherit the constructors

View File

@@ -77,10 +77,6 @@ struct Simulator<TypeTag, TTag::FlowExpProblemBlackOil>
namespace Opm::Parameters {
template<class TypeTag>
struct ContinueOnConvergenceError<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
{ static constexpr bool value = false; };
template<class TypeTag>
struct EclNewtonRelaxedTolerance<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
{
@@ -121,10 +117,6 @@ struct NewtonTolerance<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
static constexpr type value = 1e-2;
};
template<class TypeTag>
struct ThreadsPerProcess<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
{ static constexpr int value = 1; };
template<class TypeTag>
struct EclNewtonStrictIterations<TypeTag, Properties::TTag::FlowExpProblemBlackOil>
{ static constexpr int value = 100; };

View File

@@ -150,10 +150,6 @@ template<class TypeTag>
struct EnableDebuggingChecks<TypeTag, Properties::TTag::FlowProblem>
{ static constexpr bool value = false; };
template<class TypeTag>
struct OutputDir<TypeTag, Properties::TTag::FlowProblem>
{ static constexpr auto value = ""; };
}
namespace Opm {

View File

@@ -455,15 +455,6 @@ template<class TypeTag>
struct LocalDomainsOrderingMeasure<TypeTag, Properties::TTag::FlowModelParameters>
{ static constexpr auto value = "maxpressure"; };
// if openMP is available, determine the number threads per process automatically.
#if _OPENMP
template<class TypeTag>
struct ThreadsPerProcess<TypeTag, Properties::TTag::FlowModelParameters>
{
static constexpr int value = -1;
};
#endif
} // namespace Opm::Parameters
namespace Opm {
@@ -790,7 +781,13 @@ public:
Parameters::registerParam<TypeTag, Parameters::DebugEmitCellPartition>
("Whether or not to emit cell partitions as a debugging aid.");
Parameters::hideParam<TypeTag, Parameters::DebugEmitCellPartition>();
// if openMP is available, determine the number threads per process automatically.
#if _OPENMP
Parameters::SetDefault<Parameters::ThreadsPerProcess>(-1);
#endif
}
};

View File

@@ -551,7 +551,7 @@ protected:
{
asImp_().createGrids_();
asImp_().filterConnections_();
std::string outputDir = Parameters::get<TypeTag, Parameters::OutputDir>();
std::string outputDir = Parameters::Get<Parameters::OutputDir>();
bool enableEclCompatFile = !Parameters::get<TypeTag, Parameters::EnableOpmRstFile>();
asImp_().updateOutputDir_(outputDir, enableEclCompatFile);
const std::string& dryRunString = Parameters::get<TypeTag, Parameters::EnableDryRun>();

View File

@@ -107,6 +107,7 @@ namespace Opm {
("Developer option to see whether logging was on non-root processors. "
"In that case it will be appended to the *.DBG or *.PRT files");
ThreadManager<TypeTag>::registerParameters();
Simulator::registerParameters();
// register the base parameters
@@ -114,26 +115,26 @@ namespace Opm {
// hide the parameters unused by flow. TODO: this is a pain to maintain
Parameters::hideParam<TypeTag, Parameters::EnableGravity>();
Parameters::hideParam<TypeTag, Parameters::EnableGridAdaptation>();
Parameters::Hide<Parameters::EnableGridAdaptation>();
// this parameter is actually used in eWoms, but the flow well model
// hard-codes the assumption that the intensive quantities cache is enabled,
// so flow crashes. Let's hide the parameter for that reason.
Parameters::hideParam<TypeTag, Parameters::EnableIntensiveQuantityCache>();
Parameters::Hide<Parameters::EnableIntensiveQuantityCache>();
// thermodynamic hints are not implemented/required by the eWoms blackoil
// model
Parameters::hideParam<TypeTag, Parameters::EnableThermodynamicHints>();
Parameters::Hide<Parameters::EnableThermodynamicHints>();
// in flow only the deck file determines the end time of the simulation
Parameters::hideParam<TypeTag, Parameters::EndTime>();
Parameters::Hide<Parameters::EndTime<Scalar>>();
// time stepping is not done by the eWoms code in flow
Parameters::hideParam<TypeTag, Parameters::InitialTimeStepSize>();
Parameters::hideParam<TypeTag, Parameters::MaxTimeStepDivisions>();
Parameters::hideParam<TypeTag, Parameters::MaxTimeStepSize>();
Parameters::hideParam<TypeTag, Parameters::MinTimeStepSize>();
Parameters::hideParam<TypeTag, Parameters::PredeterminedTimeStepsFile>();
Parameters::Hide<Parameters::InitialTimeStepSize<Scalar>>();
Parameters::Hide<Parameters::MaxTimeStepDivisions>();
Parameters::Hide<Parameters::MaxTimeStepSize<Scalar>>();
Parameters::Hide<Parameters::MinTimeStepSize<Scalar>>();
Parameters::Hide<Parameters::PredeterminedTimeStepsFile>();
// flow also does not use the eWoms Newton method
Parameters::hideParam<TypeTag, Parameters::NewtonMaxError>();
@@ -143,7 +144,7 @@ namespace Opm {
Parameters::hideParam<TypeTag, Parameters::NewtonWriteConvergence>();
// the default eWoms checkpoint/restart mechanism does not work with flow
Parameters::hideParam<TypeTag, Parameters::RestartTime>();
Parameters::Hide<Parameters::RestartTime<Scalar>>();
Parameters::hideParam<TypeTag, Parameters::RestartWritingInterval>();
// hide all vtk related it is not currently possible to do this dependet on if the vtk writing is used
//if(not(Parameters::get<TypeTag,Properties::EnableVtkOutput>())){
@@ -226,7 +227,7 @@ namespace Opm {
}
// deal with --print-parameters and unknown parameters.
if (Parameters::get<TypeTag, Parameters::PrintParameters>() == 1) {
if (Parameters::Get<Parameters::PrintParameters>() == 1) {
if (mpiRank == 0) {
Parameters::printValues();
}
@@ -362,7 +363,7 @@ namespace Opm {
// Issue a warning if both OMP_NUM_THREADS and --threads-per-process are set,
// but let the environment variable take precedence.
constexpr int default_threads = 2;
const int requested_threads = Parameters::get<TypeTag, Parameters::ThreadsPerProcess>();
const int requested_threads = Parameters::Get<Parameters::ThreadsPerProcess>();
int threads = requested_threads > 0 ? requested_threads : default_threads;
const char* env_var = getenv("OMP_NUM_THREADS");

View File

@@ -247,6 +247,22 @@ public:
Parameters::registerParam<TypeTag, Parameters::ExplicitRockCompaction>
("Use pressure from end of the last time step when evaluating rock compaction");
Parameters::hideParam<TypeTag, Parameters::ExplicitRockCompaction>(); // 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
// after it simulated the last episode specified in the deck.)
Parameters::SetDefault<Parameters::EndTime<Scalar>>(1e100);
// The chosen value means that the size of the first time step is the
// one of the initial episode (if the length of the initial episode is
// not millions of trillions of years, that is...)
Parameters::SetDefault<Parameters::InitialTimeStepSize<Scalar>>(3600*24);
// Disable the VTK output by default for this problem ...
Parameters::SetDefault<Parameters::EnableVtkOutput>(false);
// the cache for intensive quantities can be used for ECL problems and also yields a
// decent speedup...
Parameters::SetDefault<Parameters::EnableIntensiveQuantityCache>(true);
// the cache for the storage term can also be used and also yields a decent speedup
Parameters::SetDefault<Parameters::EnableStorageCache>(true);
}
@@ -317,10 +333,10 @@ public:
enableDriftCompensation_ = Parameters::get<TypeTag, Parameters::EnableDriftCompensation>();
enableEclOutput_ = Parameters::get<TypeTag, Parameters::EnableEclOutput>();
enableVtkOutput_ = Parameters::get<TypeTag, Parameters::EnableVtkOutput>();
enableVtkOutput_ = Parameters::Get<Parameters::EnableVtkOutput>();
this->enableTuning_ = Parameters::get<TypeTag, Parameters::EnableTuning>();
this->initialTimeStepSize_ = Parameters::get<TypeTag, Parameters::InitialTimeStepSize>();
this->initialTimeStepSize_ = Parameters::Get<Parameters::InitialTimeStepSize<Scalar>>();
this->maxTimeStepAfterWellEvent_ = Parameters::get<TypeTag, Parameters::TimeStepAfterEventInDays>() * 24 * 60 * 60;
// The value N for this parameter is defined in the following order of presedence:

View File

@@ -388,56 +388,16 @@ template<class TypeTag>
struct EnableGravity<TypeTag, Properties::TTag::FlowBaseProblem>
{ static constexpr bool value = true; };
// the cache for intensive quantities can be used for ECL problems and also yields a
// decent speedup...
template<class TypeTag>
struct EnableIntensiveQuantityCache<TypeTag, Properties::TTag::FlowBaseProblem>
{ static constexpr bool value = true; };
// the cache for the storage term can also be used and also yields a decent speedup
template<class TypeTag>
struct EnableStorageCache<TypeTag, Properties::TTag::FlowBaseProblem>
{ static constexpr bool value = true; };
// Disable the VTK output by default for this problem ...
template<class TypeTag>
struct EnableVtkOutput<TypeTag, Properties::TTag::FlowBaseProblem>
{ static constexpr bool value = false; };
// only write the solutions for the report steps to disk
template<class TypeTag>
struct EnableWriteAllSolutions<TypeTag, Properties::TTag::FlowBaseProblem>
{ static constexpr bool value = false; };
// The default for the end time of the simulation [s]
//
// By default, stop it after the universe will probably have stopped
// to exist. (the ECL problem will finish the simulation explicitly
// after it simulated the last episode specified in the deck.)
template<class TypeTag>
struct EndTime<TypeTag, Properties::TTag::FlowBaseProblem>
{
using type = GetPropType<TypeTag, Properties::Scalar>;
static constexpr type value = 1e100;
};
// By default, use implicit pressure in rock compaction
template<class TypeTag>
struct ExplicitRockCompaction<TypeTag, Properties::TTag::FlowBaseProblem>
{ static constexpr bool value = false; };
// The default for the initial time step size of the simulation [s].
//
// The chosen value means that the size of the first time step is the
// one of the initial episode (if the length of the initial episode is
// not millions of trillions of years, that is...)
template<class TypeTag>
struct InitialTimeStepSize<TypeTag, Properties::TTag::FlowBaseProblem>
{
using type = GetPropType<TypeTag, Properties::Scalar>;
static constexpr type value = 3600*24;
};
// the default for the allowed volumetric error for oil per second
template<class TypeTag>
struct NewtonTolerance<TypeTag, Properties::TTag::FlowBaseProblem>
@@ -451,11 +411,6 @@ template<class TypeTag>
struct NumPressurePointsEquil<TypeTag, Properties::TTag::FlowBaseProblem>
{ static constexpr int value = ParserKeywords::EQLDIMS::DEPTH_NODES_P::defaultValue; };
// The default location for the ECL output files
template<class TypeTag>
struct OutputDir<TypeTag, Properties::TTag::FlowBaseProblem>
{ static constexpr auto value = "."; };
template<class TypeTag>
struct OutputMode<TypeTag, Properties::TTag::FlowBaseProblem>
{ static constexpr auto value = "all"; };

View File

@@ -338,7 +338,7 @@ private:
}
else {
deckFilename = Parameters::get<PreTypeTag, Parameters::EclDeckFileName>();
outputDir = Parameters::get<PreTypeTag, Parameters::OutputDir>();
outputDir = Parameters::Get<Parameters::OutputDir>();
}
#if HAVE_DAMARIS
@@ -717,7 +717,7 @@ private:
// Hence we duplicate the code of setupParallelism to get the number of threads.
static bool first_time = true;
constexpr int default_threads = 2;
const int requested_threads = Parameters::get<TypeTag, Parameters::ThreadsPerProcess>();
const int requested_threads = Parameters::Get<Parameters::ThreadsPerProcess>();
threads = requested_threads > 0 ? requested_threads : default_threads;
const char* env_var = getenv("OMP_NUM_THREADS");

View File

@@ -126,8 +126,9 @@ namespace Opm {
*/
void processElement(const ElementContext& elemCtx)
{
if (!Parameters::get<TypeTag, Parameters::EnableVtkOutput>())
if (!Parameters::Get<Parameters::EnableVtkOutput>()) {
return;
}
if (eclTracerConcentrationOutput_()) {
const auto& tracerModel = elemCtx.problem().tracerModel();

View File

@@ -127,20 +127,6 @@ template<class TypeTag>
struct UseMultisegmentWell<TypeTag, Properties::TTag::TestTypeTag>
{ static constexpr bool value = false; };
// 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).
#if _OPENMP
template<class TypeTag>
struct ThreadsPerProcess<TypeTag, Properties::TTag::TestTypeTag>
{ static constexpr int value = 2; };
#endif
// By default, ebos accepts the result of the time integration unconditionally if the
// smallest time step size is reached.
template<class TypeTag>
struct ContinueOnConvergenceError<TypeTag, Properties::TTag::TestTypeTag>
{ static constexpr bool value = true; };
} // namespace Opm::Parameters
#endif // OPM_TEST_TYPETAG_HPP

View File

@@ -511,6 +511,7 @@ struct AquiferFixture {
"test_RestartSerialization",
"--ecl-deck-file-name=GLIFT1.DATA"
};
Opm::ThreadManager<TT>::registerParameters();
AdaptiveTimeStepping<TT>::registerParameters();
BlackoilModelParameters<TT>::registerParameters();
Parameters::registerParam<TT, Parameters::EnableTerminalOutput>("Do *NOT* use!");

View File

@@ -239,6 +239,7 @@ struct EquilFixture {
#endif
using namespace Opm;
FlowGenericVanguard::setCommunication(std::make_unique<Opm::Parallel::Communication>());
Opm::ThreadManager<TypeTag>::registerParameters();
BlackoilModelParameters<TypeTag>::registerParameters();
AdaptiveTimeStepping<TypeTag>::registerParameters();
Parameters::registerParam<TypeTag,

View File

@@ -90,6 +90,7 @@ initSimulator(const char *filename)
registerEclTimeSteppingParameters<TypeTag>();
BlackoilModelParameters<TypeTag>::registerParameters();
Parameters::registerParam<TypeTag, Parameters::EnableTerminalOutput>("Do *NOT* use!");
Opm::Parameters::SetDefault<Opm::Parameters::ThreadsPerProcess>(2);
Parameters::endRegistration();
setupParameters_<TypeTag>(/*argc=*/sizeof(argv) / sizeof(argv[0]),
argv, /*registerParams=*/false);

View File

@@ -116,6 +116,7 @@ BOOST_FIXTURE_TEST_CASE(WithOutputDir, Fixture)
Opm::Parameters::reset();
Opm::ThreadManager<int>::registerParameters();
Opm::Main main(3, const_cast<char**>(no_param), false);
BOOST_CHECK_EQUAL(main.justInitialize(), EXIT_SUCCESS);
@@ -153,6 +154,7 @@ BOOST_FIXTURE_TEST_CASE(NoOutputDir, Fixture)
const char* no_param[] = {"test_outputdir", input_file_path.c_str(), nullptr};
Opm::Parameters::reset();
Opm::ThreadManager<int>::registerParameters();
Opm::Main main(2, const_cast<char**>(no_param), false);