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

#include <expression_utils.h>

Collaboration diagram for Kratos::ExpressionUtils:

Public Types

Type definitions
using IndexType = std::size_t
 

Static Public Member Functions

Static entity value operations
static Expression::ConstPointer Collapse (const Expression::ConstPointer &rpExpression)
 Collapse the lazy expression tree structure in the expression. More...
 
static Expression::ConstPointer Slice (const Expression::ConstPointer &rpExpression, std::size_t Offset, std::size_t Stride)
 Construct an expression containing a subset of the components of all items. More...
 
template<class TIterator >
static Expression::ConstPointer Reshape (const Expression::ConstPointer &rpExpression, TIterator NewShapeBegin, TIterator NewShapeEnd)
 Construct an expression with identical data but interpreted with a new item shape. More...
 
static Expression::ConstPointer Reshape (const Expression::ConstPointer &rpExpression, const std::vector< IndexType > &rNewShape)
 Construct an expression with identical data but interpreted with a new item shape. More...
 
static Expression::ConstPointer Comb (const std::vector< Expression::ConstPointer > &rpExpressions)
 Append the components of a set of expressions to the current expression's components. More...
 
template<class TIterator >
static Expression::ConstPointer Comb (TIterator ExpressionBegin, TIterator ExpressionEnd)
 Append the components of a set of expressions to the current expression's components. More...
 
static Expression::ConstPointer Abs (const Expression::ConstPointer &rpExpression)
 Returns an expression which represents the component wise absolute value of the given expression. More...
 
static Expression::ConstPointer Pow (const Expression::ConstPointer &rpExpression, const double Power)
 Returns an expression which raises each component to the given power. More...
 
static Expression::ConstPointer Pow (const Expression::ConstPointer &rpExpression, const Expression::ConstPointer &rpPowerpExpression)
 Returns an expression which raises each component to the given power from another expression. More...
 
static Expression::ConstPointer Scale (const Expression::ConstPointer &rpExpression, const double Scale)
 Returns an expression which scales each component to the specified value. More...
 
static Expression::ConstPointer Scale (const Expression::ConstPointer &rpExpression, const Expression::ConstPointer &rpScaleExpression)
 Returns an expression which scales each component by a value from another expression. More...
 
static Expression::ConstPointer EntityMin (const Expression::ConstPointer &rpExpression)
 Returns an expression having min value from all the components for each entity. More...
 
static Expression::ConstPointer EntityMax (const Expression::ConstPointer &rpExpression)
 Returns an expression having max value from all the components for each entity. More...
 
static Expression::ConstPointer EntitySum (const Expression::ConstPointer &rpExpression)
 Returns an expression having sum of component values for each entity. More...
 
Static scalar reduction operations
static double Sum (const Expression::ConstPointer &rpExpression, const DataCommunicator &rDataCommunicator)
 Returns the sum of the expression assuming it is a flat vector [Shape is not considered]. More...
 
static double NormInf (const Expression::ConstPointer &rpExpression, const DataCommunicator &rDataCommunicator)
 Returns the infinity norm of the expression assuming it is a flat vector [Shape is not considered]. More...
 
static double NormL2 (const Expression::ConstPointer &rpExpression, const DataCommunicator &rDataCommunicator)
 Returns the L2 norm of the expression assuming it is a flat vector [Shape is not considered]. More...
 
static double NormP (const Expression::ConstPointer &rpExpression, const double P, const DataCommunicator &rDataCommunicator)
 Returns the P norm of the expression assuming it is a flat vector [Shape is not considered]. More...
 
static double InnerProduct (const Expression::ConstPointer &rpExpression1, const Expression::ConstPointer &rpExpression2, const DataCommunicator &rDataCommunicator)
 Returns the inner product between two expressions. More...
 
Static Container expression operations
template<class TContainerType >
static ContainerExpression< TContainerType > Collapse (const ContainerExpression< TContainerType > &rContainerExpression)
 Returns a container expression having Collapse evaluated on the given rContainerExpression's expression. More...
 
template<class TContainerType >
static ContainerExpression< TContainerType > Abs (const ContainerExpression< TContainerType > &rContainerExpression)
 Returns a container expression having Abs evaluated on the given rContainerExpression's expression. More...
 
template<class TContainerType >
static ContainerExpression< TContainerType > EntityMin (const ContainerExpression< TContainerType > &rContainerExpression)
 Returns a container expression having EntityMin evaluated on the given rContainerExpression's expression. More...
 
template<class TContainerType >
static ContainerExpression< TContainerType > EntityMax (const ContainerExpression< TContainerType > &rContainerExpression)
 Returns a container expression having EntityMax evaluated on the given rContainerExpression's expression. More...
 
template<class TContainerType >
static ContainerExpression< TContainerType > EntitySum (const ContainerExpression< TContainerType > &rContainerExpression)
 Returns a container expression having EntitySum evaluated on the given rContainerExpression's expression. More...
 
template<class TContainerType >
static double Sum (const ContainerExpression< TContainerType > &rContainerExpression)
 Returns a reduced value by evaluating Sum on the given rContainerExpression's expression. More...
 
template<class TContainerType >
static double NormInf (const ContainerExpression< TContainerType > &rContainerExpression)
 Returns a reduced value by evaluating NormInf on the given rContainerExpression's expression. More...
 
template<class TContainerType >
static double NormL2 (const ContainerExpression< TContainerType > &rContainerExpression)
 Returns a reduced value by evaluating NormL2 on the given rContainerExpression's expression. More...
 
template<class TContainerType >
static ContainerExpression< TContainerType > Pow (const ContainerExpression< TContainerType > &rContainerExpression, const double Value)
 Returns a container expression by evaluating Pow on the given rContainerExpression's expression using Value. More...
 
template<class TContainerType >
static ContainerExpression< TContainerType > Pow (const ContainerExpression< TContainerType > &rContainerExpression1, const ContainerExpression< TContainerType > &rContainerExpression2)
 Returns a container expression by evaluating Pow on the given rContainerExpression's expression using rContainerExpression2's expression. More...
 
template<class TContainerType >
static ContainerExpression< TContainerType > Scale (const ContainerExpression< TContainerType > &rContainerExpression, const double Value)
 Returns a container expression by evaluating Scale on the given rContainerExpression's expression using Value. More...
 
template<class TContainerType >
static ContainerExpression< TContainerType > Scale (const ContainerExpression< TContainerType > &rContainerExpression1, const ContainerExpression< TContainerType > &rContainerExpression2)
 Returns a container expression by evaluating Scale on the given rContainerExpression's expression using rContainerExpression2's expression. More...
 
template<class TContainerType >
static ContainerExpression< TContainerType > Slice (const ContainerExpression< TContainerType > &rContainerExpression, std::size_t Offset, std::size_t Stride)
 Slicing given container expression's expression. More...
 
template<class TContainerType , class TIterator >
static ContainerExpression< TContainerType > Reshape (const ContainerExpression< TContainerType > &rContainerExpression, TIterator NewShapeBegin, TIterator NewShapeEnd)
 Reshape the data in the given container expression's expression. More...
 
template<class TContainerType >
static ContainerExpression< TContainerType > Reshape (const ContainerExpression< TContainerType > &rContainerExpression, const std::vector< IndexType > &rNewShape)
 Reshape the data in the given container expression's expression. More...
 
template<class TContainerType >
static ContainerExpression< TContainerType > Comb (const std::vector< typename ContainerExpression< TContainerType >::Pointer > &rpContainerExpressions)
 Append the components of a set of container expressions' expression to the current container expression's expression components. More...
 
template<class TContainerType >
static double NormP (const ContainerExpression< TContainerType > &rContainerExpression, const double P)
 Computes the P norm of the given container expression's expression. More...
 
template<class TContainerType >
static double InnerProduct (const ContainerExpression< TContainerType > &rContainerExpression1, const ContainerExpression< TContainerType > &rContainerExpression2)
 Computes inner product between two container expressions's expressions. More...
 

Member Typedef Documentation

◆ IndexType

Member Function Documentation

◆ Abs() [1/2]

template<class TContainerType >
static ContainerExpression<TContainerType> Kratos::ExpressionUtils::Abs ( const ContainerExpression< TContainerType > &  rContainerExpression)
inlinestatic

Returns a container expression having Abs evaluated on the given rContainerExpression's expression.

See also
Abs .
Template Parameters
TContainerTypeContainer type.
Parameters
ContainerExpression<TContainerType>Container expression to apply Abs .
Returns
ContainerExpression<TContainerType> Resulting container expression.

◆ Abs() [2/2]

Expression::ConstPointer Kratos::ExpressionUtils::Abs ( const Expression::ConstPointer rpExpression)
static

Returns an expression which represents the component wise absolute value of the given expression.

If the input rpExpression is \(\underline{\mathbb{u}}\), where \(u_{ij}\) representss \(j^{th}\) component of the flattened entity data for \(i^{th}\) entity , then the returned expression \(\left|\underline{\mathbb{u}}\right|\)

\[ \left|\underline{\mathbb{u}}\right| = \left|u_{ij}\right| \]

Returns
Expression::ConstPointer Expression which computes component wise absolute value.

◆ Collapse() [1/2]

template<class TContainerType >
static ContainerExpression<TContainerType> Kratos::ExpressionUtils::Collapse ( const ContainerExpression< TContainerType > &  rContainerExpression)
inlinestatic

Returns a container expression having Collapse evaluated on the given rContainerExpression's expression.

See also
Collapse .
Template Parameters
TContainerTypeContainer type.
Parameters
ContainerExpression<TContainerType>Container expression to apply Collapse .
Returns
ContainerExpression<TContainerType> Resulting container expression.

◆ Collapse() [2/2]

Expression::ConstPointer Kratos::ExpressionUtils::Collapse ( const Expression::ConstPointer rpExpression)
static

Collapse the lazy expression tree structure in the expression.

This method returns an expression which is created by collapsing the tree structure in the rpExpression. This is useful in cases, when the expression tree becomes large and memory intensive, so the tree can be collapsed to a one leaf expression releasing memory. This has to evaluate the expression for each entity, hence this is a computationly expensive task.

This method is optimized and compatible with OpenMP and MPI.

Parameters
rpExpressionExpression to collapse the lazy expression tree.
Returns
Expression::ConstPointer Collapsed expression.

◆ Comb() [1/3]

Expression::ConstPointer Kratos::ExpressionUtils::Comb ( const std::vector< Expression::ConstPointer > &  rpExpressions)
static

Append the components of a set of expressions to the current expression's components.

This method combines a set of expressions into the current one as explained in the following example: All provided expressions in rpExpressions must have the same number of items.

For example, let rpExpressions contain the following expressions:

rpExpressions[0] = data{1, 2, 3} with 3 items, and item shape = []
- - -
pybind11::list items(Parameters const &self)
Definition: add_kratos_parameters_to_python.cpp:24
data
Definition: mesh_to_mdpa_converter.py:59
rpExpressions[1] = data{4, 5, 6, 7, 8, 9} with 3 items, and item shape = [2]
---- ---- ----

The resulting expression has item shape [3] with 3 items:

output_data = [1, 4, 5, 2, 6, 7, 3, 8, 9]
------- ------- -------

This creates a lazy expression, hence it has a constant cost complexity irrespective of the data size (The expression won't be evaluated unless Expression::Evaluate is called).

Parameters
rpExpressionsExpressions to comb components from.

◆ Comb() [2/3]

template<class TContainerType >
static ContainerExpression<TContainerType> Kratos::ExpressionUtils::Comb ( const std::vector< typename ContainerExpression< TContainerType >::Pointer > &  rpContainerExpressions)
inlinestatic

Append the components of a set of container expressions' expression to the current container expression's expression components.

See also
Comb
Exceptions
Ifthe rpContainerExpressions is empty.
Template Parameters
TContainerTypeType of the data container
Parameters
rpContainerExpressionsList of container expressions to comb through.
Returns
ContainerExpression<TContainerType> Resulting container expression.

◆ Comb() [3/3]

template<class TIterator >
static Expression::ConstPointer Kratos::ExpressionUtils::Comb ( TIterator  ExpressionBegin,
TIterator  ExpressionEnd 
)
inlinestatic

Append the components of a set of expressions to the current expression's components.

This method combines a set of expressions into the current one as explained in the following example: All provided expressions in the { ExpressionBegin, ExpressionEnd } range must have the same number of items.

For example, let the { ExpressionBegin, ExpressionEnd } range contain the following expressions:

ExpressionBegin[0] = data{1, 2, 3} with 3 items, and item shape = []
- - -
ExpressionBegin[1] = data{4, 5, 6, 7, 8, 9} with 3 items, and item shape = [2]
---- ---- ----

The resulting expression has item shape [3] with 3 items:

output_data = [1, 4, 5, 2, 6, 7, 3, 8, 9]
------- ------- -------

This creates a lazy expression, hence it has a constant cost complexity irrespective of the data size (The expression won't be evaluated unless Expression::Evaluate is called).

Parameters
ExpressionBeginIterator pointing to the first expression to comb components from.
ExpressionEndIterator past the last expression to comb components from.

◆ EntityMax() [1/2]

template<class TContainerType >
static ContainerExpression<TContainerType> Kratos::ExpressionUtils::EntityMax ( const ContainerExpression< TContainerType > &  rContainerExpression)
inlinestatic

Returns a container expression having EntityMax evaluated on the given rContainerExpression's expression.

See also
EntityMax .
Template Parameters
TContainerTypeContainer type.
Parameters
ContainerExpression<TContainerType>Container expression to apply EntityMax .
Returns
ContainerExpression<TContainerType> Resulting container expression.

◆ EntityMax() [2/2]

Expression::ConstPointer Kratos::ExpressionUtils::EntityMax ( const Expression::ConstPointer rpExpression)
static

Returns an expression having max value from all the components for each entity.

If the input rpExpression is \(\underline{\mathbb{u}}\), where \(u_{ij}\) representss \(j^{th}\) component of the flattened (having \(N\) total components) entity data for \(i^{th}\) entity , Following illustrates the returned expression which is always a scalar expression having \(m_i\) representing the \(i^{th}\) entity data.

\[ EntityMax(\underline{\mathbb{u}}) = m_{i} \]

Where,

\[ m_{i} = \max_{j\in \left[0, N\right)} u_{ij} \]

Returns
Expression::ConstPointer Scalar expression having the maximum of all components for each entity in the input expression.

◆ EntityMin() [1/2]

template<class TContainerType >
static ContainerExpression<TContainerType> Kratos::ExpressionUtils::EntityMin ( const ContainerExpression< TContainerType > &  rContainerExpression)
inlinestatic

Returns a container expression having EntityMin evaluated on the given rContainerExpression's expression.

See also
EntityMin .
Template Parameters
TContainerTypeContainer type.
Parameters
ContainerExpression<TContainerType>Container expression to apply EntityMin .
Returns
ContainerExpression<TContainerType> Resulting container expression.

◆ EntityMin() [2/2]

Expression::ConstPointer Kratos::ExpressionUtils::EntityMin ( const Expression::ConstPointer rpExpression)
static

Returns an expression having min value from all the components for each entity.

If the input rpExpression is \(\underline{\mathbb{u}}\), where \(u_{ij}\) representss \(j^{th}\) component of the flattened (having \(N\) total components) entity data for \(i^{th}\) entity , Following illustrates the returned expression which is always a scalar expression having \(m_i\) representing the \(i^{th}\) entity data.

\[ EntityMin(\underline{\mathbb{u}}) = m_{i} \]

Where,

\[ m_{i} = \min_{j\in \left[0, N\right)} u_{ij} \]

Returns
Expression::ConstPointer Scalar expression having the minimum of all components for each entity in the input expression.

◆ EntitySum() [1/2]

template<class TContainerType >
static ContainerExpression<TContainerType> Kratos::ExpressionUtils::EntitySum ( const ContainerExpression< TContainerType > &  rContainerExpression)
inlinestatic

Returns a container expression having EntitySum evaluated on the given rContainerExpression's expression.

See also
EntitySum .
Template Parameters
TContainerTypeContainer type.
Parameters
ContainerExpression<TContainerType>Container expression to apply EntitySum .
Returns
ContainerExpression<TContainerType> Resulting container expression.

◆ EntitySum() [2/2]

Expression::ConstPointer Kratos::ExpressionUtils::EntitySum ( const Expression::ConstPointer rpExpression)
static

Returns an expression having sum of component values for each entity.

If the input rpExpression is \(\underline{\mathbb{u}}\), where \(u_{ij}\) representss \(j^{th}\) component of the flattened (having \(N\) total components) entity data for \(i^{th}\) entity , Following illustrates the returned expression which is always a scalar expression having \(m_i\) representing the \(i^{th}\) entity data.

\[ EntitySum(\underline{\mathbb{u}}) = m_{i} \]

Where,

\[ m_{i} = \sum_{j\in \left[0, N\right)} u_{ij} \]

Returns
Expression::ConstPointer Scalar expression having the sum of all components for each entity in the input expression.

◆ InnerProduct() [1/2]

template<class TContainerType >
static double Kratos::ExpressionUtils::InnerProduct ( const ContainerExpression< TContainerType > &  rContainerExpression1,
const ContainerExpression< TContainerType > &  rContainerExpression2 
)
inlinestatic

Computes inner product between two container expressions's expressions.

See also
InnerProduct
Template Parameters
TContainerTypeContainer type.
Parameters
rContainerExpression1Container expression 1.
rContainerExpression2Container expression 2.
Returns
double Inner product.

◆ InnerProduct() [2/2]

double Kratos::ExpressionUtils::InnerProduct ( const Expression::ConstPointer rpExpression1,
const Expression::ConstPointer rpExpression2,
const DataCommunicator rDataCommunicator 
)
static

Returns the inner product between two expressions.

If the input rpExpression1 is \(\underline{\mathbb{u}}\), where \(u_{ij}\) representss \(j^{th}\) component of the flattened (having \(N\) total components) entity data for \(i^{th}\) entity (having \(M\) entities) and the input rpExpression2 is \(\underline{\mathbb{v}}\), where \(v_{ij}\) representss \(j^{th}\) component of the flattened (having \(N\) total components) entity data for \(i^{th}\) entity (having \(M\) entities), Following illustrates the returned value where the entity data is flattened. This does not consider shapes of the expressions. They should have same size of flattened vectors.

\[ InnerProduct(\underline{\mathbb{u}}, \underline{\mathbb{v}}) = \sum_{i\in \left[0, M\right)} \sum_{j\in \left[0, N\right)} u_{ij} \times v_{ij} \]

This method is compatible with shared and distributed memory parallelized runs.

Exceptions
Ifthe flattend size mismatch.
Ifthe number of entities mismatch.
Parameters
rpExpression1Expression1.
rpExpression1Expression2.
rDataCommunicatorData communicator for MPI communication.
Returns
double The inner product of rpExpression1 and rpExpression2

◆ NormInf() [1/2]

template<class TContainerType >
static double Kratos::ExpressionUtils::NormInf ( const ContainerExpression< TContainerType > &  rContainerExpression)
inlinestatic

Returns a reduced value by evaluating NormInf on the given rContainerExpression's expression.

See also
NormInf .
Template Parameters
TContainerTypeContainer type.
Parameters
ContainerExpression<TContainerType>Container expression to apply NormInf .
Returns
double Resulting scalar value after evaluating NormInf on rContainerExpression.

◆ NormInf() [2/2]

double Kratos::ExpressionUtils::NormInf ( const Expression::ConstPointer rpExpression,
const DataCommunicator rDataCommunicator 
)
static

Returns the infinity norm of the expression assuming it is a flat vector [Shape is not considered].

If the input rpExpression is \(\underline{\mathbb{u}}\), where \(u_{ij}\) representss \(j^{th}\) component of the flattened (having \(N\) total components) entity data for \(i^{th}\) entity (having \(M\) entities) , Following illustrates the returned value where the entity data is flattened.

\[ NormInf(\underline{\mathbb{u}}) = \max_{(i,j)\in \left[0, M\right)\times \left[0, N\right)} \left|u_{ij}\right| \]

This method is compatible with shared and distributed memory parallelized runs.

Parameters
rpExpressionExpressions to be summed.
rDataCommunicatorData communicator for MPI communication.
Returns
double The infinity norm of all the components in all the entities.

◆ NormL2() [1/2]

template<class TContainerType >
static double Kratos::ExpressionUtils::NormL2 ( const ContainerExpression< TContainerType > &  rContainerExpression)
inlinestatic

Returns a reduced value by evaluating NormL2 on the given rContainerExpression's expression.

See also
NormL2 .
Template Parameters
TContainerTypeContainer type.
Parameters
ContainerExpression<TContainerType>Container expression to apply NormL2 .
Returns
double Resulting scalar value after evaluating NormL2 on rContainerExpression.

◆ NormL2() [2/2]

double Kratos::ExpressionUtils::NormL2 ( const Expression::ConstPointer rpExpression,
const DataCommunicator rDataCommunicator 
)
static

Returns the L2 norm of the expression assuming it is a flat vector [Shape is not considered].

If the input rpExpression is \(\underline{\mathbb{u}}\), where \(u_{ij}\) representss \(j^{th}\) component of the flattened (having \(N\) total components) entity data for \(i^{th}\) entity (having \(M\) entities) , Following illustrates the returned value where the entity data is flattened.

\[ NormL2(\underline{\mathbb{u}}) = \sqrt {\sum_{i\in \left[0, M\right)} \sum_{j\in \left[0, N\right)} u_{ij}^2} \]

This method is compatible with shared and distributed memory parallelized runs.

Parameters
rpExpressionExpressions to be summed.
rDataCommunicatorData communicator for MPI communication.
Returns
double The L2 norm of all the components in all the entities.

◆ NormP() [1/2]

template<class TContainerType >
static double Kratos::ExpressionUtils::NormP ( const ContainerExpression< TContainerType > &  rContainerExpression,
const double  P 
)
inlinestatic

Computes the P norm of the given container expression's expression.

See also
NormP
Template Parameters
TContainerTypeContainer type.
Parameters
rContainerExpressionInput container expression.
PNorm coefficient.
Returns
double Resulting p norm.

◆ NormP() [2/2]

double Kratos::ExpressionUtils::NormP ( const Expression::ConstPointer rpExpression,
const double  P,
const DataCommunicator rDataCommunicator 
)
static

Returns the P norm of the expression assuming it is a flat vector [Shape is not considered].

If the input rpExpression is \(\underline{\mathbb{u}}\), where \(u_{ij}\) representss \(j^{th}\) component of the flattened (having \(N\) total components) entity data for \(i^{th}\) entity (having \(M\) entities) , Following illustrates the returned value where the entity data is flattened.

\[ NormP(\underline{\mathbb{u}}, P) = \left(\sum_{i\in \left[0, M\right)} \sum_{j\in \left[0, N\right)} \left|u_{ij}\right|^P\right)^{1/P} \]

This method is compatible with shared and distributed memory parallelized runs.

Parameters
rpExpressionExpressions to be summed.
rDataCommunicatorData communicator for MPI communication.
PP norm coefficent.
Returns
double The P norm of all the components in all the entities.

◆ Pow() [1/4]

template<class TContainerType >
static ContainerExpression<TContainerType> Kratos::ExpressionUtils::Pow ( const ContainerExpression< TContainerType > &  rContainerExpression,
const double  Value 
)
inlinestatic

Returns a container expression by evaluating Pow on the given rContainerExpression's expression using Value.

See also
Pow .
Template Parameters
TContainerTypeContainer type.
Parameters
ContainerExpression<TContainerType>Container expression to apply Pow .
Returns
ContainerExpression<TContainerType> Resulting container expression.

◆ Pow() [2/4]

template<class TContainerType >
static ContainerExpression<TContainerType> Kratos::ExpressionUtils::Pow ( const ContainerExpression< TContainerType > &  rContainerExpression1,
const ContainerExpression< TContainerType > &  rContainerExpression2 
)
inlinestatic

Returns a container expression by evaluating Pow on the given rContainerExpression's expression using rContainerExpression2's expression.

See also
Pow .
Template Parameters
TContainerTypeContainer type.
Parameters
ContainerExpression<TContainerType>Container expression1 to apply Pow .
ContainerExpression<TContainerType>Container expression1 to apply Pow .
Returns
ContainerExpression<TContainerType> Resulting container expression.

◆ Pow() [3/4]

Expression::ConstPointer Kratos::ExpressionUtils::Pow ( const Expression::ConstPointer rpExpression,
const double  Power 
)
static

Returns an expression which raises each component to the given power.

If the input rpExpression is \(\underline{\mathbb{u}}\), where \(u_{ij}\) representss \(j^{th}\) component of the flattened entity data for \(i^{th}\) entity , where P is specified by Power.

\[ Pow(\underline{\mathbb{u}}, P) = u_{ij}^P \]

Returns
Expression::ConstPointer Expression which raises each component to specified power.

◆ Pow() [4/4]

Expression::ConstPointer Kratos::ExpressionUtils::Pow ( const Expression::ConstPointer rpExpression,
const Expression::ConstPointer rpPowerpExpression 
)
static

Returns an expression which raises each component to the given power from another expression.

If the input rpExpression is \(\underline{\mathbb{u}}\), where \(u_{ij}\) representss \(j^{th}\) component of the flattened entity data for \(i^{th}\) entity and the rpPowerpExpression is \(\underline{\mathbb{P}}\), where \(p_{ij}\) representss \(j^{th}\) component of the flattened entity data for \(i^{th}\) entity , then the returned expression can be illustrated as below.

\[ Pow(\underline{\mathbb{u}}, \underline{\mathbb{p}}) = u_{ij}^{p_{ij}} \]

If the given rpPowerpExpression is a scalar expression then the following will be returned

\[ Pow(\underline{\mathbb{u}}, \underline{\mathbb{p}}) = u_{ij}^{p_{i}} \]

Exceptions
Ifthe number of entities mismatch between rpExpression and rpPowerpExpression
Ifthe shape of the rpExpression and rpPowerpExpression does not match or rpPowerpExpression is not representing a scalar expression.
Returns
Expression::ConstPointer Expression which raises each component to specified power given by the rpPowerpExpression.

◆ Reshape() [1/4]

template<class TContainerType >
static ContainerExpression<TContainerType> Kratos::ExpressionUtils::Reshape ( const ContainerExpression< TContainerType > &  rContainerExpression,
const std::vector< IndexType > &  rNewShape 
)
inlinestatic

Reshape the data in the given container expression's expression.

See also
Reshape.
Template Parameters
TContainerTypeContainer type
Parameters
rContainerExpressionContainer expression to be sliced.
rNewShapeNew shape.
Returns
ContainerExpression<TContainerType> Resulting reshaped container expression.

◆ Reshape() [2/4]

template<class TContainerType , class TIterator >
static ContainerExpression<TContainerType> Kratos::ExpressionUtils::Reshape ( const ContainerExpression< TContainerType > &  rContainerExpression,
TIterator  NewShapeBegin,
TIterator  NewShapeEnd 
)
inlinestatic

Reshape the data in the given container expression's expression.

See also
Reshape.
Template Parameters
TContainerTypeContainer type
TIteratorIterator type for the shape.
Parameters
rContainerExpressionContainer expression to be sliced.
NewShapeBeginStarting iterator for the new shape.
NewShapeEndEnding iterator for the new shape
Returns
ContainerExpression<TContainerType> Resulting reshaped container expression.

◆ Reshape() [3/4]

Expression::ConstPointer Kratos::ExpressionUtils::Reshape ( const Expression::ConstPointer rpExpression,
const std::vector< IndexType > &  rNewShape 
)
static

Construct an expression with identical data but interpreted with a new item shape.

Reshaping is done on each entitiy's data array, and not on the flattened expression. For example:

Assume an Expression of shape [2, 3] and 2 entities with following data in the flattened representation:

data = [[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]
<-------- 1 ---------> <----------- 2 ----------->

The underlying data of the reshaped expression is interpreted as follows:

output_data = [[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]]
output container shape = [3, 2]
output
Definition: generate_frictional_mortar_condition.py:444

This creates a lazy expression, hence it has a constant cost complexity irrespective of the data size.

Parameters
rpExpressionExpression to reshape.
rNewShapeNew shape to used to reshape the existing expression.

◆ Reshape() [4/4]

template<class TIterator >
static Expression::ConstPointer Kratos::ExpressionUtils::Reshape ( const Expression::ConstPointer rpExpression,
TIterator  NewShapeBegin,
TIterator  NewShapeEnd 
)
inlinestatic

Construct an expression with identical data but interpreted with a new item shape.

Reshaping is done on each entitiy's data array, and not on the flattened expression. For example:

Assume an Expression of shape [2, 3] and 2 entities with following data in the flattened representation:

data = [[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]
<-------- 1 ---------> <----------- 2 ----------->

The underlying data of the reshaped expression is interpreted as follows:

output_data = [[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]]
output container shape = [3, 2]

This creates a lazy expression, hence it has a constant cost complexity irrespective of the data size.

Parameters
rpExpressionExpression to reshape.
NewShapeBeginIterator pointing to the first component of the new shape.
NewShapeEndIterator past the last component of the new shape.

◆ Scale() [1/4]

template<class TContainerType >
static ContainerExpression<TContainerType> Kratos::ExpressionUtils::Scale ( const ContainerExpression< TContainerType > &  rContainerExpression,
const double  Value 
)
inlinestatic

Returns a container expression by evaluating Scale on the given rContainerExpression's expression using Value.

See also
Scale .
Template Parameters
TContainerTypeContainer type.
Parameters
ContainerExpression<TContainerType>Container expression to apply Scale .
Returns
ContainerExpression<TContainerType> Resulting container expression.

◆ Scale() [2/4]

template<class TContainerType >
static ContainerExpression<TContainerType> Kratos::ExpressionUtils::Scale ( const ContainerExpression< TContainerType > &  rContainerExpression1,
const ContainerExpression< TContainerType > &  rContainerExpression2 
)
inlinestatic

Returns a container expression by evaluating Scale on the given rContainerExpression's expression using rContainerExpression2's expression.

See also
Scale .
Template Parameters
TContainerTypeContainer type.
Parameters
ContainerExpression<TContainerType>Container expression1 to apply Scale .
ContainerExpression<TContainerType>Container expression1 to apply Scale .
Returns
ContainerExpression<TContainerType> Resulting container expression.

◆ Scale() [3/4]

Expression::ConstPointer Kratos::ExpressionUtils::Scale ( const Expression::ConstPointer rpExpression,
const double  Scale 
)
static

Returns an expression which scales each component to the specified value.

If the input rpExpression is \(\underline{\mathbb{u}}\), where \(u_{ij}\) representss \(j^{th}\) component of the flattened entity data for \(i^{th}\) entity , where Scale is specified by Scale.

\[ Scale(\underline{\mathbb{u}}, S) = u_{ij}^S \]

Returns
Expression::ConstPointer Expression which scales the given expression by specified scale Scale

◆ Scale() [4/4]

Expression::ConstPointer Kratos::ExpressionUtils::Scale ( const Expression::ConstPointer rpExpression,
const Expression::ConstPointer rpScaleExpression 
)
static

Returns an expression which scales each component by a value from another expression.

If the input rpExpression is \(\underline{\mathbb{u}}\), where \(u_{ij}\) representss \(j^{th}\) component of the flattened entity data for \(i^{th}\) entity and the rpScaleExpression is \(\underline{\mathbb{s}}\), where \(s_{ij}\) representss \(j^{th}\) component of the flattened entity data for \(i^{th}\) entity , then the returned expression can be illustrated as below.

\[ Scale(\underline{\mathbb{u}}, \underline{\mathbb{s}}) = u_{ij}^{s_{ij}} \]

If the given rpScaleExpression is a scalar expression then the following will be returned

\[ Scale(\underline{\mathbb{u}}, \underline{\mathbb{s}}) = u_{ij}^{s_{i}} \]

Exceptions
Ifthe number of entities mismatch between rpExpression and rpScaleExpression
Ifthe shape of the rpExpression and rpScaleExpression does not match or rpScaleExpression is not representing a scalar expression.
Returns
Expression::ConstPointer Expression which scales each component to specified value given by the rpScaleExpression.

◆ Slice() [1/2]

template<class TContainerType >
static ContainerExpression<TContainerType> Kratos::ExpressionUtils::Slice ( const ContainerExpression< TContainerType > &  rContainerExpression,
std::size_t  Offset,
std::size_t  Stride 
)
inlinestatic

Slicing given container expression's expression.

See also
Slice.
Template Parameters
TContainerTypeContainer type
Parameters
rContainerExpressionContainer expression to be sliced.
OffsetIndex of the first component to begin slicing at.
StrideNumber of components from the offset in the sliced item.
Returns
ContainerExpression<TContainerType> Resulting sliced container expression.

◆ Slice() [2/2]

Expression::ConstPointer Kratos::ExpressionUtils::Slice ( const Expression::ConstPointer rpExpression,
std::size_t  Offset,
std::size_t  Stride 
)
static

Construct an expression containing a subset of the components of all items.

Slicing is done on each entitiy's data array, and not on the flattened expression. For example:

Assume an Expression of shape [5] and 2 entities with the following data in the flattened representation:

data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
<---- 1 ----> <----- 2 ----->

Data for entity 1 is represented with <–1-->.

Let

Offset = 1 @code and @code Stride = 3

. The resulting sliced expression then represents the following data:

output_data = [2, 3, 4, 7, 8, 9] output container shape = [3] = equal to Stride.

Slicing will always create a one dimensional array even if the input expression is multidimensional.

See also
Reshape to reshape the one dimensional array to the desired shape if required.

This creates a lazy expression, hence it has a constant cost complexity irrespective of the data size.

Parameters
OffsetIndex of the first component to begin slicing at.
StrideNumber of components from the offset in the sliced item.

◆ Sum() [1/2]

template<class TContainerType >
static double Kratos::ExpressionUtils::Sum ( const ContainerExpression< TContainerType > &  rContainerExpression)
inlinestatic

Returns a reduced value by evaluating Sum on the given rContainerExpression's expression.

See also
Sum .
Template Parameters
TContainerTypeContainer type.
Parameters
ContainerExpression<TContainerType>Container expression to apply Sum .
Returns
double Resulting scalar value after evaluating Sum on rContainerExpression.

◆ Sum() [2/2]

double Kratos::ExpressionUtils::Sum ( const Expression::ConstPointer rpExpression,
const DataCommunicator rDataCommunicator 
)
static

Returns the sum of the expression assuming it is a flat vector [Shape is not considered].

If the input rpExpression is \(\underline{\mathbb{u}}\), where \(u_{ij}\) representss \(j^{th}\) component of the flattened (having \(N\) total components) entity data for \(i^{th}\) entity (having \(M\) entities) , Following illustrates the returned value where the entity data is flattened.

\[ Sum(\underline{\mathbb{u}}) = \sum_{i\in \left[0, M\right)} \sum_{j\in \left[0, N\right)} u_{ij} \]

This method is compatible with shared and distributed memory parallelized runs.

Parameters
rpExpressionExpressions to be summed.
rDataCommunicatorData communicator for MPI communication.
Returns
double The sum of all the components in all the entities.

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