From 9141f2c2d58863c8ab57ccb186bbbf6b491e56e1 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sat, 6 Jul 2024 10:22:47 +0200 Subject: [PATCH] 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.