5 #ifndef VA_SPHERICAL_INTEGRATORS_H
6 #define VA_SPHERICAL_INTEGRATORS_H
8 #include "common_defs.h"
21 VA_DEVICE_ADDR
void integrand(VA_REAL *n, VA_REAL *weight,
22 VA_DEVICE_ADDR VA_REAL *A,
23 VA_DEVICE_ADDR VA_REAL *result),
24 VA_DEVICE_ADDR VA_REAL *A, VA_DEVICE_ADDR VA_REAL *result)
36 const int VA_FIBONACCI_LEVEL = 15;
39 int precedingFibonacciNumber = 0;
40 int aFibonacciNumber = 1;
41 for (i = 3; i < VA_FIBONACCI_LEVEL; i++ ) {
42 int newNumber = aFibonacciNumber + precedingFibonacciNumber;
43 precedingFibonacciNumber = aFibonacciNumber;
44 aFibonacciNumber = newNumber;
47 for (j = 1; j < aFibonacciNumber; j++) {
48 for (i = 2*j-1; i < 2*j+1; i++) {
49 VA_REAL zj_star = 2.* j / (VA_REAL) aFibonacciNumber - 1.;
50 VA_REAL phij_star = VA_PI * j
51 * (VA_REAL) precedingFibonacciNumber
52 / (VA_REAL) aFibonacciNumber;
55 n[2] = zj_star + sin( VA_PI * zj_star ) / VA_PI;
56 n[0] = pow((VA_REAL) -1.,(VA_REAL) 2.+i-2.*j) * cos(phij_star)
57 * sqrt( 1. - n[2]*n[2] );
58 n[1] = pow((VA_REAL) -1.,(VA_REAL) 2.+i-2.*j) * sin(phij_star)
59 * sqrt( 1. - n[2]*n[2] );
62 weight = (1+cos(VA_PI * zj_star)) / (2.*(VA_REAL) aFibonacciNumber);
65 integrand(n, &weight, A, result);
75 VA_DEVICE_ADDR
void integrand(VA_REAL *n, VA_REAL *weight,
76 VA_DEVICE_ADDR VA_REAL *A,
77 VA_DEVICE_ADDR VA_REAL *result),
78 VA_DEVICE_ADDR VA_REAL *A, VA_DEVICE_ADDR VA_REAL *result)
80 #include "bazant_oh_2x61_integration_points.h"
88 for (iround = 0; iround < 2; iround++) {
89 for (ipoint = 0; ipoint < 61; ipoint++) {
91 n[0] = gpoints[ipoint][0];
92 n[1] = gpoints[ipoint][1];
93 n[2] = gpoints[ipoint][2];
103 weight = gpoints[ipoint][3];
106 integrand(n, &weight, A, result);
117 VA_DEVICE_ADDR
void integrand(VA_REAL *n, VA_REAL *weight,
118 VA_DEVICE_ADDR VA_REAL *A,
119 VA_DEVICE_ADDR VA_REAL *result),
120 VA_DEVICE_ADDR VA_REAL *A, VA_DEVICE_ADDR VA_REAL *result,
int numIntervals)
130 VA_REAL stepSize = VA_PI / (VA_REAL) numIntervals;
132 VA_REAL corrFact = stepSize * stepSize / ( (VA_REAL) 4. * VA_PI );
136 for (itheta = 0; itheta < numIntervals; itheta++) {
137 theta = itheta*stepSize + stepSize / (VA_REAL) 2.;
141 sincos(theta, &sinT, &cosT);
142 #elif defined(OPENCL)
143 sinT = native_sin(theta);
144 cosT = native_cos(theta);
150 weight = sinT * corrFact;
152 for (iphi = 0; iphi < 2*numIntervals; iphi++) {
153 phi = iphi*stepSize + stepSize / (VA_REAL) 2.;
157 sincos(phi, &sinP, &cosP);
158 #elif defined(OPENCL)
159 sinP = native_sin(phi);
160 cosP = native_cos(phi);
171 integrand(n, &weight, A, result);
180 #endif // VA_SPHERICAL_INTEGRATORS_H