ABLATE Source Documentation  0.12.34
formula.hpp
1 #ifndef ABLATELIBRARY_FORMULA_HPP
2 #define ABLATELIBRARY_FORMULA_HPP
3 #include <muParser.h>
4 #include <memory>
5 #include <vector>
6 #include "formulaBase.hpp"
7 #include "parameters/parameters.hpp"
8 
9 namespace ablate::mathFunctions {
10 class Formula : public FormulaBase {
11  private:
12  // store the scratch variables
13  std::vector<std::unique_ptr<double>> nestedValues;
14  std::vector<std::shared_ptr<MathFunction>> nestedFunctions;
15 
16  private:
17  static PetscErrorCode ParsedPetscNested(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nf, PetscScalar* u, void* ctx);
18 
19  public:
20  Formula(const Formula&) = delete;
21  void operator=(const Formula&) = delete;
22 
23  explicit Formula(std::string functionString, const std::map<std::string, std::shared_ptr<MathFunction>>& = {}, std::shared_ptr<ablate::parameters::Parameters> constants = {});
24 
25  double Eval(const double& x, const double& y, const double& z, const double& t) const override;
26 
27  double Eval(const double* xyz, const int& ndims, const double& t) const override;
28 
29  void Eval(const double& x, const double& y, const double& z, const double& t, std::vector<double>& result) const override;
30 
31  void Eval(const double* xyz, const int& ndims, const double& t, std::vector<double>& result) const override;
32 
33  void* GetContext() override { return this; }
34 
35  PetscFunction GetPetscFunction() override { return ParsedPetscNested; }
36 };
37 } // namespace ablate::mathFunctions
38 #endif // ABLATELIBRARY_FORMULA_HPP
Definition: formulaBase.hpp:14
double time
the time linked to the parser
Definition: formulaBase.hpp:27
Definition: formula.hpp:10
double Eval(const double &x, const double &y, const double &z, const double &t) const override
Definition: formula.cpp:29
void * GetContext() override
Definition: formula.hpp:33
PetscFunction GetPetscFunction() override
Definition: formula.hpp:35