DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
DNDS::ExprtkWrapperEvaluator Class Reference

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.
 
realVar (const std::string &name)
 Mutable reference to a scalar variable's current value.
 
realVarVec (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 ()
 

Detailed Description

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:

e.AddScalar("t");
e.AddVector("x", 3);
e.Compile("sin(x[0]) * cos(t)");
e.Var("t") = 0.5;
e.VarVec("x", 0) = 0.1;
real val = e.Evaluate();
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).
Definition Defines.hpp:105

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.

Constructor & Destructor Documentation

◆ ~ExprtkWrapperEvaluator()

DNDS::ExprtkWrapperEvaluator::~ExprtkWrapperEvaluator ( )
inline

Definition at line 87 of file ExprtkWrapper.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ 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 51 of file ExprtkWrapper.hpp.

Here is the call graph for this function:

◆ 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 58 of file ExprtkWrapper.hpp.

Here is the call graph for this function:

◆ Clear()

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.

Here is the caller graph for this function:

◆ Compile()

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.

Here is the call graph for this function:

◆ Compiled()

bool DNDS::ExprtkWrapperEvaluator::Compiled ( ) const
inline

Whether Compile has been called and the expression parsed successfully.

Definition at line 72 of file ExprtkWrapper.hpp.

Here is the caller graph for this function:

◆ Evaluate()

real DNDS::ExprtkWrapperEvaluator::Evaluate ( )

Evaluate the compiled expression with the current variable values.

Definition at line 64 of file ExprtkWrapper.cpp.

Here is the call graph for this function:

◆ Var()

real & DNDS::ExprtkWrapperEvaluator::Var ( const std::string &  name)
inline

Mutable reference to a scalar variable's current value.

Definition at line 65 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 67 of file ExprtkWrapper.hpp.

◆ VarVecSize()

index DNDS::ExprtkWrapperEvaluator::VarVecSize ( const std::string &  name)
inline

Length of a registered vector variable.

Definition at line 69 of file ExprtkWrapper.hpp.


The documentation for this class was generated from the following files: