|
DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
|
Thin RAII wrapper over the exprtk expression library. More...
#include <ExprtkWrapper.hpp>
Public Member Functions | |
| void | AddScalar (const std::string &name, real init=0) |
Register a scalar variable. init is accepted for API symmetry but currently ignored (scalars default to 0). | |
| 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. | |
| real & | VarVec (const std::string &name, int i) |
Mutable reference to element i of a vector variable. | |
| index | VarVecSize (const std::string &name) |
| Length of a registered vector variable. | |
| bool | Compiled () const |
| Whether Compile has been called and the expression parsed successfully. | |
| void | Compile (const std::string &expr) |
Compile expr. Throws (via DNDS_check_throw) on parse error. | |
| real | Evaluate () |
| Evaluate the compiled expression with the current variable values. | |
| void | Clear () |
| Release the compiled expression and parser. Must be called before re-binding variables. | |
| ~ExprtkWrapperEvaluator () | |
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:
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.
|
inline |
|
inline |
Register a scalar variable. init is accepted for API symmetry but currently ignored (scalars default to 0).
Add* invalidates a previously compiled expression. Definition at line 51 of file ExprtkWrapper.hpp.
|
inline |
Register a dense vector variable named name of length size.
Definition at line 58 of file ExprtkWrapper.hpp.
| void DNDS::ExprtkWrapperEvaluator::Clear | ( | ) |
Release the compiled expression and parser. Must be called before re-binding variables.
Definition at line 71 of file ExprtkWrapper.cpp.
| void DNDS::ExprtkWrapperEvaluator::Compile | ( | const std::string & | expr | ) |
Compile expr. Throws (via DNDS_check_throw) on parse error.
Definition at line 16 of file ExprtkWrapper.cpp.
|
inline |
Whether Compile has been called and the expression parsed successfully.
Definition at line 72 of file ExprtkWrapper.hpp.
| real DNDS::ExprtkWrapperEvaluator::Evaluate | ( | ) |
Evaluate the compiled expression with the current variable values.
Definition at line 64 of file ExprtkWrapper.cpp.
|
inline |
Mutable reference to a scalar variable's current value.
Definition at line 65 of file ExprtkWrapper.hpp.
|
inline |
Mutable reference to element i of a vector variable.
Definition at line 67 of file ExprtkWrapper.hpp.
|
inline |
Length of a registered vector variable.
Definition at line 69 of file ExprtkWrapper.hpp.