ABLATE Source Documentation  0.12.34
constantValue.hpp
1 #ifndef ABLATELIBRARY_CONSTANTVALUE_HPP
2 #define ABLATELIBRARY_CONSTANTVALUE_HPP
3 
4 #include "mathFunction.hpp"
5 #include "memory"
6 
7 namespace ablate::mathFunctions {
8 
9 class ConstantValue : public MathFunction {
10  private:
11  const std::vector<double> value;
12  const bool uniformValue;
13  static PetscErrorCode ConstantValuePetscFunction(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nf, PetscScalar* u, void* ctx);
14  static PetscErrorCode ConstantValueUniformPetscFunction(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nf, PetscScalar* u, void* ctx);
15 
16  public:
17  explicit ConstantValue(double value);
18 
19  explicit ConstantValue(std::vector<double> values);
20 
21  explicit ConstantValue(std::initializer_list<double> values);
22 
23  [[nodiscard]] double Eval(const double& x, const double& y, const double& z, const double& t) const override;
24 
25  double Eval(const double* xyz, const int& ndims, const double& t) const override;
26 
27  void Eval(const double& x, const double& y, const double& z, const double& t, std::vector<double>& result) const override;
28 
29  void Eval(const double* xyz, const int& ndims, const double& t, std::vector<double>& result) const override;
30 
31  PetscFunction GetPetscFunction() override { return uniformValue ? ConstantValueUniformPetscFunction : ConstantValuePetscFunction; }
32 
33  void* GetContext() override { return (void*)value.data(); }
34 };
35 
36 } // namespace ablate::mathFunctions
37 #endif // ABLATELIBRARY_CONSTANTVALUE_HPP
Definition: constantValue.hpp:9
double Eval(const double &x, const double &y, const double &z, const double &t) const override
Definition: constantValue.cpp:31
PetscFunction GetPetscFunction() override
Definition: constantValue.hpp:31
void * GetContext() override
Definition: constantValue.hpp:33
Definition: mathFunction.hpp:13