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 
19 const Real PenetrationAux::NotPenetrated = -999999;
20 
22 
23 template <>
26 {
27  MooseEnum orders("FIRST SECOND THIRD FOURTH", "FIRST");
28 
30  params.addClassDescription("Auxiliary Kernel for computing several geometry related quantities "
31  "between two contacting bodies.");
32 
33  params.addRequiredParam<BoundaryName>("paired_boundary", "The boundary to be penetrated");
34  params.addParam<Real>("tangential_tolerance",
35  "Tangential distance to extend edges of contact surfaces");
36  params.addParam<Real>(
37  "normal_smoothing_distance",
38  "Distance from edge in parametric coordinates over which to smooth contact normal");
39  params.addParam<std::string>("normal_smoothing_method",
40  "Method to use to smooth normals (edge_based|nodal_normal_based)");
41  params.addParam<MooseEnum>("order", orders, "The finite element order");
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 {
79  if (parameters.isParamValid("tangential_tolerance"))
80  _penetration_locator.setTangentialTolerance(getParam<Real>("tangential_tolerance"));
81 
82  if (parameters.isParamValid("normal_smoothing_distance"))
83  _penetration_locator.setNormalSmoothingDistance(getParam<Real>("normal_smoothing_distance"));
84 
85  if (parameters.isParamValid("normal_smoothing_method"))
87  parameters.get<std::string>("normal_smoothing_method"));
88 }
89 
90 Real
92 {
93  const Node * current_node = NULL;
94 
95  if (_nodal)
96  current_node = _current_node;
97  else
99 
100  PenetrationInfo * pinfo = _penetration_locator._penetration_info[current_node->id()];
101 
102  Real retVal(NotPenetrated);
103 
104  if (pinfo)
105  switch (_quantity)
106  {
107  case PA_DISTANCE:
108  retVal = pinfo->_distance;
109  break;
110  case PA_TANG_DISTANCE:
111  retVal = pinfo->_tangential_distance;
112  break;
113  case PA_NORMAL_X:
114  retVal = pinfo->_normal(0);
115  break;
116  case PA_NORMAL_Y:
117  retVal = pinfo->_normal(1);
118  break;
119  case PA_NORMAL_Z:
120  retVal = pinfo->_normal(2);
121  break;
122  case PA_CLOSEST_POINT_X:
123  retVal = pinfo->_closest_point(0);
124  break;
125  case PA_CLOSEST_POINT_Y:
126  retVal = pinfo->_closest_point(1);
127  break;
128  case PA_CLOSEST_POINT_Z:
129  retVal = pinfo->_closest_point(2);
130  break;
131  case PA_ELEM_ID:
132  retVal = static_cast<Real>(pinfo->_elem->id() + 1);
133  break;
134  case PA_SIDE:
135  retVal = static_cast<Real>(pinfo->_side_num);
136  break;
138  retVal = pinfo->isCaptured() ? pinfo->_incremental_slip.norm() : 0;
139  break;
141  retVal = pinfo->isCaptured() ? pinfo->_incremental_slip(0) : 0;
142  break;
144  retVal = pinfo->isCaptured() ? pinfo->_incremental_slip(1) : 0;
145  break;
147  retVal = pinfo->isCaptured() ? pinfo->_incremental_slip(2) : 0;
148  break;
149  case PA_ACCUMULATED_SLIP:
150  retVal = pinfo->_accumulated_slip;
151  break;
152  case PA_FORCE_X:
153  retVal = pinfo->_contact_force(0);
154  break;
155  case PA_FORCE_Y:
156  retVal = pinfo->_contact_force(1);
157  break;
158  case PA_FORCE_Z:
159  retVal = pinfo->_contact_force(2);
160  break;
161  case PA_NORMAL_FORCE_MAG:
162  retVal = -pinfo->_contact_force * pinfo->_normal;
163  break;
164  case PA_NORMAL_FORCE_X:
165  retVal = (pinfo->_contact_force * pinfo->_normal) * pinfo->_normal(0);
166  break;
167  case PA_NORMAL_FORCE_Y:
168  retVal = (pinfo->_contact_force * pinfo->_normal) * pinfo->_normal(1);
169  break;
170  case PA_NORMAL_FORCE_Z:
171  retVal = (pinfo->_contact_force * pinfo->_normal) * pinfo->_normal(2);
172  break;
174  {
175  RealVectorValue contact_force_normal((pinfo->_contact_force * pinfo->_normal) *
176  pinfo->_normal);
177  RealVectorValue contact_force_tangential(pinfo->_contact_force - contact_force_normal);
178  retVal = contact_force_tangential.norm();
179  break;
180  }
182  retVal =
183  pinfo->_contact_force(0) - (pinfo->_contact_force * pinfo->_normal) * pinfo->_normal(0);
184  break;
186  retVal =
187  pinfo->_contact_force(1) - (pinfo->_contact_force * pinfo->_normal) * pinfo->_normal(1);
188  break;
190  retVal =
191  pinfo->_contact_force(2) - (pinfo->_contact_force * pinfo->_normal) * pinfo->_normal(2);
192  break;
194  retVal = pinfo->_frictional_energy;
195  break;
197  retVal = pinfo->_lagrange_multiplier;
198  break;
199  case PA_MECH_STATUS:
200  retVal = pinfo->_mech_status;
201  break;
202  default:
203  mooseError("Unknown PA_ENUM");
204  } // switch
205 
206  return retVal;
207 }
bool _nodal
Flag indicating if the AuxKernel is nodal.
Definition: AuxKernel.h:170
const unsigned int & _current_side
current side of the current element
Definition: AuxKernel.h:205
RealVectorValue _normal
MooseMesh & _mesh
Mesh this kernel is active on.
Definition: AuxKernel.h:190
void setNormalSmoothingDistance(Real normal_smoothing_distance)
VectorValue< Real > RealVectorValue
Definition: Assembly.h:31
Data structure used to hold penetration information.
const Node *const & _current_node
Current node (valid only for nodal kernels)
Definition: AuxKernel.h:213
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)
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
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 InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:65
const Elem * _elem
PenetrationLocator & _penetration_locator
bool isCaptured() const
InputParameters validParams< AuxKernel >()
Definition: AuxKernel.C:25
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:977
MECH_STATUS_ENUM _mech_status
virtual Real computeValue() override
Compute and return the value of the aux variable.
static const Real NotPenetrated
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition: AuxKernel.h:203
unsigned int _qp
Quadrature point index.
Definition: AuxKernel.h:219
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...
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...
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:33
void setNormalSmoothingMethod(std::string nsmString)
InputParameters validParams< PenetrationAux >()
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.