CellCenteredScalarGrid3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: CellCenteredScalarGrid3.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 3-D Cell-centered scalar grid structure.
6 > Created Time: 2017/08/01
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_CELL_CENTERED_SCALAR_GRID3_H
10 #define CUBBYFLOW_CELL_CENTERED_SCALAR_GRID3_H
11 
12 #include <Core/Grid/ScalarGrid3.h>
13 
14 namespace CubbyFlow
15 {
24  class CellCenteredScalarGrid3 final : public ScalarGrid3
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 initialValue = 0.0);
41 
45  const Size3& resolution,
46  const Vector3D& gridSpacing = Vector3D(1.0, 1.0, 1.0),
47  const Vector3D& origin = Vector3D(),
48  double initialValue = 0.0);
49 
52 
54  Size3 GetDataSize() const override;
55 
59  Vector3D GetDataOrigin() const override;
60 
62  std::shared_ptr<ScalarGrid3> Clone() const override;
63 
70  void Swap(Grid3* other) override;
71 
73  void Set(const CellCenteredScalarGrid3& other);
74 
77 
79  static Builder GetBuilder();
80  };
81 
83  using CellCenteredScalarGrid3Ptr = std::shared_ptr<CellCenteredScalarGrid3>;
84 
89  {
90  public:
92  Builder& WithResolution(const Size3& resolution);
93 
95  Builder& WithResolution(size_t resolutionX, size_t resolutionY, size_t resolutionZ);
96 
98  Builder& WithGridSpacing(const Vector3D& gridSpacing);
99 
101  Builder& WithGridSpacing(double gridSpacingX, double gridSpacingY, double gridSpacingZ);
102 
104  Builder& WithOrigin(const Vector3D& gridOrigin);
105 
107  Builder& WithOrigin(double gridOriginX, double gridOriginY, double gridOriginZ);
108 
110  Builder& WithInitialValue(double initialVal);
111 
114 
117 
124  const Size3& resolution,
125  const Vector3D& gridSpacing,
126  const Vector3D& gridOrigin,
127  double initialVal) const override;
128 
129  private:
130  Size3 m_resolution{ 1, 1, 1 };
131  Vector3D m_gridSpacing{ 1, 1, 1 };
132  Vector3D m_gridOrigin{ 0, 0, 0 };
133  double m_initialVal = 0.0;
134  };
135 }
136 
137 #endif
3-D vector class.
Definition: Vector3.h:26
Abstract base class for 3-D cartesian grid structure.
Definition: Grid3.h:30
std::shared_ptr< ScalarGrid3 > Clone() const override
Returns the copy of the grid instance.
std::shared_ptr< CellCenteredScalarGrid3 > CellCenteredScalarGrid3Ptr
Shared pointer for the CellCenteredScalarGrid3 type.
Definition: CellCenteredScalarGrid3.h:83
Builder & WithResolution(const Size3 &resolution)
Returns builder with resolution.
3-D Cell-centered scalar grid structure.
Definition: CellCenteredScalarGrid3.h:24
Builder & WithOrigin(const Vector3D &gridOrigin)
Returns builder with grid origin.
static Builder GetBuilder()
Returns builder fox CellCenteredScalarGrid3.
#define CUBBYFLOW_GRID3_TYPE_NAME(DerivedClassName)
Definition: Grid3.h:116
3-D point class.
Definition: Point3.h:26
std::shared_ptr< ScalarGrid3 > ScalarGrid3Ptr
Shared pointer for the ScalarGrid3 type.
Definition: ScalarGrid3.h:179
Vector3D GetDataOrigin() const override
Abstract base class for 3-D scalar grid builder.
Definition: ScalarGrid3.h:182
CellCenteredScalarGrid3()
Constructs zero-sized grid.
Definition: pybind11Utils.h:24
void Swap(Grid3 *other) override
Swaps the contents with the given other grid.
Builder & WithGridSpacing(const Vector3D &gridSpacing)
Returns builder with grid spacing.
void Set(const CellCenteredScalarGrid3 &other)
Sets the contents with the given other grid.
Abstract base class for 3-D scalar grid structure.
Definition: ScalarGrid3.h:21
CellCenteredScalarGrid3 & operator=(const CellCenteredScalarGrid3 &other)
Sets the contents with the given other grid.
CellCenteredScalarGrid3 Build() const
Builds CellCenteredScalarGrid3 instance.
Size3 GetDataSize() const override
Returns the actual data point size.
Front-end to create CellCenteredScalarGrid3 objects step by step.
Definition: CellCenteredScalarGrid3.h:88
CellCenteredScalarGrid3Ptr MakeShared() const
Builds shared pointer of CellCenteredScalarGrid3 instance.
Builder & WithInitialValue(double initialVal)
Returns builder with initial value.
Vector3< double > Vector3D
Double-type 3D vector.
Definition: Vector3.h:353