https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
42void
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 =
51 _current_elem_volume / _current_side_volume * 1.0 / Utility::pow<2>(elem_b_order);
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
72void
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
88RealEigenVector
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 =
95 _current_elem_volume / _current_side_volume * 1.0 / Utility::pow<2>(elem_b_order);
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
126 r += RealEigenVector::Constant(
128 break;
129 }
130
131 return r;
132}
registerMooseObject("MooseApp", ArrayDGDiffusion)
Array version of DGDiffusion.
virtual void initQpResidual(Moose::DGResidualType type) override
Put necessary evaluations depending on qp but independent on test functions here.
const MaterialProperty< RealEigenVector > & _diff_neighbor
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...
RealEigenVector _res2
static InputParameters validParams()
const MaterialProperty< RealEigenVector > & _diff
RealEigenVector _res1
virtual RealEigenVector computeQpJacobian(Moose::DGJacobianType type) override
This is the virtual that derived classes should override for computing the Jacobian on neighboring el...
ArrayDGDiffusion(const InputParameters &parameters)
The DGKernel class is responsible for calculating the residuals for various physics on internal sides...
const ArrayVariableTestGradient & _grad_test_neighbor
Gradient of side shape function.
const std::vector< Eigen::Map< RealDIMValue > > & _array_normals
Normals in type of Eigen map.
const ArrayVariablePhiValue & _phi_neighbor
Side shape function.
const ArrayVariableValue & _u
Holds the current solution at the current quadrature point on the face.
const ArrayVariableGradient & _grad_u
Holds the current solution gradient at the current quadrature point on the face.
ArrayMooseVariable & _var
Variable this kernel operates on.
const ArrayVariableTestValue & _test
test functions
const ArrayVariableTestValue & _test_neighbor
Side test function.
const ArrayVariablePhiValue & _phi
Shape functions.
const ArrayVariablePhiGradient & _grad_phi_neighbor
Gradient of side shape function.
const ArrayVariablePhiGradient & _grad_phi
Gradient of shape function.
const ArrayVariableGradient & _grad_u_neighbor
Holds the current solution gradient at the current quadrature point.
const unsigned int _count
Number of components of the array variable.
const ArrayVariableValue & _u_neighbor
Holds the current solution at the current quadrature point.
const ArrayVariableTestGradient & _grad_test
Gradient of side shape function.
static InputParameters validParams()
Factory constructor initializes all internal references needed for residual computation.
unsigned int _i
unsigned int _qp
const Real & _current_elem_volume
The volume (or length) of the current element.
unsigned int _j
const Real & _current_side_volume
The volume (or length) of the current side.
const MooseArray< Point > & _normals
Normal vectors at the quadrature points.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
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...
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 std::string & type() const
Get the type of this class.
Definition MooseBase.h:93
libMesh::Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int.
DGResidualType
Definition MooseTypes.h:798
@ Element
Definition MooseTypes.h:799
@ Neighbor
Definition MooseTypes.h:800
DGJacobianType
Definition MooseTypes.h:804
@ NeighborNeighbor
Definition MooseTypes.h:808
@ ElementElement
Definition MooseTypes.h:805
@ NeighborElement
Definition MooseTypes.h:807
@ ElementNeighbor
Definition MooseTypes.h:806