Thin RAII wrapper over the exprtk expression library.
More...
#include <ExprtkWrapper.hpp>
Thin RAII wrapper over the exprtk expression library.
Compiles a user-supplied math expression once (with named scalar and vector variables) and evaluates it many times against variable values set through Var / VarVec. Used for user-defined initial conditions and boundary functions read from config JSON (see docs/guides/array_usage.md and CFV config files).
Typical usage:
Thin RAII wrapper over the exprtk expression library.
real Evaluate()
Evaluate the compiled expression with the current variable values.
void AddScalar(const std::string &name, real init=0)
Register a scalar variable. init is accepted for API symmetry but currently ignored (scalars default ...
void AddVector(const std::string &name, int size)
Register a dense vector variable named name of length size.
real & Var(const std::string &name)
Mutable reference to a scalar variable's current value.
void Compile(const std::string &expr)
Compile expr. Throws (via DNDS_check_throw) on parse error.
real & VarVec(const std::string &name, int i)
Mutable reference to element i of a vector variable.
double real
Canonical floating-point scalar used throughout DNDSR (double precision).
The type-erased void* members hide the exprtk symbol_table / expression / parser types so exprtk headers stay out of the public API.
Definition at line 38 of file ExprtkWrapper.hpp.
◆ ExprtkWrapperEvaluator() [1/3]
| DNDS::ExprtkWrapperEvaluator::ExprtkWrapperEvaluator |
( |
| ) |
|
|
default |
◆ ExprtkWrapperEvaluator() [2/3]
◆ ExprtkWrapperEvaluator() [3/3]
◆ ~ExprtkWrapperEvaluator()
| DNDS::ExprtkWrapperEvaluator::~ExprtkWrapperEvaluator |
( |
| ) |
|
|
inline |
◆ AddScalar()
| void DNDS::ExprtkWrapperEvaluator::AddScalar |
( |
const std::string & |
name, |
|
|
real |
init = 0 |
|
) |
| |
|
inline |
Register a scalar variable. init is accepted for API symmetry but currently ignored (scalars default to 0).
- Note
- Calling any
Add* invalidates a previously compiled expression.
Definition at line 61 of file ExprtkWrapper.hpp.
◆ AddVector()
| void DNDS::ExprtkWrapperEvaluator::AddVector |
( |
const std::string & |
name, |
|
|
int |
size |
|
) |
| |
|
inline |
Register a dense vector variable named name of length size.
Definition at line 68 of file ExprtkWrapper.hpp.
◆ Clear()
| void DNDS::ExprtkWrapperEvaluator::Clear |
( |
| ) |
|
Release the compiled expression and parser. Must be called before re-binding variables.
Definition at line 78 of file ExprtkWrapper.cpp.
◆ Compile()
| void DNDS::ExprtkWrapperEvaluator::Compile |
( |
const std::string & |
expr | ) |
|
◆ Compiled()
| bool DNDS::ExprtkWrapperEvaluator::Compiled |
( |
| ) |
const |
|
inline |
◆ Evaluate()
| real DNDS::ExprtkWrapperEvaluator::Evaluate |
( |
| ) |
|
Evaluate the compiled expression with the current variable values.
Definition at line 71 of file ExprtkWrapper.cpp.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ Var()
| real & DNDS::ExprtkWrapperEvaluator::Var |
( |
const std::string & |
name | ) |
|
|
inline |
Mutable reference to a scalar variable's current value.
Definition at line 75 of file ExprtkWrapper.hpp.
◆ VarVec()
| real & DNDS::ExprtkWrapperEvaluator::VarVec |
( |
const std::string & |
name, |
|
|
int |
i |
|
) |
| |
|
inline |
Mutable reference to element i of a vector variable.
Definition at line 77 of file ExprtkWrapper.hpp.
◆ VarVecSize()
| index DNDS::ExprtkWrapperEvaluator::VarVecSize |
( |
const std::string & |
name | ) |
|
|
inline |
The documentation for this class was generated from the following files: