10 #if !defined(KRATOS_DOFS_CRITERION_H_INCLUDED )
11 #define KRATOS_DOFS_CRITERION_H_INCLUDED
46 template<
class TSparseSpace,
class TDenseSpace>
78 :
BaseType(), mRatioTolerance(RatioTolerance), mAbsoluteTolerance(AbsoluteTolerance)
80 mpScalarVariable =
nullptr;
81 mpVectorVariable =
nullptr;
82 this->
Set(LocalFlagType::SUPPLIED_DOF,
false);
89 :
BaseType(), mRatioTolerance(RatioTolerance), mAbsoluteTolerance(AbsoluteTolerance)
91 mpScalarVariable = &rScalarVariable;
92 mpVectorVariable =
nullptr;
93 this->
Set(LocalFlagType::SUPPLIED_DOF,
true);
100 :
BaseType(), mRatioTolerance(RatioTolerance), mAbsoluteTolerance(AbsoluteTolerance)
102 mpVectorVariable = &rVectorVariable;
103 mpScalarVariable =
nullptr;
104 this->
Set(LocalFlagType::SUPPLIED_DOF,
true);
110 ,mRatioTolerance(rOther.mRatioTolerance)
111 ,mAbsoluteTolerance(rOther.mAbsoluteTolerance)
112 ,mpScalarVariable(rOther.mpScalarVariable)
113 ,mpVectorVariable(rOther.mpVectorVariable)
138 std::size_t size = 0;
140 if( this->
Is(LocalFlagType::INCREMENTAL) ){
141 size = CalculateIncrementalNorm(rDofSet,rDx, ReferenceNorm, CorrectionNorm);
144 size = CalculateReferenceNorm(rDofSet,rDx, ReferenceNorm, CorrectionNorm);
148 KRATOS_WARNING(
"") << GetDofName() <<
" Dofs vector has size: " << size << std::endl;
152 if(CorrectionNorm != 0)
154 ratio = CorrectionNorm/ReferenceNorm;
157 if( ratio == 0 &&
int(CorrectionNorm-
int(ReferenceNorm))==0 )
162 const DataType absolute_norm = (CorrectionNorm/
static_cast<DataType>(size));
168 std::cout <<
"DOF (" << GetDofName() <<
") ["<<rModelPart.
GetProcessInfo()[NL_ITERATION_NUMBER]<<
"] :: Ratio = " << ratio <<
"; Norm = " << absolute_norm << std::endl;
169 std::cout <<
" CorrectionNorm = " << CorrectionNorm <<
"; ReferenceNorm = " << ReferenceNorm << std::endl;
176 if ( ratio <= mRatioTolerance || absolute_norm < mAbsoluteTolerance )
182 std::cout <<
"Convergence is achieved" << std::endl;
189 if( this->
Is(LocalFlagType::INCREMENTAL) && ratio == 1.0 && ReferenceNorm <= mRatioTolerance * 1
e-2)
195 std::cout <<
"Convergence is achieved : - no movement - " << std::endl;
289 std::size_t size = 0;
290 rCorrectionNorm = 0.0;
291 rReferenceNorm = 0.0;
293 if( this->
Is(CriterionLocalFlags::SUPPLIED_DOF) ){
295 if( mpVectorVariable !=
nullptr ){
302 if(CheckVectorDof(i_dof))
304 temp = rDx[i_dof->EquationId()];
306 temp = i_dof->GetSolutionStepValue();
313 else if( mpScalarVariable !=
nullptr ){
321 if(i_dof->GetVariable() == *mpScalarVariable)
323 temp = rDx[i_dof->EquationId()];
325 temp = i_dof->GetSolutionStepValue();
334 KRATOS_ERROR <<
" No variable dof supplied to the convergence criterion " << std::endl;
337 rCorrectionNorm = std::sqrt(rCorrectionNorm);
350 temp = i_dof->GetSolutionStepValue();
357 rReferenceNorm = std::sqrt(rReferenceNorm+1
e-20);
369 std::size_t size = 0;
370 rCorrectionNorm = 0.0;
371 rReferenceNorm = 0.0;
373 if( this->
Is(CriterionLocalFlags::SUPPLIED_DOF) ){
375 if( mpVectorVariable !=
nullptr ){
383 if(CheckVectorDof(i_dof))
385 temp = rDx[i_dof->EquationId()];
387 temp = (i_dof->GetSolutionStepValue()-i_dof->GetSolutionStepValue(1));
394 else if( mpScalarVariable !=
nullptr ){
402 if(i_dof->GetVariable() == *mpScalarVariable)
404 temp = rDx[i_dof->EquationId()];
406 temp = (i_dof->GetSolutionStepValue()-i_dof->GetSolutionStepValue(1));
415 KRATOS_ERROR <<
" No variable dof supplied to the convergence criterion " << std::endl;
426 temp = rDx[i_dof->EquationId()];
428 temp = (i_dof->GetSolutionStepValue()-i_dof->GetSolutionStepValue(1));
436 rCorrectionNorm = std::sqrt(rCorrectionNorm);
437 rReferenceNorm = std::sqrt(rReferenceNorm+1
e-20);
448 const std::string& variable_name = mpVectorVariable->Name();
449 const Variable<double>& var_x = KratosComponents<Variable<double> >::Get(variable_name+
"_X");
450 const Variable<double>& var_y = KratosComponents<Variable<double> >::Get(variable_name+
"_Y");
451 const Variable<double>& var_z = KratosComponents<Variable<double> >::Get(variable_name+
"_Z");
453 if( rDofIter->GetVariable() == var_x || rDofIter->GetVariable() == var_y || rDofIter->GetVariable() == var_z )
461 std::string GetDofName()
463 std::string name =
"DOFS";
465 if( this->
Is(CriterionLocalFlags::SUPPLIED_DOF) ){
467 if( mpVectorVariable !=
nullptr ){
468 name = mpVectorVariable->Name();
470 else if( mpScalarVariable !=
nullptr ){
471 name = mpScalarVariable->Name();
virtual int MyPID() const
Definition: communicator.cpp:91
Convergence Criterion base class.
Definition: convergence_criterion.hpp:52
TSparseSpace::DataType DataType
Definition: convergence_criterion.hpp:58
int GetEchoLevel()
Definition: convergence_criterion.hpp:109
TSparseSpace::MatrixType SystemMatrixType
Definition: convergence_criterion.hpp:60
TSparseSpace::VectorType SystemVectorType
Definition: convergence_criterion.hpp:61
Solver local flags class definition.
Definition: solution_local_flags.hpp:74
This convergence criteria checks the variable dofs.
Definition: dofs_criterion.hpp:48
BaseType::SystemMatrixType SystemMatrixType
Definition: dofs_criterion.hpp:58
array_1d< double, 3 > VectorType
Definition: dofs_criterion.hpp:61
Variable< VectorType > VariableVectorType
Definition: dofs_criterion.hpp:63
Variable< double > VectorComponentType
Definition: dofs_criterion.hpp:62
const VariableVectorType * VariableVectorPointer
Definition: dofs_criterion.hpp:65
DofsCriterion(const VariableScalarType &rScalarVariable, DataType RatioTolerance, DataType AbsoluteTolerance)
Constructor.
Definition: dofs_criterion.hpp:86
~DofsCriterion() override
Destructor.
Definition: dofs_criterion.hpp:118
BaseType::SystemVectorType SystemVectorType
Definition: dofs_criterion.hpp:59
BaseType::DataType DataType
Definition: dofs_criterion.hpp:56
KRATOS_CLASS_POINTER_DEFINITION(DofsCriterion)
Pointer definition of DofsCriterion.
BaseType::DofsArrayType DofsArrayType
Definition: dofs_criterion.hpp:57
Variable< double > VariableScalarType
Definition: dofs_criterion.hpp:64
DofsCriterion(DofsCriterion const &rOther)
Copy constructor.
Definition: dofs_criterion.hpp:108
BaseType::LocalFlagType LocalFlagType
Definition: dofs_criterion.hpp:55
DofsCriterion(DataType RatioTolerance, DataType AbsoluteTolerance)
Constructor.
Definition: dofs_criterion.hpp:76
bool PostCriteria(ModelPart &rModelPart, DofsArrayType &rDofSet, const SystemMatrixType &rA, const SystemVectorType &rDx, const SystemVectorType &rb) override
Definition: dofs_criterion.hpp:126
DofsCriterion(const VariableVectorType &rVectorVariable, DataType RatioTolerance, DataType AbsoluteTolerance)
Constructor.
Definition: dofs_criterion.hpp:97
const VariableScalarType * VariableScalarPointer
Definition: dofs_criterion.hpp:66
ConvergenceCriterion< TSparseSpace, TDenseSpace > BaseType
Definition: dofs_criterion.hpp:54
void Set(const Flags ThisFlag)
Definition: flags.cpp:33
bool Is(Flags const &rOther) const
Definition: flags.h:274
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
Communicator & GetCommunicator()
Definition: model_part.h:1821
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: pointer_vector_set.h:95
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_WARNING(label)
Definition: logger.h:265
double TwoNorm(SparseSpaceType &dummy, SparseSpaceType::VectorType &x)
Definition: add_strategies_to_python.cpp:164
TSpaceType::IndexType Size(TSpaceType &dummy, typename TSpaceType::VectorType const &rV)
Definition: add_strategies_to_python.cpp:111
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
float temp
Definition: rotating_cone.py:85
e
Definition: run_cpp_mpi_tests.py:31