https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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");
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
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
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}
registerMooseObject("MooseApp", ADDGAdvection)
DualNumber< Real, DNDerivativeType, true > ADReal
Adds residual/Jacobian contributions for a convection term from internal faces for a discontinuous Ga...
ADDGAdvection(const InputParameters &parameters)
const ADMaterialProperty< RealVectorValue > & _velocity_neighbor
The velocity on the neighbor.
const ADMaterialProperty< RealVectorValue > & _velocity
The velocity on the element.
static InputParameters validParams()
virtual ADReal computeQpResidual(Moose::DGResidualType type) override
Compute this Kernel's contribution to the residual at the current quadrature point.
const MooseArray< ADReal > & _adv_quant_elem
The advected quantity value on the element side of the face.
const MooseArray< ADReal > & _adv_quant_neighbor
The advected quantity value on the neighbor side of the face.
const VariableTestValue & _test_neighbor
Side test function.
Definition ADDGKernel.h:50
static InputParameters validParams()
Definition ADDGKernel.C:22
const VariableTestValue & _test
test functions
Definition ADDGKernel.h:42
unsigned int _i
unsigned int _qp
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
DGResidualType
Definition MooseTypes.h:798
@ Element
Definition MooseTypes.h:799
@ Neighbor
Definition MooseTypes.h:800