17 #include "libmesh/fparser_ad.hh" 29 "expression",
"FunctionExpression",
"function expression");
30 params.
addCoupledVar(
"coupled_variables",
"Scalar variables coupled in the parsed expression.");
31 params.
addParam<std::vector<std::string>>(
32 "constant_names", {},
"Vector of constants used in the parsed expression");
33 params.
addParam<std::vector<std::string>>(
34 "constant_expressions",
36 "Vector of values for the constants in constant_names (can be an FParser expression)");
37 params.
addParam<std::vector<PostprocessorName>>(
38 "postprocessors", {},
"Vector of postprocessor names used in the function expression");
46 _function(getParam<
std::string>(
"expression")),
47 _nargs(isCoupledScalar(
"coupled_variables") ? coupledScalarComponents(
"coupled_variables") : 0),
51 _number_of_nl_variables(_sys.nVariables()),
52 _arg_index(_number_of_nl_variables, -1)
58 for (
unsigned int i = 0; i <
_nargs; ++i)
71 auto pp_names = getParam<std::vector<PostprocessorName>>(
"postprocessors");
72 _pp.resize(pp_names.size());
73 for (
unsigned int i = 0; i < pp_names.size(); ++i)
75 variables +=
"," + pp_names[i];
82 _func_F = std::make_shared<SymFunction>();
89 getParam<std::vector<std::string>>(
"constant_names"),
90 getParam<std::vector<std::string>>(
"constant_expressions"));
96 "\nin ParsedODEKernel ",
102 _func_dFdu = std::make_shared<SymFunction>(*_func_F);
112 for (
unsigned int i = 0; i <
_nargs; ++i)
114 _func_dFdarg[i] = std::make_shared<SymFunction>(*_func_F);
125 for (
unsigned int i = 0; i <
_nargs; ++i)
134 for (
unsigned int i = 0; i <
_nargs; ++i)
151 for (
unsigned int j = 0; j <
_nargs; ++j)
153 for (
unsigned int j = 0; j <
_pp.size(); ++j)
std::vector< std::string > _arg_names
GenericReal< is_ad > evaluate(SymFunctionPtr &, const std::string &object_name="")
Evaluate FParser object and check EvalError.
void addFParserConstants(SymFunctionPtr &parser, const std::vector< std::string > &constant_names, const std::vector< std::string > &constant_expressions) const
add constants (which can be complex expressions) to the parser object
Parsed ODE function kernel.
std::vector< SymFunctionPtr > _func_dFdarg
function parser objects for the Jacobian
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
std::vector< const PostprocessorValue * > _pp
coupled postprocessors
processor_id_type rank() const
std::string _function
function expression
MooseVariableScalar & _var
Scalar variable.
SymFunctionPtr _func_dFdu
std::vector< unsigned int > _arg_index
Vector to look up the internal coupled variable index into arg* through the libMesh variable number...
const Parallel::Communicator & _communicator
registerMooseObject("MooseApp", ParsedODEKernel)
ParsedODEKernel(const InputParameters ¶meters)
virtual Real computeQpOffDiagJacobianScalar(unsigned int jvar) override
virtual Real computeQpJacobian() override
const std::string & name() const
Get the name of the class.
bool _enable_jit
feature flags
const VariableValue & coupledScalarValue(const std::string &var_name, unsigned int comp=0) const
Returns value of a scalar coupled variable.
SymFunctionPtr _func_F
function parser object for the residual and on-diagonal Jacobian
const unsigned int _number_of_nl_variables
number of non-linear variables in the problem
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.
unsigned int coupledScalar(const std::string &var_name, unsigned int comp=0) const
Returns the index for a scalar coupled variable by name.
const VariableValue & _u
The current solution (old solution if explicit)
virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name) const
Retrieve the value of the Postprocessor.
virtual Real computeQpResidual() override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool _disable_fpoptimizer
std::vector< GenericReal< is_ad > > _func_params
Array to stage the parameters passed to the functions when calling Eval.
unsigned int _nargs
coupled variables
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...
static InputParameters validParams()
static InputParameters validParams()
static InputParameters validParams()
std::vector< const VariableValue * > _args
void setParserFeatureFlags(SymFunctionPtr &) const
apply input parameters to internal feature flags of the parser object