KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
List of all members
Kratos::Variable< TDataType > Class Template Reference

Variable class contains all information needed to store and retrive data from a data container. More...

#include <variable.h>

Inheritance diagram for Kratos::Variable< TDataType >:
Collaboration diagram for Kratos::Variable< TDataType >:

Public Member Functions

Life Cycle
 Variable (const std::string &NewName, const TDataType Zero=TDataType(), const VariableType *pTimeDerivativeVariable=nullptr)
 Constructor with specific name and zero value. More...
 
 Variable (const std::string &NewName, const VariableType *pTimeDerivativeVariable)
 Constructor with specific name and zero value. More...
 
template<typename TSourceVariableType >
 Variable (const std::string &rNewName, TSourceVariableType *pSourceVariable, char ComponentIndex, const TDataType Zero=TDataType())
 Constructor for creating a component of other variable. More...
 
template<typename TSourceVariableType >
 Variable (const std::string &rNewName, TSourceVariableType *pSourceVariable, char ComponentIndex, const VariableType *pTimeDerivativeVariable, const TDataType Zero=TDataType())
 Constructor for creating a component of other variable. More...
 
 Variable (const VariableType &rOtherVariable)
 Copy constructor. More...
 
 ~Variable () override
 Destructor. More...
 
Operators
VariableTypeoperator= (const VariableType &rOtherVariable)=delete
 Assignment operator, deleted to avoid misuse which can lead to memory problems. More...
 
Access
const VariableTypeGetTimeDerivative () const
 This method returns the time derivative variable. More...
 
const TDataType & Zero () const
 This method returns the zero value of the variable type. More...
 
const void * pZero () const override
 
Input and output
std::string Info () const override
 
void PrintInfo (std::ostream &rOStream) const override
 
void PrintData (std::ostream &rOStream) const override
 Print object's data. More...
 
- Public Member Functions inherited from Kratos::VariableData
 VariableData (const VariableData &rOtherVariable)
 Copy constructor. More...
 
virtual ~VariableData ()
 Destructor. More...
 
 operator size_t () const
 
KeyType HashKey () const
 
KeyType Key () const
 
KeyType SourceKey () const
 
void SetKey (KeyType NewKey)
 
const std::string & Name () const
 
std::size_t Size () const
 
bool IsComponent () const
 
bool IsNotComponent () const
 
KeyType GetComponentIndex () const
 Returns the component index. More...
 
const VariableDataGetSourceVariable () const
 
 KRATOS_CLASS_POINTER_DEFINITION (VariableData)
 Pointer definition of VariableData. More...
 

Type Definitions

typedef TDataType Type
 type of this variable More...
 
typedef VariableData::KeyType KeyType
 
typedef Variable< TDataType > VariableType
 
 KRATOS_CLASS_POINTER_DEFINITION (Variable)
 Pointer definition of Variable. More...
 

Serialization

class Serializer
 

Operations

void * Clone (const void *pSource) const override
 Clone creates a copy of the object using a copy constructor of the class. More...
 
void * Copy (const void *pSource, void *pDestination) const override
 Copy is very similar to Clone except that it also the destination pointer also passed to it. More...
 
void Assign (const void *pSource, void *pDestination) const override
 Assign is very similar to Copy. It just differs in using an assignment operator besides the copy constructor. Copy creates a new object while. More...
 
void AssignZero (void *pDestination) const override
 AssignZero is a special case of Assign for which variable zero value used as source. More...
 
void Delete (void *pSource) const override
 Delete removes an object of variable type from memory. More...
 
void Destruct (void *pSource) const override
 Destruct eliminates an object maintaining the memory it is using. More...
 
void Print (const void *pSource, std::ostream &rOStream) const override
 Print is an auxiliary method to produce output of given variable knowing its address. More...
 
void PrintData (const void *pSource, std::ostream &rOStream) const override
 PrintData is an auxiliary method to produce output only the value of given variable knowing its address. More...
 
void Save (Serializer &rSerializer, void *pData) const override
 The save operation which backups the data of the class. More...
 
void Allocate (void **pData) const override
 This method allocates the data of the variable. More...
 
void Load (Serializer &rSerializer, void *pData) const override
 The load operation which restores the data of the class. More...
 
TDataType & GetValue (void *pSource) const
 
const TDataType & GetValue (const void *pSource) const
 
static const VariableTypeStaticObject ()
 This method returns the variable type. More...
 

Additional Inherited Members

- Public Types inherited from Kratos::VariableData
typedef std::size_t KeyType
 
- Static Public Member Functions inherited from Kratos::VariableData
static KeyType GenerateKey (const std::string &Name, std::size_t Size, bool IsComponent, char ComponentIndex)
 This static method generates a uinque key for given name and flags. More...
 
- Protected Member Functions inherited from Kratos::VariableData
VariableDataoperator= (const VariableData &rOtherVariable)
 
 VariableData (const std::string &NewName, std::size_t NewSize)
 Constructor for variables. More...
 
 VariableData (const std::string &NewName, std::size_t NewSize, const VariableData *pSourceVariable, char ComponentIndex)
 Constructor for variables components. More...
 
 VariableData ()
 

Detailed Description

template<class TDataType>
class Kratos::Variable< TDataType >

Variable class contains all information needed to store and retrive data from a data container.

Variable class contains all information needed to store and retrive data from a data container. It contains key value which is needed for searching in data container. Also a zero value to use as a default value in the container. Finally it has the type of the Variable as its template parameter so the container can find it in its relative part.

Template Parameters
TDataTypeThe data type hold by the variable
Author
Pooyan Dadvand

Member Typedef Documentation

◆ KeyType

template<class TDataType >
typedef VariableData::KeyType Kratos::Variable< TDataType >::KeyType

◆ Type

template<class TDataType >
typedef TDataType Kratos::Variable< TDataType >::Type

type of this variable

◆ VariableType

template<class TDataType >
typedef Variable<TDataType> Kratos::Variable< TDataType >::VariableType

Constructor & Destructor Documentation

◆ Variable() [1/5]

template<class TDataType >
Kratos::Variable< TDataType >::Variable ( const std::string &  NewName,
const TDataType  Zero = TDataType(),
const VariableType pTimeDerivativeVariable = nullptr 
)
inlineexplicit

Constructor with specific name and zero value.

Parameters
NewNameThe name to be assigned to the new variable
ZeroThe value to be assigned to the variable as zero. In case of not definition will take the value given by the constructor of the time
pTimeDerivativeVariablePointer to the time derivative variable

◆ Variable() [2/5]

template<class TDataType >
Kratos::Variable< TDataType >::Variable ( const std::string &  NewName,
const VariableType pTimeDerivativeVariable 
)
inlineexplicit

Constructor with specific name and zero value.

Parameters
NewNameThe name to be assigned to the new variable
pTimeDerivativeVariablePointer to the time derivative variable

◆ Variable() [3/5]

template<class TDataType >
template<typename TSourceVariableType >
Kratos::Variable< TDataType >::Variable ( const std::string &  rNewName,
TSourceVariableType *  pSourceVariable,
char  ComponentIndex,
const TDataType  Zero = TDataType() 
)
inlineexplicit

Constructor for creating a component of other variable.

Parameters
rNewNameThe name to be assigned to the compoenent
ZeroThe value to be assigned to the variable as zero. In case of not definition will take the value given by the constructor of the time

◆ Variable() [4/5]

template<class TDataType >
template<typename TSourceVariableType >
Kratos::Variable< TDataType >::Variable ( const std::string &  rNewName,
TSourceVariableType *  pSourceVariable,
char  ComponentIndex,
const VariableType pTimeDerivativeVariable,
const TDataType  Zero = TDataType() 
)
inlineexplicit

Constructor for creating a component of other variable.

Parameters
rNewNameThe name to be assigned to the compoenent
pTimeDerivativeVariablePointer to the time derivative variable
ZeroThe value to be assigned to the variable as zero. In case of not definition will take the value given by the constructor of the time

◆ Variable() [5/5]

template<class TDataType >
Kratos::Variable< TDataType >::Variable ( const VariableType rOtherVariable)
inlineexplicit

Copy constructor.

Copy constructor.

Parameters
rOtherVariableThe old variable to be copied

◆ ~Variable()

template<class TDataType >
Kratos::Variable< TDataType >::~Variable ( )
inlineoverride

Destructor.

Member Function Documentation

◆ Allocate()

template<class TDataType >
void Kratos::Variable< TDataType >::Allocate ( void **  pData) const
inlineoverridevirtual

This method allocates the data of the variable.

Parameters
pDataA pointer to the data to be allocated

Reimplemented from Kratos::VariableData.

◆ Assign()

template<class TDataType >
void Kratos::Variable< TDataType >::Assign ( const void *  pSource,
void *  pDestination 
) const
inlineoverridevirtual

Assign is very similar to Copy. It just differs in using an assignment operator besides the copy constructor. Copy creates a new object while.

Assign does the assignment for two existing objects.

Parameters
pSourceThe pointer of the value to be assigned
pDestinationThe pointer of the destination value

Reimplemented from Kratos::VariableData.

◆ AssignZero()

template<class TDataType >
void Kratos::Variable< TDataType >::AssignZero ( void *  pDestination) const
inlineoverridevirtual

AssignZero is a special case of Assign for which variable zero value used as source.

This method is useful for initializing arrays or resetting values in memory.

Parameters
pDestinationThe pointer of the destination variable

Reimplemented from Kratos::VariableData.

◆ Clone()

template<class TDataType >
void* Kratos::Variable< TDataType >::Clone ( const void *  pSource) const
inlineoverridevirtual

Clone creates a copy of the object using a copy constructor of the class.

It is useful to avoid shallow copying of complex objects and also without actually having information about the variable type.

Parameters
pSourceThe pointer of the variable to be cloned
Returns
A raw pointer of the variable

Reimplemented from Kratos::VariableData.

◆ Copy()

template<class TDataType >
void* Kratos::Variable< TDataType >::Copy ( const void *  pSource,
void *  pDestination 
) const
inlineoverridevirtual

Copy is very similar to Clone except that it also the destination pointer also passed to it.

It is a helpful method specially to create a copy of heterogeneous data arrays

Parameters
pSourceThe pointer of the variable to be copied
pDestinationThe pointer of the destination variable
Returns
A raw pointer of the variable

Reimplemented from Kratos::VariableData.

◆ Delete()

template<class TDataType >
void Kratos::Variable< TDataType >::Delete ( void *  pSource) const
inlineoverridevirtual

Delete removes an object of variable type from memory.

It calls a destructor of objects to prevent memory leak and frees the memory allocated for this object assuming that the object is allocated in heap.

Parameters
pSourceThe pointer of the variable to be deleted

Reimplemented from Kratos::VariableData.

◆ Destruct()

template<class TDataType >
void Kratos::Variable< TDataType >::Destruct ( void *  pSource) const
inlineoverridevirtual

Destruct eliminates an object maintaining the memory it is using.

However, the unlike Delete it does nothing with the memory allocated to it. So it is very useful in case of reallocating a part of the memory.

Parameters
pSourceThe pointer of the variable to be destructed

Reimplemented from Kratos::VariableData.

◆ GetTimeDerivative()

template<class TDataType >
const VariableType& Kratos::Variable< TDataType >::GetTimeDerivative ( ) const
inline

This method returns the time derivative variable.

Returns
The reference of the time derivative variable (if any)

◆ GetValue() [1/2]

template<class TDataType >
const TDataType& Kratos::Variable< TDataType >::GetValue ( const void *  pSource) const
inline

◆ GetValue() [2/2]

template<class TDataType >
TDataType& Kratos::Variable< TDataType >::GetValue ( void *  pSource) const
inline

◆ Info()

template<class TDataType >
std::string Kratos::Variable< TDataType >::Info ( ) const
inlineoverridevirtual

Turn back information as a string.

Reimplemented from Kratos::VariableData.

◆ KRATOS_CLASS_POINTER_DEFINITION()

template<class TDataType >
Kratos::Variable< TDataType >::KRATOS_CLASS_POINTER_DEFINITION ( Variable< TDataType >  )

Pointer definition of Variable.

◆ Load()

template<class TDataType >
void Kratos::Variable< TDataType >::Load ( Serializer rSerializer,
void *  pData 
) const
inlineoverridevirtual

The load operation which restores the data of the class.

Parameters
rSerializerThe serializer used to preserve the information
pDataA pointer to the data to be loaded

Reimplemented from Kratos::VariableData.

◆ operator=()

template<class TDataType >
VariableType& Kratos::Variable< TDataType >::operator= ( const VariableType rOtherVariable)
delete

Assignment operator, deleted to avoid misuse which can lead to memory problems.

◆ Print()

template<class TDataType >
void Kratos::Variable< TDataType >::Print ( const void *  pSource,
std::ostream &  rOStream 
) const
inlineoverridevirtual

Print is an auxiliary method to produce output of given variable knowing its address.

For example writing an heterogenous container in an output stream can be done using this method. Point assumes that the streaming operator is defined for the variable type.

Parameters
pSourceThe pointer of the variable to be printed
rOStreamThe stream used to print the information

Reimplemented from Kratos::VariableData.

◆ PrintData() [1/2]

template<class TDataType >
void Kratos::Variable< TDataType >::PrintData ( const void *  pSource,
std::ostream &  rOStream 
) const
inlineoverridevirtual

PrintData is an auxiliary method to produce output only the value of given variable knowing its address.

For example writing an heterogenous container in an output stream can be done using this method. Point assumes that the streaming operator is defined for the variable type.

Parameters
pSourceThe pointer of the variable to be printed
rOStreamThe stream used to print the information

Reimplemented from Kratos::VariableData.

◆ PrintData() [2/2]

template<class TDataType >
void Kratos::Variable< TDataType >::PrintData ( std::ostream &  rOStream) const
inlineoverridevirtual

Print object's data.

Reimplemented from Kratos::VariableData.

◆ PrintInfo()

template<class TDataType >
void Kratos::Variable< TDataType >::PrintInfo ( std::ostream &  rOStream) const
inlineoverridevirtual

Print information about this object.

Parameters
rOStreamThe stream used to print the information

Reimplemented from Kratos::VariableData.

◆ pZero()

template<class TDataType >
const void* Kratos::Variable< TDataType >::pZero ( ) const
inlineoverridevirtual

Reimplemented from Kratos::VariableData.

◆ Save()

template<class TDataType >
void Kratos::Variable< TDataType >::Save ( Serializer rSerializer,
void *  pData 
) const
inlineoverridevirtual

The save operation which backups the data of the class.

Parameters
rSerializerThe serializer used to preserve the information
pDataA pointer to the data to be saved

Reimplemented from Kratos::VariableData.

◆ StaticObject()

template<class TDataType >
static const VariableType& Kratos::Variable< TDataType >::StaticObject ( )
inlinestatic

This method returns the variable type.

Returns
The type of the variable

◆ Zero()

template<class TDataType >
const TDataType& Kratos::Variable< TDataType >::Zero ( ) const
inline

This method returns the zero value of the variable type.

Returns
The zero value of the corresponding variable

Friends And Related Function Documentation

◆ Serializer

template<class TDataType >
friend class Serializer
friend

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