24 #ifdef LIBMESH_HAVE_FPARSER_JIT
29 "Enable just-in-time compilation of function expressions for faster evaluation");
32 "enable_ad_cache",
true,
"Enable cacheing of function derivatives for faster startup time");
34 "enable_auto_optimize",
true,
"Enable automatic immediate optimization of derivatives");
36 "disable_fpoptimizer",
false,
"Disable the function parser algebraic optimizer");
40 "Fail fatally if a function evaluation returns an error code (otherwise just pass on NaN)");
52 "Square root of a negative value",
53 "Logarithm of negative value",
54 "Trigonometric error (asin or acos of illegal value)",
55 "Maximum recursion level reached"};
58 : _enable_jit(parameters.isParamValid(
"enable_jit") && parameters.get<bool>(
"enable_jit")),
59 _enable_ad_cache(parameters.get<bool>(
"enable_ad_cache")),
60 _disable_fpoptimizer(parameters.get<bool>(
"disable_fpoptimizer")),
61 _enable_auto_optimize(parameters.get<bool>(
"enable_auto_optimize") && !_disable_fpoptimizer),
62 _fail_on_evalerror(parameters.get<bool>(
"fail_on_evalerror")),
63 _nan(
std::numeric_limits<Real>::quiet_NaN())
65 #ifndef LIBMESH_HAVE_FPARSER_JIT
68 mooseWarning(
"Tried to enable FParser JIT but libmesh does not have it compiled in.");
92 int error_code = parser->EvalError();
100 mooseError(
"DerivativeParsedMaterial function evaluation encountered an error: ",
108 const std::vector<std::string> & constant_names,
109 const std::vector<std::string> & constant_expressions)
112 unsigned int nconst = constant_expressions.size();
113 if (nconst != constant_names.size())
114 mooseError(
"The parameter vectors constant_names and constant_values must have equal length.");
117 std::vector<Real> constant_values(nconst);
119 for (
unsigned int i = 0; i < nconst; ++i)
127 for (
unsigned int j = 0; j < i; ++j)
128 if (!expression->AddConstant(constant_names[j], constant_values[j]))
129 mooseError(
"Invalid constant name in ParsedMaterialHelper");
132 if (expression->Parse(constant_expressions[i],
"") >= 0)
134 constant_expressions[i],
135 "\n in parsed function object.\n",
136 expression->ErrorMsg());
138 constant_values[i] = expression->Eval(NULL);
140 if (!parser->AddConstant(constant_names[i], constant_values[i]))
141 mooseError(
"Invalid constant name in parsed function object");