VertexCenteredVectorGrid2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: VertexCenteredVectorGrid2.h
3 > Project Name: CubbyFlow
4 > Author: Dongmin Kim
5 > Purpose: 2-D Vertex-centered vector grid structure.
6 > Created Time: 2017/08/04
7 > Copyright (c) 2018, Dongmin Kim
8 *************************************************************************/
9 #ifndef CUBBYFLOW_VERTEX_CENTERED_VECTOR_GRID2_H
10 #define CUBBYFLOW_VERTEX_CENTERED_VECTOR_GRID2_H
11 
13 
14 namespace CubbyFlow
15 {
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 initialValueU = 0.0, double initialValueV = 0.0);
41 
45  const Size2& resolution,
46  const Vector2D& gridSpacing = Vector2D(1.0, 1.0),
47  const Vector2D& origin = Vector2D(),
48  const Vector2D& initialValue = Vector2D());
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 VertexCenteredVectorGrid2& other);
71 
74 
76  void Fill(const Vector2D& value, ExecutionPolicy policy = ExecutionPolicy::Parallel) override;
77 
79  void Fill(const std::function<Vector2D(const Vector2D&)>& func, ExecutionPolicy policy = ExecutionPolicy::Parallel) override;
80 
82  std::shared_ptr<VectorGrid2> Clone() const override;
83 
85  static Builder GetBuilder();
86  };
87 
89  using VertexCenteredVectorGrid2Ptr = std::shared_ptr<VertexCenteredVectorGrid2>;
90 
93  {
94  public:
96  Builder& WithResolution(const Size2& resolution);
97 
99  Builder& WithResolution(size_t resolutionX, size_t resolutionY);
100 
102  Builder& WithGridSpacing(const Vector2D& gridSpacing);
103 
105  Builder& WithGridSpacing(double gridSpacingX, double gridSpacingY);
106 
108  Builder& WithOrigin(const Vector2D& gridOrigin);
109 
111  Builder& WithOrigin(double gridOriginX, double gridOriginY);
112 
114  Builder& WithInitialValue(double initialValU, double initialValV);
115 
118 
121 
128  const Size2& resolution,
129  const Vector2D& gridSpacing,
130  const Vector2D& gridOrigin,
131  const Vector2D& initialVal) const override;
132 
133  private:
134  Size2 m_resolution{ 1, 1 };
135  Vector2D m_gridSpacing{ 1, 1 };
136  Vector2D m_gridOrigin{ 0, 0 };
137  Vector2D m_initialVal{ 0, 0 };
138  };
139 }
140 
141 #endif
void Set(const VertexCenteredVectorGrid2 &other)
Sets the contents with the given other grid.
Abstract base class for 2-D vector grid builder.
Definition: VectorGrid2.h:93
Abstract base class for 2-D cartesian grid structure.
Definition: Grid2.h:30
Builder & WithInitialValue(double initialValU, double initialValV)
Returns builder with initial value.
VertexCenteredVectorGrid2()
Constructs zero-sized grid.
VertexCenteredVectorGrid2 Build() const
Builds VertexCenteredVectorGrid2 instance.
Builder & WithResolution(const Size2 &resolution)
Returns builder with resolution.
std::shared_ptr< VectorGrid2 > Clone() const override
Returns the copy of the grid instance.
2-D Vertex-centered vector grid structure.
Definition: VertexCenteredVectorGrid2.h:24
Abstract base class for 2-D collocated vector grid structure.
Definition: CollocatedVectorGrid2.h:19
2-D point class.
Definition: Point2.h:25
static Builder GetBuilder()
Returns builder fox VertexCenteredVectorGrid2.
Definition: pybind11Utils.h:24
std::shared_ptr< VectorGrid2 > VectorGrid2Ptr
Shared pointer for the VectorGrid2 type.
Definition: VectorGrid2.h:90
Vector2< double > Vector2D
Double-type 2D vector.
Definition: Vector2.h:341
Builder & WithOrigin(const Vector2D &gridOrigin)
Returns builder with grid origin.
Vector2D GetDataOrigin() const override
void Fill(const Vector2D &value, ExecutionPolicy policy=ExecutionPolicy::Parallel) override
Fills the grid with given value.
#define CUBBYFLOW_GRID2_TYPE_NAME(DerivedClassName)
Definition: Grid2.h:110
Size2 GetDataSize() const override
Returns the actual data point size.
2-D vector class.
Definition: Vector2.h:26
ExecutionPolicy
Execution policy tag.
Definition: Parallel.h:15
VertexCenteredVectorGrid2 & operator=(const VertexCenteredVectorGrid2 &other)
Sets the contents with the given other grid.
A grid builder class that returns 2-D vertex-centered Vector grid.
Definition: VertexCenteredVectorGrid2.h:92
std::shared_ptr< VertexCenteredVectorGrid2 > VertexCenteredVectorGrid2Ptr
Shared pointer for the VertexCenteredVectorGrid2 type.
Definition: VertexCenteredVectorGrid2.h:89
void Swap(Grid2 *other) override
Swaps the contents with the given other grid.
Builder & WithGridSpacing(const Vector2D &gridSpacing)
Returns builder with grid spacing.
VertexCenteredVectorGrid2Ptr MakeShared() const
Builds shared pointer of VertexCenteredVectorGrid2 instance.