VertexCenteredVectorGrid3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: VertexCenteredVectorGrid3.h
3 > Project Name: CubbyFlow
4 > Author: Dongmin Kim
5 > Purpose: 3-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_GRID3_H
10 #define CUBBYFLOW_VERTEX_CENTERED_VECTOR_GRID3_H
11 
13 
14 namespace CubbyFlow
15 {
25  {
26  public:
28 
29  class Builder;
30 
33 
37  size_t resolutionX, size_t resolutionY, size_t resolutionZ,
38  double gridSpacingX = 1.0, double gridSpacingY = 1.0, double gridSpacingZ = 1.0,
39  double originX = 0.0, double originY = 0.0, double originZ = 0.0,
40  double initialValueU = 0.0, double initialValueV = 0.0, double initialValueW = 0.0);
41 
45  const Size3& resolution,
46  const Vector3D& gridSpacing = Vector3D(1.0, 1.0, 1.0),
47  const Vector3D& origin = Vector3D(),
48  const Vector3D& initialValue = Vector3D());
49 
52 
54  Size3 GetDataSize() const override;
55 
59  Vector3D GetDataOrigin() const override;
60 
67  void Swap(Grid3* other) override;
68 
70  void Set(const VertexCenteredVectorGrid3& other);
71 
74 
76  void Fill(const Vector3D& value, ExecutionPolicy policy = ExecutionPolicy::Parallel) override;
77 
79  void Fill(const std::function<Vector3D(const Vector3D&)>& func, ExecutionPolicy policy = ExecutionPolicy::Parallel) override;
80 
82  std::shared_ptr<VectorGrid3> Clone() const override;
83 
85  static Builder GetBuilder();
86  };
87 
89  using VertexCenteredVectorGrid3Ptr = std::shared_ptr<VertexCenteredVectorGrid3>;
90 
93  {
94  public:
96  Builder& WithResolution(const Size3& resolution);
97 
99  Builder& WithResolution(size_t resolutionX, size_t resolutionY, size_t resolutionZ);
100 
102  Builder& WithGridSpacing(const Vector3D& gridSpacing);
103 
105  Builder& WithGridSpacing(double gridSpacingX, double gridSpacingY, double gridSpacingZ);
106 
108  Builder& WithOrigin(const Vector3D& gridOrigin);
109 
111  Builder& WithOrigin(double gridOriginX, double gridOriginY, double gridOriginZ);
112 
114  Builder& WithInitialValue(double initialValU, double initialValV, double initialValW);
115 
118 
121 
128  const Size3& resolution,
129  const Vector3D& gridSpacing,
130  const Vector3D& gridOrigin,
131  const Vector3D& initialVal) const override;
132 
133  private:
134  Size3 m_resolution{ 1, 1, 1 };
135  Vector3D m_gridSpacing{ 1, 1, 1 };
136  Vector3D m_gridOrigin{ 0, 0, 0 };
137  Vector3D m_initialVal{ 0, 0, 0};
138  };
139 }
140 
141 #endif
3-D vector class.
Definition: Vector3.h:26
Abstract base class for 3-D cartesian grid structure.
Definition: Grid3.h:30
void Fill(const Vector3D &value, ExecutionPolicy policy=ExecutionPolicy::Parallel) override
Fills the grid with given value.
Abstract base class for 3-D collocated vector grid structure.
Definition: CollocatedVectorGrid3.h:19
void Swap(Grid3 *other) override
Swaps the contents with the given other grid.
Size3 GetDataSize() const override
Returns the actual data point size.
Abstract base class for 3-D vector grid builder.
Definition: VectorGrid3.h:93
Builder & WithGridSpacing(const Vector3D &gridSpacing)
Returns builder with grid spacing.
3-D Vertex-centered vector grid structure.
Definition: VertexCenteredVectorGrid3.h:24
Builder & WithResolution(const Size3 &resolution)
Returns builder with resolution.
VertexCenteredVectorGrid3 Build() const
Builds VertexCenteredVectorGrid3 instance.
#define CUBBYFLOW_GRID3_TYPE_NAME(DerivedClassName)
Definition: Grid3.h:116
Vector3D GetDataOrigin() const override
Builder & WithOrigin(const Vector3D &gridOrigin)
Returns builder with grid origin.
VertexCenteredVectorGrid3 & operator=(const VertexCenteredVectorGrid3 &other)
Sets the contents with the given other grid.
3-D point class.
Definition: Point3.h:26
A grid builder class that returns 3-D vertex-centered Vector grid.
Definition: VertexCenteredVectorGrid3.h:92
std::shared_ptr< VertexCenteredVectorGrid3 > VertexCenteredVectorGrid3Ptr
Shared pointer for the VertexCenteredVectorGrid3 type.
Definition: VertexCenteredVectorGrid3.h:89
void Set(const VertexCenteredVectorGrid3 &other)
Sets the contents with the given other grid.
Definition: pybind11Utils.h:24
static Builder GetBuilder()
Returns builder fox VertexCenteredVectorGrid3.
VertexCenteredVectorGrid3Ptr MakeShared() const
Builds shared pointer of VertexCenteredVectorGrid3 instance.
Builder & WithInitialValue(double initialValU, double initialValV, double initialValW)
Returns builder with initial value.
std::shared_ptr< VectorGrid3 > Clone() const override
Returns the copy of the grid instance.
ExecutionPolicy
Execution policy tag.
Definition: Parallel.h:15
std::shared_ptr< VectorGrid3 > VectorGrid3Ptr
Shared pointer for the VectorGrid3 type.
Definition: VectorGrid3.h:90
VertexCenteredVectorGrid3()
Constructs zero-sized grid.
Vector3< double > Vector3D
Double-type 3D vector.
Definition: Vector3.h:353