https://mooseframework.inl.gov
Loading...
Searching...
No Matches
LMWeightedGapUserObject.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{
19 auto params = emptyInputParameters();
20 params.addRequiredCoupledVar(
21 "lm_variable", "The Lagrange multiplier variable representing the contact pressure.");
22 params.addParam<bool>(
23 "use_petrov_galerkin", false, "Whether to use the Petrov-Galerkin approach.");
24 params.addCoupledVar("aux_lm",
25 "Auxiliary Lagrange multiplier variable that is utilized together with the "
26 "Petrov-Galerkin approach.");
27 return params;
28}
29
32{
35 "Provides the mortar normal Lagrange multiplier for constraint enforcement.");
37 return params;
38}
39
41 : WeightedGapUserObject(parameters),
42 _lm_var(getVar("lm_variable", 0)),
43 _use_petrov_galerkin(getParam<bool>("use_petrov_galerkin")),
44 _aux_lm_var(isCoupled("aux_lm") ? getVar("aux_lm", 0) : nullptr)
45{
46 checkInput(_lm_var, "lm_variable");
47 verifyLagrange(*_lm_var, "lm_variable");
48
49 if (_use_petrov_galerkin && ((!isParamValid("aux_lm")) || _aux_lm_var == nullptr))
50 paramError("use_petrov_galerkin",
51 "We need to specify an auxiliary variable `aux_lm` while using the Petrov-Galerkin "
52 "approach");
53
55 paramError("aux_lm",
56 "Auxiliary LM variable needs to use standard shape function, i.e., set `use_dual = "
57 "false`.");
58}
59
60void
62 const std::string & var_param_name) const
63{
64 if (isCoupledConstant(var_param_name))
65 paramError(var_param_name,
66 "The Lagrange multiplier variable must be an actual variable and not a constant.");
67 else if (!var)
68 paramError(var_param_name,
69 "The Lagrange multiplier variables must be provided and be actual variables.");
70}
71
72void
74 const std::string & var_param_name) const
75{
76 if (var.feType().family != LAGRANGE)
77 paramError(var_param_name, "The Lagrange multiplier variables must be of Lagrange type");
78}
79
85
86const ADVariableValue &
91
92Real
94{
95 const auto sys_num = _lm_var->sys().number();
96 const auto var_num = _lm_var->number();
97 if (!node->n_dofs(sys_num, var_num))
98 mooseError("No degrees of freedom for the Lagrange multiplier at the node. If this is being "
99 "called from an aux kernel make sure that your aux variable has the same order as "
100 "your Lagrange multiplier");
101
102 const auto dof_number = node->dof_number(sys_num, var_num, /*component=*/0);
103 return (*_lm_var->sys().currentSolution())(dof_number);
104}
InputParameters emptyInputParameters()
registerMooseObject("ContactApp", LMWeightedGapUserObject)
virtual bool isCoupledConstant(const std::string &var_name) const
void addClassDescription(const std::string &doc_string)
User object for computing weighted gaps and contact pressure for Lagrange multipler based mortar cons...
LMWeightedGapUserObject(const InputParameters &parameters)
static InputParameters validParams()
const MooseVariable *const _aux_lm_var
The auxiliary Lagrange multiplier variable (used together whith the Petrov-Galerkin approach)
virtual const ADVariableValue & contactPressure() const override
const bool _use_petrov_galerkin
Whether to use Petrov-Galerkin approach.
void verifyLagrange(const MooseVariable &var, const std::string &var_name) const
Verify that the provided variables have degrees of freedom at nodes.
void checkInput(const MooseVariable *const var, const std::string &var_name) const
Check user input validity for provided variable.
virtual Real getNormalContactPressure(const Node *const) const override
virtual const VariableTestValue & test() const override
const MooseVariableFE< Real > *const _lm_var
The Lagrange multiplier variable representing the contact pressure.
static InputParameters newParams()
New parameters that this sub-class introduces.
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
const libMesh::FEType & feType() const
bool useDual() const
SystemBase & sys()
unsigned int number() const
const ADTemplateVariableValue< OutputType > & adSlnLower() const
virtual const FieldVariablePhiValue & phiLower() const override
virtual const NumericVector< Number > *const & currentSolution() const=0
unsigned int number() const
Creates dof object to weighted gap map.
static InputParameters validParams()
VariableShapeValue< true > VariableTestValue
VariableValueTempl< true > ADVariableValue