ABLATE Source Documentation  0.12.34
formulaBase.hpp
1 #ifndef ABLATELIBRARY_FORMULABASE_HPP
2 #define ABLATELIBRARY_FORMULABASE_HPP
3 
4 #include <muParser.h>
5 #include <random>
6 #include "mathFunction.hpp"
7 #include "parameters/parameters.hpp"
8 
9 namespace ablate::mathFunctions {
10 
14 class FormulaBase : public MathFunction {
15  private:
17  std::minstd_rand0 pseudoRandomEngine{0};
18 
20  std::default_random_engine randomEngine{0};
21 
22  protected:
24  mutable double coordinate[3] = {0, 0, 0};
25 
27  mutable double time = 0.0;
28 
30  mu::Parser parser;
31 
33  const std::string formula;
34 
40  explicit FormulaBase(std::string functionString, const std::shared_ptr<ablate::parameters::Parameters>& constants);
41 
47  static std::invalid_argument ConvertToException(mu::Parser::exception_type& exception);
48 
49  public:
51  FormulaBase(const FormulaBase&) = delete;
53  void operator=(const FormulaBase&) = delete;
54 
55  private:
62  static mu::value_type PowerFunction(mu::value_type a, mu::value_type b);
63 
70  static mu::value_type RandomFunction(void* data, mu::value_type lowerBound, mu::value_type upperBound);
71 
78  static mu::value_type PseudoRandomFunction(void* data, mu::value_type lowerBound, mu::value_type upperBound);
79 
86  static mu::value_type ModulusOperator(mu::value_type left, mu::value_type right);
87 };
88 
89 } // namespace ablate::mathFunctions
90 #endif // ABLATELIBRARY_FORMULABASE_HPP
Definition: formulaBase.hpp:14
mu::Parser parser
The parser object library for this formula.
Definition: formulaBase.hpp:30
double time
the time linked to the parser
Definition: formulaBase.hpp:27
void operator=(const FormulaBase &)=delete
prevent copy of this object
const std::string formula
the formula output for debugging
Definition: formulaBase.hpp:33
FormulaBase(const FormulaBase &)=delete
prevent copy of this object
static std::invalid_argument ConvertToException(mu::Parser::exception_type &exception)
Definition: formulaBase.cpp:42
FormulaBase(std::string functionString, const std::shared_ptr< ablate::parameters::Parameters > &constants)
Definition: formulaBase.cpp:7
double coordinate[3]
The coordinate linked to the parser.
Definition: formulaBase.hpp:24
Definition: mathFunction.hpp:13