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::VariableData Class Reference

This class is the base of variables and variable's components which contains their common data. More...

#include <variable_data.h>

Inheritance diagram for Kratos::VariableData:
Collaboration diagram for Kratos::VariableData:

Public Member Functions

Life Cycle
 VariableData (const VariableData &rOtherVariable)
 Copy constructor. More...
 
virtual ~VariableData ()
 Destructor. More...
 
Operators
 operator size_t () const
 
Operations
virtual void * Clone (const void *pSource) const
 
virtual void * Copy (const void *pSource, void *pDestination) const
 
virtual void Assign (const void *pSource, void *pDestination) const
 
virtual void AssignZero (void *pDestination) const
 
virtual void Delete (void *pSource) const
 
virtual void Destruct (void *pSource) const
 
virtual void Print (const void *pSource, std::ostream &rOStream) const
 
virtual void PrintData (const void *pSource, std::ostream &rOStream) const
 
virtual void Allocate (void **pData) const
 
virtual void Save (Serializer &rSerializer, void *pData) const
 
virtual void Load (Serializer &rSerializer, void *pData) const
 
Access
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
 
virtual const void * pZero () const
 
Input and output
virtual std::string Info () const
 Turn back information as a string. More...
 
virtual void PrintInfo (std::ostream &rOStream) const
 Print information about this object. More...
 
virtual void PrintData (std::ostream &rOStream) const
 Print object's data. More...
 

Static Public Member Functions

Statics
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

Protected Operators
VariableDataoperator= (const VariableData &rOtherVariable)
 
Protected LifeCycle
 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 ()
 

Friends

Friends
bool operator== (const VariableData &rFirstVariable, const VariableData &rSecondVariable)
 

Type Definitions

typedef std::size_t KeyType
 
 KRATOS_CLASS_POINTER_DEFINITION (VariableData)
 Pointer definition of VariableData. More...
 

Private Operations

class Serializer
 

Detailed Description

This class is the base of variables and variable's components which contains their common data.

This class hold variables name and key and also adaptor type for variables components. It also has static method for generating a key based on the name of the variable

Member Typedef Documentation

◆ KeyType

typedef std::size_t Kratos::VariableData::KeyType

Constructor & Destructor Documentation

◆ VariableData() [1/4]

Kratos::VariableData::VariableData ( const VariableData rOtherVariable)

Copy constructor.

◆ ~VariableData()

virtual Kratos::VariableData::~VariableData ( )
inlinevirtual

Destructor.

◆ VariableData() [2/4]

Kratos::VariableData::VariableData ( const std::string &  NewName,
std::size_t  NewSize 
)
protected

Constructor for variables.

◆ VariableData() [3/4]

Kratos::VariableData::VariableData ( const std::string &  NewName,
std::size_t  NewSize,
const VariableData pSourceVariable,
char  ComponentIndex 
)
protected

Constructor for variables components.

Constructor.

◆ VariableData() [4/4]

Kratos::VariableData::VariableData ( )
inlineprotected

default constructor is to be used only with serialization due to the fact that each variable must have a name defined.

Member Function Documentation

◆ Allocate()

void Kratos::VariableData::Allocate ( void **  pData) const
virtual

◆ Assign()

void Kratos::VariableData::Assign ( const void *  pSource,
void *  pDestination 
) const
virtual

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 in Kratos::Variable< TDataType >, Kratos::Variable< TVarType >, Kratos::Variable< Kratos::Internals::Matrix >, Kratos::Variable< double >, Kratos::Variable< Kratos::GlobalPointersVector >, Kratos::Variable< GradientDataType >, Kratos::Variable< TValue >, Kratos::Variable< int >, Kratos::Variable< T >, Kratos::Variable< Kratos::GlobalPointersVector< Kratos::Node > >, and Kratos::Variable< Kratos::array_1d< double, 3 > >.

◆ AssignZero()

void Kratos::VariableData::AssignZero ( void *  pDestination) const
virtual

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 in Kratos::Variable< TDataType >, Kratos::Variable< TVarType >, Kratos::Variable< Kratos::Internals::Matrix >, Kratos::Variable< double >, Kratos::Variable< Kratos::GlobalPointersVector >, Kratos::Variable< GradientDataType >, Kratos::Variable< TValue >, Kratos::Variable< int >, Kratos::Variable< T >, Kratos::Variable< Kratos::GlobalPointersVector< Kratos::Node > >, and Kratos::Variable< Kratos::array_1d< double, 3 > >.

◆ Clone()

void * Kratos::VariableData::Clone ( const void *  pSource) const
virtual

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 in Kratos::Variable< TDataType >, Kratos::Variable< TVarType >, Kratos::Variable< Kratos::Internals::Matrix >, Kratos::Variable< double >, Kratos::Variable< Kratos::GlobalPointersVector >, Kratos::Variable< GradientDataType >, Kratos::Variable< TValue >, Kratos::Variable< int >, Kratos::Variable< T >, Kratos::Variable< Kratos::GlobalPointersVector< Kratos::Node > >, and Kratos::Variable< Kratos::array_1d< double, 3 > >.

◆ Copy()

void * Kratos::VariableData::Copy ( const void *  pSource,
void *  pDestination 
) const
virtual

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 in Kratos::Variable< TDataType >, Kratos::Variable< TVarType >, Kratos::Variable< Kratos::Internals::Matrix >, Kratos::Variable< double >, Kratos::Variable< Kratos::GlobalPointersVector >, Kratos::Variable< GradientDataType >, Kratos::Variable< TValue >, Kratos::Variable< int >, Kratos::Variable< T >, Kratos::Variable< Kratos::GlobalPointersVector< Kratos::Node > >, and Kratos::Variable< Kratos::array_1d< double, 3 > >.

◆ Delete()

void Kratos::VariableData::Delete ( void *  pSource) const
virtual

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 in Kratos::Variable< TDataType >, Kratos::Variable< TVarType >, Kratos::Variable< Kratos::Internals::Matrix >, Kratos::Variable< double >, Kratos::Variable< Kratos::GlobalPointersVector >, Kratos::Variable< GradientDataType >, Kratos::Variable< TValue >, Kratos::Variable< int >, Kratos::Variable< T >, Kratos::Variable< Kratos::GlobalPointersVector< Kratos::Node > >, and Kratos::Variable< Kratos::array_1d< double, 3 > >.

◆ Destruct()

void Kratos::VariableData::Destruct ( void *  pSource) const
virtual

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 in Kratos::Variable< TDataType >, Kratos::Variable< TVarType >, Kratos::Variable< Kratos::Internals::Matrix >, Kratos::Variable< double >, Kratos::Variable< Kratos::GlobalPointersVector >, Kratos::Variable< GradientDataType >, Kratos::Variable< TValue >, Kratos::Variable< int >, Kratos::Variable< T >, Kratos::Variable< Kratos::GlobalPointersVector< Kratos::Node > >, and Kratos::Variable< Kratos::array_1d< double, 3 > >.

◆ GenerateKey()

VariableData::KeyType Kratos::VariableData::GenerateKey ( const std::string &  Name,
std::size_t  Size,
bool  IsComponent,
char  ComponentIndex 
)
static

This static method generates a uinque key for given name and flags.

The generated key contains a 32-bit uique hash and following information:

  • Copyable : if the is a value type and can be copied by memcopy
  • Component: for component of another variables
  • Component index: The index if is component
  • Size: size of the variable in number of double. The order is as follow:

64 size 32-bit hash comp. index 0 |--------—|-—|------------------------------------------—|-|

◆ GetComponentIndex()

KeyType Kratos::VariableData::GetComponentIndex ( ) const
inline

Returns the component index.

Please note that this method don't check if it is a component or not. It uses the key to reterive the compenent index from its first 7 bits. Component index can be from 0 to 127 at most, because 7 bits are used to store it. So in case of normal variables it returns 0 (like being the first componet)

◆ GetSourceVariable()

const VariableData& Kratos::VariableData::GetSourceVariable ( ) const
inline

◆ HashKey()

KeyType Kratos::VariableData::HashKey ( ) const
inline

◆ Info()

std::string Kratos::VariableData::Info ( ) const
virtual

◆ IsComponent()

bool Kratos::VariableData::IsComponent ( ) const
inline

◆ IsNotComponent()

bool Kratos::VariableData::IsNotComponent ( ) const
inline

◆ Key()

KeyType Kratos::VariableData::Key ( ) const
inline

◆ KRATOS_CLASS_POINTER_DEFINITION()

Kratos::VariableData::KRATOS_CLASS_POINTER_DEFINITION ( VariableData  )

Pointer definition of VariableData.

◆ Load()

void Kratos::VariableData::Load ( Serializer rSerializer,
void *  pData 
) const
virtual

◆ Name()

const std::string& Kratos::VariableData::Name ( ) const
inline

◆ operator size_t()

Kratos::VariableData::operator size_t ( ) const
inline

This operator return the key. by this method user can use Variable as argument for the places which variable key is needed.

◆ operator=()

VariableData& Kratos::VariableData::operator= ( const VariableData rOtherVariable)
inlineprotected

◆ Print()

void Kratos::VariableData::Print ( const void *  pSource,
std::ostream &  rOStream 
) const
virtual

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 in Kratos::Variable< TDataType >, Kratos::Variable< TVarType >, Kratos::Variable< Kratos::Internals::Matrix >, Kratos::Variable< double >, Kratos::Variable< Kratos::GlobalPointersVector >, Kratos::Variable< GradientDataType >, Kratos::Variable< TValue >, Kratos::Variable< int >, Kratos::Variable< T >, Kratos::Variable< Kratos::GlobalPointersVector< Kratos::Node > >, and Kratos::Variable< Kratos::array_1d< double, 3 > >.

◆ PrintData() [1/2]

void Kratos::VariableData::PrintData ( const void *  pSource,
std::ostream &  rOStream 
) const
virtual

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 in Kratos::Variable< TDataType >, Kratos::Variable< TVarType >, Kratos::Variable< Kratos::Internals::Matrix >, Kratos::Variable< double >, Kratos::Variable< Kratos::GlobalPointersVector >, Kratos::Variable< GradientDataType >, Kratos::Variable< TValue >, Kratos::Variable< int >, Kratos::Variable< T >, Kratos::Variable< Kratos::GlobalPointersVector< Kratos::Node > >, and Kratos::Variable< Kratos::array_1d< double, 3 > >.

◆ PrintData() [2/2]

void Kratos::VariableData::PrintData ( std::ostream &  rOStream) const
virtual

◆ PrintInfo()

void Kratos::VariableData::PrintInfo ( std::ostream &  rOStream) const
virtual

◆ pZero()

virtual const void* Kratos::VariableData::pZero ( ) const
inlinevirtual

◆ Save()

void Kratos::VariableData::Save ( Serializer rSerializer,
void *  pData 
) const
virtual

◆ SetKey()

void Kratos::VariableData::SetKey ( KeyType  NewKey)

NOTE: This function is for internal use and not to change arbitrary any variable's key

◆ Size()

std::size_t Kratos::VariableData::Size ( ) const
inline

◆ SourceKey()

KeyType Kratos::VariableData::SourceKey ( ) const
inline

Friends And Related Function Documentation

◆ operator==

bool operator== ( const VariableData rFirstVariable,
const VariableData rSecondVariable 
)
friend

◆ Serializer

friend class Serializer
friend

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