www.mooseframework.org
GluedContactConstraint.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "GluedContactConstraint.h"
11 
12 #include "SystemBase.h"
13 #include "PenetrationLocator.h"
14 #include "ContactAction.h"
15 
16 #include "libmesh/string_to_enum.h"
17 #include "libmesh/sparse_matrix.h"
18 
20 
21 template <>
22 InputParameters
24 {
25  InputParameters params = validParams<SparsityBasedContactConstraint>();
27 
28  params.addRequiredParam<BoundaryName>("boundary", "The master boundary");
29  params.addRequiredParam<BoundaryName>("slave", "The slave boundary");
30  params.addRequiredParam<unsigned int>("component",
31  "An integer corresponding to the direction "
32  "the variable this kernel acts in. (0 for x, "
33  "1 for y, 2 for z)");
34 
35  params.addCoupledVar("disp_x", "The x displacement");
36  params.addCoupledVar("disp_y", "The y displacement");
37  params.addCoupledVar("disp_z", "The z displacement");
38 
39  params.addCoupledVar(
40  "displacements",
41  "The displacements appropriate for the simulation geometry and coordinate system");
42 
43  params.addRequiredCoupledVar("nodal_area", "The nodal area");
44 
45  params.set<bool>("use_displaced_mesh") = true;
46  params.addParam<Real>(
47  "penalty",
48  1e8,
49  "The penalty to apply. This can vary depending on the stiffness of your materials");
50  params.addParam<Real>("friction_coefficient", 0.0, "The friction coefficient");
51  params.addParam<Real>("tangential_tolerance",
52  "Tangential distance to extend edges of contact surfaces");
53  params.addParam<Real>("tension_release",
54  0.0,
55  "Tension release threshold. A node in contact "
56  "will not be released if its tensile load is below "
57  "this value. Must be positive.");
58 
59  return params;
60 }
61 
62 GluedContactConstraint::GluedContactConstraint(const InputParameters & parameters)
63  : SparsityBasedContactConstraint(parameters),
64  _component(getParam<unsigned int>("component")),
65  _model(getParam<MooseEnum>("model").getEnum<ContactModel>()),
66  _formulation(getParam<MooseEnum>("formulation").getEnum<ContactFormulation>()),
67  _penalty(getParam<Real>("penalty")),
68  _friction_coefficient(getParam<Real>("friction_coefficient")),
69  _tension_release(getParam<Real>("tension_release")),
70  _updateContactSet(true),
71  _residual_copy(_sys.residualGhosted()),
72  _vars(3, libMesh::invalid_uint),
73  _nodal_area_var(getVar("nodal_area", 0)),
74  _aux_system(_nodal_area_var->sys()),
75  _aux_solution(_aux_system.currentSolution())
76 {
77  if (parameters.isParamValid("tangential_tolerance"))
78  _penetration_locator.setTangentialTolerance(getParam<Real>("tangential_tolerance"));
79 
80  if (parameters.isParamValid("normal_smoothing_distance"))
81  _penetration_locator.setNormalSmoothingDistance(getParam<Real>("normal_smoothing_distance"));
82 
83  if (parameters.isParamValid("normal_smoothing_method"))
84  _penetration_locator.setNormalSmoothingMethod(
85  parameters.get<MooseEnum>("normal_smoothing_method"));
86 
87  if (isParamValid("displacements"))
88  {
89  // modern parameter scheme for displacements
90  for (unsigned int i = 0; i < coupledComponents("displacements"); ++i)
91  _vars[i] = coupled("displacements", i);
92  }
93  else
94  {
95  // Legacy parameter scheme for displacements
96  if (isParamValid("disp_x"))
97  _vars[0] = coupled("disp_x");
98  if (isParamValid("disp_y"))
99  _vars[1] = coupled("disp_y");
100  if (isParamValid("disp_z"))
101  _vars[2] = coupled("disp_z");
102 
103  mooseDeprecated("use the `displacements` parameter rather than the `disp_*` parameters (those "
104  "will go away with the deprecation of the Solid Mechanics module).");
105  }
106 
107  _penetration_locator.setUpdate(false);
108 }
109 
110 void
112 {
113  if (_component == 0)
114  {
115  updateContactSet(true);
116  _updateContactSet = false;
117  }
118 }
119 
120 void
122 {
123  if (_component == 0)
124  {
125  if (_updateContactSet)
127 
128  _updateContactSet = true;
129  }
130 }
131 
132 void
134 {
135  auto & has_penetrated = _penetration_locator._has_penetrated;
136 
137  for (auto & pinfo_pair : _penetration_locator._penetration_info)
138  {
139  PenetrationInfo * pinfo = pinfo_pair.second;
140 
141  // Skip this pinfo if there are no DOFs on this node.
142  if (!pinfo || pinfo->_node->n_comp(_sys.number(), _vars[_component]) < 1)
143  continue;
144 
145  const dof_id_type slave_node_num = pinfo_pair.first;
146  auto hpit = has_penetrated.find(slave_node_num);
147 
148  if (beginning_of_step)
149  {
150  pinfo->_starting_elem = pinfo->_elem;
151  pinfo->_starting_side_num = pinfo->_side_num;
152  pinfo->_starting_closest_point_ref = pinfo->_closest_point_ref;
153  }
154 
155  if (pinfo->_distance >= 0)
156  if (hpit == has_penetrated.end())
157  has_penetrated.insert(slave_node_num);
158  }
159 }
160 
161 bool
163 {
164  auto hpit = _penetration_locator._has_penetrated.find(_current_node->id());
165  return hpit != _penetration_locator._has_penetrated.end();
166 }
167 
168 Real
170 {
171  return _u_slave[_qp];
172 }
173 
174 Real
175 GluedContactConstraint::computeQpResidual(Moose::ConstraintType type)
176 {
177  switch (type)
178  {
179  case Moose::Slave:
180  {
181  PenetrationInfo * pinfo = _penetration_locator._penetration_info[_current_node->id()];
182  Real distance = (*_current_node)(_component)-pinfo->_closest_point(_component);
183  Real pen_force = _penalty * distance;
184 
185  Real resid = pen_force;
186  pinfo->_contact_force(_component) = resid;
187  pinfo->_mech_status = PenetrationInfo::MS_STICKING;
188 
189  return _test_slave[_i][_qp] * resid;
190  }
191 
192  case Moose::Master:
193  {
194  PenetrationInfo * pinfo = _penetration_locator._penetration_info[_current_node->id()];
195 
196  dof_id_type dof_number = _current_node->dof_number(0, _vars[_component], 0);
197  Real resid = _residual_copy(dof_number);
198 
199  pinfo->_contact_force(_component) = -resid;
200  pinfo->_mech_status = PenetrationInfo::MS_STICKING;
201 
202  return _test_master[_i][_qp] * resid;
203  }
204  }
205 
206  return 0.0;
207 }
208 
209 Real
210 GluedContactConstraint::computeQpJacobian(Moose::ConstraintJacobianType type)
211 {
212  switch (type)
213  {
214  case Moose::SlaveSlave:
215  return _penalty * _phi_slave[_j][_qp] * _test_slave[_i][_qp];
216 
217  case Moose::SlaveMaster:
218  return _penalty * -_phi_master[_j][_qp] * _test_slave[_i][_qp];
219 
220  case Moose::MasterSlave:
221  {
222  const double slave_jac = (*_jacobian)(_current_node->dof_number(0, _vars[_component], 0),
223  _connected_dof_indices[_j]);
224  return slave_jac * _test_master[_i][_qp];
225  }
226 
227  case Moose::MasterMaster:
228  return 0.0;
229 
230  default:
231  mooseError("Unhandled ConstraintJacobianType");
232  }
233 
234  return 0.0;
235 }
236 
237 Real
238 GluedContactConstraint::computeQpOffDiagJacobian(Moose::ConstraintJacobianType type,
239  unsigned int /*jvar*/)
240 {
241  Real retVal = 0.0;
242 
243  switch (type)
244  {
245  case Moose::SlaveSlave:
246  case Moose::SlaveMaster:
247  case Moose::MasterMaster:
248  break;
249 
250  case Moose::MasterSlave:
251  {
252  const double slave_jac = (*_jacobian)(_current_node->dof_number(0, _vars[_component], 0),
253  _connected_dof_indices[_j]);
254  retVal = slave_jac * _test_master[_i][_qp];
255  break;
256  }
257 
258  default:
259  mooseError("Unhandled ConstraintJacobianType");
260  }
261 
262  return retVal;
263 }
ContactModel
ContactModel
Definition: ContactAction.h:16
GluedContactConstraint::computeQpOffDiagJacobian
virtual Real computeQpOffDiagJacobian(Moose::ConstraintJacobianType type, unsigned int jvar)
Compute off-diagonal Jacobian entries.
Definition: GluedContactConstraint.C:238
GluedContactConstraint::timestepSetup
virtual void timestepSetup()
Definition: GluedContactConstraint.C:111
GluedContactConstraint::_residual_copy
NumericVector< Number > & _residual_copy
Definition: GluedContactConstraint.h:63
libMesh
Definition: RANFSNormalMechanicalContact.h:24
GluedContactConstraint::computeQpJacobian
virtual Real computeQpJacobian(Moose::ConstraintJacobianType type)
Definition: GluedContactConstraint.C:210
GluedContactConstraint::GluedContactConstraint
GluedContactConstraint(const InputParameters &parameters)
Definition: GluedContactConstraint.C:62
GluedContactConstraint::_penalty
const Real _penalty
Definition: GluedContactConstraint.h:58
GluedContactConstraint::shouldApply
bool shouldApply()
Definition: GluedContactConstraint.C:162
GluedContactConstraint.h
validParams< SparsityBasedContactConstraint >
InputParameters validParams< SparsityBasedContactConstraint >()
Definition: SparsityBasedContactConstraint.C:22
GluedContactConstraint::jacobianSetup
virtual void jacobianSetup()
Definition: GluedContactConstraint.C:121
GluedContactConstraint::_component
const unsigned int _component
Definition: GluedContactConstraint.h:54
GluedContactConstraint::_vars
std::vector< unsigned int > _vars
Definition: GluedContactConstraint.h:69
GluedContactConstraint::updateContactSet
virtual void updateContactSet(bool beginning_of_step=false)
Definition: GluedContactConstraint.C:133
ContactFormulation
ContactFormulation
Definition: ContactAction.h:23
SparsityBasedContactConstraint
Definition: SparsityBasedContactConstraint.h:21
ContactAction.h
GluedContactConstraint::_updateContactSet
bool _updateContactSet
Definition: GluedContactConstraint.h:61
ContactAction::commonParameters
static InputParameters commonParameters()
Definition: ContactAction.C:441
validParams< GluedContactConstraint >
InputParameters validParams< GluedContactConstraint >()
Definition: GluedContactConstraint.C:23
GluedContactConstraint::computeQpSlaveValue
virtual Real computeQpSlaveValue()
Definition: GluedContactConstraint.C:169
GluedContactConstraint
A GluedContactConstraint forces the value of a variable to be the same on both sides of an interface.
Definition: GluedContactConstraint.h:27
registerMooseObject
registerMooseObject("ContactApp", GluedContactConstraint)
GluedContactConstraint::computeQpResidual
virtual Real computeQpResidual(Moose::ConstraintType type)
Definition: GluedContactConstraint.C:175