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 25 of file SlaveConstraint.h.

Constructor & Destructor Documentation

◆ SlaveConstraint()

SlaveConstraint::SlaveConstraint ( const InputParameters &  parameters)

Definition at line 69 of file SlaveConstraint.C.

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

Member Function Documentation

◆ addPoints()

void SlaveConstraint::addPoints ( )
virtual

Definition at line 120 of file SlaveConstraint.C.

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

◆ computeQpJacobian()

Real SlaveConstraint::computeQpJacobian ( )
virtual

Definition at line 193 of file SlaveConstraint.C.

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

◆ computeQpResidual()

Real SlaveConstraint::computeQpResidual ( )
virtual

Definition at line 166 of file SlaveConstraint.C.

167 {
168  PenetrationInfo * pinfo = _point_to_info[_current_point];
169  const Node * node = pinfo->_node;
170 
171  Real resid = pinfo->_contact_force(_component);
172 
173  const Real area = nodalArea(*pinfo);
174 
175  if (_formulation == CF_DEFAULT)
176  {
177  RealVectorValue distance_vec(_mesh.nodeRef(node->id()) - pinfo->_closest_point);
178  RealVectorValue pen_force(_penalty * distance_vec);
179  if (_normalize_penalty)
180  pen_force *= area;
181 
182  if (_model == CM_FRICTIONLESS)
183  resid += pinfo->_normal(_component) * pinfo->_normal * pen_force;
184 
185  else if (_model == CM_GLUED || _model == CM_COULOMB)
186  resid += pen_force(_component);
187  }
188 
189  return _test[_i][_qp] * resid;
190 }
const Real _penalty
const ContactFormulation _formulation
const ContactModel _model
const unsigned int _component
const bool _normalize_penalty
std::map< Point, PenetrationInfo * > _point_to_info
Real nodalArea(PenetrationInfo &pinfo)

◆ nodalArea()

Real SlaveConstraint::nodalArea ( PenetrationInfo &  pinfo)
protected

Definition at line 314 of file SlaveConstraint.C.

Referenced by computeQpJacobian(), and computeQpResidual().

315 {
316  const Node * node = pinfo._node;
317 
318  dof_id_type dof = node->dof_number(_aux_system.number(), _nodal_area_var->number(), 0);
319 
320  Real area = (*_aux_solution)(dof);
321  if (area == 0)
322  {
323  if (_t_step > 1)
324  mooseError("Zero nodal area found");
325 
326  else
327  area = 1; // Avoid divide by zero during initialization
328  }
329  return area;
330 }
MooseVariable * _nodal_area_var
SystemBase & _aux_system

Member Data Documentation

◆ _aux_solution

const NumericVector<Number>* SlaveConstraint::_aux_solution
protected

Definition at line 56 of file SlaveConstraint.h.

◆ _aux_system

SystemBase& SlaveConstraint::_aux_system
protected

Definition at line 55 of file SlaveConstraint.h.

Referenced by nodalArea().

◆ _component

const unsigned int SlaveConstraint::_component
protected

Definition at line 37 of file SlaveConstraint.h.

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

◆ _formulation

const ContactFormulation SlaveConstraint::_formulation
protected

Definition at line 39 of file SlaveConstraint.h.

Referenced by computeQpResidual().

◆ _friction_coefficient

const Real SlaveConstraint::_friction_coefficient
protected

Definition at line 44 of file SlaveConstraint.h.

◆ _mesh_dimension

const unsigned int SlaveConstraint::_mesh_dimension
protected

Definition at line 52 of file SlaveConstraint.h.

Referenced by computeQpJacobian().

◆ _model

const ContactModel SlaveConstraint::_model
protected

Definition at line 38 of file SlaveConstraint.h.

Referenced by computeQpJacobian(), and computeQpResidual().

◆ _nodal_area_var

MooseVariable* SlaveConstraint::_nodal_area_var
protected

Definition at line 54 of file SlaveConstraint.h.

Referenced by nodalArea().

◆ _normalize_penalty

const bool SlaveConstraint::_normalize_penalty
protected

Definition at line 40 of file SlaveConstraint.h.

Referenced by computeQpJacobian(), and computeQpResidual().

◆ _penalty

const Real SlaveConstraint::_penalty
protected

Definition at line 43 of file SlaveConstraint.h.

Referenced by computeQpJacobian(), and computeQpResidual().

◆ _penetration_locator

PenetrationLocator& SlaveConstraint::_penetration_locator
protected

Definition at line 41 of file SlaveConstraint.h.

Referenced by addPoints(), and SlaveConstraint().

◆ _point_to_info

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

Definition at line 48 of file SlaveConstraint.h.

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

◆ _residual_copy

NumericVector<Number>& SlaveConstraint::_residual_copy
protected

Definition at line 46 of file SlaveConstraint.h.

◆ _vars

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

Definition at line 50 of file SlaveConstraint.h.

Referenced by addPoints(), and SlaveConstraint().


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