Opm::DamarisOutput::DamarisVar< T > Class Template Reference

#include <DamarisVar.hpp>

Public Member Functions

 DamarisVar (int dims, const std::vector< std::string > &param_names, const std::string &variable_name, int rank)
 
 DamarisVar (int dims, const std::vector< std::string > &param_names, const std::vector< int > &param_values, const std::string &variable_name, int rank)
 
 ~DamarisVar ()
 
void parameterIsSet ()
 
void printError () const
 
bool hasError () const
 
T * data ()
 
const std::string & variable_name () const
 
std::string returnXMLForVariable ()
 
void setDamarisParameterAndShmem (const std::vector< int > &paramSizeVal)
 
std::size_t size ()
 
void setDamarisParameter (const std::vector< int > &paramSizeVal)
 
void setDamarisPosition (const std::vector< int64_t > &positionsVals)
 
void setPointersToDamarisShmem ()
 
void commitVariableDamarisShmem ()
 
void clearVariableDamarisShmem ()
 

Detailed Description

template<typename T>
class Opm::DamarisOutput::DamarisVar< T >

class to store a Damaris variable representation for the XML file (can be used with class DamarisKeywords).

It is thought that the details stored in the object can be used to pass into an XML generation function e.g. DamarisKeywords

Constructor & Destructor Documentation

◆ DamarisVar() [1/2]

template<typename T >
Opm::DamarisOutput::DamarisVar< T >::DamarisVar ( int  dims,
const std::vector< std::string > &  param_names,
const std::string &  variable_name,
int  rank 
)

Constructor - sets private data values and dos not initialise the shared memory area.

N.B. These objects need a matching <variable ...> and <paramater ...> entries in the Damaris XML file

Two usages: Example XML definition: <parameter name="my_param_name1" type="int" value="1" > <parameter name="my_param_name2" type="int" value="1" > <layout name="my_layout" type="int" dimensions="my_param_name1,my_param_name2" > <variable name="MYVARNAME" layout="my_layout" visualizable="true">

1/ The variable's layout needs to be initialised via parameters : // Create the DamarisVar object: damaris::model::DamarisVar<int> MYVARNAME_2d(2,{std::string("my_param_name1"), std::string("my_param_name2")}, {100, 25}, std::string("MYVARNAME"), rank_); // sets the paramater sizes (so, here, my_param_name1 == 25 and my_param_name2 == 100) MYVARNAME_2d.SetDamarisParameterAndShmem( {25, 100 } }; // Get a pointer to the memeory and use it T * mymemory = MYVARNAME_2d.data(); ... write data to mymemory .... // Damaris shared memory is tidied up when object MYVARNAME_2d is out of scope. or, 2/ The variable's layout has been initialised via parameters in another variable (i.e. "my_param_name1" and "my_param_name2" have been previously set in the code) // Create the DamarisVar object: damaris::model::DamarisVar<int> MYVARNAME_2d(2, {std::string("my_param_name1"), std::string("my_param_name2")}, std::string("MYVARNAME"), rank_);

// explicitly state that the paramater values have been set somewhere else in the code previously. MYVARNAME_2d.ParameterIsSet();

N.B. This will not set the internal current_size_ value so the size() value will not be correct <- This is important to remember

MYVARNAME_2d.SetPointersToDamarisShmem() // Get a pointer to the memeory and use it T * mymemory = MYVARNAME_2d.data(); ... write data to mymemory .... // Damaris shared memory is tidied up when object MYVARNAME_2d is out of scope.

/param [IN] dims Used to check that the inputs to SetDamarisPosition() have the same number of values - one value for each dimension /param [IN] param_names The name the Damaris paramaters. These names (in typical use) control a Damaris variables size (names are defined in the Damaris XML file). /param [IN] variable_name The name of the Damaris variable (defined in the Damaris XML file) /param [IN] rank The rank of the process. Used for error output.

◆ DamarisVar() [2/2]

template<typename T >
Opm::DamarisOutput::DamarisVar< T >::DamarisVar ( int  dims,
const std::vector< std::string > &  param_names,
const std::vector< int > &  param_values,
const std::string &  variable_name,
int  rank 
)

Constructor - Sets private data values and also initialises the Damaris shared memory area for writing (and reading) by specifying the values for the variables parameters . i.e. makes the data() pointer available and sets the size of the memory block it points to.

N.B. These objects need a matching <variable ...> and <paramater ...> entries in the Damaris XML file

Example use: Example XML definition: <parameter name="my_param_name1" type="int" value="1" > <parameter name="my_param_name2" type="int" value="1" > <layout name="my_layout" type="int" dimensions="my_param_name1,my_param_name2" comment="This is a 2D variable" > <variable name="MYVARNAME" layout="my_layout" visualizable="true"> // The paramaters are intialized in the constructor code damaris::model::DamarisVar<int> MYVARNAME_2d(2,{std::string("my_param_name1"), std::string("my_param_name2")}, {100, 25}, std::string("MYVARNAME"), rank_); T * mymemory = MYVARNAME_2d.data(); ... write data to mymemory .... // Damaris shared memory is tidied up when object MYVARNAME_2d is out of scope.

/param [IN] dims Used to check that the inputs to SetDamarisPosition() have the same number of values - one value for each dimension /param [IN] param_names The name the Damaris paramaters. These names (in typical use) control a Damaris variables size (names are defined in the Damaris XML file). /param [IN] param_values The values of the paramaters - this defines how much memory we will have access to in the shared memory area (on the current and ongoing iterations, until later modified to new values) /param [IN] variable_name The name of the Damaris variable (defined in the Damaris XML file) /param [IN] rank The rank of the process. Used for error output.

◆ ~DamarisVar()

template<typename T >
Opm::DamarisOutput::DamarisVar< T >::~DamarisVar ( )

Member Function Documentation

◆ clearVariableDamarisShmem()

template<typename T >
void Opm::DamarisOutput::DamarisVar< T >::clearVariableDamarisShmem ( )

Method to release the memory of the data written to the Damaris variable - Indicates that Damaris may take control of the shared memory area that was used for the variable data_ptr_

/implicit : Implicitly uses the variable name string variable_name_

◆ commitVariableDamarisShmem()

template<typename T >
void Opm::DamarisOutput::DamarisVar< T >::commitVariableDamarisShmem ( )

Method to commit the memory of the data written to the Damaris variable - Indicates that we will not write any more data to data_ptr_

/implicit : Implicitly uses the variable name string variable_name_

◆ data()

template<typename T >
T * Opm::DamarisOutput::DamarisVar< T >::data ( )
inline

Returns the data pointer to shared memory, or nullptr if it has not been allocated

◆ hasError()

template<typename T >
bool Opm::DamarisOutput::DamarisVar< T >::hasError ( ) const
inline

◆ parameterIsSet()

template<typename T >
void Opm::DamarisOutput::DamarisVar< T >::parameterIsSet ( )
inline

Allow a user to indicate that the Damaris variable has allocated a size - This method is usefull as a single parameter can control one or more layouts and a single layout can describe the size of multiple <variable> elements. i.e. Use when the current variable has had it's paramater(s) set through via another variable.

◆ printError()

template<typename T >
void Opm::DamarisOutput::DamarisVar< T >::printError ( ) const

◆ returnXMLForVariable()

template<typename T >
std::string Opm::DamarisOutput::DamarisVar< T >::returnXMLForVariable ( )

Creates the XML representation of the variable from the available strings

◆ setDamarisParameter()

template<typename T >
void Opm::DamarisOutput::DamarisVar< T >::setDamarisParameter ( const std::vector< int > &  paramSizeVal)

Method to set the Damaris paramater values. Also calculates the total number of elements in the variable (current_size_) that is returned bt size() method.

/param [IN] paramSizeVal : An pointer to a value or array of values to set. One element per param_names_ string

/implicit : Implicitly uses the array of paramater names: param_names_

Referenced by Opm::DamarisOutput::DamarisVar< T >::setDamarisParameterAndShmem().

◆ setDamarisParameterAndShmem()

template<typename T >
void Opm::DamarisOutput::DamarisVar< T >::setDamarisParameterAndShmem ( const std::vector< int > &  paramSizeVal)
inline

Method to set the Damaris paramater values and set the shmem region data_ptr_

/param [IN] paramSizeVal : A vector of values to set the Damaris paramters to. One element per param_names_ string

References Opm::DamarisOutput::DamarisVar< T >::setDamarisParameter(), and Opm::DamarisOutput::DamarisVar< T >::setPointersToDamarisShmem().

◆ setDamarisPosition()

template<typename T >
void Opm::DamarisOutput::DamarisVar< T >::setDamarisPosition ( const std::vector< int64_t > &  positionsVals)

Method to set the Damaris position values.

/param [IN] positionsVals : An pointer to a value or array of values to set as the offset into the array. One element per dimension (one value for each dim_)

/implicit : Implicitly uses the variable name: variable_name_

◆ setPointersToDamarisShmem()

template<typename T >
void Opm::DamarisOutput::DamarisVar< T >::setPointersToDamarisShmem ( )

Method to set the internal pointer (data_ptr_) to the Damaris shared memory area.

/implicit : Implicitly uses the Damaris variable name string variable_name_ /implicit : Implicitly uses the class data element : data_ptr_

Referenced by Opm::DamarisOutput::DamarisVar< T >::setDamarisParameterAndShmem().

◆ size()

template<typename T >
std::size_t Opm::DamarisOutput::DamarisVar< T >::size ( )
inline

Returns the number of elements in the memory area. Used as a method for compatibility with std::vector

◆ variable_name()

template<typename T >
const std::string & Opm::DamarisOutput::DamarisVar< T >::variable_name ( ) const
inline

The documentation for this class was generated from the following file: