Merge pull request #5884 from akva2/damaris_param_tu

Damaris: move some more code to TU
This commit is contained in:
Bård Skaflestad 2025-01-15 10:45:54 +01:00 committed by GitHub
commit 95aa6599a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 51 additions and 50 deletions

View File

@ -163,7 +163,7 @@ public:
(simulator, this->eclIO_->finalSummaryConfig(), this->collectOnIORank_); (simulator, this->eclIO_->finalSummaryConfig(), this->collectOnIORank_);
} }
wanted_vars_set_ = Opm::DamarisOutput::getSetOfIncludedVariables<TypeTag>(); wanted_vars_set_ = DamarisOutput::getSetOfIncludedVariables();
} }
/*! /*!

View File

@ -286,7 +286,6 @@ void Main::setupVanguard()
#if HAVE_DAMARIS #if HAVE_DAMARIS
void Main::setupDamaris(const std::string& outputDir ) void Main::setupDamaris(const std::string& outputDir )
{ {
typedef Properties::TTag::FlowEarlyBird PreTypeTag;
if (!outputDir.empty()) { if (!outputDir.empty()) {
ensureOutputDirExists(outputDir); ensureOutputDirExists(outputDir);
} }
@ -294,7 +293,7 @@ void Main::setupDamaris(const std::string& outputDir )
//const auto find_replace_map; //const auto find_replace_map;
//const auto find_replace_map = Opm::DamarisOutput::DamarisKeywords<PreTypeTag>(EclGenericVanguard::comm(), outputDir); //const auto find_replace_map = Opm::DamarisOutput::DamarisKeywords<PreTypeTag>(EclGenericVanguard::comm(), outputDir);
std::map<std::string, std::string> find_replace_map; std::map<std::string, std::string> find_replace_map;
find_replace_map = Opm::DamarisOutput::getDamarisKeywords<PreTypeTag>(FlowGenericVanguard::comm(), outputDir); find_replace_map = DamarisOutput::getDamarisKeywords(FlowGenericVanguard::comm(), outputDir);
// By default EnableDamarisOutputCollective is true so all simulation results will // By default EnableDamarisOutputCollective is true so all simulation results will
// be written into one single file for each iteration using Parallel HDF5. // be written into one single file for each iteration using Parallel HDF5.

View File

@ -47,8 +47,7 @@
and defaults are set in opm/simulators/flow/FlowProblemProperties.hpp and defaults are set in opm/simulators/flow/FlowProblemProperties.hpp
*/ */
namespace Opm::DamarisOutput namespace Opm::DamarisOutput {
{
bool FileExists(const std::string& filename_in, bool FileExists(const std::string& filename_in,
const Parallel::Communication& comm) const Parallel::Communication& comm)
@ -258,4 +257,50 @@ DamarisSettings::getKeywords([[maybe_unused]] const Parallel::Communication& com
return damaris_keywords; return damaris_keywords;
} }
std::map<std::string, std::string>
getDamarisKeywords(const Parallel::Communication& comm, const std::string& OutputDir)
{
DamarisSettings settings;
// Get all of the Damaris keywords (except for --enable-damaris,
// 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<Parameters::DamarisOutputHdfCollective>();
settings.saveMeshToHDF5_ = Parameters::Get<Parameters::DamarisSaveMeshToHdf>();
settings.saveToDamarisHDF5_ = Parameters::Get<Parameters::DamarisSaveToHdf>();
settings.pythonFilename_ = Parameters::Get<Parameters::DamarisPythonScript>();
settings.paraviewPythonFilename_ = Parameters::Get<Parameters::DamarisPythonParaviewScript>();
settings.damarisSimName_ = Parameters::Get<Parameters::DamarisSimName>();
settings.nDamarisCores_ = Parameters::Get<Parameters::DamarisDedicatedCores>();
settings.nDamarisNodes_ = Parameters::Get<Parameters::DamarisDedicatedNodes>();
settings.shmemSizeBytes_ = Parameters::Get<Parameters::DamarisSharedMemorySizeBytes>();
settings.shmemName_ = Parameters::Get<Parameters::DamarisSharedMemoryName>();
settings.damarisLogLevel_ = Parameters::Get<Parameters::DamarisLogLevel>();
settings.damarisDaskFile_ = Parameters::Get<Parameters::DamarisDaskFile>();
return settings.getKeywords(comm, OutputDir);
}
std::unordered_set<std::string>
getSetOfIncludedVariables()
{
std::unordered_set<std::string> resuset ;
std::string tstr;
// The --damaris-limit-variables command line option (defaults to empty string)
std::string damarisLimitVars = Parameters::Get<Parameters::DamarisLimitVariables>();
std::stringstream ss(damarisLimitVars);
// Use while loop to check the getline() function condition.
while (std::getline(ss, tstr, ',')) {
//remove whitespace
std::string::iterator end_pos = std::remove(tstr.begin(), tstr.end(), ' ');
tstr.erase(end_pos, tstr.end());
// place in set (no duplicates possible in set and no empty string)
if (tstr != "") {
resuset.insert(tstr) ;
}
}
return resuset;
}
} // namespace Opm::DamarisOutput } // namespace Opm::DamarisOutput

View File

@ -88,53 +88,10 @@ struct DamarisSettings
* *
* N.B. This needs to be called before damaris_init() * N.B. This needs to be called before damaris_init()
*/ */
template<class TypeTag>
std::map<std::string, std::string> std::map<std::string, std::string>
getDamarisKeywords(const Parallel::Communication& comm, const std::string& OutputDir) getDamarisKeywords(const Parallel::Communication& comm, const std::string& OutputDir);
{
DamarisSettings settings;
// Get all of the Damaris keywords (except for --enable-damaris,
// 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<Parameters::DamarisOutputHdfCollective>();
settings.saveMeshToHDF5_ = Parameters::Get<Parameters::DamarisSaveMeshToHdf>();
settings.saveToDamarisHDF5_ = Parameters::Get<Parameters::DamarisSaveToHdf>();
settings.pythonFilename_ = Parameters::Get<Parameters::DamarisPythonScript>();
settings.paraviewPythonFilename_ = Parameters::Get<Parameters::DamarisPythonParaviewScript>();
settings.damarisSimName_ = Parameters::Get<Parameters::DamarisSimName>();
settings.nDamarisCores_ = Parameters::Get<Parameters::DamarisDedicatedCores>();
settings.nDamarisNodes_ = Parameters::Get<Parameters::DamarisDedicatedNodes>();
settings.shmemSizeBytes_ = Parameters::Get<Parameters::DamarisSharedMemorySizeBytes>();
settings.shmemName_ = Parameters::Get<Parameters::DamarisSharedMemoryName>();
settings.damarisLogLevel_ = Parameters::Get<Parameters::DamarisLogLevel>();
settings.damarisDaskFile_ = Parameters::Get<Parameters::DamarisDaskFile>();
return settings.getKeywords(comm, OutputDir); std::unordered_set<std::string> getSetOfIncludedVariables();
}
template<class TypeTag>
std::unordered_set<std::string>
getSetOfIncludedVariables(void)
{
std::unordered_set<std::string> resuset ;
std::string tstr;
// The --damaris-limit-variables command line option (defaults to empty string)
std::string damarisLimitVars = Parameters::Get<Parameters::DamarisLimitVariables>();
std::stringstream ss(damarisLimitVars);
// Use while loop to check the getline() function condition.
while (std::getline(ss, tstr, ',')) {
//remove whitespace
std::string::iterator end_pos = std::remove(tstr.begin(), tstr.end(), ' ');
tstr.erase(end_pos, tstr.end());
// place in set (no duplicates possible in set and no empty string)
if (tstr != "") {
resuset.insert(tstr) ;
}
}
return resuset;
}
} // namespace Opm::DamarisOutput } // namespace Opm::DamarisOutput