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::ContainerExpression< TContainerType, TMeshType > Class Template Reference

Container variable data holder. More...

#include <container_expression.h>

Collaboration diagram for Kratos::ContainerExpression< TContainerType, TMeshType >:

Public Member Functions

Life cycle

{

 ContainerExpression (ModelPart &rModelPart)
 Constructor with the model part. More...
 
 ContainerExpression (const ContainerExpression &rOther)
 Copy constructor. More...
 
ContainerExpressionoperator= (const ContainerExpression &rOther)
 Assignment operator. More...
 
virtual ~ContainerExpression ()=default
 
Public operations
ContainerExpression::Pointer Clone () const
 Clones the existing data container. More...
 
void CopyFrom (const ContainerExpression< TContainerType, TMeshType > &rOther)
 Copies the data from another same type container variable data. More...
 
Input and output
void SetExpression (Expression::ConstPointer pExpression)
 Set the Expression of the container data. More...
 
bool HasExpression () const
 Checks whether an expression has been initialized. More...
 
const ExpressionGetExpression () const
 Get the Expression. More...
 
Expression::ConstPointer pGetExpression () const
 Get the expression pointer. More...
 
const std::vector< IndexTypeGetItemShape () const
 Get the shape of the expression data. More...
 
IndexType GetItemComponentCount () const
 Get the Local Size of the data. More...
 
ModelPartpGetModelPart () const
 Get the pointer to underlying model part. More...
 
ModelPartGetModelPart ()
 Get the Model Part used in the container data. More...
 
const ModelPartGetModelPart () const
 Get the Model Part used in the container. More...
 
TContainerType & GetContainer ()
 Get the Container of the model part. More...
 
const TContainerType & GetContainer () const
 Get the Container of the model part. More...
 
IndexType GetMaxDepth () const
 Get the Max Depth of the lazy expression tree. More...
 
virtual std::string Info () const
 Get the info string. More...
 
std::string PrintData () const
 Prints containing data. More...
 
Public operators
ContainerExpressionoperator+= (const double Value)
 
ContainerExpressionoperator+= (const ContainerExpression &Value)
 
ContainerExpressionoperator-= (const double Value)
 
ContainerExpressionoperator-= (const ContainerExpression &Value)
 
ContainerExpressionoperator*= (const double Value)
 
ContainerExpressionoperator*= (const ContainerExpression &Value)
 
ContainerExpressionoperator/= (const double Value)
 
ContainerExpressionoperator/= (const ContainerExpression &Value)
 

Protected Attributes

Protected member variables
std::optional< Expression::ConstPointermpExpression
 
ModelPart *const mpModelPart
 

Type definitions

using IndexType = std::size_t
 
 KRATOS_CLASS_POINTER_DEFINITION (ContainerExpression)
 

Detailed Description

template<class TContainerType, MeshType TMeshType = MeshType::Local>
class Kratos::ContainerExpression< TContainerType, TMeshType >

Container variable data holder.

Instances of this class are used to hold any type of data in a container of TContainerType. TContainerType can be a container of nodes, conditions or elements. The data is stored as an Expression. The expression can be one of the followings:

 1. A literal expression is a concrete value expression. Followints are the eg. types:
         LiteralExpression<double>: This expression holds a single double value for
                                  all the entities of the TContainerType. This is light weight.
         LiteralExpression<array_1d<double, 3>>: This expression holds a single array3 value for
                                  all the entities of the TContainerType. This is light weight.
         LiteralFlatExpression: This expression can hold double, array3 different values for
                                  all the entities of the TContainerType. In this case, the dimension
                                  of the original data is stored, and then higher dimensional entity data
                                  is flattened out to a single vector. This will occupy almost the same memory as
                                  the variable data is stored in nodes/conditions/elements.
 2. A binary expression: These expressions does not hold any values, hence they are light weight.
                         They are used to store keep track of the operations carried on the LiteralExpressions.

Literal expressions are created on the following cases:

  1. When data is set using the VariableExpressionIO. Here, a LiteralFlatExpression is created.
  2. When data is reset to one value using either DataExpression::SetDataToZero or Here a LiteralExpression<double> or LiteralExpression<array_1d<double, 3>> is created.
  3. When a ContainerExpression is used with "+", "-", "*", "/", "Pow" operators with double values in right operand.

BinaryExpressions are created on the followin cases:

  1. When a ContainerExpression is operated with "+", "-", "*", "/", "Pow".

ContainerExpression only holds double vector if any nodal, condition or element variable data needs to be stored for future calculations where the variable can be released to store new data. Hence same variable can be used to store different data in the same container.

When operatos such as "+", "-", "*", "/", "Pow" are used on these containers in python or c++, it creates an expression. They are not evaluated and the results are not stored on vectors hence avoiding unnecessary computations and unnecessary memory allocations and de-allocations.

This class's constructors are protected, hence no objects of this class can be created. This class is used as the common interface to transfer data between compatible data containers such as:

  1. Nodal historical and non-historical.
  2. Element and element properties.
  3. Condition and condition properties.

This class is optimized and compatible with OpenMP and MPI.

Template Parameters
TContainerTypeContainer type, should be nodal, condition or elemental.
TMeshTypeMesh type, should be Local, Ghost or Interface

Member Typedef Documentation

◆ IndexType

template<class TContainerType , MeshType TMeshType = MeshType::Local>
using Kratos::ContainerExpression< TContainerType, TMeshType >::IndexType = std::size_t

Constructor & Destructor Documentation

◆ ContainerExpression() [1/2]

template<class TContainerType , MeshType TMeshType>
Kratos::ContainerExpression< TContainerType, TMeshType >::ContainerExpression ( ModelPart rModelPart)

Constructor with the model part.

◆ ContainerExpression() [2/2]

template<class TContainerType , MeshType TMeshType>
Kratos::ContainerExpression< TContainerType, TMeshType >::ContainerExpression ( const ContainerExpression< TContainerType, TMeshType > &  rOther)

Copy constructor.

◆ ~ContainerExpression()

template<class TContainerType , MeshType TMeshType = MeshType::Local>
virtual Kratos::ContainerExpression< TContainerType, TMeshType >::~ContainerExpression ( )
virtualdefault

Member Function Documentation

◆ Clone()

template<class TContainerType , MeshType TMeshType>
ContainerExpression< TContainerType, TMeshType >::Pointer Kratos::ContainerExpression< TContainerType, TMeshType >::Clone

Clones the existing data container.

This clones existing specialized data container. This is light weight operation since this just clones the expression pointer. No data copying for the underlying data in expression is done.

Returns
ContainerExpression::Pointer

◆ CopyFrom()

template<class TContainerType , MeshType TMeshType>
void Kratos::ContainerExpression< TContainerType, TMeshType >::CopyFrom ( const ContainerExpression< TContainerType, TMeshType > &  rOther)

Copies the data from another same type container variable data.

This method is used to copy data from another variable data. The model parts should be matching to successfully copy data. This does not copy the data, it only copies the expression pointer, hence this operation is also a light weight operation.

Parameters
rOtherOther container variable data

◆ GetContainer() [1/2]

template<class TContainerType , MeshType TMeshType>
TContainerType & Kratos::ContainerExpression< TContainerType, TMeshType >::GetContainer

Get the Container of the model part.

This returns the container of the model part on which this container object is responsible for. It always returns the local mesh container.

Returns
TContainerType& Container of the model part

◆ GetContainer() [2/2]

template<class TContainerType , MeshType TMeshType>
const TContainerType & Kratos::ContainerExpression< TContainerType, TMeshType >::GetContainer

Get the Container of the model part.

This returns the container of the model part on which this container object is responsible for. It always returns the local mesh container.

Returns
const TContainerType& Container of the model part

◆ GetExpression()

template<class TContainerType , MeshType TMeshType>
const Expression & Kratos::ContainerExpression< TContainerType, TMeshType >::GetExpression

Get the Expression.

Returns
const Expression& Returns the reference of the expression

◆ GetItemComponentCount()

template<class TContainerType , MeshType TMeshType>
std::size_t Kratos::ContainerExpression< TContainerType, TMeshType >::GetItemComponentCount

Get the Local Size of the data.

This returns the local size which is the sum of available indices in each dimension.

Returns
IndexType

◆ GetItemShape()

template<class TContainerType , MeshType TMeshType>
const std::vector< std::size_t > Kratos::ContainerExpression< TContainerType, TMeshType >::GetItemShape

Get the shape of the expression data.

This returns the dimension of the underlying expression in each element of the vector.

Returns
const std::vector<IndexType>

◆ GetMaxDepth()

template<class TContainerType , MeshType TMeshType>
std::size_t Kratos::ContainerExpression< TContainerType, TMeshType >::GetMaxDepth

Get the Max Depth of the lazy expression tree.

Returns the maximum depth of the lazy expression tree.

Returns
IndexType Max depth of the lazy expression tree.

◆ GetModelPart() [1/2]

template<class TContainerType , MeshType TMeshType>
ModelPart & Kratos::ContainerExpression< TContainerType, TMeshType >::GetModelPart

Get the Model Part used in the container data.

Returns
ModelPart& Model part

◆ GetModelPart() [2/2]

template<class TContainerType , MeshType TMeshType>
const ModelPart & Kratos::ContainerExpression< TContainerType, TMeshType >::GetModelPart

Get the Model Part used in the container.

Returns
const ModelPart& Model part

◆ HasExpression()

template<class TContainerType , MeshType TMeshType>
bool Kratos::ContainerExpression< TContainerType, TMeshType >::HasExpression

Checks whether an expression has been initialized.

Returns
true If an expression is initialized.
false If an expression is not initialized.

◆ Info()

template<class TContainerType , MeshType TMeshType>
std::string Kratos::ContainerExpression< TContainerType, TMeshType >::Info
virtual

Get the info string.

Returns
std::string

◆ KRATOS_CLASS_POINTER_DEFINITION()

template<class TContainerType , MeshType TMeshType = MeshType::Local>
Kratos::ContainerExpression< TContainerType, TMeshType >::KRATOS_CLASS_POINTER_DEFINITION ( ContainerExpression< TContainerType, TMeshType >  )

◆ operator*=() [1/2]

template<class TContainerType , MeshType TMeshType = MeshType::Local>
ContainerExpression& Kratos::ContainerExpression< TContainerType, TMeshType >::operator*= ( const ContainerExpression< TContainerType, TMeshType > &  Value)

◆ operator*=() [2/2]

template<class TContainerType , MeshType TMeshType = MeshType::Local>
ContainerExpression& Kratos::ContainerExpression< TContainerType, TMeshType >::operator*= ( const double  Value)

◆ operator+=() [1/2]

template<class TContainerType , MeshType TMeshType = MeshType::Local>
ContainerExpression& Kratos::ContainerExpression< TContainerType, TMeshType >::operator+= ( const ContainerExpression< TContainerType, TMeshType > &  Value)

◆ operator+=() [2/2]

template<class TContainerType , MeshType TMeshType = MeshType::Local>
ContainerExpression& Kratos::ContainerExpression< TContainerType, TMeshType >::operator+= ( const double  Value)

◆ operator-=() [1/2]

template<class TContainerType , MeshType TMeshType = MeshType::Local>
ContainerExpression& Kratos::ContainerExpression< TContainerType, TMeshType >::operator-= ( const ContainerExpression< TContainerType, TMeshType > &  Value)

◆ operator-=() [2/2]

template<class TContainerType , MeshType TMeshType = MeshType::Local>
ContainerExpression& Kratos::ContainerExpression< TContainerType, TMeshType >::operator-= ( const double  Value)

◆ operator/=() [1/2]

template<class TContainerType , MeshType TMeshType = MeshType::Local>
ContainerExpression& Kratos::ContainerExpression< TContainerType, TMeshType >::operator/= ( const ContainerExpression< TContainerType, TMeshType > &  Value)

◆ operator/=() [2/2]

template<class TContainerType , MeshType TMeshType = MeshType::Local>
ContainerExpression& Kratos::ContainerExpression< TContainerType, TMeshType >::operator/= ( const double  Value)

◆ operator=()

template<class TContainer , MeshType TMesh>
ContainerExpression< TContainer, TMesh > & Kratos::ContainerExpression< TContainer, TMesh >::operator= ( const ContainerExpression< TContainerType, TMeshType > &  rOther)

Assignment operator.

◆ pGetExpression()

template<class TContainerType , MeshType TMeshType>
Expression::ConstPointer Kratos::ContainerExpression< TContainerType, TMeshType >::pGetExpression

Get the expression pointer.

Returns
Expression::ConstPointer Returns the pointer of the expression

◆ pGetModelPart()

template<class TContainerType , MeshType TMeshType>
ModelPart * Kratos::ContainerExpression< TContainerType, TMeshType >::pGetModelPart

Get the pointer to underlying model part.

Returns
ModelPart* const

◆ PrintData()

template<class TContainerType , MeshType TMeshType>
std::string Kratos::ContainerExpression< TContainerType, TMeshType >::PrintData

Prints containing data.

Returns
std::string

◆ SetExpression()

template<class TContainerType , MeshType TMeshType>
void Kratos::ContainerExpression< TContainerType, TMeshType >::SetExpression ( Expression::ConstPointer  pExpression)

Set the Expression of the container data.

Parameters
pExpressionExpression to be used in this container variable data

Member Data Documentation

◆ mpExpression

template<class TContainerType , MeshType TMeshType = MeshType::Local>
std::optional<Expression::ConstPointer> Kratos::ContainerExpression< TContainerType, TMeshType >::mpExpression
protected

◆ mpModelPart

template<class TContainerType , MeshType TMeshType = MeshType::Local>
ModelPart* const Kratos::ContainerExpression< TContainerType, TMeshType >::mpModelPart
protected

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