ConstantScalarField.hpp
Go to the documentation of this file.
1 // This code is based on Jet framework.
2 // Copyright (c) 2018 Doyub Kim
3 // CubbyFlow is voxel-based fluid simulation engine for computer games.
4 // Copyright (c) 2020 CubbyFlow Team
5 // Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6 // AI Part: Dongheon Cho, Minseo Kim
7 // We are making my contributions/submissions to this project solely in our
8 // personal capacity and are not conveying any rights to any intellectual
9 // property of any third parties.
10 
11 #ifndef CUBBYFLOW_CONSTANT_SCALAR_FIELD_HPP
12 #define CUBBYFLOW_CONSTANT_SCALAR_FIELD_HPP
13 
15 
16 namespace CubbyFlow
17 {
19 template <size_t N>
20 class ConstantScalarField final : public ScalarField<N>
21 {
22  public:
23  class Builder;
24 
26  explicit ConstantScalarField(double value);
27 
29  [[nodiscard]] double Sample(const Vector<double, N>& x) const override;
30 
32  [[nodiscard]] std::function<double(const Vector<double, N>&)> Sampler()
33  const override;
34 
36  static Builder GetBuilder();
37 
38  private:
39  double m_value = 0.0;
40 };
41 
44 
47 
49 using ConstantScalarField2Ptr = std::shared_ptr<ConstantScalarField2>;
50 
52 using ConstantScalarField3Ptr = std::shared_ptr<ConstantScalarField3>;
53 
57 template <size_t N>
59 {
60  public:
62  Builder& WithValue(double value);
63 
65  ConstantScalarField Build() const;
66 
68  std::shared_ptr<ConstantScalarField> MakeShared() const;
69 
70  private:
71  double m_value = 0.0;
72 };
73 } // namespace CubbyFlow
74 
75 #endif
double Sample(const Vector< double, N > &x) const override
Returns the sampled value at given position x.
Abstract base class for N-D scalar field.
Definition: ScalarField.hpp:24
std::shared_ptr< ConstantScalarField3 > ConstantScalarField3Ptr
Shared pointer for the ConstantScalarField3 type.
Definition: ConstantScalarField.hpp:52
static Builder GetBuilder()
Returns builder for ConstantScalarField.
Definition: Matrix.hpp:27
Definition: pybind11Utils.hpp:20
N-D constant scalar field.
Definition: ConstantScalarField.hpp:20
ConstantScalarField(double value)
Constructs a constant scalar field with given value.
Front-end to create ConstantScalarField objects step by step.
Definition: ConstantScalarField.hpp:58
std::function< double(const Vector< double, N > &)> Sampler() const override
Returns the sampler function.
std::shared_ptr< ConstantScalarField2 > ConstantScalarField2Ptr
Shared pointer for the ConstantScalarField2 type.
Definition: ConstantScalarField.hpp:49