VectorGrid3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: VectorGrid3.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: Abstract base class for 3-D vector grid structure.
6 > Created Time: 2017/07/26
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_VECTOR_GRID3_H
10 #define CUBBYFLOW_VECTOR_GRID3_H
11 
14 #include <Core/Grid/Grid3.h>
15 
16 namespace CubbyFlow
17 {
19  class VectorGrid3 : public VectorField3, public Grid3
20  {
21  public:
24 
27 
29  VectorGrid3();
30 
32  virtual ~VectorGrid3();
33 
35  void Clear();
36 
38  void Resize(
39  size_t resolutionX, size_t resolutionY, size_t resolutionZ,
40  double gridSpacingX = 1.0, double gridSpacingY = 1.0, double gridSpacingZ = 1.0,
41  double originX = 0.0, double originY = 0.0, double originZ = 0.0,
42  double initialValueX = 0.0, double initialValueY = 0.0, double initialValueZ = 0.0);
43 
45  void Resize(
46  const Size3& resolution,
47  const Vector3D& gridSpacing = Vector3D(1, 1, 1),
48  const Vector3D& origin = Vector3D(),
49  const Vector3D& initialValue = Vector3D());
50 
52  void Resize(
53  double gridSpacingX, double gridSpacingY, double gridSpacingZ,
54  double originX, double originY, double originZ);
55 
57  void Resize(const Vector3D& gridSpacing, const Vector3D& origin);
58 
60  virtual void Fill(const Vector3D& value, ExecutionPolicy policy = ExecutionPolicy::Parallel) = 0;
61 
63  virtual void Fill(const std::function<Vector3D(const Vector3D&)>& func, ExecutionPolicy policy = ExecutionPolicy::Parallel) = 0;
64 
66  virtual std::shared_ptr<VectorGrid3> Clone() const = 0;
67 
69  void Serialize(std::vector<uint8_t>* buffer) const override;
70 
72  void Deserialize(const std::vector<uint8_t>& buffer) override;
73 
74  protected:
82  virtual void OnResize(
83  const Size3& resolution,
84  const Vector3D& gridSpacing,
85  const Vector3D& origin,
86  const Vector3D& initialValue) = 0;
87  };
88 
90  using VectorGrid3Ptr = std::shared_ptr<VectorGrid3>;
91 
94  {
95  public:
98 
100  virtual ~VectorGridBuilder3();
101 
103  virtual VectorGrid3Ptr Build(
104  const Size3& resolution,
105  const Vector3D& gridSpacing,
106  const Vector3D& gridOrigin,
107  const Vector3D& initialVal) const = 0;
108  };
109 
111  using VectorGridBuilder3Ptr = std::shared_ptr<VectorGridBuilder3>;
112 }
113 
114 #endif
void Resize(size_t resolutionX, size_t resolutionY, size_t resolutionZ, double gridSpacingX=1.0, double gridSpacingY=1.0, double gridSpacingZ=1.0, double originX=0.0, double originY=0.0, double originZ=0.0, double initialValueX=0.0, double initialValueY=0.0, double initialValueZ=0.0)
Resizes the grid using given parameters.
3-D vector class.
Definition: Vector3.h:26
Abstract base class for 3-D cartesian grid structure.
Definition: Grid3.h:30
3-D array accessor class.
Definition: ArrayAccessor3.h:31
3-D read-only array accessor class.
Definition: ArrayAccessor3.h:269
Abstract base class for 3-D vector grid builder.
Definition: VectorGrid3.h:93
VectorGrid3()
Constructs an empty grid.
void Clear()
Clears the contents of the grid.
virtual ~VectorGridBuilder3()
Default destructor.
3-D point class.
Definition: Point3.h:26
virtual ~VectorGrid3()
Default destructor.
virtual void OnResize(const Size3 &resolution, const Vector3D &gridSpacing, const Vector3D &origin, const Vector3D &initialValue)=0
Invoked when the resizing happens.
virtual VectorGrid3Ptr Build(const Size3 &resolution, const Vector3D &gridSpacing, const Vector3D &gridOrigin, const Vector3D &initialVal) const =0
Returns 3-D vector grid with given parameters.
Definition: pybind11Utils.h:24
Abstract base class for 3-D vector field.
Definition: VectorField3.h:21
void Serialize(std::vector< uint8_t > *buffer) const override
Serializes the grid instance to the output buffer.
virtual std::shared_ptr< VectorGrid3 > Clone() const =0
Returns the copy of the grid instance.
VectorGridBuilder3()
Creates a builder.
ExecutionPolicy
Execution policy tag.
Definition: Parallel.h:15
virtual void Fill(const Vector3D &value, ExecutionPolicy policy=ExecutionPolicy::Parallel)=0
Fills the grid with given value.
std::shared_ptr< VectorGrid3 > VectorGrid3Ptr
Shared pointer for the VectorGrid3 type.
Definition: VectorGrid3.h:90
Abstract base class for 3-D vector grid structure.
Definition: VectorGrid3.h:19
std::shared_ptr< VectorGridBuilder3 > VectorGridBuilder3Ptr
Shared pointer for the VectorGridBuilder3 type.
Definition: VectorGrid3.h:111
void Deserialize(const std::vector< uint8_t > &buffer) override
Deserializes the input buffer to the grid instance.
Vector3< double > Vector3D
Double-type 3D vector.
Definition: Vector3.h:353