52 template<
class TSparseSpace,
93 const std::string& OtherDoFName =
"ROTATION"
96 mOtherDoFName(OtherDoFName),
97 mRatioTolerance(RatioTolerance),
98 mAbsoluteTolerance(AbsoluteTolerance)
107 ,mOtherDoFName(rOther.mOtherDoFName)
108 ,mRatioTolerance(rOther.mRatioTolerance)
109 ,mAbsoluteTolerance(rOther.mAbsoluteTolerance)
110 ,mInitialResidualDispNorm(rOther.mInitialResidualDispNorm)
111 ,mCurrentResidualDispNorm(rOther.mCurrentResidualDispNorm)
112 ,mInitialResidualOtherDoFNorm(rOther.mInitialResidualOtherDoFNorm)
113 ,mCurrentResidualOtherDoFNorm(rOther.mCurrentResidualOtherDoFNorm)
151 CalculateResidualNorm(rModelPart, mCurrentResidualDispNorm, mCurrentResidualOtherDoFNorm, disp_size, rDofSet, rb);
153 if (mInitialResidualDispNorm == 0.0) {
154 ratio_displacement = 0.0;
156 ratio_displacement = mCurrentResidualDispNorm/mInitialResidualDispNorm;
159 if (mInitialResidualOtherDoFNorm == 0.0) {
160 ratio_other_dof = 0.0;
162 ratio_other_dof = mCurrentResidualOtherDoFNorm/mInitialResidualOtherDoFNorm;
166 const TDataType absolute_norm_disp = (mCurrentResidualDispNorm/
static_cast<TDataType>(disp_size));
167 const TDataType absolute_norm_other_dof = (mCurrentResidualOtherDoFNorm/
static_cast<TDataType>(system_size - disp_size));
169 KRATOS_INFO_IF(
"ResidualDisplacementAndOtherDoFCriteria", this->
GetEchoLevel() > 0) <<
"RESIDUAL DISPLACEMENT CRITERION :: Ratio = "<< ratio_displacement <<
"; Norm = " << absolute_norm_disp << std::endl;
170 KRATOS_INFO_IF(
"ResidualDisplacementAndOtherDoFCriteria", this->
GetEchoLevel() > 0) <<
"RESIDUAL " << mOtherDoFName <<
" CRITERION :: Ratio = "<< ratio_other_dof <<
"; Norm = " << absolute_norm_other_dof << std::endl;
172 rModelPart.
GetProcessInfo()[CONVERGENCE_RATIO] = ratio_displacement;
175 if ((ratio_displacement <= mRatioTolerance || absolute_norm_disp < mAbsoluteTolerance) && (ratio_other_dof <= mRatioTolerance || absolute_norm_other_dof < mAbsoluteTolerance)) {
176 KRATOS_INFO_IF(
"ResidualDisplacementAndOtherDoFCriteria", this->
GetEchoLevel() > 0) <<
"Convergence is achieved" << std::endl;
219 mActiveDofs.resize(rDofSet.
size());
221 #pragma omp parallel for
222 for(
int i=0; i<static_cast<int>(mActiveDofs.size()); ++
i) {
223 mActiveDofs[
i] =
true;
226 #pragma omp parallel for
227 for (
int i=0; i<static_cast<int>(rDofSet.
size()); ++
i) {
228 const auto it_dof = rDofSet.
begin() +
i;
229 if (it_dof->IsFixed()) {
230 mActiveDofs[it_dof->EquationId()] =
false;
235 for (
const auto& r_dof : r_mpc.GetMasterDofsVector()) {
236 mActiveDofs[r_dof->EquationId()] =
false;
238 for (
const auto& r_dof : r_mpc.GetSlaveDofsVector()) {
239 mActiveDofs[r_dof->EquationId()] =
false;
245 CalculateResidualNorm(rModelPart, mInitialResidualDispNorm, mInitialResidualOtherDoFNorm, size_residual, rDofSet, rb);
304 std::string mOtherDoFName;
314 std::vector<bool> mActiveDofs;
333 virtual void CalculateResidualNorm(
336 TDataType& rResidualSolutionNormOtherDof,
349 const auto it_dof_begin = rDofSet.begin();
350 const int number_of_dof =
static_cast<int>(rDofSet.size());
354 #pragma omp parallel for firstprivate(residual_dof_value) reduction(+:residual_solution_norm_disp, residual_solution_norm_other_dof, disp_dof_num)
355 for (
int i = 0;
i < number_of_dof;
i++) {
356 auto it_dof = it_dof_begin +
i;
358 const IndexType dof_id = it_dof->EquationId();
361 if (mActiveDofs[dof_id]) {
362 if (it_dof->GetVariable() == DISPLACEMENT_X || it_dof->GetVariable() == DISPLACEMENT_Y || it_dof->GetVariable() == DISPLACEMENT_Z) {
363 residual_solution_norm_disp += std::pow(residual_dof_value, 2);
366 residual_solution_norm_other_dof += std::pow(residual_dof_value, 2);
371 #pragma omp parallel for firstprivate(residual_dof_value) reduction(+:residual_solution_norm_disp, residual_solution_norm_other_dof, disp_dof_num)
372 for (
int i = 0;
i < number_of_dof;
i++) {
373 auto it_dof = it_dof_begin +
i;
375 if (!it_dof->IsFixed()) {
376 const IndexType dof_id = it_dof->EquationId();
379 if (it_dof->GetVariable() == DISPLACEMENT_X || it_dof->GetVariable() == DISPLACEMENT_Y || it_dof->GetVariable() == DISPLACEMENT_Z) {
380 residual_solution_norm_disp += std::pow(residual_dof_value, 2);
383 residual_solution_norm_other_dof += std::pow(residual_dof_value, 2);
389 rDofNumDisp = disp_dof_num;
390 rResidualSolutionNormDisp = std::sqrt(residual_solution_norm_disp);
391 rResidualSolutionNormOtherDof = std::sqrt(residual_solution_norm_other_dof);
This is the base class to define the different convergence criterion considered.
Definition: convergence_criteria.h:58
int GetEchoLevel()
This returns the level of echo for the solving strategy.
Definition: convergence_criteria.h:209
bool mActualizeRHSIsNeeded
Definition: convergence_criteria.h:447
TSparseSpace::MatrixType TSystemMatrixType
Matrix type definition.
Definition: convergence_criteria.h:72
TSparseSpace::DataType TDataType
Data type definition.
Definition: convergence_criteria.h:70
TSparseSpace::VectorType TSystemVectorType
Vector type definition.
Definition: convergence_criteria.h:74
bool mConvergenceCriteriaIsInitialized
This "flag" is set in order to know if it is necessary to actualize the RHS.
Definition: convergence_criteria.h:448
virtual void InitializeSolutionStep(ModelPart &rModelPart, DofsArrayType &rDofSet, const TSystemMatrixType &rA, const TSystemVectorType &rDx, const TSystemVectorType &rb)
This function initializes the solution step.
Definition: convergence_criteria.h:299
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MasterSlaveConstraintContainerType & MasterSlaveConstraints(IndexType ThisIndex=0)
Definition: model_part.h:654
SizeType NumberOfMasterSlaveConstraints(IndexType ThisIndex=0) const
Definition: model_part.h:649
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
size_type size() const
Returns the number of elements in the container.
Definition: pointer_vector_set.h:502
iterator begin()
Returns an iterator pointing to the beginning of the container.
Definition: pointer_vector_set.h:278
This is a convergence criteria that employes the residual as criteria, it divides the problem in two ...
Definition: residual_displacement_and_other_dof_criteria.h:57
BaseType::TSystemMatrixType TSystemMatrixType
Definition: residual_displacement_and_other_dof_criteria.h:72
~ResidualDisplacementAndOtherDoFCriteria() override
Definition: residual_displacement_and_other_dof_criteria.h:120
void Initialize(ModelPart &rModelPart) override
Definition: residual_displacement_and_other_dof_criteria.h:191
ResidualDisplacementAndOtherDoFCriteria(TDataType RatioTolerance, TDataType AbsoluteTolerance, const std::string &OtherDoFName="ROTATION")
Definition: residual_displacement_and_other_dof_criteria.h:90
ResidualDisplacementAndOtherDoFCriteria(ResidualDisplacementAndOtherDoFCriteria const &rOther)
Definition: residual_displacement_and_other_dof_criteria.h:105
std::size_t SizeType
Definition: residual_displacement_and_other_dof_criteria.h:78
void InitializeSolutionStep(ModelPart &rModelPart, DofsArrayType &rDofSet, const TSystemMatrixType &rA, const TSystemVectorType &rDx, const TSystemVectorType &rb) override
Definition: residual_displacement_and_other_dof_criteria.h:207
BaseType::TDataType TDataType
Definition: residual_displacement_and_other_dof_criteria.h:68
KRATOS_CLASS_POINTER_DEFINITION(ResidualDisplacementAndOtherDoFCriteria)
ConvergenceCriteria< TSparseSpace, TDenseSpace > BaseType
Definition: residual_displacement_and_other_dof_criteria.h:64
BaseType::TSystemVectorType TSystemVectorType
Definition: residual_displacement_and_other_dof_criteria.h:74
TSparseSpace SparseSpaceType
Definition: residual_displacement_and_other_dof_criteria.h:66
BaseType::DofsArrayType DofsArrayType
Definition: residual_displacement_and_other_dof_criteria.h:70
bool PostCriteria(ModelPart &rModelPart, DofsArrayType &rDofSet, const TSystemMatrixType &rA, const TSystemVectorType &rDx, const TSystemVectorType &rb) override
Definition: residual_displacement_and_other_dof_criteria.h:138
std::size_t IndexType
Definition: residual_displacement_and_other_dof_criteria.h:76
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
#define KRATOS_INFO_IF(label, conditional)
Definition: logger.h:251
TSpaceType::IndexType Size(TSpaceType &dummy, typename TSpaceType::VectorType const &rV)
Definition: add_strategies_to_python.cpp:111
Parameters GetValue(Parameters &rParameters, const std::string &rEntry)
Definition: add_kratos_parameters_to_python.cpp:53
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
integer i
Definition: TensorModule.f:17