www.mooseframework.org
PenetrationAux.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 // MOOSE includes
11 #include "PenetrationAux.h"
12 #include "PenetrationLocator.h"
13 #include "DisplacedProblem.h"
14 #include "MooseEnum.h"
15 #include "MooseMesh.h"
16 
17 #include "libmesh/string_to_enum.h"
18 
20 
23 {
24  MooseEnum orders("FIRST SECOND THIRD FOURTH", "FIRST");
25 
27  params.addClassDescription("Auxiliary Kernel for computing several geometry related quantities "
28  "between two contacting bodies.");
29 
30  params.addRequiredParam<BoundaryName>("paired_boundary", "The boundary to be penetrated");
31  params.addParam<Real>("tangential_tolerance",
32  "Tangential distance to extend edges of contact surfaces");
33  params.addParam<Real>(
34  "normal_smoothing_distance",
35  "Distance from edge in parametric coordinates over which to smooth contact normal");
36  params.addParam<std::string>("normal_smoothing_method",
37  "Method to use to smooth normals (edge_based|nodal_normal_based)");
38  params.addParam<MooseEnum>("order", orders, "The finite element order");
39  params.addCoupledVar("secondary_gap_offset", "offset to the gap distance from secondary side");
40  params.addCoupledVar("mapped_primary_gap_offset",
41  "offset to the gap distance mapped from primary side");
42 
43  params.set<bool>("use_displaced_mesh") = true;
44 
45  // To avoid creating a conversion routine we will list the enumeration options in the same order
46  // as the class-based enum.
47  // Care must be taken to ensure that this list stays in sync with the enum in the .h file.
48  MooseEnum quantity(
49  "distance tangential_distance normal_x normal_y normal_z closest_point_x closest_point_y "
50  "closest_point_z element_id side incremental_slip_magnitude incremental_slip_x "
51  "incremental_slip_y incremental_slip_z accumulated_slip force_x force_y force_z "
52  "normal_force_magnitude normal_force_x normal_force_y normal_force_z "
53  "tangential_force_magnitude "
54  "tangential_force_x tangential_force_y tangential_force_z frictional_energy "
55  "lagrange_multiplier "
56  "mechanical_status",
57  "distance");
58 
59  params.addParam<MooseEnum>(
60  "quantity", quantity, "The quantity to recover from the available penetration information");
61  return params;
62 }
63 
65  : AuxKernel(parameters),
66 
67  // Here we cast the value of the MOOSE enum to an integer to the class-based enum.
68  _quantity(getParam<MooseEnum>("quantity").getEnum<PenetrationAux::PA_ENUM>()),
69  _penetration_locator(
70  _nodal ? getPenetrationLocator(
71  parameters.get<BoundaryName>("paired_boundary"),
72  boundaryNames()[0],
73  Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")))
74  : getQuadraturePenetrationLocator(
75  parameters.get<BoundaryName>("paired_boundary"),
76  boundaryNames()[0],
77  Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")))),
78  _has_secondary_gap_offset(isCoupled("secondary_gap_offset")),
79  _secondary_gap_offset_var(_has_secondary_gap_offset ? getVar("secondary_gap_offset", 0)
80  : nullptr),
81  _has_mapped_primary_gap_offset(isCoupled("mapped_primary_gap_offset")),
82  _mapped_primary_gap_offset_var(
83  _has_mapped_primary_gap_offset ? getVar("mapped_primary_gap_offset", 0) : nullptr)
84 {
85  if (parameters.isParamValid("tangential_tolerance"))
86  _penetration_locator.setTangentialTolerance(getParam<Real>("tangential_tolerance"));
87 
88  if (parameters.isParamValid("normal_smoothing_distance"))
89  _penetration_locator.setNormalSmoothingDistance(getParam<Real>("normal_smoothing_distance"));
90 
91  if (parameters.isParamValid("normal_smoothing_method"))
93  parameters.get<std::string>("normal_smoothing_method"));
94 }
95 
96 Real
98 {
99  const Node * current_node = nullptr;
100 
101  if (_nodal)
102  current_node = _current_node;
103  else
105 
106  PenetrationInfo * pinfo = _penetration_locator._penetration_info[current_node->id()];
107 
108  // A node that doesn't project has zero force, closest point (i.e. not computed), slip, and its
109  // mechanical status is not in contact.
110  Real retVal(0);
111 
112  if (pinfo)
113  switch (_quantity)
114  {
115  case PA_DISTANCE:
116  retVal =
117  pinfo->_distance -
119  : 0) -
122  : 0);
123  break;
124  case PA_TANG_DISTANCE:
125  retVal = pinfo->_tangential_distance;
126  break;
127  case PA_NORMAL_X:
128  retVal = pinfo->_normal(0);
129  break;
130  case PA_NORMAL_Y:
131  retVal = pinfo->_normal(1);
132  break;
133  case PA_NORMAL_Z:
134  retVal = pinfo->_normal(2);
135  break;
136  case PA_CLOSEST_POINT_X:
137  retVal = pinfo->_closest_point(0);
138  break;
139  case PA_CLOSEST_POINT_Y:
140  retVal = pinfo->_closest_point(1);
141  break;
142  case PA_CLOSEST_POINT_Z:
143  retVal = pinfo->_closest_point(2);
144  break;
145  case PA_ELEM_ID:
146  retVal = static_cast<Real>(pinfo->_elem->id() + 1);
147  break;
148  case PA_SIDE:
149  retVal = static_cast<Real>(pinfo->_side_num);
150  break;
152  retVal = pinfo->isCaptured() ? pinfo->_incremental_slip.norm() : 0;
153  break;
155  retVal = pinfo->isCaptured() ? pinfo->_incremental_slip(0) : 0;
156  break;
158  retVal = pinfo->isCaptured() ? pinfo->_incremental_slip(1) : 0;
159  break;
161  retVal = pinfo->isCaptured() ? pinfo->_incremental_slip(2) : 0;
162  break;
163  case PA_ACCUMULATED_SLIP:
164  retVal = pinfo->_accumulated_slip;
165  break;
166  case PA_FORCE_X:
167  retVal = pinfo->_contact_force(0);
168  break;
169  case PA_FORCE_Y:
170  retVal = pinfo->_contact_force(1);
171  break;
172  case PA_FORCE_Z:
173  retVal = pinfo->_contact_force(2);
174  break;
175  case PA_NORMAL_FORCE_MAG:
176  retVal = -pinfo->_contact_force * pinfo->_normal;
177  break;
178  case PA_NORMAL_FORCE_X:
179  retVal = (pinfo->_contact_force * pinfo->_normal) * pinfo->_normal(0);
180  break;
181  case PA_NORMAL_FORCE_Y:
182  retVal = (pinfo->_contact_force * pinfo->_normal) * pinfo->_normal(1);
183  break;
184  case PA_NORMAL_FORCE_Z:
185  retVal = (pinfo->_contact_force * pinfo->_normal) * pinfo->_normal(2);
186  break;
188  {
189  RealVectorValue contact_force_normal((pinfo->_contact_force * pinfo->_normal) *
190  pinfo->_normal);
191  RealVectorValue contact_force_tangential(pinfo->_contact_force - contact_force_normal);
192  retVal = contact_force_tangential.norm();
193  break;
194  }
196  retVal =
197  pinfo->_contact_force(0) - (pinfo->_contact_force * pinfo->_normal) * pinfo->_normal(0);
198  break;
200  retVal =
201  pinfo->_contact_force(1) - (pinfo->_contact_force * pinfo->_normal) * pinfo->_normal(1);
202  break;
204  retVal =
205  pinfo->_contact_force(2) - (pinfo->_contact_force * pinfo->_normal) * pinfo->_normal(2);
206  break;
208  retVal = pinfo->_frictional_energy;
209  break;
211  retVal = pinfo->_lagrange_multiplier;
212  break;
213  case PA_MECH_STATUS:
214  retVal = pinfo->_mech_status;
215  break;
216  default:
217  mooseError("Unknown penetration info quantity in auxiliary kernel.");
218  } // switch
219 
220  return retVal;
221 }
MooseVariable * _secondary_gap_offset_var
Order
auto norm() const -> decltype(std::norm(Real()))
bool _nodal
Flag indicating if the AuxKernel is nodal.
Definition: AuxKernel.h:177
const unsigned int & _current_side
current side of the current element
Definition: AuxKernel.h:206
const bool _has_secondary_gap_offset
RealVectorValue _normal
MooseMesh & _mesh
Mesh this kernel is active on.
Definition: AuxKernel.h:188
void setNormalSmoothingDistance(Real normal_smoothing_distance)
MooseVariable * _mapped_primary_gap_offset_var
Data structure used to hold penetration information.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
const Node *const & _current_node
Current node (valid only for nodal kernels)
Definition: AuxKernel.h:214
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1147
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
PenetrationAux(const InputParameters &parameters)
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
void setTangentialTolerance(Real tangential_tolerance)
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
registerMooseObject("MooseApp", PenetrationAux)
const Elem * _elem
PenetrationLocator & _penetration_locator
T string_to_enum(const std::string &s)
bool isCaptured() const
static InputParameters validParams()
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
unsigned int _side_num
RealVectorValue _contact_force
Node * getQuadratureNode(const Elem *elem, const unsigned short int side, const unsigned int qp)
Get a specified quadrature node.
Definition: MooseMesh.C:1444
MECH_STATUS_ENUM _mech_status
void addCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
OutputData getNodalValue(const Node &node) const
Get the value of this variable at given node.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real computeValue() override
Compute and return the value of the aux variable.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition: AuxKernel.h:204
unsigned int _qp
Quadrature point index.
Definition: AuxKernel.h:230
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
const InputParameters & parameters() const
Get the parameters of the object.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
static InputParameters validParams()
Definition: AuxKernel.C:27
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:36
void setNormalSmoothingMethod(std::string nsmString)
const bool _has_mapped_primary_gap_offset
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.