https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MortarContactForce.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
10#include "MortarContactForce.h"
13#include "FEProblemBase.h"
14#include "DisplacedProblem.h"
15#include "MooseMesh.h"
16
17#include "libmesh/parallel_algebra.h"
18
20
23{
25 params.addClassDescription("Normal contact force that one mortar contact pair transmits to its "
26 "secondary surface.");
27 params.addRequiredParam<UserObjectName>(
28 "weighted_gap_uo",
29 "The weighted gap user object of the contact pair. The Contact action names it "
30 "lm_weightedgap_object_<block name> (mortar) or penalty_weightedgap_object_<block name> "
31 "(mortar_penalty), with the suffix _p_<primary>_s_<secondary> when the block has several "
32 "pairs.");
33 MooseEnum component("x y z magnitude", "magnitude");
34 params.addParam<MooseEnum>(
35 "component", component, "The force component to report, or its magnitude.");
36 return params;
37}
38
40 : GeneralPostprocessor(parameters),
41 _weighted_gap_uo(getUserObject<WeightedGapUserObject>("weighted_gap_uo")),
42 _component(getParam<MooseEnum>("component")),
43 _displaced_mesh(_fe_problem.getDisplacedProblem()->mesh()),
44 _amg(_fe_problem.getMortarInterface(
46 _weighted_gap_uo.parameters().get<BoundaryName>("primary_boundary")),
48 _weighted_gap_uo.parameters().get<BoundaryName>("secondary_boundary"))},
49 {_weighted_gap_uo.primarySubdomain(), _weighted_gap_uo.secondarySubdomain()},
50 /*on_displaced=*/true)),
51 _node_to_elems(_amg.nodesToSecondaryElem())
52{
53}
54
55void
60
61void
63{
64 // F = sum_j p_j n_j int N_j, with the normalization int N_j over the mortar segments (a dual
65 // basis function has the same integral as N_j)
66 for (const auto & [dof_object, gap_and_normalization] : _weighted_gap_uo.dofToWeightedGap())
67 {
68 if (dof_object->processor_id() != processor_id())
69 continue;
70 const Node * const node = _displaced_mesh.nodePtr(dof_object->id());
71 const Elem & elem = *libmesh_map_find(_node_to_elems, node->id()).front();
72 const auto normal = _amg.getNodalNormals(elem)[elem.get_node_index(node)];
73 const auto weighted_pressure =
74 _weighted_gap_uo.getNormalContactPressure(node) * gap_and_normalization.second;
75 if (_component < 3)
76 _force(_component) += weighted_pressure * normal(_component);
77 else
78 _force += weighted_pressure * normal;
79 }
80}
81
82void
90
93{
94 return _component == 3 ? _force.norm() : _force(_component);
95}
Real PostprocessorValue
registerMooseObject("ContactApp", MortarContactForce)
std::vector< Point > getNodalNormals(const Elem &secondary_elem) const
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
void addClassDescription(const std::string &doc_string)
const InputParameters & parameters() const
BoundaryID getBoundaryID(const BoundaryName &boundary_name) const
virtual const Node * nodePtr(const dof_id_type i) const
Normal contact force of one mortar contact pair, from its weighted gap user object.
virtual PostprocessorValue getValue() const override
const WeightedGapUserObject & _weighted_gap_uo
Weighted gap user object of the pair.
static InputParameters validParams()
virtual void finalize() override
MortarContactForce(const InputParameters &parameters)
virtual void initialize() override
const MooseMesh & _displaced_mesh
Displaced mesh, on which the pair's mortar interface lives.
const unsigned int _component
Component to report (0, 1, 2), or 3 for the magnitude.
const AutomaticMortarGeneration & _amg
Mortar interface of the pair, which holds the nodal normals.
RealVectorValue _force
Contact force.
const std::unordered_map< dof_id_type, std::vector< const Elem * > > & _node_to_elems
Map from a secondary node to its lower-dimensional secondary elements.
virtual void execute() override
void gatherSum(T &value)
Creates dof object to weighted gap map.
const std::unordered_map< const DofObject *, std::pair< ADReal, Real > > & dofToWeightedGap() const
Get the degree of freedom to weighted gap information.
virtual Real getNormalContactPressure(const Node *const) const =0
processor_id_type processor_id() const
MeshBase & mesh