https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ADDGDiffusion.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 "ADDGDiffusion.h"
11
12// MOOSE includes
13#include "MooseVariableFE.h"
14
15#include "libmesh/utility.h"
16
18
21{
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 params.addClassDescription("DG kernel for diffusion operator");
29 return params;
30}
31
33 : ADDGKernel(parameters),
34 _epsilon(getParam<Real>("epsilon")),
35 _sigma(getParam<Real>("sigma")),
36 _diff(getADMaterialProperty<Real>("diff")),
37 _diff_neighbor(getNeighborADMaterialProperty<Real>("diff"))
38{
39}
40
43{
44 ADReal r = 0.0;
45
46 const int elem_b_order = std::max(libMesh::Order(1), _var.order());
47 const Real h_elem =
48 _current_elem_volume / _current_side_volume * 1.0 / Utility::pow<2>(elem_b_order);
49
50 switch (type)
51 {
52 case Moose::Element:
53 r -= 0.5 *
56 _test[_i][_qp];
57 r += _epsilon * 0.5 * (_u[_qp] - _u_neighbor[_qp]) * _diff[_qp] * _grad_test[_i][_qp] *
59 r += _sigma / h_elem * (_u[_qp] - _u_neighbor[_qp]) * _test[_i][_qp];
60 break;
61
62 case Moose::Neighbor:
63 r += 0.5 *
67 r += _epsilon * 0.5 * (_u[_qp] - _u_neighbor[_qp]) * _diff_neighbor[_qp] *
69 r -= _sigma / h_elem * (_u[_qp] - _u_neighbor[_qp]) * _test_neighbor[_i][_qp];
70 break;
71 }
72
73 return r;
74}
registerMooseObject("MooseApp", ADDGDiffusion)
DualNumber< Real, DNDerivativeType, true > ADReal
DG kernel for diffusion.
const ADMaterialProperty< Real > & _diff_neighbor
virtual ADReal computeQpResidual(Moose::DGResidualType type) override
Compute this Kernel's contribution to the residual at the current quadrature point.
ADDGDiffusion(const InputParameters &parameters)
static InputParameters validParams()
const ADMaterialProperty< Real > & _diff
MooseVariable & _var
Variable this kernel operates on.
Definition ADDGKernel.h:36
const VariableTestValue & _test_neighbor
Side test function.
Definition ADDGKernel.h:50
const ADVariableGradient & _grad_u_neighbor
Holds the current solution gradient at the current quadrature point.
Definition ADDGKernel.h:64
const ADVariableGradient & _grad_u
Holds the solution gradient at the current quadrature points.
Definition ADDGKernel.h:58
static InputParameters validParams()
Definition ADDGKernel.C:22
const VariableTestGradient & _grad_test_neighbor
Gradient of side shape function.
Definition ADDGKernel.h:52
const VariableTestValue & _test
test functions
Definition ADDGKernel.h:42
const ADVariableValue & _u
Holds the solution at current quadrature points.
Definition ADDGKernel.h:55
const VariableTestGradient & _grad_test
Gradient of side shape function.
Definition ADDGKernel.h:44
const ADVariableValue & _u_neighbor
Holds the current solution at the current quadrature point.
Definition ADDGKernel.h:61
unsigned int _i
unsigned int _qp
const Real & _current_elem_volume
The volume (or length) of the current element.
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