ConstantScalarField2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: ConstantScalarField2.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 2-D constant scalar field.
6 > Created Time: 2017/04/01
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_CONSTANT_SCALAR_FIELD2_H
10 #define CUBBYFLOW_CONSTANT_SCALAR_FIELD2_H
11 
13 
14 namespace CubbyFlow
15 {
17  class ConstantScalarField2 final : public ScalarField2
18  {
19  public:
20  class Builder;
21 
23  explicit ConstantScalarField2(double value);
24 
26  double Sample(const Vector2D& x) const override;
27 
29  std::function<double(const Vector2D&)> Sampler() const override;
30 
32  static Builder GetBuilder();
33 
34  private:
35  double m_value = 0.0;
36  };
37 
39  using ConstantScalarField2Ptr = std::shared_ptr<ConstantScalarField2>;
40 
45  {
46  public:
48  Builder& WithValue(double value);
49 
52 
55 
56  private:
57  double m_value = 0.0;
58  };
59 }
60 
61 #endif
Abstract base class for 2-D scalar field.
Definition: ScalarField2.h:21
std::function< double(const Vector2D &)> Sampler() const override
Returns the sampler function.
Builder & WithValue(double value)
Returns builder with value.
double Sample(const Vector2D &x) const override
Returns the sampled value at given position x.
Definition: pybind11Utils.h:24
ConstantScalarField2Ptr MakeShared() const
Builds shared pointer of ConstantScalarField2 instance.
2-D constant scalar field.
Definition: ConstantScalarField2.h:17
ConstantScalarField2 Build() const
Builds ConstantScalarField2.
2-D vector class.
Definition: Vector2.h:26
ConstantScalarField2(double value)
Constructs a constant scalar field with given value.
static Builder GetBuilder()
Returns builder fox ConstantScalarField2.
Front-end to create ConstantScalarField2 objects step by step.
Definition: ConstantScalarField2.h:44
std::shared_ptr< ConstantScalarField2 > ConstantScalarField2Ptr
Shared pointer for the ConstantScalarField2 type.
Definition: ConstantScalarField2.h:39