https://mooseframework.inl.gov
MortarPressureComponentAux.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 
11 #include "SystemBase.h"
12 
14 
17 {
19  params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
20 
21  params.addClassDescription(
22  "This class transforms the Cartesian Lagrange multiplier vector to local coordinates and "
23  "outputs each individual component along the normal or tangential direction.");
24  params.addRequiredCoupledVar("lm_var_x", "Lagrange multiplier variable along the x direction.");
25  params.addRequiredCoupledVar("lm_var_y", "Lagrange multiplier variable along the y direction.");
26  params.addCoupledVar(
27  "lm_var_z",
28  "Lagrange multiplier variable along the z direction (only exist for 3D problems).");
29  params.addRequiredParam<MooseEnum>("component",
30  MooseEnum("normal tangent1 tangent2"),
31  "The component of the Lagrange multiplier to compute.");
32  params.addRequiredParam<BoundaryName>("primary_boundary",
33  "The name of the primary boundary sideset.");
34  params.addRequiredParam<BoundaryName>("secondary_boundary",
35  "The name of the secondary boundary sideset.");
36  params.addParam<bool>(
37  "use_displaced_mesh", true, "Whether to use the displaced mesh to get the mortar interface.");
38  return params;
39 }
40 
42  : AuxKernel(params),
43  _lm_var_x(&coupledValueLower("lm_var_x")),
44  _lm_var_y(&coupledValueLower("lm_var_y")),
45  _lm_var_z(params.isParamValid("lm_var_z") ? &coupledValueLower("lm_var_z") : nullptr),
46  _fe_problem(*params.get<FEProblemBase *>("_fe_problem_base")),
47  _primary_id(_fe_problem.mesh().getBoundaryID(getParam<BoundaryName>("primary_boundary"))),
48  _secondary_id(_fe_problem.mesh().getBoundaryID(getParam<BoundaryName>("secondary_boundary"))),
49  _component(getParam<MooseEnum>("component").getEnum<ComponentType>()),
50  _use_displaced_mesh(getParam<bool>("use_displaced_mesh"))
51 {
52  // Only consider nodal quantities
53  if (!isNodal())
54  mooseError("MortarPressureComponent auxiliary kernel can only be used with nodal kernels.");
55 
57  paramError("use_displaced_mesh",
58  "This auxiliary kernel requires the use of displaced meshes to compute the "
59  "frictional pressure vector.");
60 
61  // Kernel need to be boundary restricted
62  if (!this->_bnd)
63  paramError("boundary",
64  "MortarPressureComponent auxiliary kernel must be restricted to a boundary.");
65 
66  // Get mortar interfaces
67  const auto & displaced_mortar_interfaces =
69 
70  if (displaced_mortar_interfaces.size() == 0)
71  paramError("lm_var_x",
72  "No mortar interface could be identified in this problem. Make sure mortar contact "
73  "is enabled.");
74 
75  // Get automatic generation object for the boundary pair this auxiliary acts on.
76  if (displaced_mortar_interfaces.count(std::make_pair(_primary_id, _secondary_id)) != 1)
77  mooseError("primary_boundary",
78  "The boundary pairs do not correspond to a single mortar contact boundary pair. "
79  "Please revise your input file for proper mortar contact constraints and mortar "
80  "frictional pressure vector auxiliary variable definition.");
81 
83  &libmesh_map_find(displaced_mortar_interfaces, std::make_pair(_primary_id, _secondary_id));
84 }
85 
86 Real
88 {
89  // A node id may correspond to more than one lower-d elements on the secondary surface.
90  // However, we are looping over nodes below, so we will locate the correct geometry
91  const Elem * lower_dimensional_element =
92  libmesh_map_find(_mortar_generation_object->nodesToSecondaryElem(), _current_node->id())[0];
93 
94  // Get the nodal normals for this element
95  const auto & nodal_normals =
96  _mortar_generation_object->getNodalNormals(*lower_dimensional_element);
97 
98  // Get nodal tangents for this element
99  const auto & nodal_tangents =
100  _mortar_generation_object->getNodalTangents(*lower_dimensional_element);
101 
102  Point normal_vector, tangent1, tangent2;
103 
104  for (const auto lowerd_node : make_range(lower_dimensional_element->n_nodes()))
105  if (_current_node->id() == lower_dimensional_element->node_id(lowerd_node))
106  {
107  normal_vector = nodal_normals[lowerd_node];
108  tangent1 = nodal_tangents[0][lowerd_node];
109  tangent2 = nodal_tangents[1][lowerd_node];
110  break;
111  }
112 
113  Point lm_vector_value(
114  (*_lm_var_x)[_qp], (*_lm_var_y)[_qp], _lm_var_z == nullptr ? 0.0 : (*_lm_var_z)[_qp]);
115 
116  Real pressure_component_value = 0.0;
117 
118  switch (_component)
119  {
121  pressure_component_value = lm_vector_value * normal_vector;
122  break;
123 
125  pressure_component_value = lm_vector_value * tangent1;
126  break;
127 
129  pressure_component_value = lm_vector_value * tangent2;
130  break;
131  }
132 
133  return pressure_component_value;
134 }
const BoundaryID _primary_id
Boundary ID for the primary surface.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const Node *const & _current_node
ComponentType
The component of the Lagrange multiplier to compute.
T & set(const std::string &name, bool quiet_mode=false)
MeshBase & mesh
const bool _use_displaced_mesh
Whether to use displaced mesh (required for this auxiliary kernel)
enum MortarPressureComponentAux::ComponentType _component
const MooseArray< Real > *const _lm_var_x
Lagrange multiplier variable along the x direction.
const ExecFlagType EXEC_TIMESTEP_END
std::vector< Point > getNodalNormals(const Elem &secondary_elem) const
const FEProblemBase & _fe_problem
Fe problem to obtain primary/secondary ids.
void addRequiredParam(const std::string &name, const std::string &doc_string)
registerMooseObject("ContactApp", MortarPressureComponentAux)
BoundaryID getBoundaryID(const BoundaryName &boundary_name, const MeshBase &mesh)
const BoundaryID _secondary_id
Boundary ID for the secondary surface.
static InputParameters validParams()
Transforms a Cartesian Lagrange multiplier vector, typically employed for mortar mechanical contact...
std::array< MooseUtils::SemidynamicVector< Point, 9 >, 2 > getNodalTangents(const Elem &secondary_elem) const
void paramError(const std::string &param, Args... args) const
const MooseArray< Real > *const _lm_var_z
Lagrange multiplier variable along the z direction (3D)
const std::unordered_map< dof_id_type, std::vector< const Elem *> > & nodesToSecondaryElem() const
void addCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
MortarPressureComponentAux(const InputParameters &parameters)
const AutomaticMortarGeneration * _mortar_generation_object
Handle to mortar generation object to obtain mortar geometry.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real computeValue() override
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
const std::unordered_map< std::pair< BoundaryID, BoundaryID >, AutomaticMortarGeneration > & getMortarInterfaces(bool on_displaced) const
const MooseArray< Real > *const _lm_var_y
Lagrange multiplier variable along the y direction.
const Elem & get(const ElemType type_in)