VertexCenteredScalarGrid.hpp
Go to the documentation of this file.
1 // This code is based on Jet framework.
2 // Copyright (c) 2018 Doyub Kim
3 // CubbyFlow is voxel-based fluid simulation engine for computer games.
4 // Copyright (c) 2020 CubbyFlow Team
5 // Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6 // AI Part: Dongheon Cho, Minseo Kim
7 // We are making my contributions/submissions to this project solely in our
8 // personal capacity and are not conveying any rights to any intellectual
9 // property of any third parties.
10 
11 #ifndef CUBBYFLOW_VERTEX_CENTERED_SCALAR_GRID_HPP
12 #define CUBBYFLOW_VERTEX_CENTERED_SCALAR_GRID_HPP
13 
14 #include <Core/Grid/ScalarGrid.hpp>
15 
16 namespace CubbyFlow
17 {
26 template <size_t N>
27 class VertexCenteredScalarGrid final : public ScalarGrid<N>
28 {
29  public:
31 
32  class Builder;
33 
37 
39  VertexCenteredScalarGrid() = default;
40 
44  const Vector<size_t, N>& resolution,
45  const Vector<double, N>& gridSpacing =
47  const Vector<double, N>& origin = Vector<double, N>{},
48  double initialValue = 0.0);
49 
51  ~VertexCenteredScalarGrid() override = default;
52 
55 
58 
61  const VertexCenteredScalarGrid& other);
62 
65  VertexCenteredScalarGrid&& other) noexcept;
66 
68  [[nodiscard]] Vector<size_t, N> DataSize() const override;
69 
73  [[nodiscard]] Vector<double, N> DataOrigin() const override;
74 
76  [[nodiscard]] std::shared_ptr<ScalarGrid<N>> Clone() const override;
77 
84  void Swap(Grid<N>* other) override;
85 
87  void Set(const VertexCenteredScalarGrid<N>& other);
88 
90  static Builder GetBuilder();
91 
92  protected:
95 };
96 
99 
102 
104 using VertexCenteredScalarGrid2Ptr = std::shared_ptr<VertexCenteredScalarGrid2>;
105 
107 using VertexCenteredScalarGrid3Ptr = std::shared_ptr<VertexCenteredScalarGrid3>;
108 
112 template <size_t N>
114 {
115  public:
117  Builder& WithResolution(const Vector<size_t, N>& resolution);
118 
120  Builder& WithGridSpacing(const Vector<double, N>& gridSpacing);
121 
123  Builder& WithOrigin(const Vector<double, N>& gridOrigin);
124 
126  Builder& WithInitialValue(double initialVal);
127 
129  VertexCenteredScalarGrid<N> Build() const;
130 
132  std::shared_ptr<VertexCenteredScalarGrid<N>> MakeShared() const;
133 
139  [[nodiscard]] std::shared_ptr<ScalarGrid<N>> Build(
140  const Vector<size_t, N>& resolution,
141  const Vector<double, N>& gridSpacing,
142  const Vector<double, N>& gridOrigin, double initialVal) const override;
143 
144  private:
147  Vector<double, N> m_gridOrigin;
148  double m_initialVal = 0.0;
149 };
150 } // namespace CubbyFlow
151 
152 #endif
std::shared_ptr< VertexCenteredScalarGrid3 > VertexCenteredScalarGrid3Ptr
Shared pointer for the VertexCenteredScalarGrid3 type.
Definition: VertexCenteredScalarGrid.hpp:107
#define CUBBYFLOW_GRID_TYPE_NAME(DerivedClassName, N)
Definition: Grid.hpp:195
Vector< size_t, N > DataSize() const override
Returns the actual data point size.
void Set(const VertexCenteredScalarGrid< N > &other)
Sets the contents with the given other grid.
VertexCenteredScalarGrid()=default
Constructs zero-sized grid.
Abstract base class for N-D scalar grid structure.
Definition: ScalarGrid.hpp:24
Front-end to create VertexCenteredScalarGrid objects step by step.
Definition: VertexCenteredScalarGrid.hpp:113
Abstract base class for N-D cartesian grid structure.
Definition: Grid.hpp:58
void Swap(Grid< N > *other) override
Swaps the contents with the given other grid.
N-D Vertex-centered scalar grid structure.
Definition: VertexCenteredScalarGrid.hpp:27
Definition: Matrix.hpp:27
static std::enable_if_t< IsMatrixSizeStatic< Rows, Cols >), D > MakeConstant(ValueType val)
Makes a static matrix with constant entries.
Definition: MatrixDenseBase-Impl.hpp:152
Definition: pybind11Utils.hpp:20
Abstract base class for N-D scalar grid builder.
Definition: ScalarGrid.hpp:273
VertexCenteredScalarGrid< N > & operator=(const VertexCenteredScalarGrid &other)
Copy assignment operator.
std::shared_ptr< ScalarGrid< N > > Clone() const override
Returns the copy of the grid instance.
static Builder GetBuilder()
Returns builder fox VertexCenteredScalarGrid<N>.
Vector< double, N > DataOrigin() const override
~VertexCenteredScalarGrid() override=default
Default virtual destructor.
std::shared_ptr< VertexCenteredScalarGrid2 > VertexCenteredScalarGrid2Ptr
Shared pointer for the VertexCenteredScalarGrid2 type.
Definition: VertexCenteredScalarGrid.hpp:104