https://mooseframework.inl.gov
PenaltyEqualValueConstraint.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 
14 
15 template <bool is_ad>
18 {
20  params.addClassDescription(
21  "PenaltyEqualValueConstraint enforces solution continuity between secondary and "
22  "primary sides of a mortar interface using a penalty approach (no Lagrange multipliers "
23  "needed)");
25  "penalty_value",
26  "penalty_value>0",
27  "Penalty value used to impose a generalized force capturing the mortar constraint equation");
28  return params;
29 }
30 
31 template <bool is_ad>
33  const InputParameters & parameters)
34  : MortarConstraintTempl<is_ad>(parameters),
35  _penalty_value(this->template getParam<Real>("penalty_value"))
36 {
37 }
38 
39 template <bool is_ad>
42 {
43  switch (mortar_type)
44  {
46  {
47  auto residual =
48  -(_u_primary[_qp] - _u_secondary[_qp]) * _penalty_value * _test_secondary[_i][_qp];
49 
50  return residual;
51  }
52 
54  {
55  auto residual =
56  (_u_primary[_qp] - _u_secondary[_qp]) * _penalty_value * _test_primary[_i][_qp];
57 
58  return residual;
59  }
60 
61  default:
62  return 0;
63  }
64 }
65 
66 template <>
67 ADReal
69  Moose::ConstraintJacobianType /*jacobian_type*/, unsigned int /*jvar*/)
70 {
71  mooseError("ADPenaltyEqualValueConstraint does not implement manual Jacobian calculation.");
72 }
73 
74 template <>
75 Real
77  Moose::ConstraintJacobianType jacobian_type, unsigned int jvar)
78 {
79  typedef Moose::ConstraintJacobianType JType;
80 
81  switch (jacobian_type)
82  {
84  if (jvar == _secondary_var.number())
85  return (*_phi)[_j][_qp] * _penalty_value * _test_secondary[_i][_qp];
86  break;
87 
89  if (jvar == _primary_var.number())
90  return -(*_phi)[_j][_qp] * _penalty_value * _test_secondary[_i][_qp];
91  break;
92 
94  if (jvar == _secondary_var.number())
95  return -(*_phi)[_j][_qp] * _penalty_value * _test_primary[_i][_qp];
96  break;
97 
99  if (jvar == _primary_var.number())
100  return (*_phi)[_j][_qp] * _penalty_value * _test_primary[_i][_qp];
101  break;
102 
103  default:
104  return 0;
105  }
106 
107  return 0;
108 }
109 
Moose::GenericType< Real, is_ad > GenericReal
Definition: MooseTypes.h:648
void addRequiredRangeCheckedParam(const std::string &name, const std::string &parsed_function, const std::string &doc_string)
These methods add an range checked parameters.
PenaltyEqualValueConstraintTempl(const InputParameters &parameters)
GenericReal< is_ad > computeQpResidual(Moose::MortarType mortar_type) final
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
MortarType
Definition: MooseTypes.h:770
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:47
InputParameters validParams()
registerMooseObject("MooseApp", PenaltyEqualValueConstraint)
Constrain the value of a variable to be the same on both sides of an interface using a generalized fo...
typename std::conditional< is_ad, ADMortarConstraint, MortarConstraint >::type MortarConstraintTempl
GenericReal< is_ad > computeQpJacobian(Moose::ConstraintJacobianType jacobian_type, unsigned int jvar)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
ConstraintJacobianType
Definition: MooseTypes.h:796
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...