PeriDyno 1.2.1
Loading...
Searching...
No Matches
ParticleApproximation.h
Go to the documentation of this file.
1
16#pragma once
18
19#include "Kernel.h"
20
21namespace dyno
22{
23
24#define cuIntegralAdh(size, type, scale, Func,...){ \
25 uint pDims = cudaGridSize((uint)size, BLOCK_SIZE); \
26 if (type == ParticleApproximation<TDataType>::KT_Smooth) \
27 { \
28 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
29 return SmoothKernel<Real>::integral(r, h, s); \
30 }; \
31 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, ParticleApproximation<TDataType>::mScalingFactor); \
32 } \
33 else if (type == ParticleApproximation<TDataType>::KT_Spiky) \
34 { \
35 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
36 return SpikyKernel<Real>::integral(r, h, s); \
37 }; \
38 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, ParticleApproximation<TDataType>::mScalingFactor); \
39 } \
40 cuSynchronize(); \
41 }
42
43#define cuIntegral(size, type, scale, Func,...){ \
44 uint pDims = cudaGridSize((uint)size, BLOCK_SIZE); \
45 if (type == ParticleApproximation<TDataType>::KT_Smooth) \
46 { \
47 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
48 return SmoothKernel<Real>::integral(r, h, s); \
49 }; \
50 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, ParticleApproximation<TDataType>::mScalingFactor); \
51 } \
52 else if (type == ParticleApproximation<TDataType>::KT_Spiky) \
53 { \
54 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
55 return SpikyKernel<Real>::integral(r, h, s); \
56 }; \
57 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, ParticleApproximation<TDataType>::mScalingFactor); \
58 } \
59 cuSynchronize(); \
60 }
61
62#define cuZerothOrder(size, type, scale, Func,...){ \
63 uint pDims = cudaGridSize((uint)size, BLOCK_SIZE); \
64 if (type == ParticleApproximation<TDataType>::KT_Smooth) \
65 { \
66 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
67 return SmoothKernel<Real>::weight(r, h, s); \
68 }; \
69 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
70 } \
71 else if (type == ParticleApproximation<TDataType>::KT_Spiky) \
72 { \
73 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
74 return SpikyKernel<Real>::weight(r, h, s); \
75 }; \
76 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
77 } \
78 else if (type == ParticleApproximation<TDataType>::KT_Cubic) \
79 { \
80 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
81 return CubicKernel<Real>::weight(r, h, s); \
82 }; \
83 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
84 } \
85 else if (type == ParticleApproximation<TDataType>::KT_Constant) \
86 { \
87 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
88 return ConstantKernel<Real>::weight(r, h, s); \
89 }; \
90 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
91 } \
92 else if (type == ParticleApproximation<TDataType>::KT_Quartic) \
93 { \
94 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
95 return QuarticKernel<Real>::weight(r, h, s); \
96 }; \
97 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
98 } \
99 else if (type == ParticleApproximation<TDataType>::KT_Corrected) \
100 { \
101 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
102 return CorrectedKernel<Real>::weight(r, h, s); \
103 }; \
104 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
105 } \
106 else if (type == ParticleApproximation<TDataType>::KT_CorrectedQuatic) \
107 { \
108 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
109 return CorrectedQuaticKernel<Real>::weight(r, h, s); \
110 }; \
111 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
112 } \
113 else if (type == ParticleApproximation<TDataType>::KT_WendlandC2) \
114 { \
115 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
116 return WendlandC2Kernel<Real>::weight(r, h, s); \
117 }; \
118 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
119 } \
120 else if (type == ParticleApproximation<TDataType>::KT_CorrectedMPSKernel) \
121 { \
122 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
123 return CorrectedMPSKernel<Real>::weight(r, h, s); \
124 }; \
125 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
126 } \
127 cuSynchronize(); \
128 }
129
130#define cuFirstOrder(size, type, scale, Func,...){ \
131 uint pDims = cudaGridSize((uint)size, BLOCK_SIZE); \
132 if (type == ParticleApproximation<TDataType>::KT_Smooth) \
133 { \
134 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
135 return SmoothKernel<Real>::gradient(r, h, s); \
136 }; \
137 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
138 } \
139 else if (type == ParticleApproximation<TDataType>::KT_Spiky) \
140 { \
141 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
142 return SpikyKernel<Real>::gradient(r, h, s); \
143 }; \
144 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
145 } \
146 else if (type == ParticleApproximation<TDataType>::KT_Cubic) \
147 { \
148 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
149 return CubicKernel<Real>::gradient(r, h, s); \
150 }; \
151 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
152 } \
153 else if (type == ParticleApproximation<TDataType>::KT_Constant) \
154 { \
155 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
156 return ConstantKernel<Real>::gradient(r, h, s); \
157 }; \
158 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
159 } \
160 else if (type == ParticleApproximation<TDataType>::KT_Quartic) \
161 { \
162 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
163 return QuarticKernel<Real>::gradient(r, h, s); \
164 }; \
165 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
166 } \
167 else if (type == ParticleApproximation<TDataType>::KT_Corrected) \
168 { \
169 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
170 return CorrectedKernel<Real>::gradient(r, h, s); \
171 }; \
172 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
173 } \
174 else if (type == ParticleApproximation<TDataType>::KT_CorrectedQuatic) \
175 { \
176 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
177 return CorrectedQuaticKernel<Real>::gradient(r, h, s); \
178 }; \
179 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
180 } \
181 else if (type == ParticleApproximation<TDataType>::KT_WendlandC2) \
182 { \
183 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
184 return WendlandC2Kernel<Real>::gradient(r, h, s); \
185 }; \
186 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
187 } \
188 else if (type == ParticleApproximation<TDataType>::KT_CorrectedMPSKernel) \
189 { \
190 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
191 return CorrectedMPSKernel<Real>::gradient(r, h, s); \
192 }; \
193 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
194 } \
195 cuSynchronize(); \
196 }
197
198#define cuSecondOrder(size, type, scale, Func,...){ \
199 uint pDims = cudaGridSize((uint)size, BLOCK_SIZE); \
200 if (type == ParticleApproximation<TDataType>::KT_Smooth) \
201 { \
202 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
203 return ConstantKernel<Real>::weightRR(r, h, s); \
204 }; \
205 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
206 } \
207 else if (type == ParticleApproximation<TDataType>::KT_Spiky) \
208 { \
209 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
210 return ConstantKernel<Real>::weightRR(r, h, s); \
211 }; \
212 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
213 } \
214 else if (type == ParticleApproximation<TDataType>::KT_Cubic) \
215 { \
216 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
217 return ConstantKernel<Real>::weightRR(r, h, s); \
218 }; \
219 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
220 } \
221 else if (type == ParticleApproximation<TDataType>::KT_Constant) \
222 { \
223 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
224 return ConstantKernel<Real>::weightRR(r, h, s); \
225 }; \
226 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
227 } \
228 else if (type == ParticleApproximation<TDataType>::KT_Quartic) \
229 { \
230 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
231 return ConstantKernel<Real>::weightRR(r, h, s); \
232 }; \
233 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
234 } \
235 else if (type == ParticleApproximation<TDataType>::KT_Corrected) \
236 { \
237 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
238 return CorrectedKernel<Real>::weightRR(r, h, s); \
239 }; \
240 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
241 } \
242 else if (type == ParticleApproximation<TDataType>::KT_CorrectedQuatic) \
243 { \
244 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
245 return CorrectedQuaticKernel<Real>::weightRR(r, h, s); \
246 }; \
247 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
248 } \
249 else if (type == ParticleApproximation<TDataType>::KT_WendlandC2) \
250 { \
251 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
252 return ConstantKernel<Real>::weightRR(r, h, s); \
253 }; \
254 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
255 } \
256 else if (type == ParticleApproximation<TDataType>::KT_CorrectedMPSKernel) \
257 { \
258 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
259 return CorrectedMPSKernel<Real>::weightRR(r, h, s); \
260 }; \
261 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
262 } \
263 cuSynchronize(); \
264 }
265
266
267
268
269 template<typename TDataType>
271 {
273 public:
274 typedef typename TDataType::Real Real;
275
277 virtual ~ParticleApproximation();
278
279 DECLARE_ENUM(EKernelType,
280 KT_Smooth = 0,
281 KT_Spiky = 1,
282 KT_Cubic = 2,
283 KT_Constant = 3,
284 KT_Quartic = 4,
285 KT_Corrected = 5,
286 KT_CorrectedQuatic = 6,
287 KT_WendlandC2 = 7,
288 KT_CorrectedMPSKernel = 8);
289
290 void compute() override {};
291
292 public:
293 DEF_VAR_IN(Real, SmoothingLength, "Smoothing Length");
294 DEF_VAR_IN(Real, SamplingDistance, "Particle sampling distance");
295
296 DEF_ENUM(EKernelType, KernelType, EKernelType::KT_Spiky, "Rendering mode");
297
298 protected:
300
301 private:
303 };
304}
#define DECLARE_TCLASS(name, T1)
Definition Object.h:87
DEF_VAR_IN(Real, SmoothingLength, "Smoothing Length")
DEF_ENUM(EKernelType, KernelType, EKernelType::KT_Spiky, "Rendering mode")
DECLARE_ENUM(EKernelType, KT_Smooth=0, KT_Spiky=1, KT_Cubic=2, KT_Constant=3, KT_Quartic=4, KT_Corrected=5, KT_CorrectedQuatic=6, KT_WendlandC2=7, KT_CorrectedMPSKernel=8)
DEF_VAR_IN(Real, SamplingDistance, "Particle sampling distance")
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25