30 vars->table.add_variable(
"x", vars->x);
31 vars->table.add_variable(
"y", vars->y);
32 vars->table.add_variable(
"z", vars->z);
33 vars->table.add_variable(
"t", vars->t);
34 vars->table.add_constants();
35 vars->expr.register_symbol_table(vars->table);
36 exprtk::parser<double>
parser;
38 throw std::runtime_error(
"Failed to parse expression for " + name +
": " +
parser.error());
40 std::vector<std::string>
used;
41 time_dependent = !exprtk::collect_variables(
text, vars->table,
used) ||
51 double operator()(
double x,
double y,
double t = 0.0)
const {
52 return (*
this)(x, y, 0.0, t);
58 double operator()(
double x,
double y,
double z,
double t)
const {
63 return vars->expr.value();
70 double at(
const T & x,
const int n_dim,
double t = 0.0)
const {
77 double x = 0.0, y = 0.0, z = 0.0, t = 0.0;
78 exprtk::symbol_table<double> table;
79 exprtk::expression<double> expr;
81 std::unique_ptr<Vars> vars;
82 bool time_dependent =
true;
An exprtk expression in the variables x, y, z and t.
Definition expression.h:26
bool depends_on_time() const
Whether the value can depend on t.
Definition expression.h:46
double at(const T &x, const int n_dim, double t=0.0) const
Evaluate at the point with coordinates x[0..n_dim) (z = 0 if n_dim = 2).
Definition expression.h:70
Expression(const std::string &name, const std::string &text)
Definition expression.h:28
double operator()(double x, double y, double z, double t) const
Evaluate at (x, y, z, t).
Definition expression.h:58
double operator()(double x, double y, double t=0.0) const
Evaluate at (x, y, z = 0, t).
Definition expression.h:51
KOKKOS_INLINE_FUNCTION rtype dot(const rtype *a, const rtype *b)
Compute the dot product of two arrays.
Definition common_math.h:32