www.mooseframework.org
AugmentedLagrangianContactProblem.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
9 
10 // MOOSE includes
11 #include "AuxiliarySystem.h"
12 #include "DisplacedProblem.h"
13 #include "MooseApp.h"
14 #include "MooseMesh.h"
15 #include "MooseVariable.h"
16 #include "NearestNodeLocator.h"
17 #include "NonlinearSystem.h"
18 #include "PenetrationLocator.h"
19 
20 #include "SystemBase.h"
21 #include "Assembly.h"
22 #include "Executioner.h"
23 #include "AddVariableAction.h"
24 #include "ConstraintWarehouse.h"
25 
26 template <>
27 InputParameters
29 {
30  InputParameters params = validParams<ReferenceResidualProblem>();
31  params.addParam<int>("maximum_lagrangian_update_iterations",
32  100,
33  "Maximum number of update Lagrangian Multiplier iterations per step");
34  return params;
35 }
36 
38  : ReferenceResidualProblem(params),
39  _num_lagmul_iterations(0),
40  _max_lagmul_iters(getParam<int>("maximum_lagrangian_update_iterations"))
41 {
42 }
43 
44 void
46 {
49 }
50 
51 MooseNonlinearConvergenceReason
53  const PetscInt it,
54  const Real xnorm,
55  const Real snorm,
56  const Real fnorm,
57  const Real rtol,
58  const Real stol,
59  const Real abstol,
60  const PetscInt nfuncs,
61  const PetscInt /*max_funcs*/,
62  const Real ref_resid,
63  const Real /*div_threshold*/)
64 {
65 
66  Real my_max_funcs = std::numeric_limits<int>::max();
67  Real my_div_threshold = std::numeric_limits<Real>::max();
68 
69  MooseNonlinearConvergenceReason reason =
71  it,
72  xnorm,
73  snorm,
74  fnorm,
75  rtol,
76  stol,
77  abstol,
78  nfuncs,
79  my_max_funcs,
80  ref_resid,
81  my_div_threshold);
82 
83  _console << "Augmented Lagrangian contact iteration " << _num_lagmul_iterations << "\n";
84 
85  bool _augLM_repeat_step;
86 
87  if (reason > 0)
88  {
89  if (_num_lagmul_iterations < _max_lagmul_iters)
90  {
91  NonlinearSystemBase & nonlinear_sys = getNonlinearSystemBase();
92  nonlinear_sys.update();
93 
94  const ConstraintWarehouse & constraints = nonlinear_sys.getConstraintWarehouse();
95 
96  std::map<std::pair<unsigned int, unsigned int>, PenetrationLocator *> * penetration_locators =
97  NULL;
98 
99  bool displaced = false;
100  _augLM_repeat_step = false;
101  if (getDisplacedProblem() == NULL)
102  {
103  GeometricSearchData & geom_search_data = geomSearchData();
104  penetration_locators = &geom_search_data._penetration_locators;
105  }
106  else
107  {
108  GeometricSearchData & displaced_geom_search_data = getDisplacedProblem()->geomSearchData();
109  penetration_locators = &displaced_geom_search_data._penetration_locators;
110  displaced = true;
111  }
112 
113  for (const auto & it : *penetration_locators)
114  {
115  PenetrationLocator & pen_loc = *(it.second);
116 
117  BoundaryID slave_boundary = pen_loc._slave_boundary;
118 
119  if (constraints.hasActiveNodeFaceConstraints(slave_boundary, displaced))
120  {
121  const auto & ncs = constraints.getActiveNodeFaceConstraints(slave_boundary, displaced);
122 
123  for (const auto & nc : ncs)
124  {
125  if (std::dynamic_pointer_cast<MechanicalContactConstraint>(nc) == NULL)
126  mooseError("AugmentedLagrangianContactProblem: dynamic cast of "
127  "MechanicalContactConstraint object failed.");
128 
129  if (!(std::dynamic_pointer_cast<MechanicalContactConstraint>(nc))
130  ->AugmentedLagrangianContactConverged())
131  {
132  (std::dynamic_pointer_cast<MechanicalContactConstraint>(nc))
133  ->updateAugmentedLagrangianMultiplier(false);
134  _augLM_repeat_step = true;
135  break;
136  }
137  }
138  }
139  }
140 
141  if (_augLM_repeat_step)
142  {
143  // force it to keep iterating
144  reason = MOOSE_NONLINEAR_ITERATING;
145  _console << "Augmented Lagrangian Multiplier needs updating." << std::endl;
146  _num_lagmul_iterations++;
147  }
148  else
149  _console << "Augmented Lagrangian contact constraint enforcement is satisfied."
150  << std::endl;
151  }
152  else
153  {
154  // maxed out
155  _console << "Maximum Augmented Lagrangian contact iterations have been reached." << std::endl;
156  reason = MOOSE_DIVERGED_FUNCTION_COUNT;
157  }
158  }
159 
160  return reason;
161 }
InputParameters validParams< ReferenceResidualProblem >()
A MechanicalContactConstraint forces the value of a variable to be the same on both sides of an inter...
virtual MooseNonlinearConvergenceReason checkNonlinearConvergence(std::string &msg, const PetscInt it, const Real xnorm, const Real snorm, const Real fnorm, const Real rtol, const Real stol, const Real abstol, const PetscInt nfuncs, const PetscInt max_funcs, const Real ref_resid, const Real div_threshold) override
virtual MooseNonlinearConvergenceReason checkNonlinearConvergence(std::string &msg, const PetscInt it, const Real xnorm, const Real snorm, const Real fnorm, const Real rtol, const Real stol, const Real abstol, const PetscInt nfuncs, const PetscInt max_funcs, const Real ref_resid, const Real div_threshold)
AugmentedLagrangianContactProblem(const InputParameters &params)
FEProblemBase derived class to enable convergence checking relative to a user-specified postprocessor...
InputParameters validParams< AugmentedLagrangianContactProblem >()