VertexCenteredVectorGrid.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_VECTOR_GRID_HPP
12 #define CUBBYFLOW_VERTEX_CENTERED_VECTOR_GRID_HPP
13 
15 
16 namespace CubbyFlow
17 {
26 template <size_t N>
28 {
29  public:
31 
32  class Builder;
33 
40 
42  VertexCenteredVectorGrid() = default;
43 
47  const Vector<size_t, N>& resolution,
48  const Vector<double, N>& gridSpacing =
50  const Vector<double, N>& origin = Vector<double, N>{},
51  const Vector<double, N>& initialValue = Vector<double, N>{});
52 
54  ~VertexCenteredVectorGrid() override = default;
55 
58 
61 
64 
67  VertexCenteredVectorGrid&& other) noexcept;
68 
70  [[nodiscard]] Vector<size_t, N> DataSize() const override;
71 
75  [[nodiscard]] Vector<double, N> DataOrigin() const override;
76 
83  void Swap(Grid<N>* other) override;
84 
86  void Set(const VertexCenteredVectorGrid& other);
87 
89  void Fill(const Vector<double, N>& value,
90  ExecutionPolicy policy = ExecutionPolicy::Parallel) override;
91 
93  void Fill(
94  const std::function<Vector<double, N>(const Vector<double, N>&)>& func,
95  ExecutionPolicy policy = ExecutionPolicy::Parallel) override;
96 
98  [[nodiscard]] std::shared_ptr<VectorGrid<N>> Clone() const override;
99 
101  static Builder GetBuilder();
102 
103  protected:
106 };
107 
110 
113 
115 using VertexCenteredVectorGrid2Ptr = std::shared_ptr<VertexCenteredVectorGrid2>;
116 
118 using VertexCenteredVectorGrid3Ptr = std::shared_ptr<VertexCenteredVectorGrid3>;
119 
121 template <size_t N>
123 {
124  public:
126  Builder& WithResolution(const Vector<size_t, N>& resolution);
127 
129  Builder& WithGridSpacing(const Vector<double, N>& gridSpacing);
130 
132  Builder& WithOrigin(const Vector<double, N>& gridOrigin);
133 
135  Builder& WithInitialValue(const Vector<double, N>& initialVal);
136 
138  VertexCenteredVectorGrid Build() const;
139 
141  std::shared_ptr<VertexCenteredVectorGrid<N>> MakeShared() const;
142 
148  [[nodiscard]] std::shared_ptr<VectorGrid<N>> Build(
149  const Vector<size_t, N>& resolution,
150  const Vector<double, N>& gridSpacing,
151  const Vector<double, N>& gridOrigin,
152  const Vector<double, N>& initialVal) const override;
153 
154  private:
157  Vector<double, N> m_gridOrigin;
158  Vector<double, N> m_initialVal;
159 };
160 } // namespace CubbyFlow
161 
162 #endif
#define CUBBYFLOW_GRID_TYPE_NAME(DerivedClassName, N)
Definition: Grid.hpp:195
A grid builder class that returns N-D vertex-centered vector grid.
Definition: VertexCenteredVectorGrid.hpp:122
~VertexCenteredVectorGrid() override=default
Default virtual destructor.
void Set(const VertexCenteredVectorGrid &other)
Sets the contents with the given other grid.
N-D Vertex-centered vector grid structure.
Definition: VertexCenteredVectorGrid.hpp:27
Abstract base class for N-D cartesian grid structure.
Definition: Grid.hpp:58
Abstract base class for N-D vector grid builder.
Definition: VectorGrid.hpp:117
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
std::shared_ptr< VertexCenteredVectorGrid3 > VertexCenteredVectorGrid3Ptr
Shared pointer for the VertexCenteredVectorGrid3 type.
Definition: VertexCenteredVectorGrid.hpp:118
Definition: pybind11Utils.hpp:20
Vector< size_t, N > DataSize() const override
Returns the actual data point size.
VertexCenteredVectorGrid()=default
Constructs zero-sized grid.
std::shared_ptr< VectorGrid< N > > Clone() const override
Returns the copy of the grid instance.
VertexCenteredVectorGrid & operator=(const VertexCenteredVectorGrid &other)
Copy assignment operator.
static Builder GetBuilder()
Returns builder fox VertexCenteredVectorGrid.
Vector< double, N > DataOrigin() const override
void Fill(const Vector< double, N > &value, ExecutionPolicy policy=ExecutionPolicy::Parallel) override
Fills the grid with given value.
ExecutionPolicy
Execution policy tag.
Definition: Parallel.hpp:17
Abstract base class for N-D collocated vector grid structure.
Definition: CollocatedVectorGrid.hpp:22
std::shared_ptr< VertexCenteredVectorGrid2 > VertexCenteredVectorGrid2Ptr
Shared pointer for the VertexCenteredVectorGrid2 type.
Definition: VertexCenteredVectorGrid.hpp:115
void Swap(Grid< N > *other) override
Swaps the contents with the given other grid.