1 | __kernel void CapCylinderKernel(__global const float *qx, __global const float *qy, __global float *_ptvalue, __global float *vol_i, |
---|
2 | const float rad_cyl, const float rad_cap, const float length, const float thet, const float ph, const float sub, |
---|
3 | const float scale, const float phi_weight, const float theta_float, const float rad_cap_weight, const float rad_cyl_weight, |
---|
4 | const float length_weight, const int total, const int size, __const float Gauss76Wt, __const float Gauss76Z) |
---|
5 | //ph is phi, sub is sldc-slds, thet is theta |
---|
6 | { |
---|
7 | int i = get_global_id(0); |
---|
8 | if(i < total) |
---|
9 | { |
---|
10 | float q = sqrt(qx[i]*qx[i] + qy[i]*qy[i]); |
---|
11 | float pi = 4.0*atan(1.0); |
---|
12 | float theta = thet*pi/180.0; |
---|
13 | float phi = ph*pi/180.0; |
---|
14 | float cyl_x = cos(theta)*cos(phi); |
---|
15 | float cyl_y = sin(theta); |
---|
16 | float cos_val = cyl_x*qx[i]/q + cyl_y*qy[i]/q; |
---|
17 | float alpha = acos(cos_val); |
---|
18 | float yyy=0; float ans1=0; float ans2=0; float y=0; float xx=0; float ans=0; float zij=0; float be=0; float summj=0; |
---|
19 | |
---|
20 | float hDist = -1.0*sqrt(fabs(rad_cap*rad_cap-rad_cyl*rad_cyl)); |
---|
21 | vol_i[i] = pi*rad_cyl*rad_cyl*length+2.0*pi/3.0*((rad_cap-hDist)*(rad_cap-hDist)*(2*rad_cap+hDist)); |
---|
22 | float vaj = -1.0*hDist/rad_cap; |
---|
23 | |
---|
24 | for(int j=0;j<76;j++) //the 76 corresponds to the Gauss constants |
---|
25 | { |
---|
26 | zij = (Gauss76Z[j]*(1.0-vaj)+vaj+1.0)/2.0; |
---|
27 | yyy = Gauss76Wt[j]*ConvLens_kernel(length,rad_cyl,rad_cap,q,zij,alpha); |
---|
28 | summj += yyy; |
---|
29 | } |
---|
30 | float inner = (1.0-vaj)/2.0*summj*4.0*pi*rad_cap*rad_cap*rad_cap; |
---|
31 | float arg1 = q*length/2.0*cos(alpha); |
---|
32 | float arg2 = q*rad_cyl*sin(alpha); |
---|
33 | yyy = inner; |
---|
34 | |
---|
35 | if(arg2 == 0) {be = 0.5;} |
---|
36 | else { |
---|
37 | be = NR_BessJ1(arg2)/arg2; |
---|
38 | } |
---|
39 | |
---|
40 | if(arg1 == 0.0) { |
---|
41 | yyy += pi*rad_cyl*rad_cyl*length*2.0*be; |
---|
42 | } |
---|
43 | else { |
---|
44 | yyy += pi*rad_cyl*rad_cyl*length*sin(arg1)/arg1*2.0*be; |
---|
45 | } |
---|
46 | float answer=yyy*yyy*1.0e8*sub*sub*scale/pi*rad_cyl*rad_cyl*length+2.0*pi*(2.0*rad_cap*rad_cap*rad_cap/3.0+rad_cap*rad_cap*hDist-hDist*hDist*hDist/3.0); |
---|
47 | answer/=sin(alpha); |
---|
48 | |
---|
49 | _ptvalue[i] = rad_cyl_weight*length_weight*rad_cap_weight*theta_weight*phi_weight*vol_i[i]*answer |
---|
50 | if (_ptvalue[i] == INFINITY || _ptvalue == NAN){ |
---|
51 | _ptvalue[i] = 0.0; |
---|
52 | } |
---|
53 | if (size>1) { |
---|
54 | _ptvalue[i] *= fabs(cos(thet*pi/180.0)); |
---|
55 | } |
---|
56 | } |
---|
57 | } |
---|