www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
MultiDContactConstraint Class Reference

A MultiDContactConstraint forces the value of a variable to be the same on both sides of an interface. More...

#include <MultiDContactConstraint.h>

Inheritance diagram for MultiDContactConstraint:
[legend]

Public Member Functions

 MultiDContactConstraint (const InputParameters &parameters)
 
virtual ~MultiDContactConstraint ()
 
virtual void timestepSetup ()
 
virtual void jacobianSetup ()
 
virtual void updateContactSet ()
 
virtual Real computeQpSlaveValue ()
 
virtual Real computeQpResidual (Moose::ConstraintType type)
 
virtual Real computeQpJacobian (Moose::ConstraintJacobianType type)
 
bool shouldApply ()
 

Protected Attributes

NumericVector< Number > & _residual_copy
 
bool _jacobian_update
 
const unsigned int _component
 
const ContactModel _model
 
Real _penalty
 
unsigned int _x_var
 
unsigned int _y_var
 
unsigned int _z_var
 
const unsigned int _mesh_dimension
 
std::vector< unsigned int > _vars
 

Detailed Description

A MultiDContactConstraint forces the value of a variable to be the same on both sides of an interface.

Definition at line 27 of file MultiDContactConstraint.h.

Constructor & Destructor Documentation

◆ MultiDContactConstraint()

MultiDContactConstraint::MultiDContactConstraint ( const InputParameters &  parameters)

Definition at line 58 of file MultiDContactConstraint.C.

59  : NodeFaceConstraint(parameters),
60  _residual_copy(_sys.residualGhosted()),
61  _jacobian_update(getParam<bool>("jacobian_update")),
62  _component(getParam<unsigned int>("component")),
63  _model(getParam<MooseEnum>("model").getEnum<ContactModel>()),
64  _penalty(getParam<Real>("penalty")),
65  _mesh_dimension(_mesh.dimension()),
66  _vars(3, libMesh::invalid_uint)
67 {
68  _overwrite_slave_residual = false;
69 
70  if (isParamValid("displacements"))
71  {
72  // modern parameter scheme for displacements
73  for (unsigned int i = 0; i < coupledComponents("displacements"); ++i)
74  _vars[i] = coupled("displacements", i);
75  }
76  else
77  {
78  // Legacy parameter scheme for displacements
79  if (isParamValid("disp_x"))
80  _vars[0] = coupled("disp_x");
81  if (isParamValid("disp_y"))
82  _vars[1] = coupled("disp_y");
83  if (isParamValid("disp_z"))
84  _vars[2] = coupled("disp_z");
85 
86  mooseDeprecated("use the `displacements` parameter rather than the `disp_*` parameters (those "
87  "will go away with the deprecation of the Solid Mechanics module).");
88  }
89 }

◆ ~MultiDContactConstraint()

virtual MultiDContactConstraint::~MultiDContactConstraint ( )
inlinevirtual

Definition at line 31 of file MultiDContactConstraint.h.

31 {}

Member Function Documentation

◆ computeQpJacobian()

Real MultiDContactConstraint::computeQpJacobian ( Moose::ConstraintJacobianType  type)
virtual

Definition at line 264 of file MultiDContactConstraint.C.

265 {
266  PenetrationInfo * pinfo = _penetration_locator._penetration_info[_current_node->id()];
267 
268  Real slave_jac = 0.0;
269  switch (type)
270  {
271  case Moose::SlaveSlave:
272  switch (_model)
273  {
275 
276  slave_jac = pinfo->_normal(_component) * pinfo->_normal(_component) *
277  (_penalty * _phi_slave[_j][_qp] -
278  (*_jacobian)(_current_node->dof_number(0, _var.number(), 0),
279  _connected_dof_indices[_j]));
280  break;
281 
282  case ContactModel::GLUED:
283  // resid = pen_force(_component) - res_vec(_component);
284  break;
285 
286  default:
287  mooseError("Invalid or unavailable contact model");
288  break;
289  }
290  return _test_slave[_i][_qp] * slave_jac;
291 
292  case Moose::SlaveMaster:
293  switch (_model)
294  {
296 
297  slave_jac = pinfo->_normal(_component) * pinfo->_normal(_component) *
298  (-_penalty * _phi_master[_j][_qp]);
299  break;
300 
301  case ContactModel::GLUED:
302  /*
303  resid = pen_force(_component)
304  - res_vec(_component)
305  ;
306  */
307  break;
308 
309  default:
310  mooseError("Invalid or unavailable contact model");
311  break;
312  }
313  return _test_slave[_i][_qp] * slave_jac;
314 
315  case Moose::MasterSlave:
316  slave_jac =
317  (*_jacobian)(_current_node->dof_number(0, _var.number(), 0), _connected_dof_indices[_j]);
318  return slave_jac * _test_master[_i][_qp];
319 
320  case Moose::MasterMaster:
321  return 0.0;
322 
323  default:
324  mooseError("Unhandled ConstraintJacobianType");
325  }
326  return 0.0;
327 }

◆ computeQpResidual()

Real MultiDContactConstraint::computeQpResidual ( Moose::ConstraintType  type)
virtual

Definition at line 208 of file MultiDContactConstraint.C.

209 {
210  PenetrationInfo * pinfo = _penetration_locator._penetration_info[_current_node->id()];
211  const Node * node = pinfo->_node;
212 
213  RealVectorValue res_vec;
214  // Build up residual vector
215  for (unsigned int i = 0; i < _mesh_dimension; ++i)
216  {
217  dof_id_type dof_number = node->dof_number(0, _vars[i], 0);
218  res_vec(i) = _residual_copy(dof_number);
219  }
220 
221  const RealVectorValue distance_vec(_mesh.nodeRef(node->id()) - pinfo->_closest_point);
222  const RealVectorValue pen_force(_penalty * distance_vec);
223  Real resid = 0.0;
224 
225  switch (type)
226  {
227  case Moose::Slave:
228  switch (_model)
229  {
231  resid = pinfo->_normal(_component) * (pinfo->_normal * (pen_force - res_vec));
232  break;
233 
234  case ContactModel::GLUED:
235  resid = pen_force(_component) - res_vec(_component);
236  break;
237 
238  default:
239  mooseError("Invalid or unavailable contact model");
240  break;
241  }
242  return _test_slave[_i][_qp] * resid;
243  case Moose::Master:
244  switch (_model)
245  {
247  resid = pinfo->_normal(_component) * (pinfo->_normal * res_vec);
248  break;
249 
250  case ContactModel::GLUED:
251  resid = res_vec(_component);
252  break;
253 
254  default:
255  mooseError("Invalid or unavailable contact model");
256  break;
257  }
258  return _test_master[_i][_qp] * resid;
259  }
260  return 0.0;
261 }

◆ computeQpSlaveValue()

Real MultiDContactConstraint::computeQpSlaveValue ( )
virtual

Definition at line 184 of file MultiDContactConstraint.C.

185 {
186  PenetrationInfo * pinfo = _penetration_locator._penetration_info[_current_node->id()];
187 
188  // Moose::err << std::endl
189  // << "Popping out node: " << _current_node->id() << std::endl
190  // << "Closest Point " << _component << ": " << pinfo->_closest_point(_component)
191  // << std::endl
192  // << "Current Node " << _component << ": " << (*_current_node)(_component) <<
193  // std::endl
194  // << "Current Value: " << _u_slave[_qp] << std::endl
195  // << "New Value: "
196  // << pinfo->_closest_point(_component) - ((*_current_node)(_component)-_u_slave[_qp])
197  // << std::endl
198  // << "Change: "
199  // << _u_slave[_qp] - (pinfo->_closest_point(_component) -
200  // ((*_current_node)(_component)-_u_slave[_qp]))
201  // << std::endl
202  // << std::endl;
203 
204  return pinfo->_closest_point(_component) - ((*_current_node)(_component)-_u_slave[_qp]);
205 }

◆ jacobianSetup()

void MultiDContactConstraint::jacobianSetup ( )
virtual

Definition at line 99 of file MultiDContactConstraint.C.

100 {
101  if (_component == 0)
103 }

◆ shouldApply()

bool MultiDContactConstraint::shouldApply ( )

Definition at line 176 of file MultiDContactConstraint.C.

177 {
178  std::set<dof_id_type>::iterator hpit =
179  _penetration_locator._has_penetrated.find(_current_node->id());
180  return (hpit != _penetration_locator._has_penetrated.end());
181 }

◆ timestepSetup()

void MultiDContactConstraint::timestepSetup ( )
virtual

Definition at line 92 of file MultiDContactConstraint.C.

93 {
94  if (_component == 0)
96 }

◆ updateContactSet()

void MultiDContactConstraint::updateContactSet ( )
virtual

Definition at line 106 of file MultiDContactConstraint.C.

107 {
108  auto & has_penetrated = _penetration_locator._has_penetrated;
109 
110  for (auto & pinfo_pair : _penetration_locator._penetration_info)
111  {
112  PenetrationInfo * pinfo = pinfo_pair.second;
113 
114  // Skip this pinfo if there are no DOFs on this node.
115  if (!pinfo || pinfo->_node->n_comp(_sys.number(), _vars[_component]) < 1)
116  continue;
117 
118  const Node * node = pinfo->_node;
119 
120  dof_id_type slave_node_num = pinfo_pair.first;
121  auto hpit = has_penetrated.find(slave_node_num);
122 
123  RealVectorValue res_vec;
124  // Build up residual vector
125  for (unsigned int i = 0; i < _mesh_dimension; ++i)
126  {
127  dof_id_type dof_number = node->dof_number(0, _vars[i], 0);
128  res_vec(i) = _residual_copy(dof_number);
129  }
130 
131  // Real resid = 0;
132  switch (_model)
133  {
135  // resid = pinfo->_normal * res_vec;
136  break;
137 
138  case ContactModel::GLUED:
139  // resid = pinfo->_normal * res_vec;
140  break;
141 
142  default:
143  mooseError("Invalid or unavailable contact model");
144  break;
145  }
146 
147  // if (hpit != has_penetrated.end() && resid < 0)
148  // Moose::err << resid << std::endl;
149  //
150  // if (hpit != has_penetrated.end() && resid < -.15)
151  // {
152  // Moose::err << std::endl
153  // << "Unlocking node " << node->id()
154  // << " because resid:
155  // "<<resid<<std::endl<<std::endl;
156  //
157  // has_penetrated.erase(hpit);
158  // unlocked_this_step[slave_node_num] = true;
159  // }
160  // else
161 
162  if (pinfo->_distance > 0 &&
163  hpit == has_penetrated.end()) // && !unlocked_this_step[slave_node_num])
164  {
165  // Moose::err << std::endl
166  // << "Locking node " << node->id() << " because distance:" << pinfo->_distance
167  // << std::endl
168  // << std::endl;
169 
170  has_penetrated.insert(slave_node_num);
171  }
172  }
173 }

Referenced by jacobianSetup(), and timestepSetup().

Member Data Documentation

◆ _component

const unsigned int MultiDContactConstraint::_component
protected

◆ _jacobian_update

bool MultiDContactConstraint::_jacobian_update
protected

Definition at line 49 of file MultiDContactConstraint.h.

◆ _mesh_dimension

const unsigned int MultiDContactConstraint::_mesh_dimension
protected

Definition at line 61 of file MultiDContactConstraint.h.

Referenced by computeQpResidual(), and updateContactSet().

◆ _model

const ContactModel MultiDContactConstraint::_model
protected

◆ _penalty

Real MultiDContactConstraint::_penalty
protected

Definition at line 55 of file MultiDContactConstraint.h.

Referenced by computeQpJacobian(), and computeQpResidual().

◆ _residual_copy

NumericVector<Number>& MultiDContactConstraint::_residual_copy
protected

Definition at line 47 of file MultiDContactConstraint.h.

Referenced by computeQpResidual(), and updateContactSet().

◆ _vars

std::vector<unsigned int> MultiDContactConstraint::_vars
protected

◆ _x_var

unsigned int MultiDContactConstraint::_x_var
protected

Definition at line 57 of file MultiDContactConstraint.h.

◆ _y_var

unsigned int MultiDContactConstraint::_y_var
protected

Definition at line 58 of file MultiDContactConstraint.h.

◆ _z_var

unsigned int MultiDContactConstraint::_z_var
protected

Definition at line 59 of file MultiDContactConstraint.h.


The documentation for this class was generated from the following files:
ContactModel
ContactModel
Definition: ContactAction.h:16
MultiDContactConstraint::_component
const unsigned int _component
Definition: MultiDContactConstraint.h:51
MultiDContactConstraint::_jacobian_update
bool _jacobian_update
Definition: MultiDContactConstraint.h:49
MultiDContactConstraint::_residual_copy
NumericVector< Number > & _residual_copy
Definition: MultiDContactConstraint.h:47
ContactModel::GLUED
MultiDContactConstraint::_penalty
Real _penalty
Definition: MultiDContactConstraint.h:55
MultiDContactConstraint::_model
const ContactModel _model
Definition: MultiDContactConstraint.h:53
ContactModel::FRICTIONLESS
MultiDContactConstraint::updateContactSet
virtual void updateContactSet()
Definition: MultiDContactConstraint.C:106
MultiDContactConstraint::_vars
std::vector< unsigned int > _vars
Definition: MultiDContactConstraint.h:63
MultiDContactConstraint::_mesh_dimension
const unsigned int _mesh_dimension
Definition: MultiDContactConstraint.h:61