54 template<
class TSparseSpace,
130 const double DispRatioTolerance,
131 const double DispAbsTolerance,
132 const double RotRatioTolerance,
133 const double RotAbsTolerance,
134 const bool PrintingOutput =
false
139 mOptions.
Set(DisplacementContactCriteria::PRINTING_OUTPUT, PrintingOutput);
140 mOptions.
Set(DisplacementContactCriteria::TABLE_IS_INITIALIZED,
false);
141 mOptions.
Set(DisplacementContactCriteria::ROTATION_DOF_IS_CONSIDERED,
false);
144 mDispRatioTolerance = DispRatioTolerance;
145 mDispAbsTolerance = DispAbsTolerance;
148 mRotRatioTolerance = RotRatioTolerance;
149 mRotAbsTolerance = RotAbsTolerance;
155 ,mOptions(rOther.mOptions)
156 ,mDispRatioTolerance(rOther.mDispRatioTolerance)
157 ,mDispAbsTolerance(rOther.mDispAbsTolerance)
158 ,mRotRatioTolerance(rOther.mRotRatioTolerance)
159 ,mRotAbsTolerance(rOther.mRotAbsTolerance)
180 return Kratos::make_shared<ClassType>(ThisParameters);
202 double disp_solution_norm = 0.0, disp_increase_norm = 0.0;
204 double rot_solution_norm = 0.0, rot_increase_norm = 0.0;
209 std::size_t dof_id = 0;
210 double dof_value = 0.0, dof_incr = 0.0;
215 [](
const VariableData& rCurrVar) ->
bool {
return true;};
217 [](
const VariableData& rCurrVar) ->
bool {
return ((rCurrVar == DISPLACEMENT_X) || (rCurrVar == DISPLACEMENT_Y) || (rCurrVar == DISPLACEMENT_Z));};
218 const auto* p_check_disp = (mOptions.
Is(DisplacementContactCriteria::ROTATION_DOF_IS_CONSIDERED)) ? &check_with_rot : &check_without_rot;
222 std::tie(disp_solution_norm,disp_increase_norm,disp_dof_num,rot_solution_norm,rot_increase_norm,rot_dof_num) = block_for_each<SixReduction>(rDofSet, AuxValues(), [p_check_disp,&rDx](
Dof<double>& rDof, AuxValues& aux_values) {
224 aux_values.dof_id = rDof.EquationId();
225 aux_values.dof_value = rDof.GetSolutionStepValue(0);
226 aux_values.dof_incr = rDx[aux_values.dof_id];
228 const auto& r_curr_var = rDof.GetVariable();
229 if ((*p_check_disp)(r_curr_var)) {
230 return std::make_tuple(std::pow(aux_values.dof_value, 2),std::pow(aux_values.dof_incr, 2),1,0.0,0.0,0);
232 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;
233 return std::make_tuple(0.0,0.0,0,std::pow(aux_values.dof_value, 2),std::pow(aux_values.dof_incr, 2),1);
236 return std::make_tuple(0.0,0.0,0,0.0,0.0,0);
239 if(disp_increase_norm == 0.0) disp_increase_norm = 1.0;
240 if(disp_solution_norm == 0.0) disp_solution_norm = 1.0;
241 if(rot_increase_norm == 0.0) rot_increase_norm = 1.0;
242 if(rot_solution_norm == 0.0) rot_solution_norm = 1.0;
244 const double disp_ratio = std::sqrt(disp_increase_norm/disp_solution_norm);
245 const double disp_abs = std::sqrt(disp_increase_norm)/
static_cast<double>(disp_dof_num);
246 const double rot_ratio = std::sqrt(rot_increase_norm/rot_solution_norm);
247 const double rot_abs = std::sqrt(rot_increase_norm)/
static_cast<double>(rot_dof_num);
254 if (r_process_info.
Has(TABLE_UTILITY)) {
255 std::cout.precision(4);
257 auto&
Table = p_table->GetTable();
258 if (mOptions.
Is(DisplacementContactCriteria::ROTATION_DOF_IS_CONSIDERED)) {
259 Table << disp_ratio << mDispRatioTolerance << disp_abs << mDispAbsTolerance << rot_ratio << mRotRatioTolerance << rot_abs << mRotAbsTolerance;
261 Table << disp_ratio << mDispRatioTolerance << disp_abs << mDispAbsTolerance;
264 std::cout.precision(4);
265 if (mOptions.
IsNot(DisplacementContactCriteria::PRINTING_OUTPUT)) {
266 KRATOS_INFO(
"DisplacementContactCriteria") <<
BOLDFONT(
"DoF ONVERGENCE CHECK") <<
"\tSTEP: " << r_process_info[STEP] <<
"\tNL ITERATION: " << r_process_info[NL_ITERATION_NUMBER] << std::endl;
267 KRATOS_INFO(
"DisplacementContactCriteria") <<
BOLDFONT(
"\tDISPLACEMENT: RATIO = ") << disp_ratio <<
BOLDFONT(
" EXP.RATIO = ") << mDispRatioTolerance <<
BOLDFONT(
" ABS = ") << disp_abs <<
BOLDFONT(
" EXP.ABS = ") << mDispAbsTolerance << std::endl;
268 if (mOptions.
Is(DisplacementContactCriteria::ROTATION_DOF_IS_CONSIDERED)) {
269 KRATOS_INFO(
"DisplacementContactCriteria") <<
BOLDFONT(
"\tROTATION: RATIO = ") << rot_ratio <<
BOLDFONT(
" EXP.RATIO = ") << mRotRatioTolerance <<
BOLDFONT(
" ABS = ") << rot_abs <<
BOLDFONT(
" EXP.ABS = ") << mRotAbsTolerance << std::endl;
272 KRATOS_INFO(
"DisplacementContactCriteria") <<
"DoF ONVERGENCE CHECK" <<
"\tSTEP: " << r_process_info[STEP] <<
"\tNL ITERATION: " << r_process_info[NL_ITERATION_NUMBER] << std::endl;
273 KRATOS_INFO(
"DisplacementContactCriteria") <<
"\tDISPLACEMENT: RATIO = " << disp_ratio <<
" EXP.RATIO = " << mDispRatioTolerance <<
" ABS = " << disp_abs <<
" EXP.ABS = " << mDispAbsTolerance << std::endl;
274 if (mOptions.
Is(DisplacementContactCriteria::ROTATION_DOF_IS_CONSIDERED)) {
275 KRATOS_INFO(
"DisplacementContactCriteria") <<
"\tROTATION: RATIO = " << rot_ratio <<
" EXP.RATIO = " << mRotRatioTolerance <<
" ABS = " << rot_abs <<
" EXP.ABS = " << mRotAbsTolerance << std::endl;
282 const bool disp_converged = (disp_ratio <= mDispRatioTolerance || disp_abs <= mDispAbsTolerance);
283 const bool rot_converged = mOptions.
Is(DisplacementContactCriteria::ROTATION_DOF_IS_CONSIDERED) ? (rot_ratio <= mRotRatioTolerance || rot_abs <= mRotAbsTolerance) :
true;
285 if (disp_converged && rot_converged) {
287 if (r_process_info.
Has(TABLE_UTILITY)) {
289 auto& table = p_table->GetTable();
290 if (mOptions.
IsNot(DisplacementContactCriteria::PRINTING_OUTPUT))
295 if (mOptions.
IsNot(DisplacementContactCriteria::PRINTING_OUTPUT))
298 KRATOS_INFO(
"DisplacementContactCriteria") <<
"\tDoF convergence is achieved" << std::endl;
304 if (r_process_info.
Has(TABLE_UTILITY)) {
306 auto& table = p_table->GetTable();
307 if (mOptions.
IsNot(DisplacementContactCriteria::PRINTING_OUTPUT))
310 table <<
"Not achieved";
312 if (mOptions.
IsNot(DisplacementContactCriteria::PRINTING_OUTPUT))
315 KRATOS_INFO(
"DisplacementContactCriteria") <<
"\tDoF convergence is not achieved" << std::endl;
332 BaseType::mConvergenceCriteriaIsInitialized =
true;
339 if (r_process_info.
Has(TABLE_UTILITY) && mOptions.IsNot(DisplacementContactCriteria::TABLE_IS_INITIALIZED)) {
341 auto& r_table = p_table->GetTable();
342 r_table.AddColumn(
"DP RATIO", 10);
343 r_table.AddColumn(
"EXP. RAT", 10);
344 r_table.AddColumn(
"ABS", 10);
345 r_table.AddColumn(
"EXP. ABS", 10);
346 if (mOptions.Is(DisplacementContactCriteria::ROTATION_DOF_IS_CONSIDERED)) {
347 r_table.AddColumn(
"RT RATIO", 10);
348 r_table.AddColumn(
"EXP. RAT", 10);
349 r_table.AddColumn(
"ABS", 10);
350 r_table.AddColumn(
"EXP. ABS", 10);
352 r_table.AddColumn(
"CONVERGENCE", 15);
353 mOptions.
Set(DisplacementContactCriteria::TABLE_IS_INITIALIZED,
true);
365 "name" : "displacement_contact_criteria",
366 "ensure_contact" : false,
367 "print_convergence_criterion" : false,
368 "displacement_relative_tolerance" : 1.0e-4,
369 "displacement_absolute_tolerance" : 1.0e-9,
370 "rotation_relative_tolerance" : 1.0e-4,
371 "rotation_absolute_tolerance" : 1.0e-9
375 const Parameters base_default_parameters = BaseType::GetDefaultParameters();
377 return default_parameters;
386 return "displacement_contact_criteria";
402 std::string
Info()
const override
404 return "DisplacementContactCriteria";
442 BaseType::AssignSettings(ThisParameters);
445 mDispRatioTolerance = ThisParameters[
"displacement_relative_tolerance"].
GetDouble();
446 mDispAbsTolerance = ThisParameters[
"displacement_absolute_tolerance"].
GetDouble();
449 mRotRatioTolerance = ThisParameters[
"rotation_relative_tolerance"].
GetDouble();
450 mRotAbsTolerance = ThisParameters[
"rotation_absolute_tolerance"].
GetDouble();
453 mOptions.Set(DisplacementContactCriteria::PRINTING_OUTPUT, ThisParameters[
"print_convergence_criterion"].GetBool());
454 mOptions.Set(DisplacementContactCriteria::TABLE_IS_INITIALIZED,
false);
455 mOptions.Set(DisplacementContactCriteria::ROTATION_DOF_IS_CONSIDERED,
false);
469 double mDispRatioTolerance;
470 double mDispAbsTolerance;
472 double mRotRatioTolerance;
473 double mRotAbsTolerance;
482 template<
class TSparseSpace,
class TDenseSpace>
484 template<
class TSparseSpace,
class TDenseSpace>
486 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
bool IsFree() const
Definition: dof.h:382
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
This class represents the value of its variable depending to other variable.
Definition: piecewize_linear_table.h:63
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_INFO(label)
Definition: logger.h:250
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