Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
ArrayDGDiffusion.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 "ArrayDGDiffusion.h"
11 
12 // MOOSE includes
13 #include "MooseVariableFE.h"
14 
15 #include "libmesh/utility.h"
16 
18 
21 {
23  params.addRequiredParam<MaterialPropertyName>(
24  "diff", "The diffusion (or thermal conductivity or viscosity) coefficient.");
25  params.addParam<Real>("sigma", 4, "sigma");
26  params.addParam<Real>("epsilon", 1, "epsilon");
27  params.addClassDescription("Implements interior penalty method for array diffusion equations.");
28  return params;
29 }
30 
32  : ArrayDGKernel(parameters),
33  _epsilon(getParam<Real>("epsilon")),
34  _sigma(getParam<Real>("sigma")),
35  _diff(getMaterialProperty<RealEigenVector>("diff")),
36  _diff_neighbor(getNeighborMaterialProperty<RealEigenVector>("diff")),
37  _res1(_count),
38  _res2(_count)
39 {
40 }
41 
42 void
44 {
45  mooseAssert(_diff[_qp].size() == _count && _diff_neighbor[_qp].size() == _count,
46  "'diff' size is inconsistent with the number of components of array "
47  "variable");
48 
49  const int elem_b_order = std::max(libMesh::Order(1), _var.order());
50  const Real h_elem =
52 
53  // WARNING: use noalias() syntax with caution. See ArrayDiffusion.C for more details.
54  _res1.noalias() = _diff[_qp].asDiagonal() * _grad_u[_qp] * _array_normals[_qp];
55  _res1.noalias() += _diff_neighbor[_qp].asDiagonal() * _grad_u_neighbor[_qp] * _array_normals[_qp];
56  _res1 *= 0.5;
57  _res1 -= (_u[_qp] - _u_neighbor[_qp]) * _sigma / h_elem;
58 
59  switch (type)
60  {
61  case Moose::Element:
62  _res2.noalias() = _diff[_qp].asDiagonal() * (_u[_qp] - _u_neighbor[_qp]) * _epsilon * 0.5;
63  break;
64 
65  case Moose::Neighbor:
66  _res2.noalias() =
67  _diff_neighbor[_qp].asDiagonal() * (_u[_qp] - _u_neighbor[_qp]) * _epsilon * 0.5;
68  break;
69  }
70 }
71 
72 void
74 {
75  switch (type)
76  {
77  case Moose::Element:
78  residual = -_res1 * _test[_i][_qp] + _res2 * (_grad_test[_i][_qp] * _normals[_qp]);
79  break;
80 
81  case Moose::Neighbor:
82  residual =
84  break;
85  }
86 }
87 
90 {
91  RealEigenVector r = RealEigenVector::Zero(_count);
92 
93  const int elem_b_order = std::max(libMesh::Order(1), _var.order());
94  const Real h_elem =
96 
97  switch (type)
98  {
100  r -= _grad_phi[_j][_qp] * _normals[_qp] * _test[_i][_qp] * 0.5 * _diff[_qp];
101  r += _grad_test[_i][_qp] * _normals[_qp] * _epsilon * 0.5 * _phi[_j][_qp] * _diff[_qp];
102  r += RealEigenVector::Constant(_count, _sigma / h_elem * _phi[_j][_qp] * _test[_i][_qp]);
103  break;
104 
107  r -= _grad_test[_i][_qp] * _normals[_qp] * _epsilon * 0.5 * _phi_neighbor[_j][_qp] *
108  _diff[_qp];
109  r -= RealEigenVector::Constant(_count,
110  _sigma / h_elem * _phi_neighbor[_j][_qp] * _test[_i][_qp]);
111  break;
112 
114  r += _grad_phi[_j][_qp] * _normals[_qp] * _test_neighbor[_i][_qp] * 0.5 * _diff[_qp];
115  r += _grad_test_neighbor[_i][_qp] * _normals[_qp] * _epsilon * 0.5 * _phi[_j][_qp] *
117  r -= RealEigenVector::Constant(_count,
118  _sigma / h_elem * _phi[_j][_qp] * _test_neighbor[_i][_qp]);
119  break;
120 
122  r += _grad_phi_neighbor[_j][_qp] * _normals[_qp] * _test_neighbor[_i][_qp] * 0.5 *
126  r += RealEigenVector::Constant(
127  _count, _sigma / h_elem * _phi_neighbor[_j][_qp] * _test_neighbor[_i][_qp]);
128  break;
129  }
130 
131  return r;
132 }
const ArrayVariablePhiGradient & _grad_phi_neighbor
Gradient of side shape function.
registerMooseObject("MooseApp", ArrayDGDiffusion)
const std::vector< Eigen::Map< RealDIMValue > > & _array_normals
Normals in type of Eigen map.
const ArrayVariableGradient & _grad_u_neighbor
Holds the current solution gradient at the current quadrature point.
virtual RealEigenVector computeQpJacobian(Moose::DGJacobianType type) override
This is the virtual that derived classes should override for computing the Jacobian on neighboring el...
const Real & _current_side_volume
The volume (or length) of the current side.
Definition: DGKernelBase.h:100
const ArrayVariableValue & _u
Holds the current solution at the current quadrature point on the face.
Definition: ArrayDGKernel.h:98
const MaterialProperty< RealEigenVector > & _diff_neighbor
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const ArrayVariableTestGradient & _grad_test_neighbor
Gradient of side shape function.
ArrayDGDiffusion(const InputParameters &parameters)
unsigned int _i
Definition: DGKernelBase.h:136
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...
auto max(const L &left, const R &right)
virtual void initQpResidual(Moose::DGResidualType type) override
Put necessary evaluations depending on qp but independent on test functions here. ...
static InputParameters validParams()
Factory constructor initializes all internal references needed for residual computation.
Definition: ArrayDGKernel.C:27
const ArrayVariableTestValue & _test
test functions
RealEigenVector _res2
unsigned int _qp
Definition: DGKernelBase.h:134
Array version of DGDiffusion.
const unsigned int _count
Number of components of the array variable.
unsigned int _j
Definition: DGKernelBase.h:136
const ArrayVariableTestGradient & _grad_test
Gradient of side shape function.
static InputParameters validParams()
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:51
const MooseArray< Point > & _normals
Normal vectors at the quadrature points.
Definition: DGKernelBase.h:113
The DGKernel class is responsible for calculating the residuals for various physics on internal sides...
Definition: ArrayDGKernel.h:20
virtual void computeQpResidual(Moose::DGResidualType type, RealEigenVector &residual) override
This is the virtual that derived classes should override for computing the residual on neighboring el...
libMesh::Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int...
DGJacobianType
Definition: MooseTypes.h:749
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
RealEigenVector _res1
const ArrayVariableGradient & _grad_u
Holds the current solution gradient at the current quadrature point on the face.
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...
const ArrayVariablePhiValue & _phi_neighbor
Side shape function.
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...
Eigen::Matrix< Real, Eigen::Dynamic, 1 > RealEigenVector
Definition: MooseTypes.h:146
const ArrayVariableTestValue & _test_neighbor
Side test function.
const ArrayVariableValue & _u_neighbor
Holds the current solution at the current quadrature point.
const Real & _current_elem_volume
The volume (or length) of the current element.
Definition: DGKernelBase.h:87
ArrayMooseVariable & _var
Variable this kernel operates on.
Definition: ArrayDGKernel.h:96
const MaterialProperty< RealEigenVector > & _diff
const ArrayVariablePhiValue & _phi
Shape functions.
const ArrayVariablePhiGradient & _grad_phi
Gradient of shape function.
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template pow< 2 >(tan(_arg))+1.0) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(sqrt