VertexCenteredScalarGrid3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: VertexCenteredScalarGrid3.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 3-D Vertex-centered scalar grid structure.
6 > Created Time: 2017/07/08
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_VERTEX_CENTERED_SCALAR_GRID3_H
10 #define CUBBYFLOW_VERTEX_CENTERED_SCALAR_GRID3_H
11 
12 #include <Core/Grid/ScalarGrid3.h>
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 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 VertexCenteredScalarGrid3& other);
74 
77 
79  static Builder GetBuilder();
80  };
81 
83  using VertexCenteredScalarGrid3Ptr = std::shared_ptr<VertexCenteredScalarGrid3>;
84 
87  {
88  public:
90  Builder& WithResolution(const Size3& resolution);
91 
93  Builder& WithResolution(size_t resolutionX, size_t resolutionY, size_t resolutionZ);
94 
96  Builder& WithGridSpacing(const Vector3D& gridSpacing);
97 
99  Builder& WithGridSpacing(double gridSpacingX, double gridSpacingY, double gridSpacingZ);
100 
102  Builder& WithOrigin(const Vector3D& gridOrigin);
103 
105  Builder& WithOrigin(double gridOriginX, double gridOriginY, double gridOriginZ);
106 
108  Builder& WithInitialValue(double initialVal);
109 
112 
115 
122  const Size3& resolution,
123  const Vector3D& gridSpacing,
124  const Vector3D& gridOrigin,
125  double initialVal) const override;
126 
127  private:
128  Size3 m_resolution{ 1, 1, 1 };
129  Vector3D m_gridSpacing{ 1, 1, 1 };
130  Vector3D m_gridOrigin{ 0, 0, 0 };
131  double m_initialVal = 0.0;
132  };
133 }
134 
135 #endif
std::shared_ptr< VertexCenteredScalarGrid3 > VertexCenteredScalarGrid3Ptr
Shared pointer for the VertexCenteredScalarGrid3 type.
Definition: VertexCenteredScalarGrid3.h:83
3-D vector class.
Definition: Vector3.h:26
Abstract base class for 3-D cartesian grid structure.
Definition: Grid3.h:30
3-D Vertex-centered scalar grid structure.
Definition: VertexCenteredScalarGrid3.h:24
static Builder GetBuilder()
Returns builder fox VertexCenteredScalarGrid3.
#define CUBBYFLOW_GRID3_TYPE_NAME(DerivedClassName)
Definition: Grid3.h:116
VertexCenteredScalarGrid3()
Constructs zero-sized grid.
Builder & WithResolution(const Size3 &resolution)
Returns builder with resolution.
3-D point class.
Definition: Point3.h:26
VertexCenteredScalarGrid3Ptr MakeShared() const
Builds shared pointer of VertexCenteredScalarGrid3 instance.
std::shared_ptr< ScalarGrid3 > ScalarGrid3Ptr
Shared pointer for the ScalarGrid3 type.
Definition: ScalarGrid3.h:179
Size3 GetDataSize() const override
Returns the actual data point size.
A grid builder class that returns 3-D vertex-centered scalar grid.
Definition: VertexCenteredScalarGrid3.h:86
Abstract base class for 3-D scalar grid builder.
Definition: ScalarGrid3.h:182
Builder & WithGridSpacing(const Vector3D &gridSpacing)
Returns builder with grid spacing.
Definition: pybind11Utils.h:24
void Set(const VertexCenteredScalarGrid3 &other)
Sets the contents with the given other grid.
Abstract base class for 3-D scalar grid structure.
Definition: ScalarGrid3.h:21
VertexCenteredScalarGrid3 & operator=(const VertexCenteredScalarGrid3 &other)
Sets the contents with the given other grid.
std::shared_ptr< ScalarGrid3 > Clone() const override
Returns the copy of the grid instance.
Vector3D GetDataOrigin() const override
void Swap(Grid3 *other) override
Swaps the contents with the given other grid.
VertexCenteredScalarGrid3 Build() const
Builds VertexCenteredScalarGrid3 instance.
Builder & WithInitialValue(double initialVal)
Returns builder with initial value.
Vector3< double > Vector3D
Double-type 3D vector.
Definition: Vector3.h:353
Builder & WithOrigin(const Vector3D &gridOrigin)
Returns builder with grid origin.