My Project
Loading...
Searching...
No Matches
DamarisVar.hpp
1/*
2 Copyright 2023 Inria, Bretagne–Atlantique Research Center
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 DAMARISVAR_HPP
21#define DAMARISVAR_HPP
22
23#include <cstddef>
24#include <string>
25#include <vector>
26
27/*
28 File: DamarisVar.hpp
29 Author: Joshua Bowden, Inria
30 Date: 06/02/2023
31 The DamarisVar class can be used to allocate memory in the Damaris shared
32 memory region and a user can supply the data required for the variable via the data_ptr_
33 or data() method. The data will then be directly available on the Damaris server side
34 (server cores) plugin code. The templated type used should match the one specified
35 in the Damaris XML file for the variable name, if not an error is raised.
36*/
37
38namespace Opm
39{
40namespace DamarisOutput
41{
48 {
49 std::string layout_;
52 std::string mesh_;
55 std::string type_;
58 std::string visualizable_;
60 std::string unit_;
62 std::string time_varying_;
64 std::string centering_;
66 std::string store_;
68 std::string script_;
70 std::string select_mem_;
74 std::string select_file_;
78 std::string select_subset_;
82
83 public:
88 std::string ReturnXMLForVariable();
89 };
90
99 template <typename T>
101 {
102 int num_params_;
104 std::vector<int> param_sizes_;
106 std::vector<int64_t> positions_;
108 bool parameters_set_;
111 std::vector<std::string> param_names_;
113 std::string variable_name_;
115 int rank_;
116 int dam_err_;
118 bool has_error_;
119 std::string dam_err_str_;
120 DamarisVarXMLAttributes xml_attributes_;
124 T* data_ptr_;
127 std::size_t current_size_;
134
135 public:
187 DamarisVar(int dims,
188 const std::vector<std::string>& param_names,
189 const std::string& variable_name,
190 int rank);
191
222 DamarisVar(int dims,
223 const std::vector<std::string>& param_names,
224 const std::vector<int>& param_values,
225 const std::string& variable_name,
226 int rank);
227
228 ~DamarisVar();
229
238 {
239 parameters_set_ = true;
240 }
241
242 void printError() const;
243
244 bool hasError() const
245 {
246 return has_error_;
247 }
248
253 T* data()
254 {
255 if (parameters_set_ == true) {
256 return data_ptr_; // This still could be nullptr
257 } else {
258 return nullptr;
259 }
260 }
261
262 const std::string& variable_name() const
263 {
264 return variable_name_;
265 }
266
270 std::string returnXMLForVariable();
271
281 void setDamarisParameterAndShmem(const std::vector<int>& paramSizeVal)
282 {
283 this->setDamarisParameter(paramSizeVal);
285 }
286
291 std::size_t size()
292 {
293 if (parameters_set_ == true) {
294 return current_size_;
295 } else {
296 return 0;
297 }
298 }
299
311 void setDamarisParameter(const std::vector<int>& paramSizeVal);
312
323 void setDamarisPosition(const std::vector<int64_t>& positionsVals);
324
334
343
353
354 private:
359 bool TestType(const std::string& variable_name);
360
361 void formatTypeError(const std::string& var_name,
362 const std::string& type_name1,
363 const std::string& type_name2);
364 }; // class DamarisVar
365
366} // namespace DamarisOutput
367
368} // namespace Opm
369
370#endif
This class contains the extra elements that need to be part of a Damaris <variable> type.
Definition DamarisVar.hpp:48
std::string ReturnXMLForVariable()
Creates the XML representation of the variable from the available strings.
Definition DamarisVar.cpp:45
class to store a Damaris variable representation for the XML file (can be used with class DamarisKeyw...
Definition DamarisVar.hpp:101
std::size_t size()
Returns the number of elements in the memory area.
Definition DamarisVar.hpp:291
std::string returnXMLForVariable()
Creates the XML representation of the variable from the available strings.
Definition DamarisVar.cpp:141
T * data()
Returns the data pointer to shared memory, or nullptr if it has not been allocated.
Definition DamarisVar.hpp:253
void parameterIsSet()
Allow a user to indicate that the Damaris variable has allocated a size - This method is usefull as a...
Definition DamarisVar.hpp:237
void clearVariableDamarisShmem()
Method to release the memory of the data written to the Damaris variable - Indicates that Damaris may...
Definition DamarisVar.cpp:248
void setDamarisPosition(const std::vector< int64_t > &positionsVals)
Method to set the Damaris position values.
Definition DamarisVar.cpp:188
void commitVariableDamarisShmem()
Method to commit the memory of the data written to the Damaris variable - Indicates that we will not ...
Definition DamarisVar.cpp:235
void setDamarisParameterAndShmem(const std::vector< int > &paramSizeVal)
Method to set the Damaris paramater values and set the shmem region data_ptr_.
Definition DamarisVar.hpp:281
void setDamarisParameter(const std::vector< int > &paramSizeVal)
Method to set the Damaris paramater values.
Definition DamarisVar.cpp:148
void setPointersToDamarisShmem()
Method to set the internal pointer (data_ptr_) to the Damaris shared memory area.
Definition DamarisVar.cpp:209
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242