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::ResidualCriteria< TSparseSpace, TDenseSpace > Class Template Reference

This is a convergence criteria that considers the residual as criteria. More...

#include <residual_criteria.h>

Inheritance diagram for Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >:
Collaboration diagram for Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >:

Public Member Functions

Life Cycle
 ResidualCriteria ()
 Default constructor. More...
 
 ResidualCriteria (Kratos::Parameters ThisParameters)
 Default constructor. (with parameters) More...
 
 ResidualCriteria (TDataType NewRatioTolerance, TDataType AlwaysConvergedNorm)
 Constructor 2 arguments. More...
 
 ResidualCriteria (ResidualCriteria const &rOther)
 Copy constructor. More...
 
 ~ResidualCriteria () override
 Destructor. More...
 
Operators
ResidualCriteriaoperator= (ResidualCriteria const &rOther)=delete
 Deleted assignment operator. More...
 
Input and output
std::string Info () const override
 Turn back information as a string. More...
 
void PrintInfo (std::ostream &rOStream) const override
 Print information about this object. More...
 
void PrintData (std::ostream &rOStream) const override
 Print object's data. More...
 
- Public Member Functions inherited from Kratos::ConvergenceCriteria< TSparseSpace, TDenseSpace >
 ConvergenceCriteria ()
 
 ConvergenceCriteria (Kratos::Parameters ThisParameters)
 Constructor with Parameters. More...
 
 ConvergenceCriteria (ConvergenceCriteria const &rOther)
 
virtual ~ConvergenceCriteria ()
 
 KRATOS_CLASS_POINTER_DEFINITION (ConvergenceCriteria)
 Pointer definition of ConvergenceCriteria. More...
 
virtual std::vector< TSystemVectorType > & GetRHS_Element_Components ()
 Get component wise element components. More...
 
virtual std::vector< Variable< LocalSystemVectorType > > & GetRHS_Element_Variables ()
 Get component wise element variables. More...
 
virtual std::vector< TSystemVectorType > & GetRHS_Condition_Components ()
 Get component wise condition components. More...
 
virtual std::vector< Variable< LocalSystemVectorType > > & GetRHS_Condition_Variables ()
 Get component wise condition variables. More...
 
virtual void SetEchoLevel (int Level)
 It sets the level of echo for the solving strategy. More...
 
int GetEchoLevel ()
 This returns the level of echo for the solving strategy. More...
 
void SetActualizeRHSFlag (bool ActualizeRHSIsNeeded)
 This method sets the flag mActualizeRHSIsNeeded. More...
 
bool GetActualizeRHSflag ()
 This method gets the flag mActualizeRHSIsNeeded. More...
 
virtual bool PreCriteria (ModelPart &rModelPart, DofsArrayType &rDofSet, const TSystemMatrixType &rA, const TSystemVectorType &rDx, const TSystemVectorType &rb)
 Criterias that need to be called before getting the solution. More...
 
virtual void Initialize (ModelPart &rModelPart)
 This function initialize the convergence criteria. More...
 
virtual bool IsInitialized ()
 This function returns if the convergence criteria is initialized. More...
 
virtual void InitializeNonLinearIteration (ModelPart &rModelPart, DofsArrayType &rDofSet, const TSystemMatrixType &rA, const TSystemVectorType &rDx, const TSystemVectorType &rb)
 This function initializes the non-linear iteration. More...
 
virtual void FinalizeNonLinearIteration (ModelPart &rModelPart, DofsArrayType &rDofSet, const TSystemMatrixType &rA, const TSystemVectorType &rDx, const TSystemVectorType &rb)
 This function finalizes the non-linear iteration. More...
 
virtual int Check (ModelPart &rModelPart)
 This function is designed to be called once to perform all the checks needed on the input provided. Checks can be "expensive" as the function is designed to catch user's errors. More...
 

Protected Member Functions

Protected Operations
virtual void ComputeActiveDofs (ModelPart &rModelPart, const ModelPart::DofsArrayType &rDofSet)
 This method computes the active dofs. More...
 
bool IsActiveAndLocalDof (const DofType &rDof, const int Rank)
 Check if a Degree of Freedom (Dof) is active. More...
 
bool IsFreeAndLocalDof (const DofType &rDof, const int Rank)
 Check if a Degree of Freedom (Dof) is free. More...
 
virtual void CalculateResidualNorm (ModelPart &rModelPart, TDataType &rResidualSolutionNorm, SizeType &rDofNum, DofsArrayType &rDofSet, const TSystemVectorType &rb)
 This method computes the norm of the residual. More...
 
void AssignSettings (const Parameters ThisParameters) override
 This method assigns settings to member variables. More...
 
- Protected Member Functions inherited from Kratos::ConvergenceCriteria< TSparseSpace, TDenseSpace >
virtual Parameters ValidateAndAssignParameters (Parameters ThisParameters, const Parameters DefaultParameters) const
 This method validate and assign default parameters. More...
 

Protected Attributes

Protected member Variables
TDataType mRatioTolerance {}
 
TDataType mInitialResidualNorm {}
 The ratio threshold for the norm of the residual. More...
 
TDataType mCurrentResidualNorm {}
 The reference norm of the residual. More...
 
TDataType mAlwaysConvergedNorm {}
 The current norm of the residual. More...
 
TDataType mReferenceDispNorm {}
 The absolute value threshold for the norm of the residual. More...
 
std::vector< intmActiveDofs
 The norm at the beginning of the iterations. More...
 
IndexType mInitialDoFId = std::numeric_limits<IndexType>::max()
 This vector contains the dofs that are active. More...
 
- Protected Attributes inherited from Kratos::ConvergenceCriteria< TSparseSpace, TDenseSpace >
bool mActualizeRHSIsNeeded = false
 
bool mConvergenceCriteriaIsInitialized = false
 This "flag" is set in order to know if it is necessary to actualize the RHS. More...
 
int mEchoLevel
 This "flag" is set in order to know if it is convergence criteria is initialized. More...
 

Type Definitions

using BaseType = ConvergenceCriteria< TSparseSpace, TDenseSpace >
 The definition of the base ConvergenceCriteria. More...
 
using ClassType = ResidualCriteria< TSparseSpace, TDenseSpace >
 The definition of the current class. More...
 
using TDataType = typename BaseType::TDataType
 The data type. More...
 
using DofsArrayType = typename BaseType::DofsArrayType
 The dofs array type. More...
 
using DofType = typename Node::DofType
 The definition of the DoF data type. More...
 
using TSystemMatrixType = typename BaseType::TSystemMatrixType
 The sparse matrix type. More...
 
using TSystemVectorType = typename BaseType::TSystemVectorType
 The dense vector type. More...
 
using IndexType = std::size_t
 Definition of the IndexType. More...
 
using SizeType = std::size_t
 Definition of the size type. More...
 
 KRATOS_CLASS_POINTER_DEFINITION (ResidualCriteria)
 Pointer definition of ResidualCriteria. More...
 

Operations

BaseType::Pointer Create (Parameters ThisParameters) const override
 Create method. More...
 
bool PostCriteria (ModelPart &rModelPart, DofsArrayType &rDofSet, const TSystemMatrixType &rA, const TSystemVectorType &rDx, const TSystemVectorType &rb) override
 Criterion that need to be called after getting the solution. More...
 
void InitializeSolutionStep (ModelPart &rModelPart, DofsArrayType &rDofSet, const TSystemMatrixType &rA, const TSystemVectorType &rDx, const TSystemVectorType &rb) override
 This function initializes the solution step. More...
 
void FinalizeSolutionStep (ModelPart &rModelPart, DofsArrayType &rDofSet, const TSystemMatrixType &rA, const TSystemVectorType &rDx, const TSystemVectorType &rb) override
 This function finalizes the solution step. More...
 
Parameters GetDefaultParameters () const override
 This method provides the defaults parameters to avoid conflicts between the different constructors. More...
 
static std::string Name ()
 Returns the name of the class as used in the settings (snake_case format) More...
 

Additional Inherited Members

- Public Types inherited from Kratos::ConvergenceCriteria< TSparseSpace, TDenseSpace >
typedef ConvergenceCriteria< TSparseSpace, TDenseSpace > ClassType
 The definition of the current class. More...
 
typedef TSparseSpace::DataType TDataType
 Data type definition. More...
 
typedef TSparseSpace::MatrixType TSystemMatrixType
 Matrix type definition. More...
 
typedef TSparseSpace::VectorType TSystemVectorType
 Vector type definition. More...
 
typedef TDenseSpace::MatrixType LocalSystemMatrixType
 Local system matrix type definition. More...
 
typedef TDenseSpace::VectorType LocalSystemVectorType
 Local system vector type definition. More...
 
typedef ModelPart::DofsArrayType DofsArrayType
 DoF array type definition. More...
 
- Static Public Member Functions inherited from Kratos::ConvergenceCriteria< TSparseSpace, TDenseSpace >
static std::string Name ()
 Returns the name of the class as used in the settings (snake_case format) More...
 

Detailed Description

template<class TSparseSpace, class TDenseSpace>
class Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >

This is a convergence criteria that considers the residual as criteria.

The reactions from the RHS are not computed in the residual

Author
Riccardo Rossi

Member Typedef Documentation

◆ BaseType

template<class TSparseSpace , class TDenseSpace >
using Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::BaseType = ConvergenceCriteria< TSparseSpace, TDenseSpace >

The definition of the base ConvergenceCriteria.

◆ ClassType

template<class TSparseSpace , class TDenseSpace >
using Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::ClassType = ResidualCriteria< TSparseSpace, TDenseSpace >

The definition of the current class.

◆ DofsArrayType

template<class TSparseSpace , class TDenseSpace >
using Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::DofsArrayType = typename BaseType::DofsArrayType

The dofs array type.

◆ DofType

template<class TSparseSpace , class TDenseSpace >
using Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::DofType = typename Node::DofType

The definition of the DoF data type.

◆ IndexType

template<class TSparseSpace , class TDenseSpace >
using Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::IndexType = std::size_t

Definition of the IndexType.

◆ SizeType

template<class TSparseSpace , class TDenseSpace >
using Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::SizeType = std::size_t

Definition of the size type.

◆ TDataType

template<class TSparseSpace , class TDenseSpace >
using Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::TDataType = typename BaseType::TDataType

The data type.

◆ TSystemMatrixType

template<class TSparseSpace , class TDenseSpace >
using Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::TSystemMatrixType = typename BaseType::TSystemMatrixType

The sparse matrix type.

◆ TSystemVectorType

template<class TSparseSpace , class TDenseSpace >
using Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::TSystemVectorType = typename BaseType::TSystemVectorType

The dense vector type.

Constructor & Destructor Documentation

◆ ResidualCriteria() [1/4]

template<class TSparseSpace , class TDenseSpace >
Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::ResidualCriteria ( )
inlineexplicit

Default constructor.

◆ ResidualCriteria() [2/4]

template<class TSparseSpace , class TDenseSpace >
Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::ResidualCriteria ( Kratos::Parameters  ThisParameters)
inlineexplicit

Default constructor. (with parameters)

Parameters
ThisParametersThe configuration parameters

◆ ResidualCriteria() [3/4]

template<class TSparseSpace , class TDenseSpace >
Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::ResidualCriteria ( TDataType  NewRatioTolerance,
TDataType  AlwaysConvergedNorm 
)
inlineexplicit

Constructor 2 arguments.

Parameters
NewRatioToleranceThe ratio tolerance for the convergence.
AlwaysConvergedNormThe absolute tolerance for the convergence.

◆ ResidualCriteria() [4/4]

template<class TSparseSpace , class TDenseSpace >
Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::ResidualCriteria ( ResidualCriteria< TSparseSpace, TDenseSpace > const &  rOther)
inlineexplicit

Copy constructor.

Parameters
rOtherThe criteria to be copied

◆ ~ResidualCriteria()

template<class TSparseSpace , class TDenseSpace >
Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::~ResidualCriteria ( )
inlineoverride

Destructor.

Member Function Documentation

◆ AssignSettings()

template<class TSparseSpace , class TDenseSpace >
void Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::AssignSettings ( const Parameters  ThisParameters)
inlineoverrideprotectedvirtual

This method assigns settings to member variables.

Parameters
ThisParametersParameters that are assigned to the member variables

Reimplemented from Kratos::ConvergenceCriteria< TSparseSpace, TDenseSpace >.

◆ CalculateResidualNorm()

template<class TSparseSpace , class TDenseSpace >
virtual void Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::CalculateResidualNorm ( ModelPart rModelPart,
TDataType rResidualSolutionNorm,
SizeType rDofNum,
DofsArrayType rDofSet,
const TSystemVectorType rb 
)
inlineprotectedvirtual

This method computes the norm of the residual.

It checks if the dof is fixed

Parameters
rModelPartReference to the ModelPart containing the problem.
rResidualSolutionNormThe norm of the residual
rDofNumThe number of DoFs
rDofSetReference to the container of the problem's degrees of freedom (stored by the BuilderAndSolver)
rbRHS vector (residual + reactions)

◆ ComputeActiveDofs()

template<class TSparseSpace , class TDenseSpace >
virtual void Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::ComputeActiveDofs ( ModelPart rModelPart,
const ModelPart::DofsArrayType rDofSet 
)
inlineprotectedvirtual

This method computes the active dofs.

Parameters
rModelPartReference to the ModelPart containing the problem
rDofSetThe whole set of dofs

Reimplemented in Kratos::TrilinosResidualCriteria< TSparseSpace, TDenseSpace >.

◆ Create()

template<class TSparseSpace , class TDenseSpace >
BaseType::Pointer Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::Create ( Parameters  ThisParameters) const
inlineoverridevirtual

Create method.

Parameters
ThisParametersThe configuration parameters

Reimplemented from Kratos::ConvergenceCriteria< TSparseSpace, TDenseSpace >.

Reimplemented in Kratos::TrilinosResidualCriteria< TSparseSpace, TDenseSpace >.

◆ FinalizeSolutionStep()

template<class TSparseSpace , class TDenseSpace >
void Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::FinalizeSolutionStep ( ModelPart rModelPart,
DofsArrayType rDofSet,
const TSystemMatrixType rA,
const TSystemVectorType rDx,
const TSystemVectorType rb 
)
inlineoverridevirtual

This function finalizes the solution step.

Parameters
rModelPartReference to the ModelPart containing the problem.
rDofSetReference to the container of the problem's degrees of freedom (stored by the BuilderAndSolver)
ASystem matrix (unused)
DxVector of results (variations on nodal variables)
bRHS vector (residual + reactions)

Reimplemented from Kratos::ConvergenceCriteria< TSparseSpace, TDenseSpace >.

◆ GetDefaultParameters()

template<class TSparseSpace , class TDenseSpace >
Parameters Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::GetDefaultParameters ( ) const
inlineoverridevirtual

This method provides the defaults parameters to avoid conflicts between the different constructors.

Returns
The default parameters

Reimplemented from Kratos::ConvergenceCriteria< TSparseSpace, TDenseSpace >.

Reimplemented in Kratos::TrilinosResidualCriteria< TSparseSpace, TDenseSpace >.

◆ Info()

template<class TSparseSpace , class TDenseSpace >
std::string Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::Info ( ) const
inlineoverridevirtual

◆ InitializeSolutionStep()

template<class TSparseSpace , class TDenseSpace >
void Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::InitializeSolutionStep ( ModelPart rModelPart,
DofsArrayType rDofSet,
const TSystemMatrixType rA,
const TSystemVectorType rDx,
const TSystemVectorType rb 
)
inlineoverridevirtual

This function initializes the solution step.

Parameters
rModelPartReference to the ModelPart containing the problem.
rDofSetReference to the container of the problem's degrees of freedom (stored by the BuilderAndSolver)
rASystem matrix (unused)
rDxVector of results (variations on nodal variables)
rbRHS vector (residual + reactions)

Reimplemented from Kratos::ConvergenceCriteria< TSparseSpace, TDenseSpace >.

Reimplemented in Kratos::TrilinosResidualCriteria< TSparseSpace, TDenseSpace >.

◆ IsActiveAndLocalDof()

template<class TSparseSpace , class TDenseSpace >
bool Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::IsActiveAndLocalDof ( const DofType rDof,
const int  Rank 
)
inlineprotected

Check if a Degree of Freedom (Dof) is active.

This function checks if a given Degree of Freedom (Dof) is active. The reason why PARTITION_INDEX is considered in distributed runs is to avoid adding twice (or even more times) the same value into the norm

Parameters
rDofThe Degree of Freedom to check.
RankThe rank of the Dof.
Returns
True if the Dof is free, false otherwise.

◆ IsFreeAndLocalDof()

template<class TSparseSpace , class TDenseSpace >
bool Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::IsFreeAndLocalDof ( const DofType rDof,
const int  Rank 
)
inlineprotected

Check if a Degree of Freedom (Dof) is free.

This function checks if a given Degree of Freedom (Dof) is free. The reason why PARTITION_INDEX is considered in distributed runs is to avoid adding twice (or even more times) the same value into the norm

Parameters
rDofThe Degree of Freedom to check.
RankThe rank of the Dof.
Returns
True if the Dof is free, false otherwise.

◆ KRATOS_CLASS_POINTER_DEFINITION()

template<class TSparseSpace , class TDenseSpace >
Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::KRATOS_CLASS_POINTER_DEFINITION ( ResidualCriteria< TSparseSpace, TDenseSpace >  )

Pointer definition of ResidualCriteria.

◆ Name()

template<class TSparseSpace , class TDenseSpace >
static std::string Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::Name ( )
inlinestatic

Returns the name of the class as used in the settings (snake_case format)

Returns
The name of the class

◆ operator=()

template<class TSparseSpace , class TDenseSpace >
ResidualCriteria& Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::operator= ( ResidualCriteria< TSparseSpace, TDenseSpace > const &  rOther)
delete

Deleted assignment operator.

◆ PostCriteria()

template<class TSparseSpace , class TDenseSpace >
bool Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::PostCriteria ( ModelPart rModelPart,
DofsArrayType rDofSet,
const TSystemMatrixType rA,
const TSystemVectorType rDx,
const TSystemVectorType rb 
)
inlineoverridevirtual

Criterion that need to be called after getting the solution.

Compute relative and absolute error.

Parameters
rModelPartReference to the ModelPart containing the problem.
rDofSetReference to the container of the problem's degrees of freedom (stored by the BuilderAndSolver)
rASystem matrix (unused)
rDxVector of results (variations on nodal variables)
rbRHS vector (residual + reactions)
Returns
true if convergence is achieved, false otherwise

Reimplemented from Kratos::ConvergenceCriteria< TSparseSpace, TDenseSpace >.

◆ PrintData()

template<class TSparseSpace , class TDenseSpace >
void Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::PrintData ( std::ostream &  rOStream) const
inlineoverridevirtual

◆ PrintInfo()

template<class TSparseSpace , class TDenseSpace >
void Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::PrintInfo ( std::ostream &  rOStream) const
inlineoverridevirtual

Print information about this object.

Reimplemented from Kratos::ConvergenceCriteria< TSparseSpace, TDenseSpace >.

Reimplemented in Kratos::TrilinosResidualCriteria< TSparseSpace, TDenseSpace >.

Member Data Documentation

◆ mActiveDofs

template<class TSparseSpace , class TDenseSpace >
std::vector<int> Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::mActiveDofs
protected

The norm at the beginning of the iterations.

◆ mAlwaysConvergedNorm

template<class TSparseSpace , class TDenseSpace >
TDataType Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::mAlwaysConvergedNorm {}
protected

The current norm of the residual.

◆ mCurrentResidualNorm

template<class TSparseSpace , class TDenseSpace >
TDataType Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::mCurrentResidualNorm {}
protected

The reference norm of the residual.

◆ mInitialDoFId

template<class TSparseSpace , class TDenseSpace >
IndexType Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::mInitialDoFId = std::numeric_limits<IndexType>::max()
protected

This vector contains the dofs that are active.

◆ mInitialResidualNorm

template<class TSparseSpace , class TDenseSpace >
TDataType Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::mInitialResidualNorm {}
protected

The ratio threshold for the norm of the residual.

◆ mRatioTolerance

template<class TSparseSpace , class TDenseSpace >
TDataType Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::mRatioTolerance {}
protected

◆ mReferenceDispNorm

template<class TSparseSpace , class TDenseSpace >
TDataType Kratos::ResidualCriteria< TSparseSpace, TDenseSpace >::mReferenceDispNorm {}
protected

The absolute value threshold for the norm of the residual.


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