17 #include "libmesh/fparser_ad.hh" 29 "function",
"FunctionExpression",
"function expression");
31 params.
addCoupledVar(
"args",
"Scalar variables coupled in the parsed expression.");
33 params.
addParam<std::vector<std::string>>(
34 "constant_names", {},
"Vector of constants used in the parsed expression");
35 params.
addParam<std::vector<std::string>>(
36 "constant_expressions",
38 "Vector of values for the constants in constant_names (can be an FParser expression)");
39 params.
addParam<std::vector<PostprocessorName>>(
40 "postprocessors", {},
"Vector of postprocessor names used in the function expression");
48 _function(getParam<
std::string>(
"expression")),
49 _nargs(isCoupledScalar(
"coupled_variables") ? coupledScalarComponents(
"coupled_variables") : 0),
53 _number_of_nl_variables(_sys.nVariables()),
54 _arg_index(_number_of_nl_variables, -1)
60 for (
unsigned int i = 0; i <
_nargs; ++i)
73 auto pp_names = getParam<std::vector<PostprocessorName>>(
"postprocessors");
74 _pp.resize(pp_names.size());
75 for (
unsigned int i = 0; i < pp_names.size(); ++i)
77 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.
Parsed ODE function kernel.
std::vector< SymFunctionPtr > _func_dFdarg
function parser objects for the Jacobian
std::vector< const PostprocessorValue * > _pp
coupled postprocessors
const std::string & name() const override
Get the variable name.
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)
void addFParserConstants(SymFunctionPtr &parser, const std::vector< std::string > &constant_names, const std::vector< std::string > &constant_expressions)
add constants (which can be complex expressions) to the parser object
ParsedODEKernel(const InputParameters ¶meters)
virtual const std::string & name() const
Get the name of the class.
virtual Real computeQpOffDiagJacobianScalar(unsigned int jvar) override
virtual Real computeQpJacobian() override
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.
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
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
static InputParameters validParams()
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
static InputParameters validParams()
static InputParameters validParams()
std::vector< const VariableValue * > _args
void setParserFeatureFlags(SymFunctionPtr &)
apply input paramters to internal feature flags of the parser object