57 template<
class TSparseSpace,
101 static constexpr
double Tolerance = std::numeric_limits<double>::epsilon();
140 const double DispRatioTolerance,
141 const double DispAbsTolerance,
142 const double RotRatioTolerance,
143 const double RotAbsTolerance,
144 const double LMRatioTolerance,
145 const double LMAbsTolerance,
146 const bool EnsureContact =
false,
147 const bool PrintingOutput =
false
152 mOptions.
Set(DisplacementLagrangeMultiplierContactCriteria::ENSURE_CONTACT, EnsureContact);
153 mOptions.
Set(DisplacementLagrangeMultiplierContactCriteria::PRINTING_OUTPUT, PrintingOutput);
154 mOptions.
Set(DisplacementLagrangeMultiplierContactCriteria::TABLE_IS_INITIALIZED,
false);
155 mOptions.
Set(DisplacementLagrangeMultiplierContactCriteria::ROTATION_DOF_IS_CONSIDERED,
false);
158 mDispRatioTolerance = DispRatioTolerance;
159 mDispAbsTolerance = DispAbsTolerance;
162 mRotRatioTolerance = RotRatioTolerance;
163 mRotAbsTolerance = RotAbsTolerance;
166 mLMRatioTolerance = LMRatioTolerance;
167 mLMAbsTolerance = LMAbsTolerance;
173 ,mOptions(rOther.mOptions)
174 ,mDispRatioTolerance(rOther.mDispRatioTolerance)
175 ,mDispAbsTolerance(rOther.mDispAbsTolerance)
176 ,mRotRatioTolerance(rOther.mRotRatioTolerance)
177 ,mRotAbsTolerance(rOther.mRotAbsTolerance)
178 ,mLMRatioTolerance(rOther.mLMRatioTolerance)
179 ,mLMAbsTolerance(rOther.mLMAbsTolerance)
200 return Kratos::make_shared<ClassType>(ThisParameters);
222 double disp_solution_norm = 0.0, rot_solution_norm = 0.0, lm_solution_norm = 0.0, disp_increase_norm = 0.0, rot_increase_norm = 0.0, lm_increase_norm = 0.0;
223 IndexType disp_dof_num(0),rot_dof_num(0),lm_dof_num(0);
227 std::size_t dof_id = 0;
228 double dof_value = 0.0, dof_incr = 0.0;
232 const std::size_t number_active_dofs = rb.size();
236 [](
const VariableData& rCurrVar) ->
bool {
return true;};
238 [](
const VariableData& rCurrVar) ->
bool {
return ((rCurrVar == DISPLACEMENT_X) || (rCurrVar == DISPLACEMENT_Y) || (rCurrVar == DISPLACEMENT_Z));};
239 const auto* p_check_disp = (mOptions.
Is(DisplacementLagrangeMultiplierContactCriteria::ROTATION_DOF_IS_CONSIDERED)) ? &check_with_rot : &check_without_rot;
243 std::tie(disp_solution_norm, rot_solution_norm, lm_solution_norm, disp_increase_norm, rot_increase_norm, lm_increase_norm, disp_dof_num, rot_dof_num, lm_dof_num) = block_for_each<NineReduction>(rDofSet, AuxValues(), [
this,p_check_disp,&number_active_dofs,&rDx](
Dof<double>& rDof, AuxValues& aux_values) {
247 if (aux_values.dof_id < number_active_dofs) {
248 if (mActiveDofs[aux_values.dof_id] == 1) {
249 aux_values.dof_value = rDof.GetSolutionStepValue(0);
250 aux_values.dof_incr = rDx[aux_values.dof_id];
252 const auto& r_curr_var = rDof.GetVariable();
253 if ((r_curr_var == VECTOR_LAGRANGE_MULTIPLIER_X) || (r_curr_var == VECTOR_LAGRANGE_MULTIPLIER_Y) || (r_curr_var == VECTOR_LAGRANGE_MULTIPLIER_Z) || (r_curr_var == LAGRANGE_MULTIPLIER_CONTACT_PRESSURE)) {
254 return std::make_tuple(0.0,0.0,std::pow(aux_values.dof_value, 2),0.0,0.0,std::pow(aux_values.dof_incr, 2),0,0,1);
255 } else if ((*p_check_disp)(r_curr_var)) {
256 return std::make_tuple(std::pow(aux_values.dof_value, 2),0.0,0.0,std::pow(aux_values.dof_incr, 2),0.0,0.0,1,0,0);
258 KRATOS_DEBUG_ERROR_IF_NOT((r_curr_var == ROTATION_X) || (r_curr_var == ROTATION_Y) || (r_curr_var == ROTATION_Z)) <<
"Variable must be a ROTATION and it is: " << r_curr_var.Name() << std::endl;
259 return std::make_tuple(0.0,std::pow(aux_values.dof_value, 2),0.0,0.0,std::pow(aux_values.dof_incr, 2),0.0,0,1,0);
263 return std::make_tuple(0.0,0.0,0.0,0.0,0.0,0.0,0,0,0);
266 if(disp_increase_norm <
Tolerance) disp_increase_norm = 1.0;
267 if(rot_increase_norm <
Tolerance) rot_increase_norm = 1.0;
268 if(lm_increase_norm <
Tolerance) lm_increase_norm = 1.0;
269 if(disp_solution_norm <
Tolerance) disp_solution_norm = 1.0;
271 KRATOS_ERROR_IF(mOptions.
Is(DisplacementLagrangeMultiplierContactCriteria::ENSURE_CONTACT) && lm_solution_norm <
Tolerance) <<
"WARNING::CONTACT LOST::ARE YOU SURE YOU ARE SUPPOSED TO HAVE CONTACT?" << std::endl;
273 const double disp_ratio = std::sqrt(disp_increase_norm/disp_solution_norm);
274 const double rot_ratio = std::sqrt(rot_increase_norm/rot_solution_norm);
275 const double lm_ratio = lm_solution_norm >
Tolerance ? std::sqrt(lm_increase_norm/lm_solution_norm) : 0.0;
277 const double disp_abs = std::sqrt(disp_increase_norm)/
static_cast<double>(disp_dof_num);
278 const double rot_abs = std::sqrt(rot_increase_norm)/
static_cast<double>(rot_dof_num);
279 const double lm_abs = std::sqrt(lm_increase_norm)/
static_cast<double>(lm_dof_num);
286 if (r_process_info.
Has(TABLE_UTILITY)) {
287 std::cout.precision(4);
289 auto& r_table = p_table->GetTable();
290 if (mOptions.
Is(DisplacementLagrangeMultiplierContactCriteria::ROTATION_DOF_IS_CONSIDERED)) {
291 r_table << disp_ratio << mDispRatioTolerance << disp_abs << mDispAbsTolerance << rot_ratio << mRotRatioTolerance << rot_abs << mRotAbsTolerance << lm_ratio << mLMRatioTolerance << lm_abs << mLMAbsTolerance;
293 r_table << disp_ratio << mDispRatioTolerance << disp_abs << mDispAbsTolerance << lm_ratio << mLMRatioTolerance << lm_abs << mLMAbsTolerance;
296 std::cout.precision(4);
297 if (mOptions.
IsNot(DisplacementLagrangeMultiplierContactCriteria::PRINTING_OUTPUT)) {
298 KRATOS_INFO(
"DisplacementLagrangeMultiplierContactCriteria") <<
BOLDFONT(
"DoF ONVERGENCE CHECK") <<
"\tSTEP: " << r_process_info[STEP] <<
"\tNL ITERATION: " << r_process_info[NL_ITERATION_NUMBER] << std::endl;
299 KRATOS_INFO(
"DisplacementLagrangeMultiplierContactCriteria") <<
BOLDFONT(
"\tDISPLACEMENT: RATIO = ") << disp_ratio <<
BOLDFONT(
" EXP.RATIO = ") << mDispRatioTolerance <<
BOLDFONT(
" ABS = ") << disp_abs <<
BOLDFONT(
" EXP.ABS = ") << mDispAbsTolerance << std::endl;
300 if (mOptions.
Is(DisplacementLagrangeMultiplierContactCriteria::ROTATION_DOF_IS_CONSIDERED)) {
301 KRATOS_INFO(
"DisplacementLagrangeMultiplierContactCriteria") <<
BOLDFONT(
"\tROTATION: RATIO = ") << rot_ratio <<
BOLDFONT(
" EXP.RATIO = ") << mRotRatioTolerance <<
BOLDFONT(
" ABS = ") << rot_abs <<
BOLDFONT(
" EXP.ABS = ") << mRotAbsTolerance << std::endl;
303 KRATOS_INFO(
"DisplacementLagrangeMultiplierContactCriteria") <<
BOLDFONT(
" LAGRANGE MUL:\tRATIO = ") << lm_ratio <<
BOLDFONT(
" EXP.RATIO = ") << mLMRatioTolerance <<
BOLDFONT(
" ABS = ") << lm_abs <<
BOLDFONT(
" EXP.ABS = ") << mLMAbsTolerance << std::endl;
305 KRATOS_INFO(
"DisplacementLagrangeMultiplierContactCriteria") <<
"DoF ONVERGENCE CHECK" <<
"\tSTEP: " << r_process_info[STEP] <<
"\tNL ITERATION: " << r_process_info[NL_ITERATION_NUMBER] << std::endl;
306 KRATOS_INFO(
"DisplacementLagrangeMultiplierContactCriteria") <<
"\tDISPLACEMENT: RATIO = " << disp_ratio <<
" EXP.RATIO = " << mDispRatioTolerance <<
" ABS = " << disp_abs <<
" EXP.ABS = " << mDispAbsTolerance << std::endl;
307 if (mOptions.
Is(DisplacementLagrangeMultiplierContactCriteria::ROTATION_DOF_IS_CONSIDERED)) {
308 KRATOS_INFO(
"DisplacementLagrangeMultiplierContactCriteria") <<
"\tROTATION: RATIO = " << rot_ratio <<
" EXP.RATIO = " << mRotRatioTolerance <<
" ABS = " << rot_abs <<
" EXP.ABS = " << mRotAbsTolerance << std::endl;
310 KRATOS_INFO(
"DisplacementLagrangeMultiplierContactCriteria") <<
" LAGRANGE MUL:\tRATIO = " << lm_ratio <<
" EXP.RATIO = " << mLMRatioTolerance <<
" ABS = " << lm_abs <<
" EXP.ABS = " << mLMAbsTolerance << std::endl;
316 const bool disp_converged = (disp_ratio <= mDispRatioTolerance || disp_abs <= mDispAbsTolerance);
317 const bool rot_converged = (mOptions.
Is(DisplacementLagrangeMultiplierContactCriteria::ROTATION_DOF_IS_CONSIDERED)) ? (rot_ratio <= mRotRatioTolerance || rot_abs <= mRotAbsTolerance) :
true;
318 const bool lm_converged = (mOptions.
IsNot(DisplacementLagrangeMultiplierContactCriteria::ENSURE_CONTACT) && lm_solution_norm <
Tolerance) ?
true : (lm_ratio <= mLMRatioTolerance || lm_abs <= mLMAbsTolerance);
320 if (disp_converged && rot_converged && lm_converged) {
322 if (r_process_info.
Has(TABLE_UTILITY)) {
324 auto& r_table = p_table->GetTable();
325 if (mOptions.
IsNot(DisplacementLagrangeMultiplierContactCriteria::PRINTING_OUTPUT))
328 r_table <<
"Achieved";
330 if (mOptions.
IsNot(DisplacementLagrangeMultiplierContactCriteria::PRINTING_OUTPUT))
333 KRATOS_INFO(
"DisplacementLagrangeMultiplierContactCriteria") <<
"\tDoF convergence is achieved" << std::endl;
339 if (r_process_info.
Has(TABLE_UTILITY)) {
341 auto& r_table = p_table->GetTable();
342 if (mOptions.
IsNot(DisplacementLagrangeMultiplierContactCriteria::PRINTING_OUTPUT))
345 r_table <<
"Not achieved";
347 if (mOptions.
IsNot(DisplacementLagrangeMultiplierContactCriteria::PRINTING_OUTPUT))
348 KRATOS_INFO(
"DisplacementLagrangeMultiplierContactCriteria") <<
BOLDFONT(
"\tDoF") <<
" convergence is " <<
BOLDFONT(
FRED(
" not achieved")) << std::endl;
350 KRATOS_INFO(
"DisplacementLagrangeMultiplierContactCriteria") <<
"\tDoF convergence is not achieved" << std::endl;
367 BaseType::mConvergenceCriteriaIsInitialized =
true;
374 if (r_process_info.
Has(TABLE_UTILITY) && mOptions.IsNot(DisplacementLagrangeMultiplierContactCriteria::TABLE_IS_INITIALIZED)) {
376 auto& r_table = p_table->GetTable();
377 r_table.AddColumn(
"DP RATIO", 10);
378 r_table.AddColumn(
"EXP. RAT", 10);
379 r_table.AddColumn(
"ABS", 10);
380 r_table.AddColumn(
"EXP. ABS", 10);
381 if (mOptions.Is(DisplacementLagrangeMultiplierContactCriteria::ROTATION_DOF_IS_CONSIDERED)) {
382 r_table.AddColumn(
"RT RATIO", 10);
383 r_table.AddColumn(
"EXP. RAT", 10);
384 r_table.AddColumn(
"ABS", 10);
385 r_table.AddColumn(
"EXP. ABS", 10);
387 r_table.AddColumn(
"LM RATIO", 10);
388 r_table.AddColumn(
"EXP. RAT", 10);
389 r_table.AddColumn(
"ABS", 10);
390 r_table.AddColumn(
"EXP. ABS", 10);
391 r_table.AddColumn(
"CONVERGENCE", 15);
392 mOptions.
Set(DisplacementLagrangeMultiplierContactCriteria::TABLE_IS_INITIALIZED,
true);
424 "name" : "displacement_lagrangemultiplier_contact_criteria",
425 "ensure_contact" : false,
426 "print_convergence_criterion" : false,
427 "displacement_relative_tolerance" : 1.0e-4,
428 "displacement_absolute_tolerance" : 1.0e-9,
429 "rotation_relative_tolerance" : 1.0e-4,
430 "rotation_absolute_tolerance" : 1.0e-9,
431 "contact_displacement_relative_tolerance" : 1.0e-4,
432 "contact_displacement_absolute_tolerance" : 1.0e-9
436 const Parameters base_default_parameters = BaseType::GetDefaultParameters();
438 return default_parameters;
447 return "displacement_lagrangemultiplier_contact_criteria";
463 std::string
Info()
const override
465 return "DisplacementLagrangeMultiplierContactCriteria";
503 BaseType::AssignSettings(ThisParameters);
506 mDispRatioTolerance = ThisParameters[
"displacement_relative_tolerance"].
GetDouble();
507 mDispAbsTolerance = ThisParameters[
"displacement_absolute_tolerance"].
GetDouble();
510 mRotRatioTolerance = ThisParameters[
"rotation_relative_tolerance"].
GetDouble();
511 mRotAbsTolerance = ThisParameters[
"rotation_absolute_tolerance"].
GetDouble();
514 mLMRatioTolerance = ThisParameters[
"contact_displacement_relative_tolerance"].
GetDouble();
515 mLMAbsTolerance = ThisParameters[
"contact_displacement_absolute_tolerance"].
GetDouble();
518 mOptions.Set(DisplacementLagrangeMultiplierContactCriteria::ENSURE_CONTACT, ThisParameters[
"ensure_contact"].GetBool());
519 mOptions.Set(DisplacementLagrangeMultiplierContactCriteria::PRINTING_OUTPUT, ThisParameters[
"print_convergence_criterion"].GetBool());
520 mOptions.Set(DisplacementLagrangeMultiplierContactCriteria::TABLE_IS_INITIALIZED,
false);
521 mOptions.Set(DisplacementLagrangeMultiplierContactCriteria::ROTATION_DOF_IS_CONSIDERED,
false);
535 double mDispRatioTolerance;
536 double mDispAbsTolerance;
538 double mRotRatioTolerance;
539 double mRotAbsTolerance;
541 double mLMRatioTolerance;
542 double mLMAbsTolerance;
544 std::vector<int> mActiveDofs;
553 template<
class TSparseSpace,
class TDenseSpace>
555 template<
class TSparseSpace,
class TDenseSpace>
557 template<
class TSparseSpace,
class TDenseSpace>
559 template<
class TSparseSpace,
class TDenseSpace>
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
virtual int MyPID() const
Definition: communicator.cpp:91
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
virtual Parameters ValidateAndAssignParameters(Parameters ThisParameters, const Parameters DefaultParameters) const
This method validate and assign default parameters.
Definition: convergence_criteria.h:466
TSparseSpace::MatrixType TSystemMatrixType
Matrix type definition.
Definition: convergence_criteria.h:72
ModelPart::DofsArrayType DofsArrayType
DoF array type definition.
Definition: convergence_criteria.h:81
TSparseSpace::VectorType TSystemVectorType
Vector type definition.
Definition: convergence_criteria.h:74
bool Has(const Variable< TDataType > &rThisVariable) const
Checks if the data container has a value associated with a given variable.
Definition: data_value_container.h:382
Dof represents a degree of freedom (DoF).
Definition: dof.h:86
EquationIdType EquationId() const
Definition: dof.h:324
void Set(const Flags ThisFlag)
Definition: flags.cpp:33
bool Is(Flags const &rOther) const
Definition: flags.h:274
static Flags Create(IndexType ThisPosition, bool Value=true)
Definition: flags.h:138
bool IsNot(Flags const &rOther) const
Definition: flags.h:291
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
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
double GetDouble() const
This method returns the double contained in the current Parameter.
Definition: kratos_parameters.cpp:657
void RecursivelyAddMissingParameters(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing contain at least all parameters...
Definition: kratos_parameters.cpp:1457
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
utility function to do a sum reduction
Definition: reduction_utilities.h:68
static IndexType Size(VectorType const &rV)
return size of vector rV
Definition: ublas_space.h:190
This class is the base of variables and variable's components which contains their common data.
Definition: variable_data.h:49
#define FGRN(x)
Definition: color_utilities.h:27
#define FRED(x)
Definition: color_utilities.h:26
#define BOLDFONT(x)
Definition: color_utilities.h:34
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
#define KRATOS_INFO(label)
Definition: logger.h:250
void ComputeActiveDofs(ModelPart &rModelPart, std::vector< int > &rActiveDofs, const ModelPart::DofsArrayType &rDofSet)
This method computes the active dofs.
Definition: constraint_utilities.cpp:26
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
REACTION_CHECK_STIFFNESS_FACTOR INNER_LOOP_ITERATION DISTANCE_THRESHOLD ACTIVE_CHECK_FACTOR AUXILIAR_COORDINATES NORMAL_GAP WEIGHTED_GAP WEIGHTED_SCALAR_RESIDUAL bool
Definition: contact_structural_mechanics_application_variables.h:93
Definition: reduction_utilities.h:310