CellCenteredVectorGrid3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: CellCenteredVectorGrid3.h
3 > Project Name: CubbyFlow
4 > Author: Dongmin Kim
5 > Purpose: 3-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_GRID3_H
10 #define CUBBYFLOW_CELL_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 initalValueV = 0.0, double initalValueZ = 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& initalValue = Vector3D());
49 
52 
54  Size3 GetDataSize() const override;
55 
59  Vector3D GetDataOrigin() const override;
60 
62  std::shared_ptr<VectorGrid3> Clone() const override;
63 
70  void Swap(Grid3* other) override;
71 
73  void Fill(const Vector3D& value, ExecutionPolicy policy = ExecutionPolicy::Parallel) override;
74 
76  void Fill(const std::function<Vector3D(const Vector3D&)>& func, ExecutionPolicy policy = ExecutionPolicy::Parallel) override;
77 
79  void Set(const CellCenteredVectorGrid3& other);
80 
83 
85  static Builder GetBuilder();
86  };
87 
89  using CellCenteredVectorGrid3Ptr = std::shared_ptr<CellCenteredVectorGrid3>;
90 
95  {
96  public:
98  Builder& WithResolution(const Size3& resolution);
99 
101  Builder& WithResolution(size_t resolutionX, size_t resolutionY, size_t resolutionZ);
102 
104  Builder& WithGridSpacing(const Vector3D& gridSpacing);
105 
107  Builder& WithGridSpacing(double gridSpacingX, double gridSpacingY, double gridSpacingZ);
108 
110  Builder& WithOrigin(const Vector3D& gridOrigin);
111 
113  Builder& WithOrigin(double gridOriginX, double gridOriginY, double gridOriginZ);
114 
116  Builder& WithInitialValue(const Vector3D& initalVal);
117 
119  Builder& WithInitialValue(double initialValX, double initalValY, double initalValZ);
120 
123 
126 
133  const Size3& resolution,
134  const Vector3D& gridSpacing,
135  const Vector3D& gridOrigin,
136  const Vector3D& initalVal) const override;
137 
138  private:
139  Size3 m_resolution{ 1, 1, 1 };
140  Vector3D m_gridSpacing{ 1, 1, 1 };
141  Vector3D m_gridOrigin{ 0, 0, 0 };
142  Vector3D m_initialVal{ 0, 0, 0 };
143  };
144 }
145 
146 #endif
3-D vector class.
Definition: Vector3.h:26
Abstract base class for 3-D cartesian grid structure.
Definition: Grid3.h:30
Abstract base class for 3-D collocated vector grid structure.
Definition: CollocatedVectorGrid3.h:19
void Fill(const Vector3D &value, ExecutionPolicy policy=ExecutionPolicy::Parallel) override
Fills the grid with given value.
std::shared_ptr< VectorGrid3 > Clone() const override
Returns the copy of the grid instance.
Vector3D GetDataOrigin() const override
Abstract base class for 3-D vector grid builder.
Definition: VectorGrid3.h:93
static Builder GetBuilder()
Returns the builder fox CellCenteredVectorGrid3.
Size3 GetDataSize() const override
Returns the actual data point size.
std::shared_ptr< CellCenteredVectorGrid3 > CellCenteredVectorGrid3Ptr
Shared pointer for the CellCenteredVectorGrid3 type.
Definition: CellCenteredVectorGrid3.h:89
Builder & WithOrigin(const Vector3D &gridOrigin)
Returns builder with grid origin.
3-D Cell-centered vector grid structure.
Definition: CellCenteredVectorGrid3.h:24
Front-end to create CellCenteredVectorGrid3 objects step by step.
Definition: CellCenteredVectorGrid3.h:94
CellCenteredVectorGrid3 & operator=(const CellCenteredVectorGrid3 &other)
Sets the contents with the given other gird.
CellCenteredVectorGrid3Ptr MakeShared() const
Builds shared pointer of CellCenteredScalarGrid3 instance.
3-D point class.
Definition: Point3.h:26
Builder & WithGridSpacing(const Vector3D &gridSpacing)
Returns builder with grid spacing.
Definition: pybind11Utils.h:24
CellCenteredVectorGrid3 Build() const
Builds CellCenteredVectorGrid3 instance.
CellCenteredVectorGrid3()
Constructs zero-sized grid.
Builder & WithResolution(const Size3 &resolution)
Returns builder with resolution.
CUBBYFLOW_GRID3_TYPE_NAME(CellCenteredVectorGrid3)
ExecutionPolicy
Execution policy tag.
Definition: Parallel.h:15
std::shared_ptr< VectorGrid3 > VectorGrid3Ptr
Shared pointer for the VectorGrid3 type.
Definition: VectorGrid3.h:90
void Swap(Grid3 *other) override
Swaps the contents with the given other grid.
void Set(const CellCenteredVectorGrid3 &other)
Sets the contents with the given other grid.
Builder & WithInitialValue(const Vector3D &initalVal)
Returns builder with initial value.
Vector3< double > Vector3D
Double-type 3D vector.
Definition: Vector3.h:353