direct.c
/* Precompute a cache of unique, integrated Green's function values in a packed
 * array to be later used to populate the near-field interactions. */
Precompute a cache of unique, integrated Green's function values in a packed
array to be later used to populate the near-field interactions.
Precompute a cache of unique integrated Green ' s function values in a packed array to be later used to populate the near - field interactions .
int greencache (cplx *grf, int n, real k0, real cell) {
	real zero[3] = { 0., 0., 0. }, dc[3] = { cell, cell, cell };
	grf[0] = rcvint (k0, NULL, zero, dc, duffyint, fsgrnduffy);
#pragma omp parallel default(shared)
{
	int i, j, k, m, l;
	real dist[3];
#pragma omp for
	for (l = 1; l < n; ++l) {
		i = cbrt (6 * l);
		if (PPYR(i) > l) --i;
		m = l - PPYR(i);
		j = sqrt (2 * m);
		if (PTRI(j) > m) --j;
		k = m - PTRI(j);
		dist[0] = cell * i;
		dist[1] = cell * j;
		dist[2] = cell * k;
		grf[l] = rcvint (k0, zero, dist, dc, srcint, fsgreen);
	}
}
	return n;
}
int greencache ( cplx * grf , int n , real k0 , real cell ) { real zero [ 3 ] = { 0. , 0. , 0. } , dc [ 3 ] = { cell , cell , cell } ; grf [ 0 ] = rcvint ( k0 , NULL , zero , dc , duffyint , fsgrnduffy ) ; #pragma  omp parallel default(shared) { int i , j , k , m , l ; real dist [ 3 ] ; #pragma  omp for for ( l = 1 ; l < n ; ++ l ) { i = cbrt ( 6 * l ) ; if ( PPYR ( i ) > l ) -- i ; m = l - PPYR ( i ) ; j = sqrt ( 2 * m ) ; if ( PTRI ( j ) > m ) -- j ; k = m - PTRI ( j ) ; dist [ 0 ] = cell * i ; dist [ 1 ] = cell * j ; dist [ 2 ] = cell * k ; grf [ l ] = rcvint ( k0 , zero , dist , dc , srcint , fsgreen ) ; } } return n ; }
Precompute a cache of unique, integrated Green's function values in a packed
 array to be later used to populate the near-field interactions.
Precompute a cache of unique integrated Green ' s function values in a packed array to be later used to populate the near - field interactions .
/* Compute the self term. */ /* Compute the first grid index from the linear index. */ /* Compute the remainder of the index. */ /* Compute the second grid index from the linear index remainder. */ /* Compute the final grid index. */ /* Compute the distance. */ /* Integrate the appropraite term. */