https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
60Real
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) *
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}
registerMooseObject("MooseApp", AdvectiveFluxAux)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
Auxiliary kernel responsible for computing a component of the advection flux vector.
static InputParameters validParams()
const bool _advected_quantity_supplied
Whether an advected quantity was supplied in the input.
const MaterialProperty< Real > & _advected_material_property
Material property storing the advected quantity; used for finite elements.
const bool _advected_mat_prop_supplied
Whether an advected material property was supplied in the input.
const Moose::Functor< Real > *const _vel_z
const bool _use_normal
Whether the normal component has been selected.
const int _component
Will hold 0, 1, or 2 corresponding to x, y, or z.
const Moose::Functor< Real > & _advected_quantity
Functor for the scalar field advected quantity (for a variable usually)
AdvectiveFluxAux(const InputParameters &parameters)
const Moose::Functor< Real > & _vel_x
Velocity components.
virtual Real computeValue()
Compute and return the value of the aux variable.
const Moose::Functor< Real > *const _vel_y
const MooseArray< Point > & _normals
normals at quadrature points
bool isNodal() const
Nodal or elemental kernel?
Definition AuxKernel.h:43
const MooseArray< Point > & _q_point
Active quadrature points.
Definition AuxKernel.h:125
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition AuxKernel.h:133
const Node *const & _current_node
Current node (valid only for nodal kernels)
Definition AuxKernel.h:143
const unsigned int & _current_side
current side of the current element
Definition AuxKernel.h:135
unsigned int _qp
Quadrature point index.
Definition AuxKernel.h:155
MooseVariableField< Real > & _var
This is a regular kernel so we cast to a regular MooseVariable, hides base _var.
Definition AuxKernel.h:113
const QBase *const & _qrule
Quadrature rule being used.
Definition AuxKernel.h:127
static InputParameters validParams()
Definition AuxKernel.C:27
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.
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:457
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition MooseBase.h:199
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
This class provides variable solution values for other classes/objects to bind to when looping over f...
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)
Argument for requesting functor evaluation at quadrature point locations on an element side.