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

#include <SlaveConstraint.h>

Inheritance diagram for SlaveConstraint:
[legend]

Public Member Functions

 SlaveConstraint (const InputParameters &parameters)
 
virtual void addPoints ()
 
virtual Real computeQpResidual ()
 
virtual Real computeQpJacobian ()
 

Protected Member Functions

Real nodalArea (PenetrationInfo &pinfo)
 

Protected Attributes

const unsigned int _component
 
const ContactModel _model
 
const ContactFormulation _formulation
 
const bool _normalize_penalty
 
PenetrationLocator & _penetration_locator
 
const Real _penalty
 
const Real _friction_coefficient
 
NumericVector< Number > & _residual_copy
 
std::map< Point, PenetrationInfo * > _point_to_info
 
std::vector< unsigned int > _vars
 
const unsigned int _mesh_dimension
 
MooseVariable * _nodal_area_var
 
SystemBase & _aux_system
 
const NumericVector< Number > * _aux_solution
 

Detailed Description

Definition at line 24 of file SlaveConstraint.h.

Constructor & Destructor Documentation

◆ SlaveConstraint()

SlaveConstraint::SlaveConstraint ( const InputParameters &  parameters)

Definition at line 62 of file SlaveConstraint.C.

63  : DiracKernel(parameters),
64  _component(getParam<unsigned int>("component")),
65  _model(getParam<MooseEnum>("model").getEnum<ContactModel>()),
66  _formulation(getParam<MooseEnum>("formulation").getEnum<ContactFormulation>()),
67  _normalize_penalty(getParam<bool>("normalize_penalty")),
69  getPenetrationLocator(getParam<BoundaryName>("master"),
70  getParam<BoundaryName>("boundary"),
71  Utility::string_to_enum<Order>(getParam<MooseEnum>("order")))),
72  _penalty(getParam<Real>("penalty")),
73  _friction_coefficient(getParam<Real>("friction_coefficient")),
74  _residual_copy(_sys.residualGhosted()),
75  _vars(3, libMesh::invalid_uint),
76  _mesh_dimension(_mesh.dimension()),
77  _nodal_area_var(getVar("nodal_area", 0)),
79  _aux_solution(_aux_system.currentSolution())
80 {
81  if (isParamValid("displacements"))
82  {
83  // modern parameter scheme for displacements
84  for (unsigned int i = 0; i < coupledComponents("displacements"); ++i)
85  _vars[i] = coupled("displacements", i);
86  }
87  else
88  {
89  // Legacy parameter scheme for displacements
90  if (isParamValid("disp_x"))
91  _vars[0] = coupled("disp_x");
92  if (isParamValid("disp_y"))
93  _vars[1] = coupled("disp_y");
94  if (isParamValid("disp_z"))
95  _vars[2] = coupled("disp_z");
96 
97  mooseDeprecated("use the `displacements` parameter rather than the `disp_*` parameters (those "
98  "will go away with the deprecation of the Solid Mechanics module).");
99  }
100 
101  if (parameters.isParamValid("tangential_tolerance"))
102  _penetration_locator.setTangentialTolerance(getParam<Real>("tangential_tolerance"));
103 
104  if (parameters.isParamValid("normal_smoothing_distance"))
105  _penetration_locator.setNormalSmoothingDistance(getParam<Real>("normal_smoothing_distance"));
106 
107  if (parameters.isParamValid("normal_smoothing_method"))
108  _penetration_locator.setNormalSmoothingMethod(
109  parameters.get<std::string>("normal_smoothing_method"));
110 }

Member Function Documentation

◆ addPoints()

void SlaveConstraint::addPoints ( )
virtual

Definition at line 113 of file SlaveConstraint.C.

114 {
115  _point_to_info.clear();
116 
117  std::map<dof_id_type, PenetrationInfo *>::iterator
118  it = _penetration_locator._penetration_info.begin(),
119  end = _penetration_locator._penetration_info.end();
120 
121  const auto & node_to_elem_map = _mesh.nodeToElemMap();
122  for (; it != end; ++it)
123  {
124  PenetrationInfo * pinfo = it->second;
125 
126  // Skip this pinfo if there are no DOFs on this node.
127  if (!pinfo || pinfo->_node->n_comp(_sys.number(), _vars[_component]) < 1)
128  continue;
129 
130  dof_id_type slave_node_num = it->first;
131  const Node * node = pinfo->_node;
132 
133  if (pinfo->isCaptured() && node->processor_id() == processor_id())
134  {
135  // Find an element that is connected to this node that and that is also on this processor
136  auto node_to_elem_pair = node_to_elem_map.find(slave_node_num);
137  mooseAssert(node_to_elem_pair != node_to_elem_map.end(), "Missing node in node to elem map");
138  const std::vector<dof_id_type> & connected_elems = node_to_elem_pair->second;
139 
140  Elem * elem = NULL;
141 
142  for (unsigned int i = 0; i < connected_elems.size() && !elem; ++i)
143  {
144  Elem * cur_elem = _mesh.elemPtr(connected_elems[i]);
145  if (cur_elem->processor_id() == processor_id())
146  elem = cur_elem;
147  }
148 
149  mooseAssert(elem,
150  "Couldn't find an element on this processor that is attached to the slave node!");
151 
152  addPoint(elem, *node);
153  _point_to_info[*node] = pinfo;
154  }
155  }
156 }

◆ computeQpJacobian()

Real SlaveConstraint::computeQpJacobian ( )
virtual

Definition at line 186 of file SlaveConstraint.C.

187 {
188 
189  // TODO: for the default formulation,
190  // we should subtract off the existing Jacobian weighted by the effect of the normal
191 
192  PenetrationInfo * pinfo = _point_to_info[_current_point];
193  const Node * node = pinfo->_node;
194  // long int dof_number = node->dof_number(0, _var.number(), 0);
195 
196  // RealVectorValue jac_vec;
197 
198  // Build up jac vector
199  // for (unsigned int i=0; i<_dim; i++)
200  // {
201  // unsigned int dof_row = _dof_data._var_dof_indices[_var_num][_i];
202  // unsigned int dof_col = _dof_data._var_dof_indices[_var_num][_j];
203 
204  // Real jac_value = _jacobian_copy(dof_row, dof_col);
205  // }
206 
207  // Real jac_mag = pinfo->_normal(_component) * jac_value;
208  /*
209  return _test[_i][_qp] * (
210  (1e8*-_phi[_j][_qp])
211  -_jacobian_copy(dof_number, dof_number)
212  );
213  */
214 
215  RealVectorValue normal(pinfo->_normal);
216 
217  Real penalty = _penalty;
218  if (_normalize_penalty)
219  penalty *= nodalArea(*pinfo);
220 
221  Real term(0);
222 
224  {
225 
226  const Real nnTDiag = normal(_component) * normal(_component);
227  term = penalty * nnTDiag;
228 
229  const RealGradient & A1(pinfo->_dxyzdxi[0]);
230  RealGradient A2;
231  RealGradient d2;
232  if (_mesh_dimension == 3)
233  {
234  A2 = pinfo->_dxyzdeta[0];
235  d2 = pinfo->_d2xyzdxideta[0];
236  }
237  else
238  {
239  A2.zero();
240  d2.zero();
241  }
242 
243  const RealVectorValue distance_vec(_mesh.nodeRef(node->id()) - pinfo->_closest_point);
244  const Real ATA11(A1 * A1);
245  const Real ATA12(A1 * A2);
246  const Real ATA22(A2 * A2);
247  const Real D11(-ATA11);
248  const Real D12(-ATA12 + d2 * distance_vec);
249  const Real D22(-ATA22);
250 
251  Real invD11(0);
252  Real invD12(0);
253  Real invD22(0);
254  if (_mesh_dimension == 3)
255  {
256  const Real detD(D11 * D22 - D12 * D12);
257  invD11 = D22 / detD;
258  invD12 = -D12 / detD;
259  invD22 = D11 / detD;
260  }
261  else if (_mesh_dimension == 2)
262  {
263  invD11 = 1 / D11;
264  }
265 
266  const Real AinvD11(A1(0) * invD11 + A2(0) * invD12);
267  const Real AinvD12(A1(0) * invD12 + A2(0) * invD22);
268  const Real AinvD21(A1(1) * invD11 + A2(1) * invD12);
269  const Real AinvD22(A1(1) * invD12 + A2(1) * invD22);
270  const Real AinvD31(A1(2) * invD11 + A2(2) * invD12);
271  const Real AinvD32(A1(2) * invD12 + A2(2) * invD22);
272 
273  const Real AinvDAT11(AinvD11 * A1(0) + AinvD12 * A2(0));
274  // const Real AinvDAT12( AinvD11*A1(1) + AinvD12*A2(1) );
275  // const Real AinvDAT13( AinvD11*A1(2) + AinvD12*A2(2) );
276  // const Real AinvDAT21( AinvD21*A1(0) + AinvD22*A2(0) );
277  const Real AinvDAT22(AinvD21 * A1(1) + AinvD22 * A2(1));
278  // const Real AinvDAT23( AinvD21*A1(2) + AinvD22*A2(2) );
279  // const Real AinvDAT31( AinvD31*A1(0) + AinvD32*A2(0) );
280  // const Real AinvDAT32( AinvD31*A1(1) + AinvD32*A2(1) );
281  const Real AinvDAT33(AinvD31 * A1(2) + AinvD32 * A2(2));
282 
283  if (_component == 0)
284  term += penalty * (1 - nnTDiag + AinvDAT11);
285 
286  else if (_component == 1)
287  term += penalty * (1 - nnTDiag + AinvDAT22);
288 
289  else
290  term += penalty * (1 - nnTDiag + AinvDAT33);
291  }
293  {
294  normal.zero();
295  normal(_component) = 1;
296  term = penalty;
297  }
298  else
299  {
300  mooseError("Invalid or unavailable contact model");
301  }
302 
303  return _test[_i][_qp] * term * _phi[_j][_qp];
304 }

◆ computeQpResidual()

Real SlaveConstraint::computeQpResidual ( )
virtual

Definition at line 159 of file SlaveConstraint.C.

160 {
161  PenetrationInfo * pinfo = _point_to_info[_current_point];
162  const Node * node = pinfo->_node;
163 
164  Real resid = pinfo->_contact_force(_component);
165 
166  const Real area = nodalArea(*pinfo);
167 
169  {
170  RealVectorValue distance_vec(_mesh.nodeRef(node->id()) - pinfo->_closest_point);
171  RealVectorValue pen_force(_penalty * distance_vec);
172  if (_normalize_penalty)
173  pen_force *= area;
174 
176  resid += pinfo->_normal(_component) * pinfo->_normal * pen_force;
177 
179  resid += pen_force(_component);
180  }
181 
182  return _test[_i][_qp] * resid;
183 }

◆ nodalArea()

Real SlaveConstraint::nodalArea ( PenetrationInfo &  pinfo)
protected

Definition at line 307 of file SlaveConstraint.C.

308 {
309  const Node * node = pinfo._node;
310 
311  dof_id_type dof = node->dof_number(_aux_system.number(), _nodal_area_var->number(), 0);
312 
313  Real area = (*_aux_solution)(dof);
314  if (area == 0)
315  {
316  if (_t_step > 1)
317  mooseError("Zero nodal area found");
318 
319  else
320  area = 1; // Avoid divide by zero during initialization
321  }
322  return area;
323 }

Referenced by computeQpJacobian(), and computeQpResidual().

Member Data Documentation

◆ _aux_solution

const NumericVector<Number>* SlaveConstraint::_aux_solution
protected

Definition at line 55 of file SlaveConstraint.h.

◆ _aux_system

SystemBase& SlaveConstraint::_aux_system
protected

Definition at line 54 of file SlaveConstraint.h.

Referenced by nodalArea().

◆ _component

const unsigned int SlaveConstraint::_component
protected

Definition at line 36 of file SlaveConstraint.h.

Referenced by addPoints(), computeQpJacobian(), and computeQpResidual().

◆ _formulation

const ContactFormulation SlaveConstraint::_formulation
protected

Definition at line 38 of file SlaveConstraint.h.

Referenced by computeQpResidual().

◆ _friction_coefficient

const Real SlaveConstraint::_friction_coefficient
protected

Definition at line 43 of file SlaveConstraint.h.

◆ _mesh_dimension

const unsigned int SlaveConstraint::_mesh_dimension
protected

Definition at line 51 of file SlaveConstraint.h.

Referenced by computeQpJacobian().

◆ _model

const ContactModel SlaveConstraint::_model
protected

Definition at line 37 of file SlaveConstraint.h.

Referenced by computeQpJacobian(), and computeQpResidual().

◆ _nodal_area_var

MooseVariable* SlaveConstraint::_nodal_area_var
protected

Definition at line 53 of file SlaveConstraint.h.

Referenced by nodalArea().

◆ _normalize_penalty

const bool SlaveConstraint::_normalize_penalty
protected

Definition at line 39 of file SlaveConstraint.h.

Referenced by computeQpJacobian(), and computeQpResidual().

◆ _penalty

const Real SlaveConstraint::_penalty
protected

Definition at line 42 of file SlaveConstraint.h.

Referenced by computeQpJacobian(), and computeQpResidual().

◆ _penetration_locator

PenetrationLocator& SlaveConstraint::_penetration_locator
protected

Definition at line 40 of file SlaveConstraint.h.

Referenced by addPoints(), and SlaveConstraint().

◆ _point_to_info

std::map<Point, PenetrationInfo *> SlaveConstraint::_point_to_info
protected

Definition at line 47 of file SlaveConstraint.h.

Referenced by addPoints(), computeQpJacobian(), and computeQpResidual().

◆ _residual_copy

NumericVector<Number>& SlaveConstraint::_residual_copy
protected

Definition at line 45 of file SlaveConstraint.h.

◆ _vars

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

Definition at line 49 of file SlaveConstraint.h.

Referenced by addPoints(), and SlaveConstraint().


The documentation for this class was generated from the following files:
SlaveConstraint::nodalArea
Real nodalArea(PenetrationInfo &pinfo)
Definition: SlaveConstraint.C:307
SlaveConstraint::_aux_system
SystemBase & _aux_system
Definition: SlaveConstraint.h:54
SlaveConstraint::_component
const unsigned int _component
Definition: SlaveConstraint.h:36
SlaveConstraint::_point_to_info
std::map< Point, PenetrationInfo * > _point_to_info
Definition: SlaveConstraint.h:47
libMesh::RealGradient
VectorValue< Real > RealGradient
Definition: GrainForceAndTorqueInterface.h:17
SlaveConstraint::_mesh_dimension
const unsigned int _mesh_dimension
Definition: SlaveConstraint.h:51
SlaveConstraint::_nodal_area_var
MooseVariable * _nodal_area_var
Definition: SlaveConstraint.h:53
ContactModel::GLUED
SlaveConstraint::_normalize_penalty
const bool _normalize_penalty
Definition: SlaveConstraint.h:39
SlaveConstraint::_residual_copy
NumericVector< Number > & _residual_copy
Definition: SlaveConstraint.h:45
ContactFormulation::KINEMATIC
SlaveConstraint::_vars
std::vector< unsigned int > _vars
Definition: SlaveConstraint.h:49
ContactModel::COULOMB
SlaveConstraint::_model
const ContactModel _model
Definition: SlaveConstraint.h:37
ContactModel::FRICTIONLESS
SlaveConstraint::_friction_coefficient
const Real _friction_coefficient
Definition: SlaveConstraint.h:43
SlaveConstraint::_penetration_locator
PenetrationLocator & _penetration_locator
Definition: SlaveConstraint.h:40
SlaveConstraint::_penalty
const Real _penalty
Definition: SlaveConstraint.h:42
SlaveConstraint::_formulation
const ContactFormulation _formulation
Definition: SlaveConstraint.h:38
SlaveConstraint::_aux_solution
const NumericVector< Number > * _aux_solution
Definition: SlaveConstraint.h:55