https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
15template <bool is_ad>
18{
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
31template <bool is_ad>
33 const InputParameters & parameters)
34 : MortarConstraintTempl<is_ad>(parameters),
35 _penalty_value(this->template getParam<Real>("penalty_value"))
36{
37}
38
39template <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
66template <>
69 Moose::ConstraintJacobianType /*jacobian_type*/, unsigned int /*jvar*/)
70{
71 mooseError("ADPenaltyEqualValueConstraint does not implement manual Jacobian calculation.");
72}
73
74template <>
75Real
77 Moose::ConstraintJacobianType jacobian_type, unsigned int jvar)
78{
80
81 switch (jacobian_type)
82 {
83 case JType::SecondarySecondary:
84 if (jvar == _secondary_var.number())
85 return (*_phi)[_j][_qp] * _penalty_value * _test_secondary[_i][_qp];
86 break;
87
88 case JType::SecondaryPrimary:
89 if (jvar == _primary_var.number())
90 return -(*_phi)[_j][_qp] * _penalty_value * _test_secondary[_i][_qp];
91 break;
92
93 case JType::PrimarySecondary:
94 if (jvar == _secondary_var.number())
95 return -(*_phi)[_j][_qp] * _penalty_value * _test_primary[_i][_qp];
96 break;
97
98 case JType::PrimaryPrimary:
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
DualNumber< Real, DNDerivativeType, true > ADReal
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
Moose::GenericType< Real, is_ad > GenericReal
Definition MooseTypes.h:698
registerMooseObject("MooseApp", PenaltyEqualValueConstraint)
typename std::conditional< is_ad, ADMortarConstraint, MortarConstraint >::type MortarConstraintTempl
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addRequiredRangeCheckedParam(const std::string &name, const std::string &parsed_function, const std::string &doc_string)
These methods add an range checked parameters.
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.
Constrain the value of a variable to be the same on both sides of an interface using a generalized fo...
GenericReal< is_ad > computeQpResidual(Moose::MortarType mortar_type) final
PenaltyEqualValueConstraintTempl(const InputParameters &parameters)
GenericReal< is_ad > computeQpJacobian(Moose::ConstraintJacobianType jacobian_type, unsigned int jvar)
ConstraintJacobianType
Definition MooseTypes.h:851