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 28 of file MultiDContactConstraint.h.

Constructor & Destructor Documentation

◆ MultiDContactConstraint()

MultiDContactConstraint::MultiDContactConstraint ( const InputParameters &  parameters)

Definition at line 57 of file MultiDContactConstraint.C.

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

◆ ~MultiDContactConstraint()

virtual MultiDContactConstraint::~MultiDContactConstraint ( )
inlinevirtual

Definition at line 32 of file MultiDContactConstraint.h.

32 {}

Member Function Documentation

◆ computeQpJacobian()

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

Definition at line 263 of file MultiDContactConstraint.C.

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

◆ computeQpResidual()

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

Definition at line 207 of file MultiDContactConstraint.C.

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

◆ computeQpSlaveValue()

Real MultiDContactConstraint::computeQpSlaveValue ( )
virtual

Definition at line 183 of file MultiDContactConstraint.C.

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

◆ jacobianSetup()

void MultiDContactConstraint::jacobianSetup ( )
virtual

Definition at line 98 of file MultiDContactConstraint.C.

99 {
100  if (_component == 0)
102 }

◆ shouldApply()

bool MultiDContactConstraint::shouldApply ( )

Definition at line 175 of file MultiDContactConstraint.C.

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

◆ timestepSetup()

void MultiDContactConstraint::timestepSetup ( )
virtual

Definition at line 91 of file MultiDContactConstraint.C.

92 {
93  if (_component == 0)
95 }

◆ updateContactSet()

void MultiDContactConstraint::updateContactSet ( )
virtual

Definition at line 105 of file MultiDContactConstraint.C.

Referenced by jacobianSetup(), and timestepSetup().

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

Member Data Documentation

◆ _component

const unsigned int MultiDContactConstraint::_component
protected

◆ _jacobian_update

bool MultiDContactConstraint::_jacobian_update
protected

Definition at line 50 of file MultiDContactConstraint.h.

◆ _mesh_dimension

const unsigned int MultiDContactConstraint::_mesh_dimension
protected

Definition at line 62 of file MultiDContactConstraint.h.

Referenced by computeQpResidual(), and updateContactSet().

◆ _model

const ContactModel MultiDContactConstraint::_model
protected

◆ _penalty

Real MultiDContactConstraint::_penalty
protected

Definition at line 56 of file MultiDContactConstraint.h.

Referenced by computeQpJacobian(), and computeQpResidual().

◆ _residual_copy

NumericVector<Number>& MultiDContactConstraint::_residual_copy
protected

Definition at line 48 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 58 of file MultiDContactConstraint.h.

◆ _y_var

unsigned int MultiDContactConstraint::_y_var
protected

Definition at line 59 of file MultiDContactConstraint.h.

◆ _z_var

unsigned int MultiDContactConstraint::_z_var
protected

Definition at line 60 of file MultiDContactConstraint.h.


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