21 "Sets a field vector variable value to the evaluation of a parsed expression.");
26 "Parsed function expression to compute the x component");
30 "Parsed function expression to compute the y component");
31 if constexpr (LIBMESH_DIM >= 3)
35 "Parsed function expression to compute the z component");
36 params.
addCoupledVar(
"coupled_variables",
"Vector of coupled variable names");
37 params.
addCoupledVar(
"coupled_vector_variables",
"Vector of coupled variable names");
42 "Make coordinate (x,y,z) and time (t) variables available in the function expression.");
43 params.
addParam<std::vector<std::vector<std::string>>>(
44 "constant_names",
"Vector of constants used in the parsed function (use this for kB etc.)");
45 params.
addParam<std::vector<std::vector<std::string>>>(
46 "constant_expressions",
47 "Vector of values for the constants in constant_names (can be an FParser expression)");
55 _function({getParam<std::string>(
"expression_x"),
56 getParam<std::string>(
"expression_y"),
57 getParam<std::string>(
"expression_z")}),
58 _nargs(coupledComponents(
"coupled_variables")),
59 _n_vector_args(coupledComponents(
"coupled_vector_variables")),
60 _args(coupledValues(
"coupled_variables")),
61 _vector_args(coupledVectorValues(
"coupled_vector_variables")),
62 _use_xyzt(getParam<bool>(
"use_xyzt"))
64 _func_F.resize(LIBMESH_DIM);
65 _function.resize(LIBMESH_DIM);
70 std::string variables;
74 variables += (i == 0 ?
"" :
",") + getFieldVar(
"coupled_variables", i)->name();
77 for (
const auto i :
make_range(_n_vector_args))
79 (variables.empty() ?
"" :
",") + getFieldVar(
"coupled_vector_variables", i)->name();
82 const std::vector<std::string> xyzt = {
"x",
"y",
"z",
"t"};
85 variables += (variables.empty() ?
"" :
",") + v;
88 _func_F[i] = std::make_shared<SymFunction>();
91 auto constant_names = isParamValid(
"constant_names")
92 ? getParam<std::vector<std::vector<std::string>>>(
"constant_names")
93 : std::vector<std::vector<std::string>>{};
94 auto constant_expressions =
95 isParamValid(
"constant_expressions")
96 ? getParam<std::vector<std::vector<std::string>>>(
"constant_expressions")
97 : std::vector<std::vector<std::string>>{};
98 if (constant_names.size() && i > constant_names.size())
99 paramError(
"constant_names",
100 "Constant names must be specified for each component. Use ';' for outer-indexing " 101 "of double-indexed vector of constants.");
102 if (constant_expressions.size() && i > constant_expressions.size())
103 paramError(
"constant_expressions",
104 "Constant expressions must be specified for each component. Use ';' for " 105 "outer-indexing of double-indexed vector of constants.");
106 const std::vector<std::string> empty_vec{};
107 const auto names = constant_names.size() ? constant_names[i] : empty_vec;
108 const auto expressions = constant_expressions.size() ? constant_expressions[i] : empty_vec;
111 parsedFunctionSetup(_func_F[i], _function[i], variables, names, expressions, comm());
114 _func_params.resize(_nargs + _n_vector_args + (_use_xyzt ? 4 : 0));
GenericReal< is_ad > evaluate(SymFunctionPtr &, const std::string &object_name="")
Evaluate FParser object and check EvalError.
const std::vector< const VariableValue * > _args
const unsigned int _nargs
coupled variables NOTE: a potential optimization would be to have different number of arguments per c...
std::vector< SymFunctionPtr > _func_F
function parser object
const bool _use_xyzt
import coordinates and time
std::vector< const VectorVariableValue * > _vector_args
ParsedVectorAux(const InputParameters ¶meters)
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
const unsigned int _n_vector_args
virtual RealVectorValue computeValue() override
Compute and return the value of the aux variable.
static InputParameters validParams()
AuxKernel that evaluates a parsed function expression for every component.
virtual const OutputTools< RealVectorValue >::VariableValue & value()
The value of the variable this object is operating on.
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)
unsigned int _qp
Quadrature point index.
static InputParameters validParams()
static InputParameters validParams()
const MooseArray< Point > & _q_point
Active quadrature points.
bool isNodal() const
Nodal or elemental kernel?
registerMooseObject("MooseApp", ParsedVectorAux)