CellCenteredVectorGrid2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: CellCenteredVectorGrid2.h
3 > Project Name: CubbyFlow
4 > Author: Dongmin Kim
5 > Purpose: 2-D Cell-centered vector grid structure.
6 > Created Time: 2017/08/02
7 > Copyright (c) 2018, Dongmin Kim
8 *************************************************************************/
9 #ifndef CUBBYFLOW_CELL_CENTERED_VECTOR_GRID2_H
10 #define CUBBYFLOW_CELL_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 initalValueV = 0.0);
41 
45  const Size2& resolution,
46  const Vector2D& gridSpacing = Vector2D(1.0, 1.0),
47  const Vector2D& origin = Vector2D(),
48  const Vector2D& initalValue = Vector2D());
49 
52 
54  Size2 GetDataSize() const override;
55 
59  Vector2D GetDataOrigin() const override;
60 
62  std::shared_ptr<VectorGrid2> Clone() const override;
63 
70  void Swap(Grid2* other) override;
71 
73  void Fill(const Vector2D& value, ExecutionPolicy policy = ExecutionPolicy::Parallel) override;
74 
76  void Fill(const std::function<Vector2D(const Vector2D&)>& func, ExecutionPolicy policy = ExecutionPolicy::Parallel) override;
77 
79  void Set(const CellCenteredVectorGrid2& other);
80 
83 
85  static Builder GetBuilder();
86  };
87 
89  using CellCenteredVectorGrid2Ptr = std::shared_ptr<CellCenteredVectorGrid2>;
90 
95  {
96  public:
98  Builder& WithResolution(const Size2& resolution);
99 
101  Builder& WithResolution(size_t resolutionX, size_t resolutionY);
102 
104  Builder& WithGridSpacing(const Vector2D& gridSpacing);
105 
107  Builder& WithGridSpacing(double gridSpacingX, double gridSpacingY);
108 
110  Builder& WithOrigin(const Vector2D& gridOrigin);
111 
113  Builder& WithOrigin(double gridOriginX, double gridOriginY);
114 
116  Builder& WithInitialValue(const Vector2D& initalVal);
117 
119  Builder& WithInitialValue(double initialValX, double initialValY);
120 
123 
126 
133  const Size2& resolution,
134  const Vector2D& gridSpacing,
135  const Vector2D& gridOrigin,
136  const Vector2D& initalVal) const override;
137 
138  private:
139  Size2 m_resolution{ 1, 1 };
140  Vector2D m_gridSpacing{ 1, 1 };
141  Vector2D m_gridOrigin{ 0, 0 };
142  Vector2D m_initialVal{ 0, 0 };
143  };
144 }
145 
146 #endif
Builder & WithGridSpacing(const Vector2D &gridSpacing)
Returns builder with grid spacing.
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
CellCenteredVectorGrid2 & operator=(const CellCenteredVectorGrid2 &other)
Sets the contents with the given other gird.
std::shared_ptr< CellCenteredVectorGrid2 > CellCenteredVectorGrid2Ptr
Shared pointer for the CellCenteredVectorGrid2 type.
Definition: CellCenteredVectorGrid2.h:89
Size2 GetDataSize() const override
Returns the actual data point size.
void Set(const CellCenteredVectorGrid2 &other)
Sets the contents with the given other grid.
Abstract base class for 2-D collocated vector grid structure.
Definition: CollocatedVectorGrid2.h:19
2-D point class.
Definition: Point2.h:25
CUBBYFLOW_GRID2_TYPE_NAME(CellCenteredVectorGrid2)
void Swap(Grid2 *other) override
Swaps the contents with the given other grid.
Builder & WithResolution(const Size2 &resolution)
Returns builder with resolution.
2-D Cell-centered vector grid structure.
Definition: CellCenteredVectorGrid2.h:24
CellCenteredVectorGrid2 Build() const
Builds CellCenteredVectorGrid2 instance.
Definition: pybind11Utils.h:24
Builder & WithInitialValue(const Vector2D &initalVal)
Returns builder with initial value.
std::shared_ptr< VectorGrid2 > VectorGrid2Ptr
Shared pointer for the VectorGrid2 type.
Definition: VectorGrid2.h:90
void Fill(const Vector2D &value, ExecutionPolicy policy=ExecutionPolicy::Parallel) override
Fills the grid with given value.
Vector2< double > Vector2D
Double-type 2D vector.
Definition: Vector2.h:341
Front-end to create CellCenteredVectorGrid2 objects step by step.
Definition: CellCenteredVectorGrid2.h:94
Builder & WithOrigin(const Vector2D &gridOrigin)
Returns builder with grid origin.
2-D vector class.
Definition: Vector2.h:26
ExecutionPolicy
Execution policy tag.
Definition: Parallel.h:15
std::shared_ptr< VectorGrid2 > Clone() const override
Returns the copy of the grid instance.
CellCenteredVectorGrid2()
Constructs zero-sized grid.
CellCenteredVectorGrid2Ptr MakeShared() const
Builds shared pointer of CellCenteredScalarGrid2 instance.
Vector2D GetDataOrigin() const override
static Builder GetBuilder()
Returns the builder fox CellCenteredVectorGrid2.