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.
|
Container variable data holder. More...
#include <container_expression.h>
Public Member Functions | |
Life cycle | |
{ | |
ContainerExpression (ModelPart &rModelPart) | |
Constructor with the model part. More... | |
ContainerExpression (const ContainerExpression &rOther) | |
Copy constructor. More... | |
ContainerExpression & | operator= (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 Expression & | GetExpression () const |
Get the Expression. More... | |
Expression::ConstPointer | pGetExpression () const |
Get the expression pointer. More... | |
const std::vector< IndexType > | GetItemShape () const |
Get the shape of the expression data. More... | |
IndexType | GetItemComponentCount () const |
Get the Local Size of the data. More... | |
ModelPart * | pGetModelPart () const |
Get the pointer to underlying model part. More... | |
ModelPart & | GetModelPart () |
Get the Model Part used in the container data. More... | |
const ModelPart & | GetModelPart () 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 | |
ContainerExpression & | operator+= (const double Value) |
ContainerExpression & | operator+= (const ContainerExpression &Value) |
ContainerExpression & | operator-= (const double Value) |
ContainerExpression & | operator-= (const ContainerExpression &Value) |
ContainerExpression & | operator*= (const double Value) |
ContainerExpression & | operator*= (const ContainerExpression &Value) |
ContainerExpression & | operator/= (const double Value) |
ContainerExpression & | operator/= (const ContainerExpression &Value) |
Protected Attributes | |
Protected member variables | |
std::optional< Expression::ConstPointer > | mpExpression |
ModelPart *const | mpModelPart |
Type definitions | |
using | IndexType = std::size_t |
KRATOS_CLASS_POINTER_DEFINITION (ContainerExpression) | |
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:
BinaryExpressions are created on the followin cases:
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:
This class is optimized and compatible with OpenMP and MPI.
TContainerType | Container type, should be nodal, condition or elemental. |
TMeshType | Mesh type, should be Local, Ghost or Interface |
using Kratos::ContainerExpression< TContainerType, TMeshType >::IndexType = std::size_t |
Kratos::ContainerExpression< TContainerType, TMeshType >::ContainerExpression | ( | ModelPart & | rModelPart | ) |
Constructor with the model part.
Kratos::ContainerExpression< TContainerType, TMeshType >::ContainerExpression | ( | const ContainerExpression< TContainerType, TMeshType > & | rOther | ) |
Copy constructor.
|
virtualdefault |
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.
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.
rOther | Other container variable data |
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.
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.
const Expression & Kratos::ContainerExpression< TContainerType, TMeshType >::GetExpression |
Get the Expression.
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.
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.
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.
ModelPart & Kratos::ContainerExpression< TContainerType, TMeshType >::GetModelPart |
const ModelPart & Kratos::ContainerExpression< TContainerType, TMeshType >::GetModelPart |
bool Kratos::ContainerExpression< TContainerType, TMeshType >::HasExpression |
Checks whether an expression has been initialized.
|
virtual |
Get the info string.
Kratos::ContainerExpression< TContainerType, TMeshType >::KRATOS_CLASS_POINTER_DEFINITION | ( | ContainerExpression< TContainerType, TMeshType > | ) |
ContainerExpression& Kratos::ContainerExpression< TContainerType, TMeshType >::operator*= | ( | const ContainerExpression< TContainerType, TMeshType > & | Value | ) |
ContainerExpression& Kratos::ContainerExpression< TContainerType, TMeshType >::operator*= | ( | const double | Value | ) |
ContainerExpression& Kratos::ContainerExpression< TContainerType, TMeshType >::operator+= | ( | const ContainerExpression< TContainerType, TMeshType > & | Value | ) |
ContainerExpression& Kratos::ContainerExpression< TContainerType, TMeshType >::operator+= | ( | const double | Value | ) |
ContainerExpression& Kratos::ContainerExpression< TContainerType, TMeshType >::operator-= | ( | const ContainerExpression< TContainerType, TMeshType > & | Value | ) |
ContainerExpression& Kratos::ContainerExpression< TContainerType, TMeshType >::operator-= | ( | const double | Value | ) |
ContainerExpression& Kratos::ContainerExpression< TContainerType, TMeshType >::operator/= | ( | const ContainerExpression< TContainerType, TMeshType > & | Value | ) |
ContainerExpression& Kratos::ContainerExpression< TContainerType, TMeshType >::operator/= | ( | const double | Value | ) |
ContainerExpression< TContainer, TMesh > & Kratos::ContainerExpression< TContainer, TMesh >::operator= | ( | const ContainerExpression< TContainerType, TMeshType > & | rOther | ) |
Assignment operator.
Expression::ConstPointer Kratos::ContainerExpression< TContainerType, TMeshType >::pGetExpression |
Get the expression pointer.
ModelPart * Kratos::ContainerExpression< TContainerType, TMeshType >::pGetModelPart |
Get the pointer to underlying model part.
std::string Kratos::ContainerExpression< TContainerType, TMeshType >::PrintData |
Prints containing data.
void Kratos::ContainerExpression< TContainerType, TMeshType >::SetExpression | ( | Expression::ConstPointer | pExpression | ) |
Set the Expression of the container data.
pExpression | Expression to be used in this container variable data |
|
protected |
|
protected |