https://mooseframework.inl.gov
ADDGAdvection.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 "ADDGAdvection.h"
11 
13 
16 {
18  params.addRequiredParam<MaterialPropertyName>("velocity", "Velocity vector");
19  params.addClassDescription(
20  "Adds internal face advection flux contributions for discontinuous Galerkin discretizations");
21  params.addParam<MaterialPropertyName>("advected_quantity",
22  "An optional material property to be advected. If not "
23  "supplied, then the variable will be used.");
24  return params;
25 }
26 
28  : ADDGKernel(parameters),
29  _velocity(getADMaterialProperty<RealVectorValue>("velocity")),
30  _velocity_neighbor(getNeighborADMaterialProperty<RealVectorValue>("velocity")),
31  _adv_quant_elem(isParamValid("advected_quantity")
32  ? getADMaterialProperty<Real>("advected_quantity").get()
33  : _u),
34  _adv_quant_neighbor(isParamValid("advected_quantity")
35  ? getNeighborADMaterialProperty<Real>("advected_quantity").get()
36  : _u_neighbor)
37 {
38 }
39 
40 ADReal
42 {
43  ADReal r = 0;
44 
45  auto average = [](const auto & elem_value, const auto & neighbor_value)
46  { return (elem_value + neighbor_value) / 2; };
47 
48  const auto vdotn = average(_velocity[_qp], _velocity_neighbor[_qp]) * _normals[_qp];
49 
50  const auto face_u = [&]()
51  {
52  if (vdotn >= 0)
53  return _adv_quant_elem[_qp];
54  else
55  return _adv_quant_neighbor[_qp];
56  }();
57 
58  switch (type)
59  {
60  case Moose::Element:
61  r += vdotn * face_u * _test[_i][_qp];
62  break;
63 
64  case Moose::Neighbor:
65  r -= vdotn * face_u * _test_neighbor[_i][_qp];
66  break;
67  }
68 
69  return r;
70 }
virtual ADReal computeQpResidual(Moose::DGResidualType type) override
Compute this Kernel&#39;s contribution to the residual at the current quadrature point.
Definition: ADDGAdvection.C:41
ADDGAdvection(const InputParameters &parameters)
Definition: ADDGAdvection.C:27
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1155
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
Definition: ADDGKernel.C:22
unsigned int _i
Definition: DGKernelBase.h:136
DGResidualType
Definition: MooseTypes.h:744
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:46
static InputParameters validParams()
Definition: ADDGAdvection.C:15
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...
unsigned int _qp
Definition: DGKernelBase.h:134
const ADMaterialProperty< RealVectorValue > & _velocity
The velocity on the element.
Definition: ADDGAdvection.h:29
const VariableTestValue & _test_neighbor
Side test function.
Definition: ADDGKernel.h:50
Adds residual/Jacobian contributions for a convection term from internal faces for a discontinuous Ga...
Definition: ADDGAdvection.h:18
const ADMaterialProperty< RealVectorValue > & _velocity_neighbor
The velocity on the neighbor.
Definition: ADDGAdvection.h:31
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:89
const MooseArray< Point > & _normals
Normal vectors at the quadrature points.
Definition: DGKernelBase.h:113
const MooseArray< ADReal > & _adv_quant_elem
The advected quantity value on the element side of the face.
Definition: ADDGAdvection.h:34
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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...
const MooseArray< ADReal > & _adv_quant_neighbor
The advected quantity value on the neighbor side of the face.
Definition: ADDGAdvection.h:36
const VariableTestValue & _test
test functions
Definition: ADDGKernel.h:42
registerMooseObject("MooseApp", ADDGAdvection)