https://mooseframework.inl.gov
LMDiffusion.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 
10 #include "LMDiffusion.h"
11 
12 registerMooseObject("ScalarTransportApp", LMDiffusion);
13 
16 {
18  params.addRequiredCoupledVar("primal_variable",
19  "The coupled primal variable from which to pull the Laplacian");
20  params.addParam<bool>(
21  "lm_sign_positive",
22  true,
23  "Whether to use a positive sign when adding this object's residual to the Lagrange "
24  "multiplier constraint equation. Positive or negative sign should be chosen such that the "
25  "diagonals for the LM block of the matrix are positive");
26  params.addParam<Real>("diffusivity", 1, "The value of the diffusivity");
27  params.addClassDescription(
28  "Adds a diffusion term to a Lagrange multiplier constrained primal equation");
29  return params;
30 }
31 
33  : Kernel(parameters),
34  _primal_var(coupled("primal_variable")),
35  _second_primal(coupledSecond("primal_variable")),
36  _second_primal_phi(getVar("primal_variable", 0)->secondPhi()),
37  _lm_sign(getParam<bool>("lm_sign_positive") ? 1. : -1),
38  _diffusivity(getParam<Real>("diffusivity"))
39 {
40  if (_var.number() == _primal_var)
41  paramError(
42  "primal_variable",
43  "Coupled variable 'primal_variable' needs to be different from 'variable' with "
44  "LMDiffusion. It is expected in general that 'variable' should be a Lagrange multiplier "
45  "variable, and that 'primal_variable' be the primal variable on which the Lagrange "
46  "multiplier is acting");
47 }
48 
49 Real
51 {
52  return _lm_sign * _test[_i][_qp] * -_diffusivity * _second_primal[_qp].tr();
53 }
54 
55 Real
57 {
58  return 0;
59 }
60 
61 Real
63 {
64  if (jvar == _primal_var)
65  return _lm_sign * _test[_i][_qp] * -_diffusivity * _second_primal_phi[_j][_qp].tr();
66 
67  return 0;
68 }
Real computeQpResidual() override
Definition: LMDiffusion.C:50
const Real _lm_sign
The sign of the Lagrange multiplier (the &#39;variable&#39; of this kernel) in the primal equation...
Definition: LMDiffusion.h:41
static InputParameters validParams()
MooseVariable & _var
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
unsigned int number() const
registerMooseObject("ScalarTransportApp", LMDiffusion)
Adds the strong diffusive term of the primal equation to stabilization of the Lagrange multiplier equ...
Definition: LMDiffusion.h:18
const VariableSecond & _second_primal
The matrix of second spatial derivatives of the primal variable.
Definition: LMDiffusion.h:35
const VariableTestValue & _test
unsigned int _i
void paramError(const std::string &param, Args... args) const
Real computeQpOffDiagJacobian(unsigned int jvar) override
Definition: LMDiffusion.C:62
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
unsigned int _j
const VariablePhiSecond & _second_primal_phi
The matrix of second spatial derivatives of the basis functions of the primal variable.
Definition: LMDiffusion.h:38
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real computeQpJacobian() override
Definition: LMDiffusion.C:56
LMDiffusion(const InputParameters &parameters)
Definition: LMDiffusion.C:32
void addClassDescription(const std::string &doc_string)
const unsigned int _primal_var
The primal variable number.
Definition: LMDiffusion.h:32
static InputParameters validParams()
Definition: LMDiffusion.C:15
unsigned int _qp
const Real _diffusivity
The primal variable diffusivity.
Definition: LMDiffusion.h:44