20 "Sets a field variable value to the evaluation of a parsed expression.");
23 "expression",
"FunctionExpression",
"Parsed function expression to compute");
24 params.
addCoupledVar(
"coupled_variables",
"Vector of coupled variable names");
26 params.
addParam<std::vector<MaterialPropertyName>>(
27 "material_properties", {},
"Material properties (Real-valued) in the expression");
28 params.
addParam<std::vector<MaterialPropertyName>>(
29 "ad_material_properties", {},
"AD material properties (ADReal-valued) in the expression");
34 "Make coordinate (x,y,z) and time (t) variables available in the function expression.");
35 params.
addParam<std::vector<std::string>>(
38 "Vector of constants used in the parsed function (use this for kB etc.)");
39 params.
addParam<std::vector<std::string>>(
40 "constant_expressions",
42 "Vector of values for the constants in constant_names (can be an FParser expression)");
43 params.
addParam<std::vector<MooseFunctorName>>(
44 "functor_names", {},
"Functors to use in the parsed expression");
45 params.
addParam<std::vector<std::string>>(
48 "Symbolic name to use for each functor in 'functor_names' in the parsed expression. If not " 49 "provided, then the actual functor names will be used in the parsed expression.");
51 "evaluate_functors_on_qp",
53 "Whether to evaluate functors using the ElemQpArg/ElemSideQpArg or the ElemArg/FaceArg " 54 "functor arguments. The behavior of a functor for each argument is implementation-defined by " 55 "the functor. But for most functors, the former two use the quadrature rule points as " 56 "evaluation locations, while the latter two use the element centroid/face centroid.");
63 _function(getParam<
std::string>(
"expression")),
64 _nargs(coupledComponents(
"coupled_variables")),
65 _args(coupledValues(
"coupled_variables")),
66 _matprop_names(getParam<
std::vector<MaterialPropertyName>>(
"material_properties")),
67 _ad_matprop_names(getParam<
std::vector<MaterialPropertyName>>(
"ad_material_properties")),
68 _n_matprops(_matprop_names.size()),
69 _n_ad_matprops(_ad_matprop_names.size()),
70 _use_xyzt(getParam<bool>(
"use_xyzt")),
71 _xyzt({
"x",
"y",
"z",
"t"}),
72 _functor_names(getParam<std::vector<MooseFunctorName>>(
"functor_names")),
73 _n_functors(_functor_names.size()),
74 _functor_symbols(getParam<std::vector<std::string>>(
"functor_symbols")),
75 _use_qp_functor_arguments(getParam<bool>(
"evaluate_functors_on_qp"))
79 _coupled_variable_names.push_back(getFieldVar(
"coupled_variables", i)->
name());
82 if (!_functor_symbols.empty() && (_functor_symbols.size() != _n_functors))
83 paramError(
"functor_symbols",
"functor_symbols must be the same length as functor_names.");
84 if (isNodal() && _use_qp_functor_arguments && isParamSetByUser(
"evaluate_functors_on_qp"))
85 paramError(
"evaluate_functors_on_qp",
"QPs are not used for computing variable nodal values.");
87 validateFunctorSymbols();
88 validateFunctorNames();
90 if (_bnd && !_use_qp_functor_arguments)
94 std::string variables;
97 for (
const auto i :
index_range(_coupled_variable_names))
98 variables += (i == 0 ?
"" :
",") + _coupled_variable_names[i];
101 if (_functor_symbols.size())
102 for (
const auto & symbol : _functor_symbols)
103 variables += (variables.empty() ?
"" :
",") + symbol;
105 for (
const auto & name : _functor_names)
106 variables += (variables.empty() ?
"" :
",") + name;
109 for (
const auto & matprop : _matprop_names)
110 variables += (variables.empty() ?
"" :
",") + matprop;
111 for (
const auto & matprop : _ad_matprop_names)
112 variables += (variables.empty() ?
"" :
",") + matprop;
113 if (isNodal() && (_matprop_names.size() || _ad_matprop_names.size()))
114 mooseError(
"Material properties cannot be retrieved in a nodal auxkernel. Use a different " 115 "auxiliary variable family.");
119 for (
auto & v : _xyzt)
120 variables += (variables.empty() ?
"" :
",") + v;
123 _func_F = std::make_shared<SymFunction>();
124 parsedFunctionSetup(_func_F,
127 getParam<std::vector<std::string>>(
"constant_names"),
128 getParam<std::vector<std::string>>(
"constant_expressions"),
132 _func_params.resize(_nargs + _n_functors + _n_matprops + _n_ad_matprops + (_use_xyzt ? 4 : 0));
135 for (
const auto & name : _matprop_names)
136 _matprops.push_back(&getMaterialProperty<Real>(name));
137 for (
const auto & name : _ad_matprop_names)
138 _ad_matprops.push_back(&getADMaterialProperty<Real>(name));
141 for (
const auto & name : _functor_names)
142 _functors.push_back(&getFunctor<Real>(name));
std::string name(const ElemQuality q)
void validateFunctorNames()
Function to validate the names in _functor_names.
GenericReal< is_ad > evaluate(SymFunctionPtr &, const std::string &object_name="")
Evaluate FParser object and check EvalError.
static const std::set< SubdomainID > undefined_subdomain_connection
A static member that can be used when the connection of a node to subdomains is unknown.
const unsigned int & _current_side
current side of the current element
const unsigned int _nargs
coupled variables
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
const Node *const & _current_node
Current node (valid only for nodal kernels)
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
std::vector< const Moose::Functor< Real > * > _functors
Vector of pointers to functors.
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
const bool _use_xyzt
import coordinates and time
const std::vector< MooseFunctorName > & _functor_names
Functors to use in the parsed expression.
MooseMesh & _mesh
Mesh this kernel is active on.
const bool _bnd
true if the kernel is boundary kernel, false if it is interior kernels
std::vector< const ADMaterialProperty< Real > * > _ad_matprops
AuxKernel that evaluates a parsed function expression.
SymFunctionPtr _func_F
function parser object to compute the local value of the aux-variable
const std::vector< const FaceInfo * > & faceInfo() const
Accessor for local FaceInfo objects.
const bool _use_qp_functor_arguments
Whether to use qp-functor arguments.
const std::vector< std::string > _functor_symbols
Symbolic name to use for each functor.
A structure defining a "face" evaluation calling argument for Moose functors.
const unsigned int _n_matprops
const unsigned int _n_functors
Number of functors.
A structure that is used to evaluate Moose functors logically at an element/cell center.
Argument for requesting functor evaluation at a quadrature point location in an element.
std::vector< const MaterialProperty< Real > * > _matprops
registerMooseObject("MooseApp", ParsedAux)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const QBase *const & _qrule
Quadrature rule being used.
std::vector< GenericReal< is_ad > > _func_params
Array to stage the parameters passed to the functions when calling Eval.
IntRange< T > make_range(T beg, T end)
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
unsigned int _qp
Quadrature point index.
const std::vector< const VariableValue * > _args
static InputParameters validParams()
static InputParameters validParams()
static InputParameters validParams()
void validateGenericVectorNames(const std::vector< T > &names_vec, const std::string ¶m_name)
Function to ensure vector entries (names) do not overlap with xyzt or coupled variable names...
const unsigned int _n_ad_matprops
ParsedAux(const InputParameters ¶meters)
virtual Real computeValue() override
Compute and return the value of the aux variable.
const MooseArray< Point > & _q_point
Active quadrature points.
auto index_range(const T &sizable)
Argument for requesting functor evaluation at quadrature point locations on an element side...
void validateFunctorSymbols()
Function to validate the symbols in _functor_symbols.
bool isNodal() const
Nodal or elemental kernel?