AQUAgpusph 5.0.4
Loading...
Searching...
No Matches
deltaSPH.cl
Go to the documentation of this file.
1/*
2 * This file is part of AQUAgpusph, a free CFD program based on SPH.
3 * Copyright (C) 2012 Jose Luis Cercos Pita <jl.cercos@upm.es>
4 *
5 * AQUAgpusph is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * AQUAgpusph is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with AQUAgpusph. If not, see <http://www.gnu.org/licenses/>.
17 */
18
22
26
27#ifndef EXCLUDED_PARTICLE
35 #define EXCLUDED_PARTICLE(index) imove[index] <= 0
36#endif
37
38#if defined(LOCAL_MEM_SIZE) && defined(NO_LOCAL_MEM)
39 #error NO_LOCAL_MEM has been set.
40#endif
41
44
57__kernel void simple(const __global unsigned int* iset,
58 const __global int* imove,
59 __global vec* lap_p_corr,
60 __constant float* refd,
61 usize N,
62 vec g)
63{
64 const usize i = get_global_id(0);
65 if(i >= N)
66 return;
68 return;
69
70 lap_p_corr[i] = refd[iset[i]] * g;
71}
72
94__kernel void full(const __global int* imove,
95 const __global vec* r,
96 const __global float* rho,
97 const __global float* m,
98 const __global float* p,
99 __global vec* lap_p_corr,
100 usize N,
102{
103 const usize i = get_global_id(0);
104 const usize it = get_local_id(0);
105 if(i >= N)
106 return;
107 if(EXCLUDED_PARTICLE(i)){
108 return;
109 }
110
111 const vec_xyz r_i = r[i].XYZ;
112 const float p_i = p[i];
113
114 // Initialize the output
115 #ifndef LOCAL_MEM_SIZE
116 #define _GRADP_ lap_p_corr[i].XYZ
117 #else
118 #define _GRADP_ lap_p_corr_l[it]
119 __local vec_xyz lap_p_corr_l[LOCAL_MEM_SIZE];
120 _GRADP_ = VEC_ZERO.XYZ;
121 #endif
122
123 const usize c_i = icell[i];
124 BEGIN_NEIGHS(c_i, N, n_cells, icell, ihoc){
125 if( (i == j) || (EXCLUDED_PARTICLE(j))){
126 j++;
127 continue;
128 }
129 const vec_xyz r_ij = r[j].XYZ - r_i;
130 const float q = length(r_ij) / H;
131 if(q >= SUPPORT)
132 {
133 j++;
134 continue;
135 }
136 {
137 const float f_ij = kernelF(q) * CONF * m[j] / rho[j];
138 _GRADP_ += (p[j] - p_i) * f_ij * r_ij;
139 }
140 }END_NEIGHS()
141
142 #ifdef LOCAL_MEM_SIZE
143 lap_p_corr[i].XYZ = _GRADP_;
144 #endif
145}
146
160__kernel void full_mls(const __global int* imove,
161 const __global matrix* mls,
162 __global vec* lap_p_corr,
163 usize N)
164{
165 const usize i = get_global_id(0);
166 if(i >= N)
167 return;
168 if(EXCLUDED_PARTICLE(i)){
169 return;
170 }
171
172 lap_p_corr[i] = MATRIX_DOT(mls[i], lap_p_corr[i]);
173}
174
191__kernel void lapp(const __global int* imove,
192 const __global vec* r,
193 const __global float* rho,
194 const __global float* m,
195 const __global float* p,
196 __global float* lap_p,
197 usize N,
199{
200 const usize i = get_global_id(0);
201 const usize it = get_local_id(0);
202 if(i >= N)
203 return;
204 if(EXCLUDED_PARTICLE(i)){
205 return;
206 }
207
208 const vec_xyz r_i = r[i].XYZ;
209 const float p_i = p[i];
210
211 // Initialize the output
212 #ifndef LOCAL_MEM_SIZE
213 #define _LAPP_ lap_p[i]
214 #else
215 #define _LAPP_ lap_p_l[it]
216 __local float lap_p_l[LOCAL_MEM_SIZE];
217 _LAPP_ = 0.f;
218 #endif
219
220 const usize c_i = icell[i];
221 BEGIN_NEIGHS(c_i, N, n_cells, icell, ihoc){
222 if( (i == j) || (EXCLUDED_PARTICLE(j))){
223 j++;
224 continue;
225 }
226 const vec_xyz r_ij = r[j].XYZ - r_i;
227 const float q = length(r_ij) / H;
228 if(q >= SUPPORT)
229 {
230 j++;
231 continue;
232 }
233 {
234 const float f_ij = kernelF(q) * CONF * m[j] / rho[j];
235 _LAPP_ += (p[j] - p_i) * f_ij;
236 }
237 }END_NEIGHS()
238
239 #ifdef LOCAL_MEM_SIZE
240 lap_p[i] = _LAPP_;
241 #endif
242}
243
261__kernel void lapp_corr(const __global int* imove,
262 const __global vec* r,
263 const __global float* rho,
264 const __global float* m,
265 const __global vec* lap_p_corr,
266 __global float* lap_p,
267 usize N,
269{
270 const usize i = get_global_id(0);
271 const usize it = get_local_id(0);
272 if(i >= N)
273 return;
274 if(EXCLUDED_PARTICLE(i)){
275 return;
276 }
277
278 const vec_xyz r_i = r[i].XYZ;
279 const vec_xyz gradp_i = lap_p_corr[i].XYZ;
280
281 // Initialize the output
282 #ifndef LOCAL_MEM_SIZE
283 #define _LAPP_ lap_p[i]
284 #else
285 #define _LAPP_ lap_p_l[it]
286 __local float lap_p_l[LOCAL_MEM_SIZE];
287 _LAPP_ = lap_p[i];
288 #endif
289
290 const usize c_i = icell[i];
291 BEGIN_NEIGHS(c_i, N, n_cells, icell, ihoc){
292 if( (i == j) || (EXCLUDED_PARTICLE(j))){
293 j++;
294 continue;
295 }
296 const vec_xyz r_ij = r[j].XYZ - r_i;
297 const float q = length(r_ij) / H;
298 if(q >= SUPPORT)
299 {
300 j++;
301 continue;
302 }
303 {
304 const vec_xyz gradp_ij = lap_p_corr[j].XYZ + gradp_i;
305 const float f_ij = kernelF(q) * CONF * m[j] / rho[j];
306 _LAPP_ -= 0.5f * dot(gradp_ij, r_ij) * f_ij;
307 }
308 }END_NEIGHS()
309
310 #ifdef LOCAL_MEM_SIZE
311 lap_p[i] = _LAPP_;
312 #endif
313}
314
330__kernel void deltaSPH(const __global unsigned int* iset,
331 const __global int* imove,
332 const __global float* rho,
333 const __global float* lap_p,
334 __global float* drhodt,
335 __constant float* refd,
336 __constant float* delta,
337 usize N,
338 float dt)
339{
340 const usize i = get_global_id(0);
341 if(i >= N)
342 return;
343 if(EXCLUDED_PARTICLE(i))
344 return;
345
346 const uint set_i = iset[i];
347 const float delta_f = delta[set_i] * dt * rho[i] / refd[set_i];
348
349 drhodt[i] += delta_f * lap_p[i];
350}
351
352/*
353 * @}
354 */
#define MATRIX_DOT(_M, _V)
Multiply a matrix by a vector (inner product)
Definition 2D.h:197
#define BEGIN_NEIGHS(CELL, NPARTS, NCELLS, ICELL, IHOC)
Loop over the neighbours to compute the interactions.
Definition 2D.h:174
#define vec_xyz
Vectors with the minimum number of components.
Definition 2D.h:86
#define END_NEIGHS()
End of the loop over the neighs to compute the interactions.
Definition 2D.h:189
float kernelF(float q)
The kernel gradient factor .
Definition CubicSpline2D.hcl:67
Generic/automatic kernel header file.
#define VEC_ZERO
Definition Reduction.hcl.in:70
#define _GRADP_
#define _LAPP_
__kernel void lapp(const __global int *imove, const __global vec *r, const __global float *rho, const __global float *m, const __global float *p, __global float *lap_p, usize N, LINKLIST_LOCAL_PARAMS)
Laplacian of the pressure computation.
Definition deltaSPH.cl:191
#define EXCLUDED_PARTICLE(index)
Condition to exclude a particle from the delta-SPH model.
Definition deltaSPH.cl:35
__kernel void deltaSPH(const __global unsigned int *iset, const __global int *imove, const __global float *rho, const __global float *lap_p, __global float *drhodt, __constant float *refd, __constant float *delta, usize N, float dt)
Density variation rates delta-SPH term.
Definition deltaSPH.cl:330
__kernel void simple(const __global unsigned int *iset, const __global int *imove, __global vec *lap_p_corr, __constant float *refd, usize N, vec g)
Simple hidrostatic based correction term.
Definition deltaSPH.cl:57
__kernel void lapp_corr(const __global int *imove, const __global vec *r, const __global float *rho, const __global float *m, const __global vec *lap_p_corr, __global float *lap_p, usize N, LINKLIST_LOCAL_PARAMS)
Laplacian of the pressure correction.
Definition deltaSPH.cl:261
__kernel void full_mls(const __global int *imove, const __global matrix *mls, __global vec *lap_p_corr, usize N)
MLS based correction term.
Definition deltaSPH.cl:160
__kernel void full(const __global int *imove, const __global vec *r, const __global float *rho, const __global float *m, const __global float *p, __global vec *lap_p_corr, usize N, LINKLIST_LOCAL_PARAMS)
MLS based correction term.
Definition deltaSPH.cl:94
Generic types definition file.
#define LINKLIST_LOCAL_PARAMS
Macro to easily add the parameters to run BEGIN_NEIGHS macro, interacting with the local set of parti...
Definition types.h:106