https://mooseframework.inl.gov
Loading...
Searching...
No Matches
DGDiffusion.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 "DGDiffusion.h"
11#include "MooseVariableFE.h"
12
13#include "libmesh/utility.h"
14
16
19{
21 params.addClassDescription("Computes residual contribution for the diffusion operator using "
22 "discontinous Galerkin method.");
23 // See header file for sigma and epsilon
24 params.addRequiredParam<Real>("sigma", "sigma");
25 params.addRequiredParam<Real>("epsilon", "epsilon");
26 params.addParam<MaterialPropertyName>(
27 "diff", 1., "The diffusion (or thermal conductivity or viscosity) coefficient.");
28 return params;
29}
30
32 : DGKernel(parameters),
33 _epsilon(getParam<Real>("epsilon")),
34 _sigma(getParam<Real>("sigma")),
35 _diff(getMaterialProperty<Real>("diff")),
36 _diff_neighbor(getNeighborMaterialProperty<Real>("diff"))
37{
38}
39
40Real
42{
43 Real r = 0.0;
44
45 const int elem_b_order = std::max(libMesh::Order(1), _var.order());
46 const Real h_elem =
47 _current_elem_volume / _current_side_volume * 1.0 / Utility::pow<2>(elem_b_order);
48
49 switch (type)
50 {
51 case Moose::Element:
52 r -= 0.5 *
55 _test[_i][_qp];
56 r += _epsilon * 0.5 * (_u[_qp] - _u_neighbor[_qp]) * _diff[_qp] * _grad_test[_i][_qp] *
58 r += _sigma / h_elem * (_u[_qp] - _u_neighbor[_qp]) * _test[_i][_qp];
59 break;
60
61 case Moose::Neighbor:
62 r += 0.5 *
66 r += _epsilon * 0.5 * (_u[_qp] - _u_neighbor[_qp]) * _diff_neighbor[_qp] *
68 r -= _sigma / h_elem * (_u[_qp] - _u_neighbor[_qp]) * _test_neighbor[_i][_qp];
69 break;
70 }
71
72 return r;
73}
74
75Real
77{
78 Real r = 0.0;
79
80 const int elem_b_order = std::max(libMesh::Order(1), _var.order());
81 const Real h_elem =
82 _current_elem_volume / _current_side_volume * 1.0 / Utility::pow<2>(elem_b_order);
83
84 switch (type)
85 {
87 r -= 0.5 * _diff[_qp] * _grad_phi[_j][_qp] * _normals[_qp] * _test[_i][_qp];
88 r += _epsilon * 0.5 * _phi[_j][_qp] * _diff[_qp] * _grad_test[_i][_qp] * _normals[_qp];
89 r += _sigma / h_elem * _phi[_j][_qp] * _test[_i][_qp];
90 break;
91
94 r += _epsilon * 0.5 * -_phi_neighbor[_j][_qp] * _diff[_qp] * _grad_test[_i][_qp] *
96 r += _sigma / h_elem * -_phi_neighbor[_j][_qp] * _test[_i][_qp];
97 break;
98
100 r += 0.5 * _diff[_qp] * _grad_phi[_j][_qp] * _normals[_qp] * _test_neighbor[_i][_qp];
102 _normals[_qp];
103 r -= _sigma / h_elem * _phi[_j][_qp] * _test_neighbor[_i][_qp];
104 break;
105
109 r += _epsilon * 0.5 * -_phi_neighbor[_j][_qp] * _diff_neighbor[_qp] *
111 r -= _sigma / h_elem * -_phi_neighbor[_j][_qp] * _test_neighbor[_i][_qp];
112 break;
113 }
114
115 return r;
116}
registerMooseObject("MooseApp", DGDiffusion)
DG kernel for diffusion.
Definition DGDiffusion.h:25
DGDiffusion(const InputParameters &parameters)
Definition DGDiffusion.C:31
const MaterialProperty< Real > & _diff_neighbor
Definition DGDiffusion.h:38
const MaterialProperty< Real > & _diff
Definition DGDiffusion.h:37
virtual Real computeQpResidual(Moose::DGResidualType type) override
This is the virtual that derived classes should override for computing the residual on neighboring el...
Definition DGDiffusion.C:41
static InputParameters validParams()
Definition DGDiffusion.C:18
virtual Real computeQpJacobian(Moose::DGJacobianType type) override
This is the virtual that derived classes should override for computing the Jacobian on neighboring el...
Definition DGDiffusion.C:76
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 DGKernel class is responsible for calculating the residuals for various physics on internal sides...
Definition DGKernel.h:19
const VariableTestGradient & _grad_test
Gradient of side shape function.
Definition DGKernel.h:104
const VariableTestValue & _test_neighbor
Side test function.
Definition DGKernel.h:110
const VariableGradient & _grad_u
Holds the current solution gradient at the current quadrature point on the face.
Definition DGKernel.h:96
const VariableValue & _u
Holds the current solution at the current quadrature point on the face.
Definition DGKernel.h:94
static InputParameters validParams()
Factory constructor initializes all internal references needed for residual computation.
Definition DGKernel.C:27
const VariableValue & _u_neighbor
Holds the current solution at the current quadrature point.
Definition DGKernel.h:114
const VariablePhiValue & _phi_neighbor
Side shape function.
Definition DGKernel.h:106
const VariableTestGradient & _grad_test_neighbor
Gradient of side shape function.
Definition DGKernel.h:112
const VariablePhiGradient & _grad_phi_neighbor
Gradient of side shape function.
Definition DGKernel.h:108
const VariableTestValue & _test
test functions
Definition DGKernel.h:102
const VariableGradient & _grad_u_neighbor
Holds the current solution gradient at the current quadrature point.
Definition DGKernel.h:116
const VariablePhiGradient & _grad_phi
Gradient of shape function.
Definition DGKernel.h:100
MooseVariable & _var
Variable this kernel operates on.
Definition DGKernel.h:92
const VariablePhiValue & _phi
Shape functions.
Definition DGKernel.h:98
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