1 | __kernel void EllipsoidKernel(__global const real *qx, __global const real *qy, __global const int *place, __global const real *array, |
---|
2 | __global real *final, const real scale, const real sub, const int length, const int size)//, __local real *poly) |
---|
3 | { |
---|
4 | //__local real rada, radaw, radb, radbw, th, thw, ph, phw; |
---|
5 | |
---|
6 | __local real rada; |
---|
7 | int uno=0; int dos=1; int count = 0; |
---|
8 | int l = get_local_id(0); |
---|
9 | for(int j = 0; j < 4; j++) |
---|
10 | { |
---|
11 | for(int i = place[uno]; i < place[dos]; i++) |
---|
12 | { |
---|
13 | rada[count] = array[i] |
---|
14 | radaw[count] = array[] |
---|
15 | } |
---|
16 | uno+=2; |
---|
17 | dos+=2; |
---|
18 | count = 0; |
---|
19 | } |
---|
20 | |
---|
21 | |
---|
22 | int i = get_global_id(0); |
---|
23 | if(i < length){ |
---|
24 | //do local mem? |
---|
25 | real sum=0.0; real vol=0.0; real norm_vol=0.0; real norm=0.0; |
---|
26 | |
---|
27 | for(int a = 0; a < place[0]; a++) //radius_a values |
---|
28 | { |
---|
29 | real radius_a = array[a]; |
---|
30 | real radius_a_weight = array[a+place[0]]; |
---|
31 | for(int b = place[1]; b < place[2]; b++) //radius_b values |
---|
32 | { |
---|
33 | real radius_b = array[b]; |
---|
34 | real radius_b_weight = array[b+place[2]]; |
---|
35 | for(int t = place[3]; t < place[4]; t++) //Axis_theta values |
---|
36 | { |
---|
37 | real axis_theta = array[t]; |
---|
38 | real axis_theta_weight = array[t+place[4]]; |
---|
39 | for(int p = place[5]; p < place[6]; p++) //axis_phi values |
---|
40 | { |
---|
41 | real axis_phi = array[p]; |
---|
42 | real axis_phi_weight = array[p+place[6]]; |
---|
43 | |
---|
44 | real ret = 0; |
---|
45 | real q = sqrt(qx[i]*qx[i] + qy[i]*qy[i]); |
---|
46 | real pi = 4.0*atan(1.0); |
---|
47 | real theta = axis_theta*pi/180.0; |
---|
48 | real cos_val = cos(theta)*cos(axis_phi*pi/180.0)*(qx[i]/q) + sin(theta)*(qy[i]/q); |
---|
49 | |
---|
50 | real arg = q*radius_b*sqrt(1.0+(cos_val*cos_val*(((radius_a*radius_a/(radius_b*radius_b))-1.0)))); |
---|
51 | if(arg == 0.0){ |
---|
52 | ret = 1.0/3.0; |
---|
53 | } |
---|
54 | else{ |
---|
55 | ret = (sin(arg)-arg*cos(arg))/(arg*arg*arg); |
---|
56 | } |
---|
57 | ret*=ret*9.0*sub*sub*4.0/3.0*acos(-1.0)*radius_b*radius_b*radius_a*scale*(1.0e8); |
---|
58 | real _ptvalue = radius_a_weight*radius_b_weight*axis_theta_weight*radius_a*axis_phi_weight*ret*pow(radius_b, 2); |
---|
59 | if(size > 1){ |
---|
60 | _ptvalue *= fabs(cos(axis_theta*pi/180.0)); |
---|
61 | } |
---|
62 | |
---|
63 | sum += _ptvalue; |
---|
64 | vol += radius_a_weight*radius_b_weight*pow(radius_b, 2)*radius_a; |
---|
65 | norm_vol += radius_a_weight*radius_b_weight; |
---|
66 | norm += radius_a_weight*radius_b_weight*axis_theta_weight*axis_phi_weight; |
---|
67 | } |
---|
68 | } |
---|
69 | } |
---|
70 | } |
---|
71 | |
---|
72 | if(size > 1){ |
---|
73 | norm /= asin(1.0); |
---|
74 | } |
---|
75 | if(vol != 0.0 && norm_vol != 0.0){ |
---|
76 | sum *= norm_vol/vol; |
---|
77 | } |
---|
78 | |
---|
79 | final[i] = sum/norm; |
---|
80 | } |
---|
81 | } |
---|