13 #include "AuxiliarySystem.h"
14 #include "DisplacedProblem.h"
16 #include "MooseMesh.h"
17 #include "MooseVariable.h"
18 #include "NearestNodeLocator.h"
19 #include "NonlinearSystem.h"
20 #include "PenetrationLocator.h"
22 #include "SystemBase.h"
24 #include "Executioner.h"
25 #include "AddVariableAction.h"
26 #include "ConstraintWarehouse.h"
34 InputParameters params = validParams<ReferenceResidualProblem>();
35 params.addParam<
int>(
"maximum_lagrangian_update_iterations",
37 "Maximum number of update Lagrangian Multiplier iterations per step");
42 : ReferenceResidualProblem(params),
43 _num_lagmul_iterations(0),
44 _max_lagmul_iters(getParam<int>(
"maximum_lagrangian_update_iterations"))
52 ReferenceResidualProblem::timestepSetup();
55 MooseNonlinearConvergenceReason
65 const PetscInt nfuncs,
67 const PetscBool force_iteration,
72 Real my_max_funcs = std::numeric_limits<int>::max();
73 Real my_div_threshold = std::numeric_limits<Real>::max();
75 MooseNonlinearConvergenceReason reason =
76 ReferenceResidualProblem::checkNonlinearConvergence(msg,
93 bool _augLM_repeat_step;
95 if (reason == MooseNonlinearConvergenceReason::CONVERGED_FNORM_ABS ||
96 reason == MooseNonlinearConvergenceReason::CONVERGED_FNORM_RELATIVE ||
97 reason == MooseNonlinearConvergenceReason::CONVERGED_SNORM_RELATIVE)
101 NonlinearSystemBase & nonlinear_sys = getNonlinearSystemBase();
102 nonlinear_sys.update();
104 const ConstraintWarehouse & constraints = nonlinear_sys.getConstraintWarehouse();
106 std::map<std::pair<unsigned int, unsigned int>, PenetrationLocator *> * penetration_locators =
109 bool displaced =
false;
110 _augLM_repeat_step =
false;
111 if (getDisplacedProblem() == NULL)
113 GeometricSearchData & geom_search_data = geomSearchData();
114 penetration_locators = &geom_search_data._penetration_locators;
118 GeometricSearchData & displaced_geom_search_data = getDisplacedProblem()->geomSearchData();
119 penetration_locators = &displaced_geom_search_data._penetration_locators;
123 for (
const auto & it : *penetration_locators)
125 PenetrationLocator & pen_loc = *(it.second);
127 BoundaryID slave_boundary = pen_loc._slave_boundary;
129 if (constraints.hasActiveNodeFaceConstraints(slave_boundary, displaced))
131 const auto & ncs = constraints.getActiveNodeFaceConstraints(slave_boundary, displaced);
133 for (
const auto & nc : ncs)
135 if (std::dynamic_pointer_cast<MechanicalContactConstraint>(nc) == NULL)
136 mooseError(
"AugmentedLagrangianContactProblem: dynamic cast of "
137 "MechanicalContactConstraint object failed.");
139 if (!(std::dynamic_pointer_cast<MechanicalContactConstraint>(nc))
140 ->AugmentedLagrangianContactConverged())
142 (std::dynamic_pointer_cast<MechanicalContactConstraint>(nc))
143 ->updateAugmentedLagrangianMultiplier(
false);
144 _augLM_repeat_step =
true;
151 if (_augLM_repeat_step)
154 reason = MooseNonlinearConvergenceReason::ITERATING;
155 _console <<
"Augmented Lagrangian Multiplier needs updating." << std::endl;
159 _console <<
"Augmented Lagrangian contact constraint enforcement is satisfied."
165 _console <<
"Maximum Augmented Lagrangian contact iterations have been reached." << std::endl;
166 reason = MooseNonlinearConvergenceReason::DIVERGED_FUNCTION_COUNT;