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
26
27#ifndef EXCLUDED_PARTICLE
38 #define EXCLUDED_PARTICLE(index) imove[index] >= 3
39#endif
40
41#if defined(LOCAL_MEM_SIZE) && defined(NO_LOCAL_MEM)
42 #error NO_LOCAL_MEM has been set.
43#endif
44
47
76__kernel void entry(const __global int* imove,
77 const __global vec* r,
78 const __global float* rho,
79 const __global float* m,
80 __global float* shepard,
81 usize N,
83{
84 const usize i = get_global_id(0);
85 const usize it = get_local_id(0);
86 if(i >= N)
87 return;
88 if((imove[i] < -3) || ((imove[i] > 0) && (EXCLUDED_PARTICLE(i))))
89 return;
90
91 const vec_xyz r_i = r[i].XYZ;
92
93 // Initialize the output
94 #ifndef LOCAL_MEM_SIZE
95 #define _SHEPARD_ shepard[i]
96 #else
97 #define _SHEPARD_ shepard_l[it]
98 __local float shepard_l[LOCAL_MEM_SIZE];
99 _SHEPARD_ = 0.f;
100 #endif
101
102 const usize c_i = icell[i];
103 BEGIN_NEIGHS(c_i, N, n_cells, icell, ihoc){
104 if(EXCLUDED_PARTICLE(j)){
105 j++;
106 continue;
107 }
108
109 const vec_xyz r_ij = r[j].XYZ - r_i;
110 const float q = length(r_ij) / H;
111 if(q >= SUPPORT)
112 {
113 j++;
114 continue;
115 }
116
117 {
118 _SHEPARD_ += kernelW(q) * CONW * m[j] / rho[j];
119 }
120 }END_NEIGHS()
121
122 #ifdef LOCAL_MEM_SIZE
123 shepard[i] = _SHEPARD_;
124 #endif
125}
#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