#include <Parser.h>
|
virtual std::string | eval (hit::Field *n, const std::list< std::string > &args, hit::BraceExpander &exp) |
|
Definition at line 33 of file Parser.h.
◆ eval()
virtual std::string FuncParseEvaler::eval |
( |
hit::Field * |
n, |
|
|
const std::list< std::string > & |
args, |
|
|
hit::BraceExpander & |
exp |
|
) |
| |
|
inlinevirtual |
Definition at line 37 of file Parser.h.
39 std::string func_text;
42 auto n_errs = exp.errors.size();
45 fp.AddConstant(
"pi", libMesh::pi);
46 fp.AddConstant(
"e", std::exp(Real(1)));
47 std::vector<std::string> var_names;
48 auto ret = fp.ParseAndDeduceVariables(func_text, var_names);
51 exp.errors.push_back(hit::errormsg(exp.fname,
n,
"fparse error: ", fp.ErrorMsg()));
56 std::vector<double> var_vals;
57 for (
auto & var : var_names)
61 while ((curr = curr->parent()))
63 auto src = curr->find(var);
64 if (src && src !=
n && src->type() == hit::NodeType::Field)
66 exp.used.push_back(hit::pathJoin({curr->fullpath(), var}));
67 var_vals.push_back(curr->param<
double>(var));
73 exp.errors.push_back(hit::errormsg(exp.fname,
77 "' found for use in function parser expression"));
80 if (exp.errors.size() != n_errs)
84 ss << std::setprecision(17) << fp.Eval(var_vals.data());
87 n->setVal(
n->val(), hit::Field::Kind::Float);
The documentation for this class was generated from the following file: