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

The serialization consists in storing the state of an object into a storage format like data file or memory buffer and also retrieving the object from such a media. More...

#include <serializer.h>

Inheritance diagram for Kratos::Serializer:
Collaboration diagram for Kratos::Serializer:

Public Types

Enum's
enum  PointerType { SP_INVALID_POINTER , SP_BASE_CLASS_POINTER , SP_DERIVED_CLASS_POINTER }
 
enum  TraceType { SERIALIZER_NO_TRACE =0 , SERIALIZER_TRACE_ERROR =1 , SERIALIZER_TRACE_ALL =2 }
 

Public Member Functions

Life Cycle
 Serializer (BufferType *pBuffer, TraceType const &rTrace=SERIALIZER_NO_TRACE)
 Default constructor. More...
 
virtual ~Serializer ()
 Destructor. More...
 
Operators
void SetLoadState ()
 
Inquiry
bool Is (Flags const &rOtherFlag) 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...
 

Type Definitions

typedef std::size_t SizeType
 
typedef void *(* ObjectFactoryType) ()
 
typedef std::map< void *, void * > LoadedPointersContainerType
 
typedef std::map< std::string, ObjectFactoryTypeRegisteredObjectsContainerType
 
typedef std::map< std::string, std::string > RegisteredObjectsNameContainerType
 
typedef std::set< const void * > SavedPointersContainerType
 
typedef std::iostream BufferType
 
 KRATOS_CLASS_POINTER_DEFINITION (Serializer)
 Pointer definition of Serializer. More...
 
 KRATOS_DEFINE_LOCAL_FLAG (MPI)
 
 KRATOS_DEFINE_LOCAL_FLAG (SHALLOW_GLOBAL_POINTERS_SERIALIZATION)
 

Operations

This function returns the "trace type" used in initializing the serializer. Trace type is one of SERIALIZER_NO_TRACE,SERIALIZER_TRACE_ERROR,SERIALIZER_TRACE_ALL

TraceType GetTraceType () const
 
void SetBuffer (BufferType *pBuffer)
 
template<class TDataType >
void load (std::string const &rTag, TDataType &rObject)
 
template<class TDataType >
void load (std::string const &rTag, Kratos::shared_ptr< TDataType > &pValue)
 
template<class TDataType >
void load (std::string const &rTag, Kratos::intrusive_ptr< TDataType > &pValue)
 
template<class TDataType >
void load (std::string const &rTag, Kratos::unique_ptr< TDataType > &pValue)
 
template<class TDataType >
void load (std::string const &rTag, TDataType *&pValue)
 
void load (std::string const &rTag, ModelPart *&pValue)
 
void load (std::string const &rTag, Kratos::unique_ptr< ModelPart > &pValue)
 
void load (std::string const &rTag, Kratos::shared_ptr< ModelPart > &pValue)
 
template<class TDataType >
void load (std::string const &rTag, Kratos::weak_ptr< TDataType > &pValue)
 
template<class TDataType >
void load (std::string const &rTag, WeakPointerVector< TDataType > &pValue)
 
template<class TDataType >
void load (std::string const &rTag, const Variable< TDataType > *)
 
template<class TDataType , std::size_t TDataSize>
void load (std::string const &rTag, std::array< TDataType, TDataSize > &rObject)
 
template<class TDataType >
void load (std::string const &rTag, std::vector< TDataType > &rObject)
 
template<class TDataType >
void load (std::string const &rTag, DenseVector< TDataType > &rObject)
 
template<class TKeyType , class TDataType >
void load (std::string const &rTag, std::map< TKeyType, TDataType > &rObject)
 
template<class TKeyType , class TDataType >
void load (std::string const &rTag, std::unordered_map< TKeyType, TDataType > &rObject)
 
template<class TDataType >
void load (std::string const &rTag, std::set< TDataType > &rObject)
 
template<class TDataType >
void load (std::string const &rTag, std::unordered_set< TDataType > &rObject)
 
template<class TDataType , std::size_t TDimension>
void load (std::string const &rTag, array_1d< TDataType, TDimension > &rObject)
 
template<class TFirstType , class TSecondType >
void load (std::string const &rTag, std::pair< TFirstType, TSecondType > &rObject)
 
template<class TDataType , std::size_t TDimension>
void load (std::string const &rTag, BoundedVector< TDataType, TDimension > &rObject)
 
template<class TDataType , std::size_t TDimension1, std::size_t TDimension2>
void load (std::string const &rTag, BoundedMatrix< TDataType, TDimension1, TDimension2 > &rObject)
 
template<class TDataType , std::size_t TDataSize>
void save (std::string const &rTag, std::array< TDataType, TDataSize > const &rObject)
 
template<class TDataType >
void save (std::string const &rTag, std::vector< TDataType > const &rObject)
 
template<class TDataType >
void save (std::string const &rTag, DenseVector< TDataType > const &rObject)
 
template<class TDataType , std::size_t TDimension>
void save (std::string const &rTag, array_1d< TDataType, TDimension > const &rObject)
 
template<class TKeyType , class TDataType >
void save (std::string const &rTag, std::map< TKeyType, TDataType > const &rObject)
 
template<class TKeyType , class TDataType >
void save (std::string const &rTag, std::unordered_map< TKeyType, TDataType > const &rObject)
 
template<class TDataType >
void save (std::string const &rTag, std::set< TDataType > const &rObject)
 
template<class TDataType >
void save (std::string const &rTag, std::unordered_set< TDataType > const &rObject)
 
template<class TDataType >
void save (std::string const &rTag, TDataType const &rObject)
 
template<class TDataType >
void save (std::string const &rTag, const Variable< TDataType > *pVariable)
 
template<class TDataType >
void save (std::string const &rTag, Kratos::shared_ptr< TDataType > pValue)
 
template<class TDataType >
void save (std::string const &rTag, Kratos::intrusive_ptr< TDataType > pValue)
 
template<class TDataType >
void save (std::string const &rTag, Kratos::unique_ptr< TDataType > const &pValue)
 
template<class TDataType >
void save (std::string const &rTag, const TDataType *pValue)
 
template<class TDataType >
bool IsDerived (TDataType *pValue)
 
template<class TDataType >
void save (std::string const &rTag, TDataType *pValue)
 
template<class TDataType >
void save (std::string const &rTag, Kratos::weak_ptr< TDataType > pValue)
 
template<class TDataType >
void save (std::string const &rTag, Kratos::WeakPointerVector< TDataType > pValue)
 
template<class TDataType >
void save (std::string const &rTag, Kratos::shared_ptr< const TDataType > pValue)
 
void save (std::string const &rTag, const char *pValue)
 
template<class TFirstType , class TSecondType >
void save (std::string const &rTag, std::pair< TFirstType, TSecondType > rObject)
 
template<class TDataType , std::size_t TDimension>
void save (std::string const &rTag, BoundedVector< TDataType, TDimension > const &rObject)
 
template<class TDataType , std::size_t TDimension1, std::size_t TDimension2>
void save (std::string const &rTag, BoundedMatrix< TDataType, TDimension1, TDimension2 > const &rObject)
 
template<class TDataType >
void load_base (std::string const &rTag, TDataType &rObject)
 
template<class TDataType >
void load_base (std::string const &rTag, std::vector< TDataType > &rObject)
 
template<class TDataType >
void load_base (std::string const &rTag, DenseVector< TDataType > &rObject)
 
template<class TDataType , std::size_t TDimension>
void load_base (std::string const &rTag, array_1d< TDataType, TDimension > &rObject)
 
template<class TDataType >
void save_base (std::string const &rTag, std::vector< TDataType > const &rObject)
 
template<class TDataType >
void save_base (std::string const &rTag, DenseVector< TDataType > const &rObject)
 
template<class TDataType , std::size_t TDimension>
void save_base (std::string const &rTag, array_1d< TDataType, TDimension > const &rObject)
 
template<class TDataType >
void save_base (std::string const &rTag, TDataType const &rObject)
 
void save_trace_point (std::string const &rTag)
 
bool load_trace_point (std::string const &rTag)
 
template<class TDataType >
static void * Create ()
 
template<class TDataType >
static void Register (std::string const &rName, TDataType const &pPrototype)
 

Access

BufferTypepGetBuffer ()
 
template<class TDataType >
void AddToSavedPointers (const TDataType &pValue)
 
void RedirectLoadingPointer (void *pStoredPointer, void *pAllocatedPosition)
 
void Set (const Flags ThisFlag)
 
static RegisteredObjectsContainerTypeGetRegisteredObjects ()
 
static RegisteredObjectsNameContainerTypeGetRegisteredObjectsName ()
 

Detailed Description

The serialization consists in storing the state of an object into a storage format like data file or memory buffer and also retrieving the object from such a media.

The serialization consists in storing the state of an object into a storage format like data file or memory buffer and also retrieving the object from such a media. The idea of serialization is based on saving all object's data consecutively in the file or buffer and then load it in the same order. In Kratos a serialization mechanism is used for creating the restart file. So for storing an object into restart file and retrieve it afterward on must add the necessary component used by serialization.

Author
Pooyan Dadvand

Member Typedef Documentation

◆ BufferType

typedef std::iostream Kratos::Serializer::BufferType

◆ LoadedPointersContainerType

typedef std::map<void*, void*> Kratos::Serializer::LoadedPointersContainerType

◆ ObjectFactoryType

typedef void*(* Kratos::Serializer::ObjectFactoryType) ()

◆ RegisteredObjectsContainerType

◆ RegisteredObjectsNameContainerType

typedef std::map<std::string, std::string> Kratos::Serializer::RegisteredObjectsNameContainerType

◆ SavedPointersContainerType

typedef std::set<const void*> Kratos::Serializer::SavedPointersContainerType

◆ SizeType

typedef std::size_t Kratos::Serializer::SizeType

Member Enumeration Documentation

◆ PointerType

Enumerator
SP_INVALID_POINTER 
SP_BASE_CLASS_POINTER 
SP_DERIVED_CLASS_POINTER 

◆ TraceType

Enumerator
SERIALIZER_NO_TRACE 
SERIALIZER_TRACE_ERROR 
SERIALIZER_TRACE_ALL 

Constructor & Destructor Documentation

◆ Serializer()

Kratos::Serializer::Serializer ( BufferType pBuffer,
TraceType const &  rTrace = SERIALIZER_NO_TRACE 
)
inlineexplicit

Default constructor.

◆ ~Serializer()

virtual Kratos::Serializer::~Serializer ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ AddToSavedPointers()

template<class TDataType >
void Kratos::Serializer::AddToSavedPointers ( const TDataType &  pValue)
inline

This function let's one introduce "pValue" between the objects which are considered to be already serialized TODO: verify if this should be a void* or if it is correct that it is taken as TDataType

◆ Create()

template<class TDataType >
static void* Kratos::Serializer::Create ( )
inlinestatic

◆ GetRegisteredObjects()

static RegisteredObjectsContainerType& Kratos::Serializer::GetRegisteredObjects ( )
inlinestatic

◆ GetRegisteredObjectsName()

static RegisteredObjectsNameContainerType& Kratos::Serializer::GetRegisteredObjectsName ( )
inlinestatic

◆ GetTraceType()

TraceType Kratos::Serializer::GetTraceType ( ) const
inline

◆ Info()

virtual std::string Kratos::Serializer::Info ( ) const
inlinevirtual

Turn back information as a string.

◆ Is()

bool Kratos::Serializer::Is ( Flags const &  rOtherFlag) const
inline

◆ IsDerived()

template<class TDataType >
bool Kratos::Serializer::IsDerived ( TDataType *  pValue)
inline

◆ KRATOS_CLASS_POINTER_DEFINITION()

Kratos::Serializer::KRATOS_CLASS_POINTER_DEFINITION ( Serializer  )

Pointer definition of Serializer.

◆ KRATOS_DEFINE_LOCAL_FLAG() [1/2]

Kratos::Serializer::KRATOS_DEFINE_LOCAL_FLAG ( MPI  )

◆ KRATOS_DEFINE_LOCAL_FLAG() [2/2]

Kratos::Serializer::KRATOS_DEFINE_LOCAL_FLAG ( SHALLOW_GLOBAL_POINTERS_SERIALIZATION  )

◆ load() [1/22]

template<class TDataType , std::size_t TDimension>
void Kratos::Serializer::load ( std::string const &  rTag,
array_1d< TDataType, TDimension > &  rObject 
)
inline

◆ load() [2/22]

template<class TDataType , std::size_t TDimension1, std::size_t TDimension2>
void Kratos::Serializer::load ( std::string const &  rTag,
BoundedMatrix< TDataType, TDimension1, TDimension2 > &  rObject 
)
inline

◆ load() [3/22]

template<class TDataType , std::size_t TDimension>
void Kratos::Serializer::load ( std::string const &  rTag,
BoundedVector< TDataType, TDimension > &  rObject 
)
inline

◆ load() [4/22]

template<class TDataType >
void Kratos::Serializer::load ( std::string const &  rTag,
const Variable< TDataType > *   
)
inline

◆ load() [5/22]

template<class TDataType >
void Kratos::Serializer::load ( std::string const &  rTag,
DenseVector< TDataType > &  rObject 
)
inline

◆ load() [6/22]

template<class TDataType >
void Kratos::Serializer::load ( std::string const &  rTag,
Kratos::intrusive_ptr< TDataType > &  pValue 
)
inline

◆ load() [7/22]

void Serializer::load ( std::string const &  rTag,
Kratos::shared_ptr< ModelPart > &  pValue 
)

◆ load() [8/22]

template<class TDataType >
void Kratos::Serializer::load ( std::string const &  rTag,
Kratos::shared_ptr< TDataType > &  pValue 
)
inline

◆ load() [9/22]

void Serializer::load ( std::string const &  rTag,
Kratos::unique_ptr< ModelPart > &  pValue 
)

◆ load() [10/22]

template<class TDataType >
void Kratos::Serializer::load ( std::string const &  rTag,
Kratos::unique_ptr< TDataType > &  pValue 
)
inline

◆ load() [11/22]

template<class TDataType >
void Kratos::Serializer::load ( std::string const &  rTag,
Kratos::weak_ptr< TDataType > &  pValue 
)
inline

◆ load() [12/22]

void Serializer::load ( std::string const &  rTag,
ModelPart *&  pValue 
)

◆ load() [13/22]

template<class TDataType , std::size_t TDataSize>
void Kratos::Serializer::load ( std::string const &  rTag,
std::array< TDataType, TDataSize > &  rObject 
)
inline

◆ load() [14/22]

template<class TKeyType , class TDataType >
void Kratos::Serializer::load ( std::string const &  rTag,
std::map< TKeyType, TDataType > &  rObject 
)
inline

◆ load() [15/22]

template<class TFirstType , class TSecondType >
void Kratos::Serializer::load ( std::string const &  rTag,
std::pair< TFirstType, TSecondType > &  rObject 
)
inline

◆ load() [16/22]

template<class TDataType >
void Kratos::Serializer::load ( std::string const &  rTag,
std::set< TDataType > &  rObject 
)
inline

◆ load() [17/22]

template<class TKeyType , class TDataType >
void Kratos::Serializer::load ( std::string const &  rTag,
std::unordered_map< TKeyType, TDataType > &  rObject 
)
inline

◆ load() [18/22]

template<class TDataType >
void Kratos::Serializer::load ( std::string const &  rTag,
std::unordered_set< TDataType > &  rObject 
)
inline

◆ load() [19/22]

template<class TDataType >
void Kratos::Serializer::load ( std::string const &  rTag,
std::vector< TDataType > &  rObject 
)
inline

◆ load() [20/22]

template<class TDataType >
void Kratos::Serializer::load ( std::string const &  rTag,
TDataType &  rObject 
)
inline

◆ load() [21/22]

template<class TDataType >
void Kratos::Serializer::load ( std::string const &  rTag,
TDataType *&  pValue 
)
inline

◆ load() [22/22]

template<class TDataType >
void Kratos::Serializer::load ( std::string const &  rTag,
WeakPointerVector< TDataType > &  pValue 
)
inline

◆ load_base() [1/4]

template<class TDataType , std::size_t TDimension>
void Kratos::Serializer::load_base ( std::string const &  rTag,
array_1d< TDataType, TDimension > &  rObject 
)
inline

◆ load_base() [2/4]

template<class TDataType >
void Kratos::Serializer::load_base ( std::string const &  rTag,
DenseVector< TDataType > &  rObject 
)
inline

◆ load_base() [3/4]

template<class TDataType >
void Kratos::Serializer::load_base ( std::string const &  rTag,
std::vector< TDataType > &  rObject 
)
inline

◆ load_base() [4/4]

template<class TDataType >
void Kratos::Serializer::load_base ( std::string const &  rTag,
TDataType &  rObject 
)
inline

◆ load_trace_point()

bool Kratos::Serializer::load_trace_point ( std::string const &  rTag)
inline

◆ pGetBuffer()

BufferType* Kratos::Serializer::pGetBuffer ( )
inline

◆ PrintData()

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

Print object's data.

◆ PrintInfo()

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

Print information about this object.

◆ RedirectLoadingPointer()

void Kratos::Serializer::RedirectLoadingPointer ( void *  pStoredPointer,
void *  pAllocatedPosition 
)
inline

This function is to be used to inform the serializer that the object initially stored in "pStoredPosition" is after loading located at pAllocatedPosition This function is useful to substitute some objects with others that already exist.

◆ Register()

template<class TDataType >
static void Kratos::Serializer::Register ( std::string const &  rName,
TDataType const &  pPrototype 
)
inlinestatic

◆ save() [1/22]

template<class TDataType , std::size_t TDimension>
void Kratos::Serializer::save ( std::string const &  rTag,
array_1d< TDataType, TDimension > const &  rObject 
)
inline

◆ save() [2/22]

template<class TDataType , std::size_t TDimension1, std::size_t TDimension2>
void Kratos::Serializer::save ( std::string const &  rTag,
BoundedMatrix< TDataType, TDimension1, TDimension2 > const &  rObject 
)
inline

◆ save() [3/22]

template<class TDataType , std::size_t TDimension>
void Kratos::Serializer::save ( std::string const &  rTag,
BoundedVector< TDataType, TDimension > const &  rObject 
)
inline

◆ save() [4/22]

void Kratos::Serializer::save ( std::string const &  rTag,
const char *  pValue 
)
inline

◆ save() [5/22]

template<class TDataType >
void Kratos::Serializer::save ( std::string const &  rTag,
const TDataType *  pValue 
)
inline

◆ save() [6/22]

template<class TDataType >
void Kratos::Serializer::save ( std::string const &  rTag,
const Variable< TDataType > *  pVariable 
)
inline

◆ save() [7/22]

template<class TDataType >
void Kratos::Serializer::save ( std::string const &  rTag,
DenseVector< TDataType > const &  rObject 
)
inline

◆ save() [8/22]

template<class TDataType >
void Kratos::Serializer::save ( std::string const &  rTag,
Kratos::intrusive_ptr< TDataType >  pValue 
)
inline

◆ save() [9/22]

template<class TDataType >
void Kratos::Serializer::save ( std::string const &  rTag,
Kratos::shared_ptr< const TDataType >  pValue 
)
inline

◆ save() [10/22]

template<class TDataType >
void Kratos::Serializer::save ( std::string const &  rTag,
Kratos::shared_ptr< TDataType >  pValue 
)
inline

◆ save() [11/22]

template<class TDataType >
void Kratos::Serializer::save ( std::string const &  rTag,
Kratos::unique_ptr< TDataType > const &  pValue 
)
inline

◆ save() [12/22]

template<class TDataType >
void Kratos::Serializer::save ( std::string const &  rTag,
Kratos::weak_ptr< TDataType >  pValue 
)
inline

◆ save() [13/22]

template<class TDataType >
void Kratos::Serializer::save ( std::string const &  rTag,
Kratos::WeakPointerVector< TDataType >  pValue 
)
inline

◆ save() [14/22]

template<class TDataType , std::size_t TDataSize>
void Kratos::Serializer::save ( std::string const &  rTag,
std::array< TDataType, TDataSize > const &  rObject 
)
inline

◆ save() [15/22]

template<class TKeyType , class TDataType >
void Kratos::Serializer::save ( std::string const &  rTag,
std::map< TKeyType, TDataType > const &  rObject 
)
inline

◆ save() [16/22]

template<class TFirstType , class TSecondType >
void Kratos::Serializer::save ( std::string const &  rTag,
std::pair< TFirstType, TSecondType >  rObject 
)
inline

◆ save() [17/22]

template<class TDataType >
void Kratos::Serializer::save ( std::string const &  rTag,
std::set< TDataType > const &  rObject 
)
inline

◆ save() [18/22]

template<class TKeyType , class TDataType >
void Kratos::Serializer::save ( std::string const &  rTag,
std::unordered_map< TKeyType, TDataType > const &  rObject 
)
inline

◆ save() [19/22]

template<class TDataType >
void Kratos::Serializer::save ( std::string const &  rTag,
std::unordered_set< TDataType > const &  rObject 
)
inline

◆ save() [20/22]

template<class TDataType >
void Kratos::Serializer::save ( std::string const &  rTag,
std::vector< TDataType > const &  rObject 
)
inline

◆ save() [21/22]

template<class TDataType >
void Kratos::Serializer::save ( std::string const &  rTag,
TDataType *  pValue 
)
inline

◆ save() [22/22]

template<class TDataType >
void Kratos::Serializer::save ( std::string const &  rTag,
TDataType const &  rObject 
)
inline

◆ save_base() [1/4]

template<class TDataType , std::size_t TDimension>
void Kratos::Serializer::save_base ( std::string const &  rTag,
array_1d< TDataType, TDimension > const &  rObject 
)
inline

◆ save_base() [2/4]

template<class TDataType >
void Kratos::Serializer::save_base ( std::string const &  rTag,
DenseVector< TDataType > const &  rObject 
)
inline

◆ save_base() [3/4]

template<class TDataType >
void Kratos::Serializer::save_base ( std::string const &  rTag,
std::vector< TDataType > const &  rObject 
)
inline

◆ save_base() [4/4]

template<class TDataType >
void Kratos::Serializer::save_base ( std::string const &  rTag,
TDataType const &  rObject 
)
inline

◆ save_trace_point()

void Kratos::Serializer::save_trace_point ( std::string const &  rTag)
inline

◆ Set()

void Kratos::Serializer::Set ( const Flags  ThisFlag)
inline

◆ SetBuffer()

void Kratos::Serializer::SetBuffer ( BufferType pBuffer)
inline

◆ SetLoadState()

void Serializer::SetLoadState ( )

Sets the Serializer in a state ready to be loaded Note: If the same object is loaded twice before deleting it from memory all its pointers will be duplicated.


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