https://mooseframework.inl.gov
AdvectiveFluxAux.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 "AdvectiveFluxAux.h"
11 #include "Assembly.h"
12 
14 
17 {
19  MooseEnum component("x y z normal");
20 
21  params.addRequiredParam<MooseEnum>("component", component, "The desired component of flux.");
22  params.addParam<MooseFunctorName>("advected_variable", 0, "The name of the variable");
23  params.addRequiredParam<MooseFunctorName>("vel_x", "x-component of the advecting velocity");
24  params.addParam<MooseFunctorName>("vel_y", "y-component of the advecting velocity");
25  params.addParam<MooseFunctorName>("vel_z", "z-component of the advecting velocity");
26  params.addParam<MaterialPropertyName>(
27  "advected_mat_prop",
28  0,
29  "The advected material property of which to study the flow; "
30  "useful for finite element simulations");
31 
32  params.addClassDescription("Compute components of flux vector for advection problems "
33  "$(\\vec{J} \\cdot \\vec{n} = \\vec{v} u \\cdot \\vec{n})$.");
34 
35  return params;
36 }
37 
39  : AuxKernel(parameters),
40  _use_normal(getParam<MooseEnum>("component") == "normal"),
41  _component(getParam<MooseEnum>("component")),
42  _advected_quantity(getFunctor<Real>("advected_variable")),
43  _normals(_assembly.normals()),
44  _vel_x(getFunctor<Real>("vel_x")),
45  _vel_y(_mesh.dimension() >= 2 ? &getFunctor<Real>("vel_y") : nullptr),
46  _vel_z(_mesh.dimension() == 3 ? &getFunctor<Real>("vel_z") : nullptr),
47  _advected_quantity_supplied(parameters.isParamSetByUser("advected_variable")),
48  _advected_mat_prop_supplied(parameters.isParamSetByUser("advected_mat_prop")),
49  _advected_material_property(getMaterialProperty<Real>("advected_mat_prop"))
50 {
51  if (_use_normal && !isParamValid("boundary"))
52  paramError("boundary", "A boundary must be provided if using the normal component!");
54  mooseError("AdvectiveFluxAux should be provided either an advected variable "
55  "or an advected material property");
56  if (dynamic_cast<MooseVariableFV<Real> *>(&_var))
57  mooseError("AdvectiveFluxAux is designed for use in finite element simulations.");
58 }
59 
60 Real
62 {
64 
65  const Moose::ElemSideQpArg side_arg = {
67  const auto state = determineState();
68  Real vel_x, vel_y, vel_z = 0;
69 
70  vel_x = raw_value(_vel_x(side_arg, state));
71  vel_y = _vel_y ? raw_value((*_vel_y)(side_arg, state)) : 0;
72  vel_z = _vel_z ? raw_value((*_vel_z)(side_arg, state)) : 0;
73 
75  return (_use_normal ? _advected_quantity(side_arg, state) *
76  RealVectorValue(vel_x, vel_y, vel_z) * _normals[_qp]
77  : _advected_quantity(side_arg, state) *
78  RealVectorValue(vel_x, vel_y, vel_z)(_component));
80  return (_use_normal ? _advected_material_property[_qp] * RealVectorValue(vel_x, vel_y, vel_z) *
81  _normals[_qp]
83  RealVectorValue(vel_x, vel_y, vel_z)(_component));
84  else
85  return (_use_normal ? RealVectorValue(vel_x, vel_y, vel_z) * _normals[_qp]
86  : RealVectorValue(vel_x, vel_y, vel_z)(_component));
87 }
Auxiliary kernel responsible for computing a component of the advection flux vector.
const Moose::Functor< Real > & _vel_x
Velocity components.
static InputParameters validParams()
const Moose::Functor< Real > & _advected_quantity
Functor for the scalar field advected quantity (for a variable usually)
const unsigned int & _current_side
current side of the current element
Definition: AuxKernel.h:206
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition: MooseBase.h:435
AdvectiveFluxAux(const InputParameters &parameters)
virtual Real computeValue()
Compute and return the value of the aux variable.
const Node *const & _current_node
Current node (valid only for nodal kernels)
Definition: AuxKernel.h:214
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
auto raw_value(const Eigen::Map< T > &in)
Definition: EigenADReal.h:73
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const bool _advected_mat_prop_supplied
Whether an advected material property was supplied in the input.
const bool _use_normal
Whether the normal component has been selected.
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...
const MaterialProperty< Real > & _advected_material_property
Material property storing the advected quantity; used for finite elements.
const MooseArray< Point > & _normals
normals at quadrature points
const bool _advected_quantity_supplied
Whether an advected quantity was supplied in the input.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
const Moose::Functor< Real > *const _vel_z
MooseVariableField< Real > & _var
This is a regular kernel so we cast to a regular MooseVariable.
Definition: AuxKernel.h:174
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const QBase *const & _qrule
Quadrature rule being used.
Definition: AuxKernel.h:198
const Moose::Functor< Real > *const _vel_y
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:267
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition: AuxKernel.h:204
unsigned int _qp
Quadrature point index.
Definition: AuxKernel.h:230
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...
static InputParameters validParams()
Definition: AuxKernel.C:27
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:36
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseBase.h:195
const MooseArray< Point > & _q_point
Active quadrature points.
Definition: AuxKernel.h:196
registerMooseObject("MooseApp", AdvectiveFluxAux)
Argument for requesting functor evaluation at quadrature point locations on an element side...
bool isNodal() const
Nodal or elemental kernel?
Definition: AuxKernel.h:86
const int _component
Will hold 0, 1, or 2 corresponding to x, y, or z.