GridSystemData3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: GridSystemData3.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 3-D grid system data.
6 > Created Time: 2017/08/05
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_GRID_SYSTM_DATA3_H
10 #define CUBBYFLOW_GRID_SYSTM_DATA3_H
11 
13 #include <Core/Grid/ScalarGrid3.h>
15 
16 namespace CubbyFlow
17 {
27  {
28  public:
31 
47  GridSystemData3(const Size3& resolution, const Vector3D& gridSpacing, const Vector3D& origin);
48 
50  GridSystemData3(const GridSystemData3& other);
51 
53  virtual ~GridSystemData3();
54 
70  void Resize(const Size3& resolution, const Vector3D& gridSpacing, const Vector3D& origin);
71 
84  Size3 GetResolution() const;
85 
87  Vector3D GetGridSpacing() const;
88 
90  Vector3D GetOrigin() const;
91 
94 
109  size_t AddScalarData(const ScalarGridBuilder3Ptr& builder, double initialVal = 0.0);
110 
125  size_t AddVectorData(const VectorGridBuilder3Ptr& builder, const Vector3D& initialVal = Vector3D());
126 
141  size_t AddAdvectableScalarData(const ScalarGridBuilder3Ptr& builder, double initialVal = 0.0);
142 
157  size_t AddAdvectableVectorData(const VectorGridBuilder3Ptr& builder, const Vector3D& initialVal = Vector3D());
158 
167  const FaceCenteredGrid3Ptr& GetVelocity() const;
168 
178  size_t GetVelocityIndex() const;
179 
181  const ScalarGrid3Ptr& GetScalarDataAt(size_t idx) const;
182 
184  const VectorGrid3Ptr& GetVectorDataAt(size_t idx) const;
185 
187  const ScalarGrid3Ptr& GetAdvectableScalarDataAt(size_t idx) const;
188 
190  const VectorGrid3Ptr& 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  Size3 m_resolution;
212  Vector3D m_gridSpacing;
213  Vector3D m_origin;
214 
215  FaceCenteredGrid3Ptr m_velocity;
216  size_t m_velocityIdx;
217  std::vector<ScalarGrid3Ptr> m_scalarDataList;
218  std::vector<VectorGrid3Ptr> m_vectorDataList;
219  std::vector<ScalarGrid3Ptr> m_advectableScalarDataList;
220  std::vector<VectorGrid3Ptr> m_advectableVectorDataList;
221  };
222 
224  using GridSystemData3Ptr = std::shared_ptr<GridSystemData3>;
225 }
226 
227 #endif
3-D vector class.
Definition: Vector3.h:26
Abstract base class for any serializable class.
Definition: Serialization.h:20
GridSystemData3()
Constructs empty grid system.
size_t GetNumberOfAdvectableScalarData() const
Returns the number of advectable scalar data.
size_t AddVectorData(const VectorGridBuilder3Ptr &builder, const Vector3D &initialVal=Vector3D())
Adds a non-advectable vector data grid by passing its builder and initial value.
size_t GetNumberOfScalarData() const
Returns the number of non-advectable scalar data.
BoundingBox3D GetBoundingBox() const
Returns the bounding box of the grid.
size_t GetVelocityIndex() const
Returns the index of the velocity field.
3-D grid system data.
Definition: GridSystemData3.h:26
Vector3D GetOrigin() const
Returns the origin of the grid.
const FaceCenteredGrid3Ptr & GetVelocity() const
Returns the velocity field.
3-D point class.
Definition: Point3.h:26
std::shared_ptr< ScalarGrid3 > ScalarGrid3Ptr
Shared pointer for the ScalarGrid3 type.
Definition: ScalarGrid3.h:179
size_t GetNumberOfVectorData() const
Returns the number of non-advectable vector data.
std::shared_ptr< FaceCenteredGrid3 > FaceCenteredGrid3Ptr
Shared pointer type for the FaceCenteredGrid3.
Definition: FaceCenteredGrid3.h:276
const ScalarGrid3Ptr & GetAdvectableScalarDataAt(size_t idx) const
Returns the advectable scalar data at given index.
size_t GetNumberOfAdvectableVectorData() const
Returns the number of advectable vector data.
const VectorGrid3Ptr & GetAdvectableVectorDataAt(size_t idx) const
Returns the advectable vector data at given index.
virtual ~GridSystemData3()
Destructor.
const VectorGrid3Ptr & GetVectorDataAt(size_t idx) const
Returns the non-advectable vector data at given index.
Definition: pybind11Utils.h:24
void Serialize(std::vector< uint8_t > *buffer) const override
Serialize the data to the given buffer.
std::shared_ptr< ScalarGridBuilder3 > ScalarGridBuilder3Ptr
Shared pointer for the ScalarGridBuilder3 type.
Definition: ScalarGrid3.h:200
3-D axis-aligned bounding box class.
Definition: BoundingBox3.h:44
size_t AddScalarData(const ScalarGridBuilder3Ptr &builder, double initialVal=0.0)
Adds a non-advectable scalar data grid by passing its builder and initial value.
std::shared_ptr< GridSystemData3 > GridSystemData3Ptr
Shared pointer type of GridSystemData3.
Definition: GridSystemData3.h:224
size_t AddAdvectableScalarData(const ScalarGridBuilder3Ptr &builder, double initialVal=0.0)
Adds an advectable scalar data grid by passing its builder and initial value.
Vector3D GetGridSpacing() const
Return the grid spacing.
size_t AddAdvectableVectorData(const VectorGridBuilder3Ptr &builder, const Vector3D &initialVal=Vector3D())
Adds an advectable vector data grid by passing its builder and initial value.
void Deserialize(const std::vector< uint8_t > &buffer) override
Serialize the data from the given buffer.
std::shared_ptr< VectorGrid3 > VectorGrid3Ptr
Shared pointer for the VectorGrid3 type.
Definition: VectorGrid3.h:90
std::shared_ptr< VectorGridBuilder3 > VectorGridBuilder3Ptr
Shared pointer for the VectorGridBuilder3 type.
Definition: VectorGrid3.h:111
Size3 GetResolution() const
Returns the resolution of the grid.
void Resize(const Size3 &resolution, const Vector3D &gridSpacing, const Vector3D &origin)
Resizes the whole system with given resolution, grid spacing, and origin.
const ScalarGrid3Ptr & GetScalarDataAt(size_t idx) const
Returns the non-advectable scalar data at given index.
Vector3< double > Vector3D
Double-type 3D vector.
Definition: Vector3.h:353