AQUAgpusph 5.0.4
Loading...
Searching...
No Matches
Shepard.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
27
28#ifndef EXCLUDED_PARTICLE
39 #define EXCLUDED_PARTICLE(index) imove[index] >= 3
40#endif
41
42#if defined(LOCAL_MEM_SIZE) && defined(NO_LOCAL_MEM)
43 #error NO_LOCAL_MEM has been set.
44#endif
45
48
78__kernel void entry(const __global int* imove,
79 const __global vec* r,
80 const __global float* rho,
81 const __global float* m,
82 const __global float* h_var,
83 __global float* shepard,
84 usize N,
86{
87 const usize i = get_global_id(0);
88 const usize it = get_local_id(0);
89 if(i >= N)
90 return;
91 if((imove[i] < -3) || ((imove[i] > 0) && (EXCLUDED_PARTICLE(i))))
92 return;
93
94 const vec_xyz r_i = r[i].XYZ;
95 const float h_i = h_var[i];
96 #ifndef HAVE_3D
97 const float conw = 1.f / (h_i * h_i);
98 #else
99 const float conw = 1.f / (h_i * h_i * h_i);
100 #endif
101
102 // Initialize the output
103 #ifndef LOCAL_MEM_SIZE
104 #define _SHEPARD_ shepard[i]
105 #else
106 #define _SHEPARD_ shepard_l[it]
107 __local float shepard_l[LOCAL_MEM_SIZE];
108 _SHEPARD_ = 0.f;
109 #endif
110
111 const usize c_i = icell[i];
112 BEGIN_NEIGHS(c_i, N, n_cells, icell, ihoc){
113 if(EXCLUDED_PARTICLE(j)){
114 j++;
115 continue;
116 }
117
118 const vec_xyz r_ij = r[j].XYZ - r_i;
119 const float q = length(r_ij) / h_i;
120 if(q >= SUPPORT)
121 {
122 j++;
123 continue;
124 }
125
126 {
127 _SHEPARD_ += conw * kernelW(q) * m[j] / rho[j];
128 }
129 }END_NEIGHS()
130
131 #ifdef LOCAL_MEM_SIZE
132 shepard[i] = _SHEPARD_;
133 #endif
134}
#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 kernelW(float q)
The kernel value .
Definition CubicSpline2D.hcl:44
Generic/automatic kernel header file.
#define _SHEPARD_
#define EXCLUDED_PARTICLE(index)
Excluded particles from the Shepard renormalization factor computation.
Definition Shepard.cl:38
__kernel void entry(const __global int *imove, const __global vec *r, const __global float *rho, const __global float *m, __global float *shepard, usize N, LINKLIST_LOCAL_PARAMS)
Shepard factor computation.
Definition Shepard.cl:76
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