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
62__kernel void lapp(const __global int* imove,
63 const __global vec* r,
64 const __global float* rho,
65 const __global float* m,
66 const __global float* p,
67 const __global float* h_var,
68 __global float* lap_p,
69 usize N,
71{
72 const usize i = get_global_id(0);
73 const usize it = get_local_id(0);
74 if(i >= N)
75 return;
76 if(EXCLUDED_PARTICLE(i)){
77 return;
78 }
79
80 const vec_xyz r_i = r[i].XYZ;
81 const float h_i = h_var[i];
82 const float p_i = p[i];
83 #ifndef HAVE_3D
84 const float conf_i = 1.f / (h_i * h_i * h_i * h_i);
85 #else
86 const float conf_i = 1.f / (h_i * h_i * h_i * h_i * h_i);
87 #endif
88
89 // Initialize the output
90 #ifndef LOCAL_MEM_SIZE
91 #define _LAPP_ lap_p[i]
92 #else
93 #define _LAPP_ lap_p_l[it]
94 __local float lap_p_l[LOCAL_MEM_SIZE];
95 _LAPP_ = 0.f;
96 #endif
97
98 const usize c_i = icell[i];
99 BEGIN_NEIGHS(c_i, N, n_cells, icell, ihoc){
100 if( (i == j) || (EXCLUDED_PARTICLE(j))){
101 j++;
102 continue;
103 }
104 const vec_xyz r_ij = r[j].XYZ - r_i;
105 const float h_j = h_var[j];
106 const float l_ij = length(r_ij);
107 const float q_i = min(l_ij / h_i, SUPPORT);
108 const float q_j = min(l_ij / h_j, SUPPORT);
109 if((q_i == SUPPORT) && (q_j == SUPPORT))
110 {
111 j++;
112 continue;
113 }
114 {
115 #ifndef HAVE_3D
116 const float conf_j = 1.f / (h_j * h_j * h_j * h_j);
117 #else
118 const float conf_j = 1.f / (h_j * h_j * h_j * h_j * h_j);
119 #endif
120 const float fi_ij = conf_i * kernelF(q_i);
121 const float fj_ij = conf_j * kernelF(q_j);
122 _LAPP_ += (p[j] - p_i) * 0.5f * (fi_ij + fj_ij) * m[j] / rho[j];
123 }
124 }END_NEIGHS()
125
126 #ifdef LOCAL_MEM_SIZE
127 lap_p[i] = _LAPP_;
128 #endif
129}
130
131/*
132 * @}
133 */
#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 _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
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