SPHKernels.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 // Adopted from the sample code of:
12 // Bart Adams and Martin Wicke,
13 // "Meshless Approximation Methods and Applications in Physics Based Modeling
14 // and Animation", Eurographics 2009 Tutorial
15 
16 #ifndef CUBBYFLOW_SPH_KERNELS_HPP
17 #define CUBBYFLOW_SPH_KERNELS_HPP
18 
19 #include <Core/Matrix/Matrix.hpp>
20 
21 namespace CubbyFlow
22 {
31 template <size_t N>
33 {
34  // Do nothing
35 };
36 
37 template <>
38 struct SPHStdKernel<2>
39 {
41  SPHStdKernel();
42 
44  explicit SPHStdKernel(double kernelRadius);
45 
47  double operator()(double distance) const;
48 
50  [[nodiscard]] double FirstDerivative(double distance) const;
51 
53  [[nodiscard]] double SecondDerivative(double distance) const;
54 
56  [[nodiscard]] Vector2D Gradient(const Vector2D& point) const;
57 
59  [[nodiscard]] Vector2D Gradient(double distance,
60  const Vector2D& direction) const;
61 
63  double h;
64 
66  double h2;
67 
69  double h3;
70 
72  double h4;
73 };
74 
75 template <>
76 struct SPHStdKernel<3>
77 {
79  SPHStdKernel();
80 
82  explicit SPHStdKernel(double kernelRadius);
83 
85  double operator()(double distance) const;
86 
88  [[nodiscard]] double FirstDerivative(double distance) const;
89 
91  [[nodiscard]] double SecondDerivative(double distance) const;
92 
94  [[nodiscard]] Vector3D Gradient(const Vector3D& point) const;
95 
97  [[nodiscard]] Vector3D Gradient(double distance,
98  const Vector3D& direction) const;
99 
101  double h;
102 
104  double h2;
105 
107  double h3;
108 
110  double h5;
111 };
112 
114 
116 
125 template <size_t N>
127 {
128  // Do nothing
129 };
130 
131 template <>
132 struct SPHSpikyKernel<2>
133 {
135  SPHSpikyKernel();
136 
138  explicit SPHSpikyKernel(double kernelRadius);
139 
141  double operator()(double distance) const;
142 
144  [[nodiscard]] double FirstDerivative(double distance) const;
145 
147  [[nodiscard]] double SecondDerivative(double distance) const;
148 
150  [[nodiscard]] Vector2D Gradient(const Vector2D& point) const;
151 
153  [[nodiscard]] Vector2D Gradient(double distance,
154  const Vector2D& direction) const;
155 
157  double h;
158 
160  double h2;
161 
163  double h3;
164 
166  double h4;
167 
169  double h5;
170 };
171 
172 template <>
173 struct SPHSpikyKernel<3>
174 {
176  SPHSpikyKernel();
177 
179  explicit SPHSpikyKernel(double kernelRadius);
180 
182  double operator()(double distance) const;
183 
185  [[nodiscard]] double FirstDerivative(double distance) const;
186 
188  [[nodiscard]] double SecondDerivative(double distance) const;
189 
191  [[nodiscard]] Vector3D Gradient(const Vector3D& point) const;
192 
194  [[nodiscard]] Vector3D Gradient(double distance,
195  const Vector3D& direction) const;
196 
198  double h;
199 
201  double h2;
202 
204  double h3;
205 
207  double h4;
208 
210  double h5;
211 };
212 
214 
216 } // namespace CubbyFlow
217 
219 
220 #endif
Definition: SPHKernels.hpp:132
double h2
Square of the kernel radius.
Definition: SPHKernels.hpp:201
double h4
Fourth-power of the kernel radius.
Definition: SPHKernels.hpp:166
double h
Kernel radius.
Definition: SPHKernels.hpp:101
double h5
Fifth-power of the kernel radius.
Definition: SPHKernels.hpp:210
Spiky N-D SPH kernel function object.
Definition: SPHKernels.hpp:126
double h2
Square of the kernel radius.
Definition: SPHKernels.hpp:104
double h
Kernel radius.
Definition: SPHKernels.hpp:63
double h2
Square of the kernel radius.
Definition: SPHKernels.hpp:160
double h3
Cubic of the kernel radius.
Definition: SPHKernels.hpp:107
Definition: Matrix.hpp:27
double h5
Fifth-power of the kernel radius.
Definition: SPHKernels.hpp:169
Definition: pybind11Utils.hpp:20
double h3
Cubic of the kernel radius.
Definition: SPHKernels.hpp:163
Standard N-D SPH kernel function object.
Definition: SPHKernels.hpp:32
Definition: SPHKernels.hpp:76
Definition: SPHKernels.hpp:173
double h
Kernel radius.
Definition: SPHKernels.hpp:198
Definition: SPHKernels.hpp:38
double h4
Fourth-power of the kernel radius.
Definition: SPHKernels.hpp:207
double h3
Cubic of the kernel radius.
Definition: SPHKernels.hpp:69
double h3
Cubic of the kernel radius.
Definition: SPHKernels.hpp:204
double h4
Fourth-power of the kernel radius.
Definition: SPHKernels.hpp:72
double h5
Fifth-power of the kernel radius.
Definition: SPHKernels.hpp:110
double h
Kernel radius.
Definition: SPHKernels.hpp:157
double h2
Square of the kernel radius.
Definition: SPHKernels.hpp:66