5 #ifndef VA_COROTATION_COMMON_H
6 #define VA_COROTATION_COMMON_H
8 #include "common_defs.h"
10 #include "spherical_integrators.h"
24 VA_REAL *residual_vorticity,
25 VA_REAL *residual_strain,
26 VA_REAL *principal_axis)
28 VA_REAL S_D_11, S_D_12;
34 vort = (SO[1] - SO[3]) / 2.;
37 S_D_11 = 0.5 * (SO[0] - SO[4]);
38 S_D_12 = 0.5 * (SO[1] + SO[3]);
45 as_D = sqrt( S_D_12 * S_D_12 + S_D_11 * S_D_11 );
48 length = sqrt(((S_D_11 - as_D)*(S_D_11 - as_D) ) + (S_D_12 * S_D_12));
49 if (length >= (VA_REAL) 1.e-5) {
51 principal_axis[0] = S_D_12 / length;
52 principal_axis[1] = - (S_D_11 - as_D) / length;
56 length = sqrt(((-S_D_11 - as_D)*(-S_D_11 - as_D))
57 +( S_D_12 * S_D_12 ) );
58 if (length >= (VA_REAL) 1.e-5) {
59 principal_axis[0] = (S_D_11 + as_D) / length;
60 principal_axis[1] = S_D_12 / length;
65 principal_axis[0] = (VA_REAL) 1.;
66 principal_axis[1] = (VA_REAL) 0.;
71 if (fabs (vort) >= as_D) {
72 *residual_vorticity =
valib_sign( fabs(vort) - as_D,vort );
73 *residual_strain = (VA_REAL) 0.;
76 *residual_vorticity = (VA_REAL) 0.;
77 *residual_strain = as_D - fabs(vort);
95 VA_DEVICE_ADDR VA_REAL *A,
96 VA_DEVICE_ADDR VA_REAL *avgcorot)
100 extern __shared__ VA_REAL s_data[];
101 VA_REAL *Q = &s_data[0];
102 #elif defined(OPENCL)
104 __private VA_REAL Q[9];
112 VA_REAL vort_res, s_res, principal_axis[3];
118 sinb = sqrt(1. - cosb*cosb);
124 if (threadIdx.x == 0) {
125 #elif defined(OPENCL)
126 if (get_local_id(0) == 0) {
132 #elif defined(OPENCL)
134 barrier(CLK_LOCAL_MEM_FENCE);
143 principal_axis[2] = 0.;
146 avgcorot[0] = avgcorot[0] + 6. * ( vort_res * n[0] ) * *weight;
147 avgcorot[1] = avgcorot[1] + 6. * ( vort_res * n[1] ) * *weight;
148 avgcorot[2] = avgcorot[2] + 6. * ( vort_res * n[2] ) * *weight;
152 #elif defined(OPENCL)
153 barrier(CLK_LOCAL_MEM_FENCE);
164 VA_DEVICE_ADDR VA_REAL *A,
165 VA_DEVICE_ADDR VA_REAL *S_RAVG)
171 extern __shared__ VA_REAL s_data[];
172 VA_REAL *Q = &s_data[0];
173 #elif defined(OPENCL)
175 __private VA_REAL Q[9];
183 VA_REAL localResStrain[9];
186 VA_REAL vort_res, s_res, principal_axis[3];
192 sinb = sqrt(1. - cosb*cosb);
198 if (threadIdx.x == 0) {
199 #elif defined(OPENCL)
200 if (get_local_id(0) == 0) {
206 #elif defined(OPENCL)
208 barrier(CLK_LOCAL_MEM_FENCE);
217 principal_axis[2] = 0.;
220 for (i = 0; i < 9; i++) {
221 SO[i] = (VA_REAL) 0.;
226 principal_axis[2] = principal_axis[0];
227 principal_axis[0] = -principal_axis[1];
229 principal_axis[1] = principal_axis[2];
230 principal_axis[2] = (VA_REAL) 0.;
236 if (threadIdx.x == 0) {
237 #elif defined(OPENCL)
238 if (get_local_id(0) == 0) {
244 #elif defined(OPENCL)
246 barrier(CLK_LOCAL_MEM_FENCE);
253 for (i = 0; i < 9; i++) {
254 S_RAVG[i] = S_RAVG[i] + (VA_REAL) 2.5 * localResStrain[i] * *weight;
259 #elif defined(OPENCL)
260 barrier(CLK_LOCAL_MEM_FENCE);
270 VA_DEVICE_ADDR VA_REAL *A,
271 VA_DEVICE_ADDR VA_REAL *result)
273 result[0] = result[0] + *weight;
280 #endif // VA_COROTATION_COMMON_H