CellCenteredScalarGrid2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: CellCenteredScalarGrid2.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 2-D Cell-centered scalar grid structure.
6 > Created Time: 2017/08/01
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_CELL_CENTERED_SCALAR_GRID2_H
10 #define CUBBYFLOW_CELL_CENTERED_SCALAR_GRID2_H
11 
12 #include <Core/Grid/ScalarGrid2.h>
13 
14 namespace CubbyFlow
15 {
24  class CellCenteredScalarGrid2 final : public ScalarGrid2
25  {
26  public:
28 
29  class Builder;
30 
33 
37  size_t resolutionX, size_t resolutionY,
38  double gridSpacingX = 1.0, double gridSpacingY = 1.0,
39  double originX = 0.0, double originY = 0.0,
40  double initialValue = 0.0);
41 
45  const Size2& resolution,
46  const Vector2D& gridSpacing = Vector2D(1.0, 1.0),
47  const Vector2D& origin = Vector2D(),
48  double initialValue = 0.0);
49 
52 
54  Size2 GetDataSize() const override;
55 
59  Vector2D GetDataOrigin() const override;
60 
67  void Swap(Grid2* other) override;
68 
70  void Set(const CellCenteredScalarGrid2& other);
71 
74 
76  std::shared_ptr<ScalarGrid2> Clone() const override;
77 
79  static Builder GetBuilder();
80  };
81 
83  using CellCenteredScalarGrid2Ptr = std::shared_ptr<CellCenteredScalarGrid2>;
84 
89  {
90  public:
92  Builder& WithResolution(const Size2& resolution);
93 
95  Builder& WithResolution(size_t resolutionX, size_t resolutionY);
96 
98  Builder& WithGridSpacing(const Vector2D& gridSpacing);
99 
101  Builder& WithGridSpacing(double gridSpacingX, double gridSpacingY);
102 
104  Builder& WithOrigin(const Vector2D& gridOrigin);
105 
107  Builder& WithOrigin(double gridOriginX, double gridOriginY);
108 
110  Builder& WithInitialValue(double initialVal);
111 
114 
117 
124  const Size2& resolution,
125  const Vector2D& gridSpacing,
126  const Vector2D& gridOrigin,
127  double initialVal) const override;
128 
129  private:
130  Size2 m_resolution{ 1, 1 };
131  Vector2D m_gridSpacing{ 1, 1 };
132  Vector2D m_gridOrigin{ 0, 0 };
133  double m_initialVal = 0.0;
134  };
135 }
136 
137 #endif
Builder & WithGridSpacing(const Vector2D &gridSpacing)
Returns builder with grid spacing.
Abstract base class for 2-D cartesian grid structure.
Definition: Grid2.h:30
Size2 GetDataSize() const override
Returns the actual data point size.
Builder & WithOrigin(const Vector2D &gridOrigin)
Returns builder with grid origin.
Front-end to create CellCenteredScalarGrid2 objects step by step.
Definition: CellCenteredScalarGrid2.h:88
Abstract base class for 2-D scalar grid builder.
Definition: ScalarGrid2.h:182
Vector2D GetDataOrigin() const override
CellCenteredScalarGrid2 & operator=(const CellCenteredScalarGrid2 &other)
Sets the contents with the given other grid.
2-D point class.
Definition: Point2.h:25
CellCenteredScalarGrid2 Build() const
Builds CellCenteredScalarGrid2 instance.
2-D Cell-centered scalar grid structure.
Definition: CellCenteredScalarGrid2.h:24
std::shared_ptr< ScalarGrid2 > Clone() const override
Returns the copy of the grid instance.
Builder & WithResolution(const Size2 &resolution)
Returns builder with resolution.
Definition: pybind11Utils.h:24
CellCenteredScalarGrid2()
Constructs zero-sized grid.
std::shared_ptr< ScalarGrid2 > ScalarGrid2Ptr
Shared pointer for the ScalarGrid2 type.
Definition: ScalarGrid2.h:179
Vector2< double > Vector2D
Double-type 2D vector.
Definition: Vector2.h:341
void Set(const CellCenteredScalarGrid2 &other)
Sets the contents with the given other grid.
std::shared_ptr< CellCenteredScalarGrid2 > CellCenteredScalarGrid2Ptr
Shared pointer for the CellCenteredScalarGrid2 type.
Definition: CellCenteredScalarGrid2.h:83
static Builder GetBuilder()
Returns builder fox CellCenteredScalarGrid2.
void Swap(Grid2 *other) override
Swaps the contents with the given other grid.
#define CUBBYFLOW_GRID2_TYPE_NAME(DerivedClassName)
Definition: Grid2.h:110
2-D vector class.
Definition: Vector2.h:26
Abstract base class for 2-D scalar grid structure.
Definition: ScalarGrid2.h:21
CellCenteredScalarGrid2Ptr MakeShared() const
Builds shared pointer of CellCenteredScalarGrid2 instance.
Builder & WithInitialValue(double initialVal)
Returns builder with initial value.