19defaultLuluFactor(
const unsigned int dim)
21 return 1.0 /
static_cast<Real
>(
dim);
24template <
bool is_ad,
typename Variable>
26secondSln(Variable & var)
29 return var.adSecondSln();
31 return var.secondSln();
35template <
typename SolutionSecond,
typename TestSecond>
37regularization(
const SolutionSecond & second_u,
38 const TestSecond & second_test,
40 const Real lulu_factor)
45 return second_u.contract(second_test);
47 return second_u.tr() * second_test.tr();
50 return second_u.contract(second_test) - lulu_factor * second_u.tr() * second_test.tr();
53 mooseError(
"Unknown second-derivative regularization type.");
62 params.
addClassDescription(
"Adds a second-derivative regularization term using HuHu, LuLu, "
63 "or HuHu-LuLu Hessian/Laplacian contractions.");
67 "Regularization type to apply: 'huhu' for Hessian-Hessian, 'lulu' for "
68 "Laplacian-Laplacian, or 'huhu_lulu' for HuHu minus a scaled LuLu correction.");
70 "coefficient",
"coefficient >= 0",
"Coefficient multiplying the regularization term.");
72 "Factor multiplying the LuLu correction for 'huhu_lulu'. If omitted, "
73 "defaults to 1 / dim, where dim is the mesh dimension.");
81 _regularization_type(this->template getParam<
MooseEnum>(
"regularization")
83 _coefficient(this->template getParam<Real>(
"coefficient")),
84 _dim(this->_mesh.dimension()),
85 _lulu_factor(this->isParamValid(
"lulu_factor") ? this->template getParam<Real>(
"lulu_factor")
86 : defaultLuluFactor(_dim)),
87 _second_u(secondSln<is_ad>(this->_var)),
88 _second_test(this->secondTest()),
89 _second_phi(this->_var.secondPhi())
93 this->
paramError(
"lulu_factor",
"Only used when 'regularization = huhu_lulu'.");
97 this->
mooseWarning(
"The 'lulu_factor' parameter is larger than 1 / dim. This may cause "
98 "negative strain energy contributions for the HuHu-LuLu regularization.");
105 return _coefficient *
106 regularization(_second_u[_qp], _second_test[_i][_qp], _regularization_type, _lulu_factor);
114 "In ADSecondDerivativeRegularization, computeQpJacobian should not be called. Check "
115 "computeJacobian implementation.");
116 return _coefficient *
118 _second_phi[_j][_qp], _second_test[_i][_qp], _regularization_type, _lulu_factor);
void mooseError(Args &&... args)
Moose::GenericType< VariableSecond, is_ad > GenericVariableSecond
Moose::GenericType< Real, is_ad > GenericReal
registerMooseObject("SolidMechanicsApp", SecondDerivativeRegularization)
SecondDerivativeRegularizationType
static InputParameters validParams()
void paramError(const std::string ¶m, Args... args) const
void mooseWarning(Args &&... args) const
bool isParamValid(const std::string &name) const
Adds regularization terms based on Hessian and Laplacian contractions of a scalar nonlinear variable.
SecondDerivativeRegularizationTempl(const InputParameters ¶meters)
static InputParameters validParams()
virtual Real computeQpJacobian() override
const unsigned int _dim
Mesh dimension used for the default LuLu factor.
virtual GenericReal< is_ad > computeQpResidual() override
const Real _lulu_factor
LuLu correction factor used only by HuHu-LuLu.
const SecondDerivativeRegularizationType _regularization_type
Selected regularization contraction.