https://mooseframework.inl.gov
LMWeightedVelocitiesUserObject.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 "MooseVariableFE.h"
12 #include "SystemBase.h"
13 
15 
18 {
20  params.addClassDescription("Provides the mortar contact Lagrange multipliers (normal and "
21  "tangential) for constraint enforcement.");
22  params.addRequiredCoupledVar(
23  "lm_variable_normal",
24  "The Lagrange multiplier variable representing the normal contact pressure value.");
25  params.addRequiredCoupledVar(
26  "lm_variable_tangential_one",
27  "The Lagrange multiplier variable representing the tangential contact pressure along the "
28  "first tangential direction (the only one in two dimensions).");
29  params.addCoupledVar("lm_variable_tangential_two",
30  "The Lagrange multiplier variable representing the tangential contact "
31  "pressure along the second tangential direction.");
32  params.addParam<bool>(
33  "use_petrov_galerkin", false, "Whether to use the Petrov-Galerkin approach.");
34  params.addCoupledVar("aux_lm",
35  "Auxiliary Lagrange multiplier variable that is utilized together with the "
36  "Petrov-Galerkin approach.");
37  return params;
38 }
39 
41  : WeightedGapUserObject(parameters),
42  WeightedVelocitiesUserObject(parameters),
43  _lm_normal_var(getVar("lm_variable_normal", 0)),
44  _lm_variable_tangential_one(getVar("lm_variable_tangential_one", 0)),
45  _lm_variable_tangential_two(isParamValid("lm_variable_tangential_two")
46  ? getVar("lm_variable_tangential_two", 0)
47  : nullptr),
48  _use_petrov_galerkin(getParam<bool>("use_petrov_galerkin")),
49  _aux_lm_var(isCoupled("aux_lm") ? getVar("aux_lm", 0) : nullptr)
50 {
51  // Check that user inputted a variable
52  auto check_input = [this](const auto var, const auto & var_name)
53  {
54  if (isCoupledConstant(var_name))
55  paramError("lm_variable_normal",
56  "The Lagrange multiplier variable must be an actual variable and not a constant.");
57  else if (!var)
58  paramError(var_name,
59  "The Lagrange multiplier variables must be provided and be actual variables.");
60  };
61 
62  check_input(_lm_normal_var, "lm_variable_normal");
63  check_input(_lm_variable_tangential_one, "lm_variable_tangential_one");
65  check_input(_lm_variable_tangential_two, "lm_variable_tangential_two");
66 
67  // Check that user inputted the right type of variable
68  auto check_type = [this](const auto & var, const auto & var_name)
69  {
70  if (!var.isNodal())
71  paramError(var_name,
72  "The Lagrange multiplier variables must have degrees of freedom exclusively on "
73  "nodes, e.g. they should probably be of finite element type 'Lagrange'.");
74  };
75 
76  check_type(*_lm_normal_var, "lm_variable_normal");
77  check_type(*_lm_variable_tangential_one, "lm_variable_tangential_one");
79  check_type(*_lm_variable_tangential_two, "lm_variable_tangential_two");
80 
81  if (_use_petrov_galerkin && ((!isParamValid("aux_lm")) || _aux_lm_var == nullptr))
82  paramError("use_petrov_galerkin",
83  "We need to specify an auxiliary variable `aux_lm` while using the Petrov-Galerkin "
84  "approach");
85 
87  paramError("aux_lm",
88  "Auxiliary LM variable needs to use standard shape function, i.e., set `use_dual = "
89  "false`.");
90 }
91 
92 const ADVariableValue &
94 {
96 }
97 
98 const ADVariableValue &
100 {
102 }
103 
104 const ADVariableValue &
106 {
107  return _lm_normal_var->adSlnLower();
108 }
109 
110 const VariableTestValue &
112 {
114 }
virtual bool isCoupledConstant(const std::string &var_name) const
LMWeightedVelocitiesUserObject(const InputParameters &parameters)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const bool _use_petrov_galerkin
Whether to use Petrov-Galerkin approach.
Creates dof object to weighted tangential velocities map.
virtual const VariableTestValue & test() const override
virtual const ADVariableValue & contactPressure() const override
bool isParamValid(const std::string &name) const
const MooseVariable *const _aux_lm_var
The auxiliary Lagrange multiplier variable (used together whith the Petrov-Galerkin approach) ...
const MooseVariableFE< Real > *const _lm_normal_var
The Lagrange multiplier variables representing the contact pressure along various directions...
Nodal-based mortar contact user object for frictional problem.
OutputTools< Real >::VariableTestValue VariableTestValue
void paramError(const std::string &param, Args... args) const
void addCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
Creates dof object to weighted gap map.
const MooseVariableFE< Real > *const _lm_variable_tangential_one
virtual const ADVariableValue & contactTangentialPressureDirOne() const override
const MooseVariableFE< Real > *const _lm_variable_tangential_two
virtual const FieldVariablePhiValue & phiLower() const override
void addClassDescription(const std::string &doc_string)
const ADTemplateVariableValue< Real > & adSlnLower() const
registerMooseObject("ContactApp", LMWeightedVelocitiesUserObject)
virtual const ADVariableValue & contactTangentialPressureDirTwo() const override