ABLATE Source Documentation  0.12.34
functionWrapper.hpp
1 #ifndef ABLATELIBRARY_FUNCTIONWRAPPER_HPP
2 #define ABLATELIBRARY_FUNCTIONWRAPPER_HPP
3 #include <functional>
4 #include "mathFunction.hpp"
5 namespace ablate::mathFunctions {
6 
7 class FunctionWrapper : public MathFunction {
8  public:
9  typedef std::function<PetscErrorCode(int dim, double time, const double x[], int nf, double* u, void* ctx)> Function;
10 
11  private:
12  Function function;
13 
14  static PetscErrorCode WrappedPetscFunction(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nf, PetscScalar* u, void* ctx);
15 
16  public:
17  FunctionWrapper(const FunctionWrapper&) = delete;
18  void operator=(const FunctionWrapper&) = delete;
19 
20  explicit FunctionWrapper(Function);
21 
22  double Eval(const double& x, const double& y, const double& z, const double& t) const override;
23 
24  double Eval(const double* xyz, const int& ndims, const double& t) const override;
25 
26  void Eval(const double& x, const double& y, const double& z, const double& t, std::vector<double>& result) const override;
27 
28  void Eval(const double* xyz, const int& ndims, const double& t, std::vector<double>& result) const override;
29 
30  PetscFunction GetPetscFunction() override { return WrappedPetscFunction; }
31 
32  void* GetContext() override { return &function; }
33 };
34 } // namespace ablate::mathFunctions
35 #endif // ABLATELIBRARY_FUNCTIONWRAPPER_HPP
Definition: functionWrapper.hpp:7
void * GetContext() override
Definition: functionWrapper.hpp:32
double Eval(const double &x, const double &y, const double &z, const double &t) const override
Definition: functionWrapper.cpp:6
PetscFunction GetPetscFunction() override
Definition: functionWrapper.hpp:30
Definition: mathFunction.hpp:13