https://mooseframework.inl.gov
MortarFrictionalPressureVectorAux.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"
13 
15 
18 {
20  params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
21 
22  params.addClassDescription("This class creates an auxiliary vector for outputting the mortar "
23  "frictional pressure vector.");
24  params.addRequiredCoupledVar(
25  "tangent_one",
26  "First tangent vector Lagrange's multiplier for computing the mortar "
27  "frictional pressure vector.");
28  params.addRequiredCoupledVar(
29  "tangent_two",
30  "Second tangent vector Lagrange's multiplier for computing the mortar "
31  "frictional pressure vector.");
32  params.addRequiredParam<unsigned int>("component",
33  "Cartesian component of frictional tangent vector");
34 
35  params.addRequiredParam<BoundaryName>("primary_boundary",
36  "The name of the primary boundary sideset.");
37  params.addRequiredParam<BoundaryName>("secondary_boundary",
38  "The name of the secondary boundary sideset.");
39  params.addParam<bool>(
40  "use_displaced_mesh", true, "Whether to use the displaced mesh to get the mortar interface.");
41  return params;
42 }
43 
45  : AuxKernel(params),
46  _tangent_one(&coupledValueLower("tangent_one")),
47  _tangent_two(&coupledValueLower("tangent_two")),
48  _fe_problem(*params.get<FEProblemBase *>("_fe_problem_base")),
49  _primary_id(_fe_problem.mesh().getBoundaryID(getParam<BoundaryName>("primary_boundary"))),
50  _secondary_id(_fe_problem.mesh().getBoundaryID(getParam<BoundaryName>("secondary_boundary"))),
51  _component(getParam<unsigned int>("component")),
52  _use_displaced_mesh(getParam<bool>("use_displaced_mesh"))
53 {
54  // Only consider nodal quantities
55  if (!isNodal())
56  mooseError(
57  "MortarFrictionalPressureVector auxiliary kernel can only be used with nodal kernels.");
58 
60  paramError("use_displaced_mesh",
61  "This auxiliary kernel requires the use of displaced meshes to compute the "
62  "frictional pressure vector.");
63 
64  // Kernel need to be boundary restricted
65  if (!this->_bnd)
66  paramError("boundary",
67  "MortarFrictionalPressureVector auxiliary kernel must be restricted to a boundary.");
68 
69  // Get mortar interfaces
70  const auto & displaced_mortar_interfaces =
72 
73  if (displaced_mortar_interfaces.size() == 0)
74  paramError("tangent_one",
75  "No mortar interface could be identified in this problem. Make sure mortar contact "
76  "is enabled.");
77 
78  const auto mortar_dimension = _fe_problem.mesh().dimension() - 1;
79  if (mortar_dimension == 1)
80  paramError("tangent_two",
81  "MortarFrictionalPressureVector auxiliary kernel can only be used in "
82  "three-dimensional problems");
83 
84  // Get automatic generation object for the boundary pair this auxiliary acts on.
85  if (displaced_mortar_interfaces.count(std::make_pair(_primary_id, _secondary_id)) != 1)
86  mooseError("primary_boundary",
87  "The boundary pairs do not correspond to a single mortar contact boundary pair. "
88  "Please revise your input file for proper mortar contact constraints and mortar "
89  "frictional pressure vector auxiliary variable definition.");
90 
92  libmesh_map_find(displaced_mortar_interfaces, std::make_pair(_primary_id, _secondary_id))
93  .get();
94 }
95 
96 Real
98 {
99 
100  // A node id may correspond to more than one lower-d elements on the secondary surface.
101  // However, we are looping over nodes below, so we will locate the correct geometry
102  const Elem * lower_dimensional_element =
103  libmesh_map_find(_mortar_generation_object->nodesToSecondaryElem(), _current_node->id())[0];
104 
105  // Get nodal tangents for this element
106  const auto & nodal_tangents =
107  _mortar_generation_object->getNodalTangents(*lower_dimensional_element);
108 
109  Real tangent_one_component = 0;
110  Real tangent_two_component = 0;
111 
112  for (const auto lowerd_node : make_range(lower_dimensional_element->n_nodes()))
113  {
114  if (_current_node->id() == lower_dimensional_element->node_id(lowerd_node))
115  {
116  tangent_one_component = nodal_tangents[0][lowerd_node](_component);
117  tangent_two_component = nodal_tangents[1][lowerd_node](_component);
118  break;
119  }
120  }
121 
122  // Compute nodal tangent vector component
123  const Real tangent_vector_component =
124  tangent_one_component * (*_tangent_one)[_qp] + tangent_two_component * (*_tangent_two)[_qp];
125 
126  return tangent_vector_component;
127 }
const unsigned int _component
The component.
const bool _use_displaced_mesh
Whether to use displaced mesh (required for this auxiliary kernel)
void paramError(const std::string &param, Args... args) const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
registerMooseObject("ContactApp", MortarFrictionalPressureVectorAux)
const Node *const & _current_node
T & set(const std::string &name, bool quiet_mode=false)
MeshBase & mesh
const ExecFlagType EXEC_TIMESTEP_END
const BoundaryID _primary_id
Boundary ID for the primary surface.
void addRequiredParam(const std::string &name, const std::string &doc_string)
BoundaryID getBoundaryID(const BoundaryName &boundary_name, const MeshBase &mesh)
virtual unsigned int dimension() const
const std::unordered_map< std::pair< BoundaryID, BoundaryID >, std::unique_ptr< AutomaticMortarGeneration > > & getMortarInterfaces(bool on_displaced) const
MortarFrictionalPressureVectorAux(const InputParameters &parameters)
const BoundaryID _secondary_id
Boundary ID for the secondary surface.
std::array< MooseUtils::SemidynamicVector< Point, 9 >, 2 > getNodalTangents(const Elem &secondary_elem) const
const std::unordered_map< dof_id_type, std::vector< const Elem *> > & nodesToSecondaryElem() const
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
virtual MooseMesh & mesh() override
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
const FEProblemBase & _fe_problem
Fe problem to obtain primary/secondary ids.
void ErrorVector unsigned int
const Elem & get(const ElemType type_in)
const AutomaticMortarGeneration * _mortar_generation_object
Handle to mortar generation object to obtain mortar geometry.
Computes the frictional pressure vector for three-dimensional mortar mechanical contact.