https://mooseframework.inl.gov
PenaltyInterfaceDiffusion.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 
16 
17 template <typename T, bool is_ad>
20 {
22  params.addRequiredParam<Real>(
23  "penalty", "The penalty that penalizes jump between primary and neighbor variables.");
24  params.addParam<MaterialPropertyName>(
25  "jump_prop_name", "the name of the material property that calculates the jump.");
26  params.addClassDescription(
27  "A penalty-based interface condition that forces"
28  "the continuity of variables and the flux equivalence across an interface.");
29  return params;
30 }
31 
32 template <typename T, bool is_ad>
34  const InputParameters & parameters)
35  : GenericInterfaceKernelTempl<T, is_ad>(parameters),
36  _penalty(this->template getParam<Real>("penalty")),
37  _jump(isParamValid("jump_prop_name")
38  ? &this->template getGenericMaterialProperty<T, is_ad>("jump_prop_name")
39  : nullptr)
40 {
41 }
42 
43 template <typename T, bool is_ad>
46 {
47  GenericReal<is_ad> r = 0;
48 
49  Moose::GenericType<T, is_ad> jump_value = 0;
50 
51  if (_jump != nullptr)
52  jump_value = (*_jump)[_qp];
53  else
54  jump_value = _u[_qp] - _neighbor_value[_qp];
55 
56  switch (type)
57  {
58  case Moose::Element:
59  r = _test[_i][_qp] * _penalty * jump_value;
60  break;
61 
62  case Moose::Neighbor:
63  r = _test_neighbor[_i][_qp] * -_penalty * jump_value;
64  break;
65  }
66 
67  return r;
68 }
69 
70 template <typename T, bool is_ad>
71 Real
73 {
74  Real jac = 0;
75 
76  switch (type)
77  {
79  jac = _test[_i][_qp] * _penalty * _phi[_j][_qp];
80  break;
81 
83  jac = _test[_i][_qp] * _penalty * -_phi_neighbor[_j][_qp];
84  break;
85 
87  jac = _test_neighbor[_i][_qp] * -_penalty * _phi[_j][_qp];
88  break;
89 
91  jac = _test_neighbor[_i][_qp] * -_penalty * -_phi_neighbor[_j][_qp];
92  break;
93  }
94 
95  return jac;
96 }
97 
GenericReal< is_ad > computeQpResidual(Moose::DGResidualType type) override
Compute residuals at quadrature points.
Moose::GenericType< Real, is_ad > GenericReal
Definition: MooseTypes.h:648
Real computeQpJacobian(Moose::DGJacobianType type) override
Compute jacobians at quadrature points.
Interface kernel for interfacing diffusion between two variables on adjacent blocks.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
DGResidualType
Definition: MooseTypes.h:743
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
typename std::conditional< is_ad, typename ADType< T >::type, T >::type GenericType
Definition: MooseTypes.h:644
static InputParameters validParams()
DGJacobianType
Definition: MooseTypes.h:749
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
PenaltyInterfaceDiffusionTempl(const InputParameters &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...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
registerMooseObject("MooseApp", PenaltyInterfaceDiffusion)