waLBerla 7.2
Loading...
Searching...
No Matches
walberla::math::FunctionParser Class Reference

Detailed Description

Function parser, for parsing and evaluating functions.

Can parse mathematical expressions containing the standard arithmetic operations(+,-,/,*) , brackets, functions (cos,sin,exp,sqrt) and variables

After parsing an expression, values can be bound to variables using a symbol table.

Example:

p.parse("(t*t +5) + exp(Pi/2) * sin(cos(1)) ");
std::map<string,double> symbolTable;
symbolTable["Pi"]=3.141;
symbolTable["t"] = 24;
p.evaluate(symbolTable);
Function parser, for parsing and evaluating functions.
Definition Parser.h:61
void parse(const std::string &equation)
Definition Parser.cpp:72
double evaluate(const std::map< std::string, double > &symbolTable) const
Definition Parser.cpp:115

#include <Parser.h>

Public Member Functions

 FunctionParser ()
 
 ~FunctionParser ()
 
void parse (const std::string &equation)
 
double evaluate (const std::map< std::string, double > &symbolTable) const
 
const bool & isConstant () const
 
const bool & isZero () const
 
bool symbolExists (const std::string &symbol) const
 

Protected Member Functions

 FunctionParser (const FunctionParser &other)
 
FunctionParseroperator= (const FunctionParser &other)
 

Protected Attributes

exprtk::expression< double > * expression_ { nullptr }
 
exprtk::symbol_table< double > * symbolTable_ { nullptr }
 
bool isConstant_ {false}
 
bool isZero_ {false}
 

Constructor & Destructor Documentation

◆ FunctionParser() [1/2]

walberla::math::FunctionParser::FunctionParser ( )
default

◆ ~FunctionParser()

walberla::math::FunctionParser::~FunctionParser ( )

◆ FunctionParser() [2/2]

walberla::math::FunctionParser::FunctionParser ( const FunctionParser & other)
protected

Member Function Documentation

◆ evaluate()

double walberla::math::FunctionParser::evaluate ( const std::map< std::string, double > & symbolTable) const

◆ isConstant()

const bool & walberla::math::FunctionParser::isConstant ( ) const
inline

◆ isZero()

const bool & walberla::math::FunctionParser::isZero ( ) const
inline

◆ operator=()

FunctionParser & walberla::math::FunctionParser::operator= ( const FunctionParser & other)
protected

◆ parse()

void walberla::math::FunctionParser::parse ( const std::string & equation)

◆ symbolExists()

bool walberla::math::FunctionParser::symbolExists ( const std::string & symbol) const

Member Data Documentation

◆ expression_

exprtk::expression<double>* walberla::math::FunctionParser::expression_ { nullptr }
protected

◆ isConstant_

bool walberla::math::FunctionParser::isConstant_ {false}
protected

◆ isZero_

bool walberla::math::FunctionParser::isZero_ {false}
protected

◆ symbolTable_

exprtk::symbol_table<double>* walberla::math::FunctionParser::symbolTable_ { nullptr }
protected

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