DamarisKeywords.hpp
Go to the documentation of this file.
1/*
2 Copyright 2021 Equinor.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef OPM_DAMARISKEYWORDS_HEADER_INCLUDED
21#define OPM_DAMARISKEYWORDS_HEADER_INCLUDED
22
24
27
28#include <map>
29#include <string>
30#include <sstream>
31#include <algorithm>
32#include <unordered_set>
33
34/*
35 Below is the std::map with the keywords that are supported by Damaris.
36
37 Most entries in the map below are not critical ('static') and will not
38 be changed. We only allow changing FileMode together with output directory
39*/
40
41namespace Opm::DamarisOutput {
42
50bool FileExists(const std::string& filename_in,
51 const Parallel::Communication& comm);
52
54{
56 bool saveToDamarisHDF5_ = true;
57 // if saveMeshToDamarisHDF5 is true, requires enableDamarisOutputCollective to be false
58 // (until offsets are are added to mesh data for collective writing)
59 bool saveMeshToHDF5_ = false;
60 std::string pythonFilename_;
62
63 std::string damarisSimName_; // empty and set to "opm-flow-<random-number>" if none provided on command line. Used as prefix to HDF5 filenames
64 std::string shmemName_; // empty and needs to be unique if multiple simulations are running on the same server/node. Used to name the Damaris shared memory region.
65 std::string damarisLogLevel_ = "info";
66 std::string damarisDaskFile_ = "";
67 // std::string damarisLimitVars_ = "";
68 int nDamarisCores_ = 1; // this is the number of (Damaris server) cores per node
70 long shmemSizeBytes_ = 536870912; // 512 MB
71
72 std::string rand_value_str_ ; // to be added to sheared memory name to make unique
73
74 std::map<std::string, std::string>
76 const std::string& OutputDir);
77
78 void SetRandString(void); // sets the value of rand_value_str_
79};
80
91template<class TypeTag>
92std::map<std::string, std::string>
93getDamarisKeywords(const Parallel::Communication& comm, const std::string& OutputDir)
94{
95 DamarisSettings settings;
96 // Get all of the Damaris keywords (except for --enable-damaris,
97 // which is used in simulators/flow/Main.hpp)
98 // These command line arguments are defined in opm/simulators/flow/DamarisWriter.hpp and
99 // defaults are set in opm/simulators/flow/FlowProblemProperties.hpp
100 settings.enableDamarisOutputCollective_ = Parameters::Get<Parameters::DamarisOutputHdfCollective>();
101 settings.saveMeshToHDF5_ = Parameters::Get<Parameters::DamarisSaveMeshToHdf>();
102 settings.saveToDamarisHDF5_ = Parameters::Get<Parameters::DamarisSaveToHdf>();
103 settings.pythonFilename_ = Parameters::Get<Parameters::DamarisPythonScript>();
104 settings.paraviewPythonFilename_ = Parameters::Get<Parameters::DamarisPythonParaviewScript>();
105 settings.damarisSimName_ = Parameters::Get<Parameters::DamarisSimName>();
106 settings.nDamarisCores_ = Parameters::Get<Parameters::DamarisDedicatedCores>();
107 settings.nDamarisNodes_ = Parameters::Get<Parameters::DamarisDedicatedNodes>();
108 settings.shmemSizeBytes_ = Parameters::Get<Parameters::DamarisSharedMemorySizeBytes>();
109 settings.shmemName_ = Parameters::Get<Parameters::DamarisSharedMemoryName>();
110 settings.damarisLogLevel_ = Parameters::Get<Parameters::DamarisLogLevel>();
111 settings.damarisDaskFile_ = Parameters::Get<Parameters::DamarisDaskFile>();
112
113 return settings.getKeywords(comm, OutputDir);
114}
115
116template<class TypeTag>
117std::unordered_set<std::string>
119{
120 std::unordered_set<std::string> resuset ;
121 std::string tstr;
122 // The --damaris-limit-variables command line option (defaults to empty string)
123 std::string damarisLimitVars = Parameters::Get<Parameters::DamarisLimitVariables>();
124 std::stringstream ss(damarisLimitVars);
125
126 // Use while loop to check the getline() function condition.
127 while (std::getline(ss, tstr, ',')) {
128 //remove whitespace
129 std::string::iterator end_pos = std::remove(tstr.begin(), tstr.end(), ' ');
130 tstr.erase(end_pos, tstr.end());
131 // place in set (no duplicates possible in set and no empty string)
132 if (tstr != "") {
133 resuset.insert(tstr) ;
134 }
135 }
136 return resuset;
137}
138
139} // namespace Opm::DamarisOutput
140
141
142#endif
Definition: DamarisWriter.hpp:60
std::map< std::string, std::string > getDamarisKeywords(const Parallel::Communication &comm, const std::string &OutputDir)
Definition: DamarisKeywords.hpp:93
bool FileExists(const std::string &filename_in, const Parallel::Communication &comm)
std::unordered_set< std::string > getSetOfIncludedVariables(void)
Definition: DamarisKeywords.hpp:118
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
This file provides the infrastructure to retrieve run-time parameters.
Definition: DamarisKeywords.hpp:54
bool saveMeshToHDF5_
Definition: DamarisKeywords.hpp:59
std::string paraviewPythonFilename_
Definition: DamarisKeywords.hpp:61
std::string shmemName_
Definition: DamarisKeywords.hpp:64
long shmemSizeBytes_
Definition: DamarisKeywords.hpp:70
std::string rand_value_str_
Definition: DamarisKeywords.hpp:72
int nDamarisNodes_
Definition: DamarisKeywords.hpp:69
std::string damarisSimName_
Definition: DamarisKeywords.hpp:63
std::string damarisDaskFile_
Definition: DamarisKeywords.hpp:66
std::map< std::string, std::string > getKeywords(const Parallel::Communication &comm, const std::string &OutputDir)
std::string pythonFilename_
Definition: DamarisKeywords.hpp:60
bool enableDamarisOutputCollective_
Definition: DamarisKeywords.hpp:55
int nDamarisCores_
Definition: DamarisKeywords.hpp:68
std::string damarisLogLevel_
Definition: DamarisKeywords.hpp:65
bool saveToDamarisHDF5_
Definition: DamarisKeywords.hpp:56