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::KratosComponents< TComponentType > Class Template Reference

KratosComponents class encapsulates a lookup table for a family of classes in a generic way. More...

#include <kratos_components.h>

Collaboration diagram for Kratos::KratosComponents< TComponentType >:

Public Member Functions

Life Cycle
 KratosComponents ()=default
 Default constructor. More...
 
virtual ~KratosComponents ()=default
 Destructor. More...
 
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

Operations
static void Add (const std::string &rName, const TComponentType &rComponent)
 Adds a component to the collection. More...
 
static void Remove (const std::string &rName)
 Removes a component with the specified name. More...
 
static const TComponentType & Get (const std::string &rName)
 Retrieves a component with the specified name. More...
 
static void Register ()
 Registers the function. More...
 
Access
static ComponentsContainerTypeGetComponents ()
 Retrieves the ComponentsContainer. More...
 
static ComponentsContainerTypepGetComponents ()
 Retrieves the pointer to the ComponentsContainerType object. More...
 
Inquiry
static bool Has (const std::string &rName)
 Check if the given name exists in the set of components. More...
 

Type Definitions

using ComponentsContainerType = std::map< std::string, const TComponentType * >
 The map type used to store the components // TODO: Replace std::map with faster alternative. More...
 
using ValueType = typename ComponentsContainerType::value_type
 Component type. More...
 
 KRATOS_CLASS_POINTER_DEFINITION (KratosComponents)
 Pointer definition of KratosComponents. More...
 

Detailed Description

template<class TComponentType>
class Kratos::KratosComponents< TComponentType >

KratosComponents class encapsulates a lookup table for a family of classes in a generic way.

Prototypes must be added to this table by unique names to be accessible by IO. These names can be created automatically using C++ RTTI or given manually for each component. In this design the manual approach is chosen, so shorter and more clear names can be given to each component and also there is a flexibility to give different names to different states of an object and create them via different prototypes. For example having TriangularThermal and both

Author
Pooyan Dadvand
Template Parameters
TComponentTypeThe type of components to be stored in this table.

Member Typedef Documentation

◆ ComponentsContainerType

template<class TComponentType >
using Kratos::KratosComponents< TComponentType >::ComponentsContainerType = std::map<std::string, const TComponentType*>

The map type used to store the components // TODO: Replace std::map with faster alternative.

◆ ValueType

template<class TComponentType >
using Kratos::KratosComponents< TComponentType >::ValueType = typename ComponentsContainerType::value_type

Component type.

Constructor & Destructor Documentation

◆ KratosComponents()

template<class TComponentType >
Kratos::KratosComponents< TComponentType >::KratosComponents ( )
default

Default constructor.

◆ ~KratosComponents()

template<class TComponentType >
virtual Kratos::KratosComponents< TComponentType >::~KratosComponents ( )
virtualdefault

Destructor.

Member Function Documentation

◆ Add()

template<class TComponentType >
static void Kratos::KratosComponents< TComponentType >::Add ( const std::string &  rName,
const TComponentType &  rComponent 
)
inlinestatic

Adds a component to the collection.

Parameters
rNamethe name of the component
rComponentthe component to add
Exceptions
std::runtime_errorif a different object was already registered with the same name

◆ Get()

template<class TComponentType >
static const TComponentType& Kratos::KratosComponents< TComponentType >::Get ( const std::string &  rName)
inlinestatic

Retrieves a component with the specified name.

This function retrieves a component from the ComponentsContainer using the provided name.

Parameters
rNameThe name of the component to retrieve.
Returns
A reference to the retrieved component.
Note
If the component is not found in debug, an error message will be printed and the program may terminate.

◆ GetComponents()

template<class TComponentType >
static ComponentsContainerType& Kratos::KratosComponents< TComponentType >::GetComponents ( )
inlinestatic

Retrieves the ComponentsContainer.

This function returns a reference to the ComponentsContainer, which stores all the components.

Returns
A reference to the ComponentsContainer.

◆ Has()

template<class TComponentType >
static bool Kratos::KratosComponents< TComponentType >::Has ( const std::string &  rName)
inlinestatic

Check if the given name exists in the set of components.

Parameters
rNamethe name to check
Returns
true if the name exists, false otherwise

◆ Info()

template<class TComponentType >
virtual std::string Kratos::KratosComponents< TComponentType >::Info ( ) const
inlinevirtual

Turn back information as a string.

◆ KRATOS_CLASS_POINTER_DEFINITION()

template<class TComponentType >
Kratos::KratosComponents< TComponentType >::KRATOS_CLASS_POINTER_DEFINITION ( KratosComponents< TComponentType >  )

Pointer definition of KratosComponents.

◆ pGetComponents()

template<class TComponentType >
static ComponentsContainerType* Kratos::KratosComponents< TComponentType >::pGetComponents ( )
inlinestatic

Retrieves the pointer to the ComponentsContainerType object.

Returns
Pointer to the ComponentsContainerType object.

◆ PrintData()

template<class TComponentType >
virtual void Kratos::KratosComponents< TComponentType >::PrintData ( std::ostream &  rOStream) const
inlinevirtual

Print object's data.

◆ PrintInfo()

template<class TComponentType >
virtual void Kratos::KratosComponents< TComponentType >::PrintInfo ( std::ostream &  rOStream) const
inlinevirtual

Print information about this object.

◆ Register()

template<class TComponentType >
static void Kratos::KratosComponents< TComponentType >::Register ( )
inlinestatic

Registers the function.

◆ Remove()

template<class TComponentType >
static void Kratos::KratosComponents< TComponentType >::Remove ( const std::string &  rName)
inlinestatic

Removes a component with the specified name.

Parameters
rNameThe name of the component to remove.
Exceptions
ErrorTypeIf the component with the specified name does not exist.

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