www.mooseframework.org
Public Member Functions | Private Attributes | List of all members
AugmentedLagrangianContactProblem Class Reference

Class to manage nested solution for augmented Lagrange contact. More...

#include <AugmentedLagrangianContactProblem.h>

Inheritance diagram for AugmentedLagrangianContactProblem:
[legend]

Public Member Functions

 AugmentedLagrangianContactProblem (const InputParameters &params)
 
virtual ~AugmentedLagrangianContactProblem ()
 
virtual void timestepSetup () 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) override
 
virtual void initialSetup ()
 
void updateReferenceResidual ()
 
bool checkConvergenceIndividVars (const Real fnorm, const Real abstol, const Real rtol, const Real ref_resid)
 

Protected Attributes

std::vector< std::string > _solnVarNames
 
std::vector< std::string > _refResidVarNames
 
std::vector< unsigned int > _solnVars
 
std::vector< unsigned int > _refResidVars
 
Real _accept_mult
 
int _accept_iters
 
std::vector< Real > _refResid
 
std::vector< Real > _resid
 

Private Attributes

int _num_lagmul_iterations
 
int _max_lagmul_iters
 

Detailed Description

Class to manage nested solution for augmented Lagrange contact.

The AugmentedLagrangianContactProblem manages the nested solution procedure, repeating the solution until convergence has been achieved, checking for convergence, and updating the Lagrangian multipliers.

Definition at line 26 of file AugmentedLagrangianContactProblem.h.

Constructor & Destructor Documentation

AugmentedLagrangianContactProblem::AugmentedLagrangianContactProblem ( const InputParameters &  params)

Definition at line 37 of file AugmentedLagrangianContactProblem.C.

38  : ReferenceResidualProblem(params),
40  _max_lagmul_iters(getParam<int>("maximum_lagrangian_update_iterations"))
41 {
42 }
ReferenceResidualProblem(const InputParameters &params)
virtual AugmentedLagrangianContactProblem::~AugmentedLagrangianContactProblem ( )
inlinevirtual

Definition at line 30 of file AugmentedLagrangianContactProblem.h.

30 {}

Member Function Documentation

bool ReferenceResidualProblem::checkConvergenceIndividVars ( const Real  fnorm,
const Real  abstol,
const Real  rtol,
const Real  ref_resid 
)
inherited

Definition at line 240 of file ReferenceResidualProblem.C.

Referenced by ReferenceResidualProblem::checkNonlinearConvergence().

244 {
245  bool convergedRelative = true;
246  if (_resid.size() > 0)
247  {
248  for (unsigned int i = 0; i < _resid.size(); ++i)
249  convergedRelative &= ((_resid[i] < _refResid[i] * rtol) || (_resid[i] < abstol));
250  }
251 
252  else if (fnorm > ref_resid * rtol)
253  convergedRelative = false;
254 
255  return convergedRelative;
256 }
MooseNonlinearConvergenceReason AugmentedLagrangianContactProblem::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 
)
overridevirtual

Reimplemented from ReferenceResidualProblem.

Definition at line 52 of file AugmentedLagrangianContactProblem.C.

Referenced by ~AugmentedLagrangianContactProblem().

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 }
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)
void ReferenceResidualProblem::initialSetup ( )
virtualinherited

Definition at line 59 of file ReferenceResidualProblem.C.

60 {
61  NonlinearSystemBase & nonlinear_sys = getNonlinearSystemBase();
62  AuxiliarySystem & aux_sys = getAuxiliarySystem();
63  System & s = nonlinear_sys.system();
64  TransientExplicitSystem & as = aux_sys.sys();
65 
66  if (_solnVarNames.size() > 0 && _solnVarNames.size() != s.n_vars())
67  mooseError("In ReferenceResidualProblem, size of solution_variables (",
68  _solnVarNames.size(),
69  ") != number of variables in system (",
70  s.n_vars(),
71  ")");
72 
73  _solnVars.clear();
74  for (unsigned int i = 0; i < _solnVarNames.size(); ++i)
75  {
76  bool foundMatch = false;
77  for (unsigned int var_num = 0; var_num < s.n_vars(); var_num++)
78  {
79  if (_solnVarNames[i] == s.variable_name(var_num))
80  {
81  _solnVars.push_back(var_num);
82  _resid.push_back(0.0);
83  foundMatch = true;
84  break;
85  }
86  }
87  if (!foundMatch)
88  mooseError("Could not find solution variable '", _solnVarNames[i], "' in system");
89  }
90 
91  _refResidVars.clear();
92  for (unsigned int i = 0; i < _refResidVarNames.size(); ++i)
93  {
94  bool foundMatch = false;
95  for (unsigned int var_num = 0; var_num < as.n_vars(); var_num++)
96  {
97  if (_refResidVarNames[i] == as.variable_name(var_num))
98  {
99  _refResidVars.push_back(var_num);
100  _refResid.push_back(0.0);
101  foundMatch = true;
102  break;
103  }
104  }
105  if (!foundMatch)
106  mooseError("Could not find variable '", _refResidVarNames[i], "' in auxiliary system");
107  }
108 
109  FEProblemBase::initialSetup();
110 }
std::vector< unsigned int > _solnVars
std::vector< std::string > _solnVarNames
std::vector< unsigned int > _refResidVars
std::vector< std::string > _refResidVarNames
void AugmentedLagrangianContactProblem::timestepSetup ( )
overridevirtual
void ReferenceResidualProblem::updateReferenceResidual ( )
inherited

Definition at line 124 of file ReferenceResidualProblem.C.

Referenced by ReferenceResidualProblem::checkNonlinearConvergence().

125 {
126  NonlinearSystemBase & nonlinear_sys = getNonlinearSystemBase();
127  AuxiliarySystem & aux_sys = getAuxiliarySystem();
128  System & s = nonlinear_sys.system();
129  TransientExplicitSystem & as = aux_sys.sys();
130 
131  for (unsigned int i = 0; i < _solnVars.size(); ++i)
132  _resid[i] = s.calculate_norm(nonlinear_sys.RHS(), _solnVars[i], DISCRETE_L2);
133 
134  for (unsigned int i = 0; i < _refResidVars.size(); ++i)
135  _refResid[i] = as.calculate_norm(*as.current_local_solution, _refResidVars[i], DISCRETE_L2);
136 }
std::vector< unsigned int > _solnVars
std::vector< unsigned int > _refResidVars

Member Data Documentation

int ReferenceResidualProblem::_accept_iters
protectedinherited
Real ReferenceResidualProblem::_accept_mult
protectedinherited

"Acceptable" absolute and relative tolerance multiplier and acceptable number of iterations. Used when checking the convergence of individual variables.

Definition at line 67 of file ReferenceResidualProblem.h.

Referenced by ReferenceResidualProblem::checkNonlinearConvergence(), and ReferenceResidualProblem::ReferenceResidualProblem().

int AugmentedLagrangianContactProblem::_max_lagmul_iters
private

Definition at line 50 of file AugmentedLagrangianContactProblem.h.

Referenced by checkNonlinearConvergence().

int AugmentedLagrangianContactProblem::_num_lagmul_iterations
private

Definition at line 49 of file AugmentedLagrangianContactProblem.h.

Referenced by checkNonlinearConvergence(), and timestepSetup().

std::vector<Real> ReferenceResidualProblem::_refResid
protectedinherited
std::vector<std::string> ReferenceResidualProblem::_refResidVarNames
protectedinherited
std::vector<unsigned int> ReferenceResidualProblem::_refResidVars
protectedinherited
std::vector<Real> ReferenceResidualProblem::_resid
protectedinherited
std::vector<std::string> ReferenceResidualProblem::_solnVarNames
protectedinherited

List of solution variable names whose reference residuals will be stored, and the residual variable names that will store them.

Definition at line 53 of file ReferenceResidualProblem.h.

Referenced by ReferenceResidualProblem::checkNonlinearConvergence(), ReferenceResidualProblem::initialSetup(), and ReferenceResidualProblem::ReferenceResidualProblem().

std::vector<unsigned int> ReferenceResidualProblem::_solnVars
protectedinherited

Variable numbers assoicated with the names in _solnVarNames and _refResidVarNames.

Definition at line 59 of file ReferenceResidualProblem.h.

Referenced by ReferenceResidualProblem::checkNonlinearConvergence(), ReferenceResidualProblem::initialSetup(), and ReferenceResidualProblem::updateReferenceResidual().


The documentation for this class was generated from the following files: