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.
Public Member Functions | List of all members
Kratos::VariableUtils Class Reference

This class implements a set of auxiliar, already parallelized, methods to perform some common tasks related with the variable values and fixity. More...

#include <variable_utils.h>

Collaboration diagram for Kratos::VariableUtils:

Public Member Functions

template<>
void AuxiliaryHistoricalValueSetter (const Variable< array_1d< double, 3 >> &rVariable, const array_1d< double, 3 > &rValue, NodeType &rNode)
 

Type Definitions

typedef ModelPart::NodeType NodeType
 The node type. More...
 
typedef ModelPart::ConditionType ConditionType
 The condition type. More...
 
typedef ModelPart::ElementType ElementType
 The element type. More...
 
typedef ModelPart::NodesContainerType NodesContainerType
 The nodes container. More...
 
typedef ModelPart::ConditionsContainerType ConditionsContainerType
 The conditions container. More...
 
typedef ModelPart::ElementsContainerType ElementsContainerType
 The elements container. More...
 
typedef Variable< doubleDoubleVarType
 A definition of the double variable. More...
 
typedef Variable< array_1d< double, 3 > > ArrayVarType
 A definition of the array variable. More...
 
 KRATOS_CLASS_POINTER_DEFINITION (VariableUtils)
 We create the Pointer related to VariableUtils. More...
 

Operations

template<class TVarType >
void CopyModelPartNodalVar (const TVarType &rVariable, const TVarType &rDestinationVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, const unsigned int ReadBufferStep, const unsigned int WriteBufferStep)
 Copies the nodal value of a variable from an origin model part nodes to the nodes in a destination model part. It is assumed that both origin and destination model parts have the same number of nodes. More...
 
template<class TVarType >
void CopyModelPartNodalVar (const TVarType &rVariable, const TVarType &rDestinationVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, const unsigned int BuffStep=0)
 Copies the nodal value of a variable from an origin model part nodes to the nodes in a destination model part. It is assumed that both origin and destination model parts have the same number of nodes. More...
 
template<class TVarType >
void CopyModelPartNodalVar (const TVarType &rVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, const unsigned int BuffStep=0)
 Copies the nodal value of a variable from an origin model part nodes to the nodes in a destination model part. It is assumed that both origin and destination model parts have the same number of nodes. More...
 
template<class TVarType >
void CopyModelPartNodalVarToNonHistoricalVar (const TVarType &rVariable, const TVarType &rDestinationVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, const unsigned int BuffStep=0)
 
template<class TVarType >
void CopyModelPartNodalVarToNonHistoricalVar (const TVarType &rVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, const unsigned int BuffStep=0)
 
template<class TDataType >
void CopyModelPartFlaggedNodalHistoricalVarToHistoricalVar (const Variable< TDataType > &rOriginVariable, const Variable< TDataType > &rDestinationVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, const Flags &rFlag, const bool CheckValue=true, const unsigned int ReadBufferStep=0, const unsigned int WriteBufferStep=0)
 
template<class TDataType >
void CopyModelPartFlaggedNodalHistoricalVarToHistoricalVar (const Variable< TDataType > &rOriginVariable, const Variable< TDataType > &rDestinationVariable, ModelPart &rModelPart, const Flags &rFlag, const bool CheckValue=true, const unsigned int ReadBufferStep=0, const unsigned int WriteBufferStep=0)
 
template<class TDataType >
void CopyModelPartFlaggedNodalHistoricalVarToHistoricalVar (const Variable< TDataType > &rVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, const Flags &rFlag, const bool CheckValue=true, const unsigned int ReadBufferStep=0, const unsigned int WriteBufferStep=0)
 
template<class TDataType >
void CopyModelPartFlaggedNodalHistoricalVarToNonHistoricalVar (const Variable< TDataType > &rOriginVariable, const Variable< TDataType > &rDestinationVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, const Flags &rFlag, const bool CheckValue=true, const unsigned int ReadBufferStep=0)
 
template<class TDataType >
void CopyModelPartFlaggedNodalHistoricalVarToNonHistoricalVar (const Variable< TDataType > &rOriginVariable, const Variable< TDataType > &rDestinationVariable, ModelPart &rModelPart, const Flags &rFlag, const bool CheckValue=true, const unsigned int ReadBufferStep=0)
 
template<class TDataType >
void CopyModelPartFlaggedNodalHistoricalVarToNonHistoricalVar (const Variable< TDataType > &rVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, const Flags &rFlag, const bool CheckValue=true, const unsigned int ReadBufferStep=0)
 
template<class TDataType >
void CopyModelPartFlaggedNodalHistoricalVarToNonHistoricalVar (const Variable< TDataType > &rVariable, ModelPart &rModelPart, const Flags &rFlag, const bool CheckValue=true, const unsigned int ReadBufferStep=0)
 
template<class TDataType >
void CopyModelPartFlaggedNodalNonHistoricalVarToHistoricalVar (const Variable< TDataType > &rOriginVariable, const Variable< TDataType > &rDestinationVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, const Flags &rFlag, const bool CheckValue=true, const unsigned int WriteBufferStep=0)
 
template<class TDataType >
void CopyModelPartFlaggedNodalNonHistoricalVarToHistoricalVar (const Variable< TDataType > &rOriginVariable, const Variable< TDataType > &rDestinationVariable, ModelPart &rModelPart, const Flags &rFlag, const bool CheckValue=true, const unsigned int WriteBufferStep=0)
 
template<class TDataType >
void CopyModelPartFlaggedNodalNonHistoricalVarToHistoricalVar (const Variable< TDataType > &rVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, const Flags &rFlag, const bool CheckValue=true, const unsigned int WriteBufferStep=0)
 
template<class TDataType >
void CopyModelPartFlaggedNodalNonHistoricalVarToHistoricalVar (const Variable< TDataType > &rVariable, ModelPart &rModelPart, const Flags &rFlag, const bool CheckValue=true, const unsigned int WriteBufferStep=0)
 
template<class TDataType >
void CopyModelPartFlaggedNodalNonHistoricalVarToNonHistoricalVar (const Variable< TDataType > &rOriginVariable, const Variable< TDataType > &rDestinationVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, const Flags &rFlag, const bool CheckValue=true)
 
template<class TDataType >
void CopyModelPartFlaggedNodalNonHistoricalVarToNonHistoricalVar (const Variable< TDataType > &rOriginVariable, const Variable< TDataType > &rDestinationVariable, ModelPart &rModelPart, const Flags &rFlag, const bool CheckValue=true)
 
template<class TDataType >
void CopyModelPartFlaggedNodalNonHistoricalVarToNonHistoricalVar (const Variable< TDataType > &rVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, const Flags &rFlag, const bool CheckValue=true)
 
template<class TDataType >
void CopyModelPartFlaggedElementVar (const Variable< TDataType > &rOriginVariable, const Variable< TDataType > &rDestinationVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, const Flags &rFlag, const bool CheckValue=true)
 
template<class TDataType >
void CopyModelPartFlaggedElementVar (const Variable< TDataType > &rOriginVariable, const Variable< TDataType > &rDestinationVariable, ModelPart &rModelPart, const Flags &rFlag, const bool CheckValue=true)
 
template<class TDataType >
void CopyModelPartFlaggedElementVar (const Variable< TDataType > &rVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, const Flags &rFlag, const bool CheckValue=true)
 
template<class TDataType >
void CopyModelPartFlaggedConditionVar (const Variable< TDataType > &rOriginVariable, const Variable< TDataType > &rDestinationVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, const Flags &rFlag, const bool CheckValue=true)
 
template<class TDataType >
void CopyModelPartFlaggedConditionVar (const Variable< TDataType > &rOriginVariable, const Variable< TDataType > &rDestinationVariable, ModelPart &rModelPart, const Flags &rFlag, const bool CheckValue=true)
 
template<class TDataType >
void CopyModelPartFlaggedConditionVar (const Variable< TDataType > &rVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, const Flags &rFlag, const bool CheckValue=true)
 
template<class TVarType >
void CopyModelPartElementalVar (const TVarType &rVariable, const ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart)
 Copies the elemental value of a variable from an origin model part elements to the elements in a destination model part. It is assumed that both origin and destination model parts have the same number of elements. More...
 
template<class TDataType , class TVarType = Variable<TDataType>>
void SetVariable (const TVarType &rVariable, const TDataType &rValue, NodesContainerType &rNodes, const unsigned int Step=0)
 Sets the nodal value of a scalar variable. More...
 
template<class TDataType , class TVarType = Variable<TDataType>>
void SetVariable (const TVarType &rVariable, const TDataType &rValue, NodesContainerType &rNodes, const Flags Flag, const bool CheckValue=true)
 Sets the nodal value of a scalar variable (considering flag) More...
 
template<class TType , class TContainerType >
void SetNonHistoricalVariableToZero (const Variable< TType > &rVariable, TContainerType &rContainer)
 Sets the nodal value of any variable to zero. More...
 
template<class TType >
void SetHistoricalVariableToZero (const Variable< TType > &rVariable, NodesContainerType &rNodes)
 Sets the nodal value of any variable to zero. More...
 
template<class TType , class TContainerType , class TVarType = Variable< TType >>
void SetNonHistoricalVariable (const TVarType &rVariable, const TType &Value, TContainerType &rContainer)
 Sets the container value of any type of non historical variable. More...
 
template<class TType , class TContainerType , class TVarType = Variable< TType >>
void SetNonHistoricalVariable (const TVarType &rVariable, const TType &rValue, TContainerType &rContainer, const Flags Flag, const bool Check=true)
 Sets the container value of any type of non historical variable (considering flag) More...
 
template<class TContainerType , class TVarType >
void EraseNonHistoricalVariable (const TVarType &rVariable, TContainerType &rContainer)
 Erases the container non historical variable. More...
 
template<class TContainerType >
void ClearNonHistoricalData (TContainerType &rContainer)
 Clears the container data value container. More...
 
template<class TDataType , class TContainerType , class TWeightDataType >
void WeightedAccumulateVariableOnNodes (ModelPart &rModelPart, const Variable< TDataType > &rVariable, const Variable< TWeightDataType > &rWeightVariable, const bool IsInverseWeightProvided=false)
 Distributes variable values in TContainerType container to nodes. More...
 
template<class TContainerType >
void SetFlag (const Flags &rFlag, const bool FlagValue, TContainerType &rContainer)
 Sets a flag according to a given status over a given container. More...
 
template<class TContainerType >
void ResetFlag (const Flags &rFlag, TContainerType &rContainer)
 Flips a flag over a given container. More...
 
template<class TContainerType >
void FlipFlag (const Flags &rFlag, TContainerType &rContainer)
 Flips a flag over a given container. More...
 
template<class TDataType , class TVariableType = Variable<TDataType>>
void SaveVariable (const TVariableType &rOriginVariable, const TVariableType &rSavedVariable, NodesContainerType &rNodesContainer)
 Takes the value of a non-historical variable and saves it in another variable For a nodal container, this takes the value of a non-historical variable and saves it in another one. More...
 
template<class TDataType , class TContainerType , class TVariableType = Variable<TDataType>>
void SaveNonHistoricalVariable (const TVariableType &rOriginVariable, const TVariableType &rSavedVariable, TContainerType &rContainer)
 Takes the value of a non-historical variable and saves it in another historical variable For a non-nodal container, this method takes the value of an origin variable and saves it in a destination one. More...
 
template<class TDataType , class TVariableType = Variable<TDataType>>
void CopyVariable (const TVariableType &rOriginVariable, const TVariableType &rDestinationVariable, NodesContainerType &rNodesContainer)
 Takes the value of an historical variable and sets it in another variable This function takes the value of an historical variable and sets in another variable in all the nodes of the provided container. More...
 
NodesContainerType SelectNodeList (const DoubleVarType &Variable, const double Value, const NodesContainerType &rOriginNodes)
 Returns a list of nodes filtered using the given double variable and value. More...
 
template<class TVarType >
int CheckVariableExists (const TVarType &rVariable, const NodesContainerType &rNodes)
 Checks if all the nodes of a node set has the specified variable. More...
 
template<class TVarType >
void ApplyFixity (const TVarType &rVar, const bool IsFixed, NodesContainerType &rNodes)
 Fixes or frees a variable for all of the nodes in the list. The dof has to exist. More...
 
template<class TVarType >
void ApplyFixity (const TVarType &rVariable, const bool IsFixed, NodesContainerType &rNodes, const Flags &rFlag, const bool CheckValue=true)
 Fixes/Frees dofs based on a flag. More...
 
template<class TVarType >
void ApplyVector (const TVarType &rVar, const Vector &rData, NodesContainerType &rNodes)
 Loops along a vector data to set its values to the nodes contained in a node set. More...
 
array_1d< double, 3 > SumNonHistoricalNodeVectorVariable (const ArrayVarType &rVar, const ModelPart &rModelPart)
 Returns the nodal value summation of a non-historical vector variable. More...
 
template<class TVarType >
double SumNonHistoricalNodeScalarVariable (const TVarType &rVar, const ModelPart &rModelPart)
 Returns the nodal value summation of a non-historical scalar variable. More...
 
template<class TDataType , class TVarType = Variable<TDataType>>
TDataType SumHistoricalVariable (const TVarType &rVariable, const ModelPart &rModelPart, const unsigned int BuffStep=0)
 This method accumulates and return a variable value For a nodal historical variable, this method accumulates and returns the summation in a model part. More...
 
array_1d< double, 3 > SumConditionVectorVariable (const ArrayVarType &rVar, const ModelPart &rModelPart)
 Returns the condition value summation of a historical vector variable. More...
 
template<class TVarType >
double SumConditionScalarVariable (const TVarType &rVar, const ModelPart &rModelPart)
 Returns the condition value summation of a historical scalar variable. More...
 
array_1d< double, 3 > SumElementVectorVariable (const ArrayVarType &rVar, const ModelPart &rModelPart)
 Returns the element value summation of a historical vector variable. More...
 
template<class TVarType >
double SumElementScalarVariable (const TVarType &rVar, const ModelPart &rModelPart)
 Returns the element value summation of a historical scalar variable. More...
 
template<class TVarType >
void AddDof (const TVarType &rVar, ModelPart &rModelPart)
 This function add dofs to the nodes in a model part. It is useful since addition is done in parallel. More...
 
template<class TVarType >
void AddDofWithReaction (const TVarType &rVar, const TVarType &rReactionVar, ModelPart &rModelPart)
 This function add dofs to the nodes in a model part. It is useful since addition is done in parallel. More...
 
bool CheckVariableKeys ()
 This method checks the variable keys. More...
 
void UpdateCurrentToInitialConfiguration (const ModelPart::NodesContainerType &rNodes)
 This method updates the current nodal coordinates back to the initial coordinates. More...
 
void UpdateInitialToCurrentConfiguration (const ModelPart::NodesContainerType &rNodes)
 This method updates the initial nodal coordinates to the current coordinates. More...
 
void UpdateCurrentPosition (const ModelPart::NodesContainerType &rNodes, const ArrayVarType &rUpdateVariable=DISPLACEMENT, const IndexType BufferPosition=0)
 This method updates the current coordinates For each node, this method takes the value of the provided variable and updates the current position as the initial position (X0, Y0, Z0) plus such variable value. More...
 
template<class TVectorType = Vector>
TVectorType GetCurrentPositionsVector (const ModelPart::NodesContainerType &rNodes, const unsigned int Dimension)
 This function returns the CURRENT coordinates of all the nodes in a consecutive vector. it allows working in 1D,2D or 3D For each node, this method takes the value of the provided variable and updates the current position as the initial position (X0, Y0, Z0) plus such variable value in case Dimension == 1 the vector is in the form (X X X ....) in case Dimension == 2 the vector is in the form (X Y X Y X Y ....) in case Dimension == 3 the vector is in the form (X Y Z X Y Z ....) More...
 
template<class TVectorType = Vector>
TVectorType GetInitialPositionsVector (const ModelPart::NodesContainerType &rNodes, const unsigned int Dimension)
 This function returns the INITIAL coordinates of all the nodes in a consecutive vector. it allows working in 1D,2D or 3D For each node, this method takes the value of the provided variable and updates the current position as the initial position (X0, Y0, Z0) plus such variable value in case Dimension == 1 the vector is in the form (X0 X0 X0 ....) in case Dimension == 2 the vector is in the form (X0 Y0 X0 Y0 X0 Y0 ....) in case Dimension == 3 the vector is in the form (X0 Y0 Z0 X0 Y0 Z0 ....) More...
 
void SetCurrentPositionsVector (ModelPart::NodesContainerType &rNodes, const Vector &rPositions)
 This function represent the "set" counterpart of GetCurrentPositionsVector and allows setting the CURRENT coordinates of all the nodes considering them stored in a consecutive 1D vector. it allows working in 1D,2D or 3D For each node, this method takes the value of the provided variable and updates the current position as the initial position (X, Y, Z) plus such variable value in case Dimension == 1 the expected input vector is in the form (X X X ....) in case Dimension == 2 the expected input vector is in the form (X Y X Y X Y ....) in case Dimension == 3 the expected input vector is in the form (X Y Z X Y Z ....) More...
 
void SetInitialPositionsVector (ModelPart::NodesContainerType &rNodes, const Vector &rPositions)
 This function represent the "set" counterpart of GetInitialPositionsVector and allows setting the INITIAL coordinates of all the nodes considering them stored in a consecutive 1D vector. it allows working in 1D,2D or 3D For each node, this method takes the value of the provided variable and updates the current position as the initial position (X0, Y0, Z0) plus such variable value in case Dimension == 1 the expected input vector is in the form (X0 X0 X0 ....) in case Dimension == 2 the expected input vector is in the form (X0 Y0 X0 Y0 X0 Y0 ....) in case Dimension == 3 the expected input vector is in the form (X0 Y0 Z0 X0 Y0 Z0 ....) More...
 
Vector GetSolutionStepValuesVector (const ModelPart::NodesContainerType &rNodes, const Variable< array_1d< double, 3 >> &rVar, const unsigned int Step, const unsigned int Dimension=3)
 This function allows getting the database entries corresponding to rVar contained on all rNodes flattened so that the components of interest appear in the output vector. This version works with VECTOR VARIABLES (of type Variable<array_1d<double,3>>) In case Dimension is 1 one would obtain only the first component, for Dimension 2 the x and y component and for Dimension==3 the 3 components at once. More...
 
Vector GetSolutionStepValuesVector (const ModelPart::NodesContainerType &rNodes, const Variable< double > &rVar, const unsigned int Step)
 This function allows getting the database entries corresponding to rVar contained on all rNodes flattened so that the components of interest appear in the output vector. This version works with SCALAR VARIABLES (of type Variable<double>) In case Dimension is 1 one would obtain only the first component, for Dimension 2 the x and y component and for Dimension==3 the 3 components at once. More...
 
void SetSolutionStepValuesVector (ModelPart::NodesContainerType &rNodes, const Variable< array_1d< double, 3 >> &rVar, const Vector &rData, const unsigned int Step)
 This function allows setting the database entries corresponding to rVar contained on all rNodes given a flat array in which all the variable components are present consecutively. This version works with VECTOR VARIABLES (of type Variable<array_1d<double,3>>) More...
 
void SetSolutionStepValuesVector (ModelPart::NodesContainerType &rNodes, const Variable< double > &rVar, const Vector &rData, const unsigned int Step)
 This function allows setting the database entries corresponding to rVar contained on all rNodes given a flat array in which all the variable components are present consecutively. This version works with SCALAR VARIABLES (of type Variable<double>) More...
 
Vector GetValuesVector (const ModelPart::NodesContainerType &rNodes, const Variable< array_1d< double, 3 >> &rVar, const unsigned int Dimension=3)
 This function allows getting the database entries corresponding to rVar contained on all rNodes flattened so that the components of interest appear in the output vector. This version works with VECTOR VARIABLES (of type Variable<array_1d<double,3>>) In case Dimension is 1 one would obtain only the first component, for Dimension 2 the x and y component and for Dimension==3 the 3 components at once also note that this version accesses NON HISTORICAL data. More...
 
Vector GetValuesVector (const ModelPart::NodesContainerType &rNodes, const Variable< double > &rVar)
 This function allows getting the database entries corresponding to rVar contained on all rNodes flattened so that the components of interest appear in the output vector. This version works with SCALAR VARIABLES (of type Variable<double>) In case Dimension is 1 one would obtain only the first component, for Dimension 2 the x and y component and for Dimension==3 the 3 components at once also note that this version accesses NON HISTORICAL data. More...
 
void SetValuesVector (ModelPart::NodesContainerType &rNodes, const Variable< array_1d< double, 3 >> &rVar, const Vector &rData)
 This function allows setting the database entries corresponding to rVar contained on all rNodes given a flat array in which all the variable components are present consecutively. This version works with VECTOR VARIABLES (of type Variable<array_1d<double,3>>) also note that this version accesses NON HISTORICAL data. More...
 
void SetValuesVector (ModelPart::NodesContainerType &rNodes, const Variable< double > &rVar, const Vector &rData)
 This function allows setting the database entries corresponding to rVar contained on all rNodes given a flat array in which all the variable components are present consecutively. This version works with SCALAR VARIABLES (of type Variable<double>) also note that this version accesses NON HISTORICAL data. More...
 
template<class TContainerType , class... TVariableArgs>
static void SetNonHistoricalVariablesToZero (TContainerType &rContainer, const TVariableArgs &... rVariableArgs)
 Set the Non Historical Variables To Zero This method sets the provided list of variables to zero in the non-historical database. More...
 
template<class... TVariableArgs>
static void SetHistoricalVariablesToZero (NodesContainerType &rNodes, const TVariableArgs &... rVariableArgs)
 Set the Historical Variables To Zero This method sets the provided list of variables to zero in the nodal historical database. More...
 
static void AddDofsList (const std::vector< std::string > &rDofsVarNamesList, ModelPart &rModelPart)
 Add a list of DOFs to the nodes Provided a list with the DOFs variable names, this method adds such variables as DOFs to the nodes of the given model part. Note that the addition is performed at once. More...
 
static void AddDofsWithReactionsList (const std::vector< std::array< std::string, 2 >> &rDofsAndReactionsNamesList, ModelPart &rModelPart)
 Add a list of DOFs to the nodes Provided a list with the DOFs and reactions variable names, this method adds such variables as DOFs and reaction to the nodes of the given model part. Note that the addition is performed at once. More...
 
template<Globals::DataLocation TLocation, class TEntity , class TValue >
static bool HasValue (const TEntity &rEntity, const Variable< TValue > &rVariable)
 Check whether a Node, Element, Condition, ProcessInfo, or ModelPart stores a value for the provided Variable. More...
 
template<Globals::DataLocation TLocation, class TEntity , class TValue >
static std::conditional_t< std::is_arithmetic_v< TValue >, TValue, const TValue & > GetValue (const TEntity &rEntity, const Variable< TValue > &rVariable)
 Fetch the value of a variable stored in an entity. More...
 
template<Globals::DataLocation TLocation, class TEntity , class TValue >
static TValue & GetValue (TEntity &rEntity, const Variable< TValue > &rVariable)
 Fetch the value of a variable stored in an entity. More...
 
template<Globals::DataLocation TLocation, class TEntity , class TValue >
static void SetValue (TEntity &rEntity, const Variable< TValue > &rVariable, std::conditional_t< std::is_arithmetic_v< TValue >, TValue, const TValue & > Value)
 Overwrite the value of a variable stored in an entity. More...
 

Detailed Description

This class implements a set of auxiliar, already parallelized, methods to perform some common tasks related with the variable values and fixity.

The methods are exported to python in order to add this improvements to the python interface

Author
Riccardo Rossi
Ruben Zorrilla
Vicente Mataix Ferrandiz

Member Typedef Documentation

◆ ArrayVarType

A definition of the array variable.

◆ ConditionsContainerType

The conditions container.

◆ ConditionType

The condition type.

◆ DoubleVarType

A definition of the double variable.

◆ ElementsContainerType

The elements container.

◆ ElementType

The element type.

◆ NodesContainerType

The nodes container.

◆ NodeType

The node type.

Member Function Documentation

◆ AddDof()

template<class TVarType >
void Kratos::VariableUtils::AddDof ( const TVarType &  rVar,
ModelPart rModelPart 
)
inline

This function add dofs to the nodes in a model part. It is useful since addition is done in parallel.

Parameters
rVarThe variable to be added as DoF
rModelPartreference to the model part that contains the objective element set

◆ AddDofsList()

void Kratos::VariableUtils::AddDofsList ( const std::vector< std::string > &  rDofsVarNamesList,
ModelPart rModelPart 
)
static

Add a list of DOFs to the nodes Provided a list with the DOFs variable names, this method adds such variables as DOFs to the nodes of the given model part. Note that the addition is performed at once.

Parameters
rDofsVarNamesListList with the string variable names to be added as DOFs
rModelPartModel part to which the DOFs are added

◆ AddDofsWithReactionsList()

void Kratos::VariableUtils::AddDofsWithReactionsList ( const std::vector< std::array< std::string, 2 >> &  rDofsAndReactionsNamesList,
ModelPart rModelPart 
)
static

Add a list of DOFs to the nodes Provided a list with the DOFs and reactions variable names, this method adds such variables as DOFs and reaction to the nodes of the given model part. Note that the addition is performed at once.

Parameters
rDofsAndReactionsNamesListList with the DOF and reaction string variable names to be added as DOFs and reaction
rModelPartModel part to which the DOFs are added

◆ AddDofWithReaction()

template<class TVarType >
void Kratos::VariableUtils::AddDofWithReaction ( const TVarType &  rVar,
const TVarType &  rReactionVar,
ModelPart rModelPart 
)
inline

This function add dofs to the nodes in a model part. It is useful since addition is done in parallel.

Parameters
rVarThe variable to be added as DoF
rReactionVarThe corresponding reaction to the added DoF
rModelPartreference to the model part that contains the objective element set

◆ ApplyFixity() [1/2]

template<class TVarType >
void Kratos::VariableUtils::ApplyFixity ( const TVarType &  rVar,
const bool  IsFixed,
NodesContainerType rNodes 
)
inline

Fixes or frees a variable for all of the nodes in the list. The dof has to exist.

Parameters
rVarreference to the variable to be fixed or freed
IsFixedif true fixes, if false frees
rNodesreference to the nodes set to be frixed or freed

◆ ApplyFixity() [2/2]

template<class TVarType >
void Kratos::VariableUtils::ApplyFixity ( const TVarType &  rVariable,
const bool  IsFixed,
NodesContainerType rNodes,
const Flags rFlag,
const bool  CheckValue = true 
)
inline

Fixes/Frees dofs based on a flag.

This method fixes/frees given rVariable, if rFlag matches CheckValue provided for that specific node.

Template Parameters
TVarTypeVariable type
Parameters
rVariableVariable to be fixed or freed
IsFixedTrue to fix variable, false to free variable
rNodesNodes container
rFlagFlag to be checked to fix or free
CheckValueFlag value which is checked against

◆ ApplyVector()

template<class TVarType >
void Kratos::VariableUtils::ApplyVector ( const TVarType &  rVar,
const Vector rData,
NodesContainerType rNodes 
)
inline

Loops along a vector data to set its values to the nodes contained in a node set.

Note
This function is suitable for scalar historical variables, since each one of the values in the data vector is set to its correspondent node. Besides, the values must be sorted as the nodes are (value i corresponds to node i).
Parameters
rVarreference to the variable to be fixed or freed
rDatarData vector. Note that its lenght must equal the number of nodes
rNodesreference to the nodes set to be set

◆ AuxiliaryHistoricalValueSetter()

template<>
void Kratos::VariableUtils::AuxiliaryHistoricalValueSetter ( const Variable< array_1d< double, 3 >> &  rVariable,
const array_1d< double, 3 > &  rValue,
NodeType rNode 
)

◆ CheckVariableExists()

template<class TVarType >
int Kratos::VariableUtils::CheckVariableExists ( const TVarType &  rVariable,
const NodesContainerType rNodes 
)
inline

Checks if all the nodes of a node set has the specified variable.

Parameters
rVariablereference to a variable to be checked
rNodesreference to the nodes set to be checked
Returns
0: if succeeds, return 0

◆ CheckVariableKeys()

bool Kratos::VariableUtils::CheckVariableKeys ( )

This method checks the variable keys.

Returns
True if all the keys are correct

◆ ClearNonHistoricalData()

template<class TContainerType >
void Kratos::VariableUtils::ClearNonHistoricalData ( TContainerType &  rContainer)
inline

Clears the container data value container.

Parameters
rContainerReference to the objective container

◆ CopyModelPartElementalVar()

template<class TVarType >
void Kratos::VariableUtils::CopyModelPartElementalVar ( const TVarType &  rVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart 
)
inline

Copies the elemental value of a variable from an origin model part elements to the elements in a destination model part. It is assumed that both origin and destination model parts have the same number of elements.

Parameters
rVariablereference to the variable to be set
rOriginModelPartorigin model part from where the values are retrieved
rDestinationModelPartdestination model part to where the values are copied to
BuffStepbuffer step

◆ CopyModelPartFlaggedConditionVar() [1/3]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedConditionVar ( const Variable< TDataType > &  rOriginVariable,
const Variable< TDataType > &  rDestinationVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart,
const Flags rFlag,
const bool  CheckValue = true 
)
inline

◆ CopyModelPartFlaggedConditionVar() [2/3]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedConditionVar ( const Variable< TDataType > &  rOriginVariable,
const Variable< TDataType > &  rDestinationVariable,
ModelPart rModelPart,
const Flags rFlag,
const bool  CheckValue = true 
)
inline

◆ CopyModelPartFlaggedConditionVar() [3/3]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedConditionVar ( const Variable< TDataType > &  rVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart,
const Flags rFlag,
const bool  CheckValue = true 
)
inline

◆ CopyModelPartFlaggedElementVar() [1/3]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedElementVar ( const Variable< TDataType > &  rOriginVariable,
const Variable< TDataType > &  rDestinationVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart,
const Flags rFlag,
const bool  CheckValue = true 
)
inline

◆ CopyModelPartFlaggedElementVar() [2/3]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedElementVar ( const Variable< TDataType > &  rOriginVariable,
const Variable< TDataType > &  rDestinationVariable,
ModelPart rModelPart,
const Flags rFlag,
const bool  CheckValue = true 
)
inline

◆ CopyModelPartFlaggedElementVar() [3/3]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedElementVar ( const Variable< TDataType > &  rVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart,
const Flags rFlag,
const bool  CheckValue = true 
)
inline

◆ CopyModelPartFlaggedNodalHistoricalVarToHistoricalVar() [1/3]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedNodalHistoricalVarToHistoricalVar ( const Variable< TDataType > &  rOriginVariable,
const Variable< TDataType > &  rDestinationVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart,
const Flags rFlag,
const bool  CheckValue = true,
const unsigned int  ReadBufferStep = 0,
const unsigned int  WriteBufferStep = 0 
)
inline

◆ CopyModelPartFlaggedNodalHistoricalVarToHistoricalVar() [2/3]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedNodalHistoricalVarToHistoricalVar ( const Variable< TDataType > &  rOriginVariable,
const Variable< TDataType > &  rDestinationVariable,
ModelPart rModelPart,
const Flags rFlag,
const bool  CheckValue = true,
const unsigned int  ReadBufferStep = 0,
const unsigned int  WriteBufferStep = 0 
)
inline

◆ CopyModelPartFlaggedNodalHistoricalVarToHistoricalVar() [3/3]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedNodalHistoricalVarToHistoricalVar ( const Variable< TDataType > &  rVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart,
const Flags rFlag,
const bool  CheckValue = true,
const unsigned int  ReadBufferStep = 0,
const unsigned int  WriteBufferStep = 0 
)
inline

◆ CopyModelPartFlaggedNodalHistoricalVarToNonHistoricalVar() [1/4]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedNodalHistoricalVarToNonHistoricalVar ( const Variable< TDataType > &  rOriginVariable,
const Variable< TDataType > &  rDestinationVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart,
const Flags rFlag,
const bool  CheckValue = true,
const unsigned int  ReadBufferStep = 0 
)
inline

◆ CopyModelPartFlaggedNodalHistoricalVarToNonHistoricalVar() [2/4]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedNodalHistoricalVarToNonHistoricalVar ( const Variable< TDataType > &  rOriginVariable,
const Variable< TDataType > &  rDestinationVariable,
ModelPart rModelPart,
const Flags rFlag,
const bool  CheckValue = true,
const unsigned int  ReadBufferStep = 0 
)
inline

◆ CopyModelPartFlaggedNodalHistoricalVarToNonHistoricalVar() [3/4]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedNodalHistoricalVarToNonHistoricalVar ( const Variable< TDataType > &  rVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart,
const Flags rFlag,
const bool  CheckValue = true,
const unsigned int  ReadBufferStep = 0 
)
inline

◆ CopyModelPartFlaggedNodalHistoricalVarToNonHistoricalVar() [4/4]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedNodalHistoricalVarToNonHistoricalVar ( const Variable< TDataType > &  rVariable,
ModelPart rModelPart,
const Flags rFlag,
const bool  CheckValue = true,
const unsigned int  ReadBufferStep = 0 
)
inline

◆ CopyModelPartFlaggedNodalNonHistoricalVarToHistoricalVar() [1/4]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedNodalNonHistoricalVarToHistoricalVar ( const Variable< TDataType > &  rOriginVariable,
const Variable< TDataType > &  rDestinationVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart,
const Flags rFlag,
const bool  CheckValue = true,
const unsigned int  WriteBufferStep = 0 
)
inline

◆ CopyModelPartFlaggedNodalNonHistoricalVarToHistoricalVar() [2/4]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedNodalNonHistoricalVarToHistoricalVar ( const Variable< TDataType > &  rOriginVariable,
const Variable< TDataType > &  rDestinationVariable,
ModelPart rModelPart,
const Flags rFlag,
const bool  CheckValue = true,
const unsigned int  WriteBufferStep = 0 
)
inline

◆ CopyModelPartFlaggedNodalNonHistoricalVarToHistoricalVar() [3/4]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedNodalNonHistoricalVarToHistoricalVar ( const Variable< TDataType > &  rVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart,
const Flags rFlag,
const bool  CheckValue = true,
const unsigned int  WriteBufferStep = 0 
)
inline

◆ CopyModelPartFlaggedNodalNonHistoricalVarToHistoricalVar() [4/4]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedNodalNonHistoricalVarToHistoricalVar ( const Variable< TDataType > &  rVariable,
ModelPart rModelPart,
const Flags rFlag,
const bool  CheckValue = true,
const unsigned int  WriteBufferStep = 0 
)
inline

◆ CopyModelPartFlaggedNodalNonHistoricalVarToNonHistoricalVar() [1/3]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedNodalNonHistoricalVarToNonHistoricalVar ( const Variable< TDataType > &  rOriginVariable,
const Variable< TDataType > &  rDestinationVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart,
const Flags rFlag,
const bool  CheckValue = true 
)
inline

◆ CopyModelPartFlaggedNodalNonHistoricalVarToNonHistoricalVar() [2/3]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedNodalNonHistoricalVarToNonHistoricalVar ( const Variable< TDataType > &  rOriginVariable,
const Variable< TDataType > &  rDestinationVariable,
ModelPart rModelPart,
const Flags rFlag,
const bool  CheckValue = true 
)
inline

◆ CopyModelPartFlaggedNodalNonHistoricalVarToNonHistoricalVar() [3/3]

template<class TDataType >
void Kratos::VariableUtils::CopyModelPartFlaggedNodalNonHistoricalVarToNonHistoricalVar ( const Variable< TDataType > &  rVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart,
const Flags rFlag,
const bool  CheckValue = true 
)
inline

◆ CopyModelPartNodalVar() [1/3]

template<class TVarType >
void Kratos::VariableUtils::CopyModelPartNodalVar ( const TVarType &  rVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart,
const unsigned int  BuffStep = 0 
)
inline

Copies the nodal value of a variable from an origin model part nodes to the nodes in a destination model part. It is assumed that both origin and destination model parts have the same number of nodes.

Parameters
rVariablereference to the variable to get the value from and to save in
rOriginModelPartorigin model part from where the values are retrieved
rDestinationModelPartdestination model part to where the values are copied to
BuffStepbuffer step

◆ CopyModelPartNodalVar() [2/3]

template<class TVarType >
void Kratos::VariableUtils::CopyModelPartNodalVar ( const TVarType &  rVariable,
const TVarType &  rDestinationVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart,
const unsigned int  BuffStep = 0 
)
inline

Copies the nodal value of a variable from an origin model part nodes to the nodes in a destination model part. It is assumed that both origin and destination model parts have the same number of nodes.

Parameters
rVariablereference to the variable to get the value from
rDestinationVariablereference to the variable to be set
rOriginModelPartorigin model part from where the values are retrieved
rDestinationModelPartdestination model part to where the values are copied to
BuffStepbuffer step

◆ CopyModelPartNodalVar() [3/3]

template<class TVarType >
void Kratos::VariableUtils::CopyModelPartNodalVar ( const TVarType &  rVariable,
const TVarType &  rDestinationVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart,
const unsigned int  ReadBufferStep,
const unsigned int  WriteBufferStep 
)
inline

Copies the nodal value of a variable from an origin model part nodes to the nodes in a destination model part. It is assumed that both origin and destination model parts have the same number of nodes.

Parameters
rVariablereference to the variable to get the value from
rDestinationVariablereference to the variable to be set
rOriginModelPartorigin model part from where the values are retrieved
rDestinationModelPartdestination model part to where the values are copied to
ReadBufferSteporigin buffer step
WriteBufferStepdestination buffer step

◆ CopyModelPartNodalVarToNonHistoricalVar() [1/2]

template<class TVarType >
void Kratos::VariableUtils::CopyModelPartNodalVarToNonHistoricalVar ( const TVarType &  rVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart,
const unsigned int  BuffStep = 0 
)
inline

◆ CopyModelPartNodalVarToNonHistoricalVar() [2/2]

template<class TVarType >
void Kratos::VariableUtils::CopyModelPartNodalVarToNonHistoricalVar ( const TVarType &  rVariable,
const TVarType &  rDestinationVariable,
const ModelPart rOriginModelPart,
ModelPart rDestinationModelPart,
const unsigned int  BuffStep = 0 
)
inline

◆ CopyVariable()

template<class TDataType , class TVariableType = Variable<TDataType>>
void Kratos::VariableUtils::CopyVariable ( const TVariableType &  rOriginVariable,
const TVariableType &  rDestinationVariable,
NodesContainerType rNodesContainer 
)
inline

Takes the value of an historical variable and sets it in another variable This function takes the value of an historical variable and sets in another variable in all the nodes of the provided container.

Template Parameters
TDataTypeThe variable data type
Variable<TDataType>The variable type
Parameters
rOriginVariableReference to the origin variable
rDestinationVariableReference to the destination variable
rNodesContainerReference to the nodes container

◆ EraseNonHistoricalVariable()

template<class TContainerType , class TVarType >
void Kratos::VariableUtils::EraseNonHistoricalVariable ( const TVarType &  rVariable,
TContainerType &  rContainer 
)
inline

Erases the container non historical variable.

Parameters
rVariablereference to the scalar variable to be erased
rContainerReference to the objective container

◆ FlipFlag()

template<class TContainerType >
void Kratos::VariableUtils::FlipFlag ( const Flags rFlag,
TContainerType &  rContainer 
)
inline

Flips a flag over a given container.

Parameters
rFlagflag to be set
rContainerReference to the objective container

◆ GetCurrentPositionsVector()

template<class TVectorType >
template Vector Kratos::VariableUtils::GetCurrentPositionsVector< Vector > ( const ModelPart::NodesContainerType rNodes,
const unsigned int  Dimension 
)

This function returns the CURRENT coordinates of all the nodes in a consecutive vector. it allows working in 1D,2D or 3D For each node, this method takes the value of the provided variable and updates the current position as the initial position (X0, Y0, Z0) plus such variable value in case Dimension == 1 the vector is in the form (X X X ....) in case Dimension == 2 the vector is in the form (X Y X Y X Y ....) in case Dimension == 3 the vector is in the form (X Y Z X Y Z ....)

Parameters
rNodesarray of nodes from which coordinates will be extracted
Dimensionnumber of desired components

◆ GetInitialPositionsVector()

template<class TVectorType >
template Vector Kratos::VariableUtils::GetInitialPositionsVector< Vector > ( const ModelPart::NodesContainerType rNodes,
const unsigned int  Dimension 
)

This function returns the INITIAL coordinates of all the nodes in a consecutive vector. it allows working in 1D,2D or 3D For each node, this method takes the value of the provided variable and updates the current position as the initial position (X0, Y0, Z0) plus such variable value in case Dimension == 1 the vector is in the form (X0 X0 X0 ....) in case Dimension == 2 the vector is in the form (X0 Y0 X0 Y0 X0 Y0 ....) in case Dimension == 3 the vector is in the form (X0 Y0 Z0 X0 Y0 Z0 ....)

Parameters
rNodesarray of nodes from which coordinates will be extracted
Dimensionnumber of desired components

◆ GetSolutionStepValuesVector() [1/2]

Vector Kratos::VariableUtils::GetSolutionStepValuesVector ( const ModelPart::NodesContainerType rNodes,
const Variable< array_1d< double, 3 >> &  rVar,
const unsigned int  Step,
const unsigned int  Dimension = 3 
)

This function allows getting the database entries corresponding to rVar contained on all rNodes flattened so that the components of interest appear in the output vector. This version works with VECTOR VARIABLES (of type Variable<array_1d<double,3>>) In case Dimension is 1 one would obtain only the first component, for Dimension 2 the x and y component and for Dimension==3 the 3 components at once.

Parameters
rNodesarray of nodes from which data will be extracted
rVarthe variable being addressed
Stepstep in the database
Dimensionnumber of components in output

◆ GetSolutionStepValuesVector() [2/2]

Vector Kratos::VariableUtils::GetSolutionStepValuesVector ( const ModelPart::NodesContainerType rNodes,
const Variable< double > &  rVar,
const unsigned int  Step 
)

This function allows getting the database entries corresponding to rVar contained on all rNodes flattened so that the components of interest appear in the output vector. This version works with SCALAR VARIABLES (of type Variable<double>) In case Dimension is 1 one would obtain only the first component, for Dimension 2 the x and y component and for Dimension==3 the 3 components at once.

Parameters
rNodesarray of nodes from which data will be extracted
rVarthe variable being addressed
Stepstep in the database

◆ GetValue() [1/2]

template<Globals::DataLocation TLocation, class TEntity , class TValue >
static std::conditional_t<std::is_arithmetic_v<TValue>, TValue, const TValue&> Kratos::VariableUtils::GetValue ( const TEntity &  rEntity,
const Variable< TValue > &  rVariable 
)
inlinestatic

Fetch the value of a variable stored in an entity.

Parameters
rEntityNode, Element, Condition, ProcessInfo, or ModelPart to fetch data from.
rVariableVariable to fetch the value of.

◆ GetValue() [2/2]

template<Globals::DataLocation TLocation, class TEntity , class TValue >
static TValue& Kratos::VariableUtils::GetValue ( TEntity &  rEntity,
const Variable< TValue > &  rVariable 
)
inlinestatic

Fetch the value of a variable stored in an entity.

Parameters
rEntityNode, Element, Condition, ProcessInfo, or ModelPart to fetch data from.
rVariableVariable to fetch the value of.

◆ GetValuesVector() [1/2]

Vector Kratos::VariableUtils::GetValuesVector ( const ModelPart::NodesContainerType rNodes,
const Variable< array_1d< double, 3 >> &  rVar,
const unsigned int  Dimension = 3 
)

This function allows getting the database entries corresponding to rVar contained on all rNodes flattened so that the components of interest appear in the output vector. This version works with VECTOR VARIABLES (of type Variable<array_1d<double,3>>) In case Dimension is 1 one would obtain only the first component, for Dimension 2 the x and y component and for Dimension==3 the 3 components at once also note that this version accesses NON HISTORICAL data.

Parameters
rNodesarray of nodes from which data will be extracted
rVarthe variable being addressed
Stepstep in the database
Dimensionnumber of components in output

◆ GetValuesVector() [2/2]

Vector Kratos::VariableUtils::GetValuesVector ( const ModelPart::NodesContainerType rNodes,
const Variable< double > &  rVar 
)

This function allows getting the database entries corresponding to rVar contained on all rNodes flattened so that the components of interest appear in the output vector. This version works with SCALAR VARIABLES (of type Variable<double>) In case Dimension is 1 one would obtain only the first component, for Dimension 2 the x and y component and for Dimension==3 the 3 components at once also note that this version accesses NON HISTORICAL data.

Parameters
rNodesarray of nodes from which data will be extracted
rVarthe variable being addressed
Stepstep in the database

◆ HasValue()

template<Globals::DataLocation TLocation, class TEntity , class TValue >
static bool Kratos::VariableUtils::HasValue ( const TEntity &  rEntity,
const Variable< TValue > &  rVariable 
)
inlinestatic

Check whether a Node, Element, Condition, ProcessInfo, or ModelPart stores a value for the provided Variable.

Parameters
rEntityNode, Element, Condition, ProcessInfo, or ModelPart to check.
rVariableto check.

◆ KRATOS_CLASS_POINTER_DEFINITION()

Kratos::VariableUtils::KRATOS_CLASS_POINTER_DEFINITION ( VariableUtils  )

We create the Pointer related to VariableUtils.

◆ ResetFlag()

template<class TContainerType >
void Kratos::VariableUtils::ResetFlag ( const Flags rFlag,
TContainerType &  rContainer 
)
inline

Flips a flag over a given container.

Parameters
rFlagflag to be set
rContainerReference to the objective container

◆ SaveNonHistoricalVariable()

template<class TDataType , class TContainerType , class TVariableType = Variable<TDataType>>
void Kratos::VariableUtils::SaveNonHistoricalVariable ( const TVariableType &  rOriginVariable,
const TVariableType &  rSavedVariable,
TContainerType &  rContainer 
)
inline

Takes the value of a non-historical variable and saves it in another historical variable For a non-nodal container, this method takes the value of an origin variable and saves it in a destination one.

Template Parameters
TDataTypeThe variable data type
TContainerTypeThe container type
Variable<TDataType>The variable type
Parameters
rOriginVariableReference to the origin variable
rSavedVariableReference to the destination variable
rContainerReference to the container of interest

◆ SaveVariable()

template<class TDataType , class TVariableType = Variable<TDataType>>
void Kratos::VariableUtils::SaveVariable ( const TVariableType &  rOriginVariable,
const TVariableType &  rSavedVariable,
NodesContainerType rNodesContainer 
)
inline

Takes the value of a non-historical variable and saves it in another variable For a nodal container, this takes the value of a non-historical variable and saves it in another one.

Template Parameters
TDataTypeThe variable data type
Variable<TDataType>The variable type
Parameters
rOriginVariableReference to the origin variable
rSavedVariableReference to the destination variable
rNodesContainerReference to the nodal container

◆ SelectNodeList()

ModelPart::NodesContainerType Kratos::VariableUtils::SelectNodeList ( const DoubleVarType Variable,
const double  Value,
const NodesContainerType rOriginNodes 
)

Returns a list of nodes filtered using the given double variable and value.

Parameters
Variablereference to the double variable to be filtered
ValueFiltering Value
rOriginNodesReference to the objective node set
Returns
selected_nodes: List of filtered nodes

◆ SetCurrentPositionsVector()

void Kratos::VariableUtils::SetCurrentPositionsVector ( ModelPart::NodesContainerType rNodes,
const Vector rPositions 
)

This function represent the "set" counterpart of GetCurrentPositionsVector and allows setting the CURRENT coordinates of all the nodes considering them stored in a consecutive 1D vector. it allows working in 1D,2D or 3D For each node, this method takes the value of the provided variable and updates the current position as the initial position (X, Y, Z) plus such variable value in case Dimension == 1 the expected input vector is in the form (X X X ....) in case Dimension == 2 the expected input vector is in the form (X Y X Y X Y ....) in case Dimension == 3 the expected input vector is in the form (X Y Z X Y Z ....)

Parameters
rNodesarray of nodes from which coordinates will be extracted
rPositionsvector containing the CURRENT positions

◆ SetFlag()

template<class TContainerType >
void Kratos::VariableUtils::SetFlag ( const Flags rFlag,
const bool  FlagValue,
TContainerType &  rContainer 
)
inline

Sets a flag according to a given status over a given container.

Parameters
rFlagflag to be set
FlagValueflag value to be set
rContainerReference to the objective container

◆ SetHistoricalVariablesToZero()

template<class... TVariableArgs>
static void Kratos::VariableUtils::SetHistoricalVariablesToZero ( NodesContainerType rNodes,
const TVariableArgs &...  rVariableArgs 
)
inlinestatic

Set the Historical Variables To Zero This method sets the provided list of variables to zero in the nodal historical database.

Template Parameters
TVariableArgsVariadic template argument representing the variables types
Parameters
rNodesNodes container to be initialized to zero
rVariableArgsVariables to be set to zero

◆ SetHistoricalVariableToZero()

template<class TType >
void Kratos::VariableUtils::SetHistoricalVariableToZero ( const Variable< TType > &  rVariable,
NodesContainerType rNodes 
)
inline

Sets the nodal value of any variable to zero.

Parameters
rVariablereference to the scalar variable to be set
rNodesreference to the objective node set

◆ SetInitialPositionsVector()

void Kratos::VariableUtils::SetInitialPositionsVector ( ModelPart::NodesContainerType rNodes,
const Vector rPositions 
)

This function represent the "set" counterpart of GetInitialPositionsVector and allows setting the INITIAL coordinates of all the nodes considering them stored in a consecutive 1D vector. it allows working in 1D,2D or 3D For each node, this method takes the value of the provided variable and updates the current position as the initial position (X0, Y0, Z0) plus such variable value in case Dimension == 1 the expected input vector is in the form (X0 X0 X0 ....) in case Dimension == 2 the expected input vector is in the form (X0 Y0 X0 Y0 X0 Y0 ....) in case Dimension == 3 the expected input vector is in the form (X0 Y0 Z0 X0 Y0 Z0 ....)

Parameters
rNodesarray of nodes from which coordinates will be extracted
rPositionsvector containing the INITIAL positions

◆ SetNonHistoricalVariable() [1/2]

template<class TType , class TContainerType , class TVarType = Variable< TType >>
void Kratos::VariableUtils::SetNonHistoricalVariable ( const TVarType &  rVariable,
const TType &  rValue,
TContainerType &  rContainer,
const Flags  Flag,
const bool  Check = true 
)
inline

Sets the container value of any type of non historical variable (considering flag)

Parameters
rVariablereference to the scalar variable to be set
ValueValue to be set
rContainerReference to the objective container
FlagThe flag to be considered in the assignation
CheckWhat is checked from the flag

◆ SetNonHistoricalVariable() [2/2]

template<class TType , class TContainerType , class TVarType = Variable< TType >>
void Kratos::VariableUtils::SetNonHistoricalVariable ( const TVarType &  rVariable,
const TType &  Value,
TContainerType &  rContainer 
)
inline

Sets the container value of any type of non historical variable.

Parameters
rVariablereference to the scalar variable to be set
ValueValue to be set
rContainerReference to the objective container

◆ SetNonHistoricalVariablesToZero()

template<class TContainerType , class... TVariableArgs>
static void Kratos::VariableUtils::SetNonHistoricalVariablesToZero ( TContainerType &  rContainer,
const TVariableArgs &...  rVariableArgs 
)
inlinestatic

Set the Non Historical Variables To Zero This method sets the provided list of variables to zero in the non-historical database.

Template Parameters
TContainerTypeContainer type (nodes, elements or conditions)
TVariableArgsVariadic template argument representing the variables types
Parameters
rContainerContainer to be initialized to zero
rVariableArgsVariables to be set to zero

◆ SetNonHistoricalVariableToZero()

template<class TType , class TContainerType >
void Kratos::VariableUtils::SetNonHistoricalVariableToZero ( const Variable< TType > &  rVariable,
TContainerType &  rContainer 
)
inline

Sets the nodal value of any variable to zero.

Parameters
rVariablereference to the scalar variable to be set
rContainerreference to the objective container

◆ SetSolutionStepValuesVector() [1/2]

void Kratos::VariableUtils::SetSolutionStepValuesVector ( ModelPart::NodesContainerType rNodes,
const Variable< array_1d< double, 3 >> &  rVar,
const Vector rData,
const unsigned int  Step 
)

This function allows setting the database entries corresponding to rVar contained on all rNodes given a flat array in which all the variable components are present consecutively. This version works with VECTOR VARIABLES (of type Variable<array_1d<double,3>>)

Parameters
rNodesarray of nodes from which data will be extracted
rVarthe variable being addressed
rDatainput vector (must be of size rNodes.size()*Dimension)
Stepdatabase step to which we will write

◆ SetSolutionStepValuesVector() [2/2]

void Kratos::VariableUtils::SetSolutionStepValuesVector ( ModelPart::NodesContainerType rNodes,
const Variable< double > &  rVar,
const Vector rData,
const unsigned int  Step 
)

This function allows setting the database entries corresponding to rVar contained on all rNodes given a flat array in which all the variable components are present consecutively. This version works with SCALAR VARIABLES (of type Variable<double>)

Parameters
rNodesarray of nodes from which data will be extracted
rVarthe variable being addressed
rDatainput vector (must be of size rNodes.size()*Dimension)
Stepdatabase step to which we will write

◆ SetValue()

template<Globals::DataLocation TLocation, class TEntity , class TValue >
static void Kratos::VariableUtils::SetValue ( TEntity &  rEntity,
const Variable< TValue > &  rVariable,
std::conditional_t< std::is_arithmetic_v< TValue >, TValue, const TValue & >  Value 
)
inlinestatic

Overwrite the value of a variable stored in an entity.

Parameters
rEntityNode, Element, Condition, ProcessInfo, or ModelPart to set the value of.
rVariableVariable to overwrite the value of.
Valuenew value of rVariable to set in rEntity.

◆ SetValuesVector() [1/2]

void Kratos::VariableUtils::SetValuesVector ( ModelPart::NodesContainerType rNodes,
const Variable< array_1d< double, 3 >> &  rVar,
const Vector rData 
)

This function allows setting the database entries corresponding to rVar contained on all rNodes given a flat array in which all the variable components are present consecutively. This version works with VECTOR VARIABLES (of type Variable<array_1d<double,3>>) also note that this version accesses NON HISTORICAL data.

Parameters
rNodesarray of nodes from which data will be extracted
rVarthe variable being addressed
rDatainput vector (must be of size rNodes.size()*Dimension)
Stepdatabase step to which we will write

◆ SetValuesVector() [2/2]

void Kratos::VariableUtils::SetValuesVector ( ModelPart::NodesContainerType rNodes,
const Variable< double > &  rVar,
const Vector rData 
)

This function allows setting the database entries corresponding to rVar contained on all rNodes given a flat array in which all the variable components are present consecutively. This version works with SCALAR VARIABLES (of type Variable<double>) also note that this version accesses NON HISTORICAL data.

Parameters
rNodesarray of nodes from which data will be extracted
rVarthe variable being addressed
rDatainput vector (must be of size rNodes.size()*Dimension)
Stepdatabase step to which we will write

◆ SetVariable() [1/2]

template<class TDataType , class TVarType = Variable<TDataType>>
void Kratos::VariableUtils::SetVariable ( const TVarType &  rVariable,
const TDataType &  rValue,
NodesContainerType rNodes,
const Flags  Flag,
const bool  CheckValue = true 
)
inline

Sets the nodal value of a scalar variable (considering flag)

Template Parameters
TDataTypeVariable data type
Variable<TDataType>Variable type
Parameters
rVariablereference to the scalar variable to be set
rValueValue to be set
rNodesreference to the objective node set
FlagThe flag to be considered in the assignation
CheckWhat is checked from the flag

◆ SetVariable() [2/2]

template<class TDataType , class TVarType = Variable<TDataType>>
void Kratos::VariableUtils::SetVariable ( const TVarType &  rVariable,
const TDataType &  rValue,
NodesContainerType rNodes,
const unsigned int  Step = 0 
)
inline

Sets the nodal value of a scalar variable.

Template Parameters
TDataTypeVariable data type
Variable<TDataType>Variable type
Parameters
rVariablereference to the scalar variable to be set
ValueValue to be set
rNodesreference to the objective node set

◆ SumConditionScalarVariable()

template<class TVarType >
double Kratos::VariableUtils::SumConditionScalarVariable ( const TVarType &  rVar,
const ModelPart rModelPart 
)
inline

Returns the condition value summation of a historical scalar variable.

Parameters
rVarreference to the scalar variable to be summed
rModelPartreference to the model part that contains the objective condition set
Returns
sum_value: summation result

◆ SumConditionVectorVariable()

array_1d< double, 3 > Kratos::VariableUtils::SumConditionVectorVariable ( const ArrayVarType rVar,
const ModelPart rModelPart 
)

Returns the condition value summation of a historical vector variable.

Parameters
rVarreference to the vector variable to be summed
rModelPartreference to the model part that contains the objective condition set
Returns
sum_value: summation result

◆ SumElementScalarVariable()

template<class TVarType >
double Kratos::VariableUtils::SumElementScalarVariable ( const TVarType &  rVar,
const ModelPart rModelPart 
)
inline

Returns the element value summation of a historical scalar variable.

Parameters
rVarreference to the scalar variable to be summed
rModelPartreference to the model part that contains the objective element set
Returns
sum_value: summation result

◆ SumElementVectorVariable()

array_1d< double, 3 > Kratos::VariableUtils::SumElementVectorVariable ( const ArrayVarType rVar,
const ModelPart rModelPart 
)

Returns the element value summation of a historical vector variable.

Parameters
rVarreference to the vector variable to be summed
rModelPartreference to the model part that contains the objective element set
Returns
sum_value: summation result

◆ SumHistoricalVariable()

template<class TDataType , class TVarType = Variable<TDataType>>
TDataType Kratos::VariableUtils::SumHistoricalVariable ( const TVarType &  rVariable,
const ModelPart rModelPart,
const unsigned int  BuffStep = 0 
)
inline

This method accumulates and return a variable value For a nodal historical variable, this method accumulates and returns the summation in a model part.

Template Parameters
TDataTypeVariable datatype
Variable<TDataType>Variable type
Parameters
rVariableNodal historical variable to be accumulated
rModelPartModel part in where the summation is done
BuffStepBuffer position
Returns
TDataType Value of the summation

◆ SumNonHistoricalNodeScalarVariable()

template<class TVarType >
double Kratos::VariableUtils::SumNonHistoricalNodeScalarVariable ( const TVarType &  rVar,
const ModelPart rModelPart 
)
inline

Returns the nodal value summation of a non-historical scalar variable.

Parameters
rVarreference to the scalar variable to be summed
rModelPartreference to the model part that contains the objective node set
Returns
sum_value: summation result

◆ SumNonHistoricalNodeVectorVariable()

array_1d< double, 3 > Kratos::VariableUtils::SumNonHistoricalNodeVectorVariable ( const ArrayVarType rVar,
const ModelPart rModelPart 
)

Returns the nodal value summation of a non-historical vector variable.

Parameters
rVarreference to the vector variable to summed
rModelPartreference to the model part that contains the objective node set
Returns
sum_value: summation vector result

◆ UpdateCurrentPosition()

void Kratos::VariableUtils::UpdateCurrentPosition ( const ModelPart::NodesContainerType rNodes,
const ArrayVarType rUpdateVariable = DISPLACEMENT,
const IndexType  BufferPosition = 0 
)

This method updates the current coordinates For each node, this method takes the value of the provided variable and updates the current position as the initial position (X0, Y0, Z0) plus such variable value.

Parameters
rNodes
rUpdateVariablevariable to retrieve the updating values from

◆ UpdateCurrentToInitialConfiguration()

void Kratos::VariableUtils::UpdateCurrentToInitialConfiguration ( const ModelPart::NodesContainerType rNodes)

This method updates the current nodal coordinates back to the initial coordinates.

Parameters
rNodesthe nodes to be updated

◆ UpdateInitialToCurrentConfiguration()

void Kratos::VariableUtils::UpdateInitialToCurrentConfiguration ( const ModelPart::NodesContainerType rNodes)

This method updates the initial nodal coordinates to the current coordinates.

Parameters
rNodesthe nodes to be updated

◆ WeightedAccumulateVariableOnNodes()

template<class TDataType , class TContainerType , class TWeightDataType >
template void Kratos::VariableUtils::WeightedAccumulateVariableOnNodes< array_1d< double, 3 >, ModelPart::ElementsContainerType, double > ( ModelPart rModelPart,
const Variable< TDataType > &  rVariable,
const Variable< TWeightDataType > &  rWeightVariable,
const bool  IsInverseWeightProvided = false 
)

Distributes variable values in TContainerType container to nodes.

This method distributes variables values stored in TContainerType data value container in rModelPart to nodes. Constant weighting is used for each node based on rWeightVariable value. The result is stored in nodal non-historical data value container under the same rVariable. If IsInverseWeightProvided is true, then the weights provided by rWeightVariable is inverted to get nodal weight. Otherwise, the value given by rWeightVariable is used as weight.

Template Parameters
TDataTypeData type
TContainerTypeContainerType of model part
TWeightDataTypeData type of weight variable (this should be either int or double)
Parameters
rModelPartModel part
rVariableVariable to be distributed
rWeightVariableVariable which holds weight to distribute entity values to nodes
IsInverseWeightProvidedWhether the weight is provided as inverse or not.

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