GridSystemData2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: GridSystemData2.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 2-D grid system data.
6 > Created Time: 2017/08/05
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_GRID_SYSTM_DATA2_H
10 #define CUBBYFLOW_GRID_SYSTM_DATA2_H
11 
13 #include <Core/Grid/ScalarGrid2.h>
15 
16 namespace CubbyFlow
17 {
27  {
28  public:
31 
47  GridSystemData2(const Size2& resolution, const Vector2D& gridSpacing, const Vector2D& origin);
48 
50  GridSystemData2(const GridSystemData2& other);
51 
53  virtual ~GridSystemData2();
54 
70  void Resize(const Size2& resolution, const Vector2D& gridSpacing, const Vector2D& origin);
71 
84  Size2 GetResolution() const;
85 
87  Vector2D GetGridSpacing() const;
88 
90  Vector2D GetOrigin() const;
91 
94 
109  size_t AddScalarData(const ScalarGridBuilder2Ptr& builder, double initialVal = 0.0);
110 
125  size_t AddVectorData(const VectorGridBuilder2Ptr& builder, const Vector2D& initialVal = Vector2D());
126 
141  size_t AddAdvectableScalarData(const ScalarGridBuilder2Ptr& builder, double initialVal = 0.0);
142 
157  size_t AddAdvectableVectorData(const VectorGridBuilder2Ptr& builder, const Vector2D& initialVal = Vector2D());
158 
167  const FaceCenteredGrid2Ptr& GetVelocity() const;
168 
178  size_t GetVelocityIndex() const;
179 
181  const ScalarGrid2Ptr& GetScalarDataAt(size_t idx) const;
182 
184  const VectorGrid2Ptr& GetVectorDataAt(size_t idx) const;
185 
187  const ScalarGrid2Ptr& GetAdvectableScalarDataAt(size_t idx) const;
188 
190  const VectorGrid2Ptr& GetAdvectableVectorDataAt(size_t idx) const;
191 
193  size_t GetNumberOfScalarData() const;
194 
196  size_t GetNumberOfVectorData() const;
197 
199  size_t GetNumberOfAdvectableScalarData() const;
200 
202  size_t GetNumberOfAdvectableVectorData() const;
203 
205  void Serialize(std::vector<uint8_t>* buffer) const override;
206 
208  void Deserialize(const std::vector<uint8_t>& buffer) override;
209 
210  private:
211  Size2 m_resolution;
212  Vector2D m_gridSpacing;
213  Vector2D m_origin;
214 
215  FaceCenteredGrid2Ptr m_velocity;
216  size_t m_velocityIdx;
217  std::vector<ScalarGrid2Ptr> m_scalarDataList;
218  std::vector<VectorGrid2Ptr> m_vectorDataList;
219  std::vector<ScalarGrid2Ptr> m_advectableScalarDataList;
220  std::vector<VectorGrid2Ptr> m_advectableVectorDataList;
221  };
222 
224  using GridSystemData2Ptr = std::shared_ptr<GridSystemData2>;
225 }
226 
227 #endif
void Resize(const Size2 &resolution, const Vector2D &gridSpacing, const Vector2D &origin)
Resizes the whole system with given resolution, grid spacing, and origin.
size_t AddAdvectableScalarData(const ScalarGridBuilder2Ptr &builder, double initialVal=0.0)
Adds an advectable scalar data grid by passing its builder and initial value.
Abstract base class for any serializable class.
Definition: Serialization.h:20
void Deserialize(const std::vector< uint8_t > &buffer) override
Serialize the data from the given buffer.
const VectorGrid2Ptr & GetVectorDataAt(size_t idx) const
Returns the non-advectable vector data at given index.
BoundingBox2D GetBoundingBox() const
Returns the bounding box of the grid.
size_t AddAdvectableVectorData(const VectorGridBuilder2Ptr &builder, const Vector2D &initialVal=Vector2D())
Adds an advectable vector data grid by passing its builder and initial value.
Size2 GetResolution() const
Returns the resolution of the grid.
Vector2D GetOrigin() const
Returns the origin of the grid.
2-D point class.
Definition: Point2.h:25
std::shared_ptr< GridSystemData2 > GridSystemData2Ptr
Shared pointer type of GridSystemData2.
Definition: GridSystemData2.h:224
const VectorGrid2Ptr & GetAdvectableVectorDataAt(size_t idx) const
Returns the advectable vector data at given index.
GridSystemData2()
Constructs empty grid system.
size_t AddScalarData(const ScalarGridBuilder2Ptr &builder, double initialVal=0.0)
Adds a non-advectable scalar data grid by passing its builder and initial value.
2-D axis-aligned bounding box class.
Definition: BoundingBox2.h:44
Definition: pybind11Utils.h:24
2-D grid system data.
Definition: GridSystemData2.h:26
const ScalarGrid2Ptr & GetScalarDataAt(size_t idx) const
Returns the non-advectable scalar data at given index.
std::shared_ptr< VectorGrid2 > VectorGrid2Ptr
Shared pointer for the VectorGrid2 type.
Definition: VectorGrid2.h:90
virtual ~GridSystemData2()
Destructor.
std::shared_ptr< ScalarGrid2 > ScalarGrid2Ptr
Shared pointer for the ScalarGrid2 type.
Definition: ScalarGrid2.h:179
size_t AddVectorData(const VectorGridBuilder2Ptr &builder, const Vector2D &initialVal=Vector2D())
Adds a non-advectable vector data grid by passing its builder and initial value.
Vector2< double > Vector2D
Double-type 2D vector.
Definition: Vector2.h:341
void Serialize(std::vector< uint8_t > *buffer) const override
Serialize the data to the given buffer.
size_t GetNumberOfVectorData() const
Returns the number of non-advectable vector data.
const ScalarGrid2Ptr & GetAdvectableScalarDataAt(size_t idx) const
Returns the advectable scalar data at given index.
size_t GetVelocityIndex() const
Returns the index of the velocity field.
std::shared_ptr< FaceCenteredGrid2 > FaceCenteredGrid2Ptr
Shared pointer type for the FaceCenteredGrid2.
Definition: FaceCenteredGrid2.h:228
size_t GetNumberOfScalarData() const
Returns the number of non-advectable scalar data.
2-D vector class.
Definition: Vector2.h:26
std::shared_ptr< VectorGridBuilder2 > VectorGridBuilder2Ptr
Shared pointer for the VectorGridBuilder2 type.
Definition: VectorGrid2.h:111
std::shared_ptr< ScalarGridBuilder2 > ScalarGridBuilder2Ptr
Shared pointer for the ScalarGridBuilder2 type.
Definition: ScalarGrid2.h:200
size_t GetNumberOfAdvectableVectorData() const
Returns the number of advectable vector data.
const FaceCenteredGrid2Ptr & GetVelocity() const
Returns the velocity field.
size_t GetNumberOfAdvectableScalarData() const
Returns the number of advectable scalar data.
Vector2D GetGridSpacing() const
Return the grid spacing.