CUDASPHSystemData2.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_CUDA_SPH_SYSTEM_DATA2_HPP
12 #define CUBBYFLOW_CUDA_SPH_SYSTEM_DATA2_HPP
13 
14 #ifdef CUBBYFLOW_USE_CUDA
15 
17 #include <Core/Utils/Constants.hpp>
18 
19 namespace CubbyFlow
20 {
21 class CUDASPHSystemData2 : public CUDAParticleSystemData2
22 {
23  public:
25  CUDASPHSystemData2();
26 
28  explicit CUDASPHSystemData2(size_t numberOfParticles);
29 
31  ~CUDASPHSystemData2() override = default;
32 
34  CUDASPHSystemData2(const CUDASPHSystemData2& other);
35 
37  CUDASPHSystemData2(CUDASPHSystemData2&& other) noexcept;
38 
40  CUDASPHSystemData2& operator=(const CUDASPHSystemData2& other);
41 
43  CUDASPHSystemData2& operator=(CUDASPHSystemData2&& other) noexcept;
44 
46  ConstCUDAArrayView1<float> Densities() const;
47 
49  CUDAArrayView1<float> Densities();
50 
52  ConstCUDAArrayView1<float> Pressures() const;
53 
55  CUDAArrayView1<float> Pressures();
56 
66  void UpdateDensities();
67 
69  float TargetDensity() const;
70 
72  void SetTargetDensity(float targetDensity);
73 
75  float TargetSpacing() const;
76 
83  void SetTargetSpacing(float spacing);
84 
91  float RelativeKernelRadius() const;
92 
101  void SetRelativeKernelRadius(float relativeRadius);
102 
104  float KernelRadius() const;
105 
114  void SetKernelRadius(float kernelRadius);
115 
117  float Mass() const;
118 
120  void BuildNeighborSearcher();
121 
123  void BuildNeighborListsAndUpdateDensities();
124 
126  void Set(const CUDASPHSystemData2& other);
127 
128  private:
130  float m_targetDensity = WATER_DENSITY_FLOAT;
131 
133  float m_targetSpacing = 0.1f;
134 
137  float m_kernelRadiusOverTargetSpacing = 1.8f;
138 
140  float m_kernelRadius = 0.1f;
141 
142  float m_mass = 1e-3f;
143 
144  size_t m_pressureIdx = 0;
145 
146  size_t m_densityIdx = 0;
147 
149  void ComputeMass();
150 };
151 
153 using CUDASPHSystemData2Ptr = std::shared_ptr<CUDASPHSystemData2>;
154 
155 } // namespace CubbyFlow
156 
157 #endif
158 
159 #endif
constexpr float WATER_DENSITY_FLOAT
Water density.
Definition: Constants.hpp:302
Definition: pybind11Utils.hpp:20