direct.c
/* Precompute some values for the direct interactions. */
Precompute some values for the direct interactions.
Precompute some values for the direct interactions .
int dirprecalc (int numsrcpts) {
	int totbpnbr, nborsvol, rank, sepmax, ncache;
	cplx *grc;
	MPI_Comm_rank (MPI_COMM_WORLD, &rank);
	nbors = nborsvol = 2 * fmaconf.numbuffer + 1;
	nborsvol *= nborsvol * nborsvol;
	nfft = 2 * fmaconf.bspbox;
	nfftprod = nfft * nfft * nfft;
	totbpnbr = nfftprod * nborsvol;
	gridints = FFTW_MALLOC (totbpnbr * sizeof(cplx));
	fprintf (stderr, "Rank %d: Green's function grid size: %ld bytes\n",
			rank, totbpnbr * sizeof(cplx));
	fplan = FFTW_PLAN_DFT_3D (nfft, nfft, nfft,
			gridints, gridints, FFTW_FORWARD, FFTW_MEASURE);
	bplan = FFTW_PLAN_DFT_3D (nfft, nfft, nfft,
			gridints, gridints, FFTW_BACKWARD, FFTW_MEASURE);
	sepmax = nfft + fmaconf.numbuffer * fmaconf.bspbox;
	ncache = PPYR(sepmax);
	grc = malloc(ncache * sizeof(cplx));
	greencache (grc, ncache, fmaconf.k0, fmaconf.cell);
	if (!rank)
		fprintf (stderr, "Cached %d Green's function integrations\n", ncache);
#pragma omp parallel default(shared)
{
	int off[3], l, idx[3];
	cplx *grf;
#pragma omp for
	for (l = 0; l < nborsvol; ++l) {
		GRID(idx, l, nbors, nbors);
		grf = gridints + l * nfftprod;
		off[0] = (idx[0] - fmaconf.numbuffer) * fmaconf.bspbox;
		off[1] = (idx[1] - fmaconf.numbuffer) * fmaconf.bspbox;
		off[2] = (idx[2] - fmaconf.numbuffer) * fmaconf.bspbox;
		greengrid (grf, fmaconf.bspbox, nfft, off, fmaconf.k0, grc);
		FFTW_EXECUTE_DFT (fplan, grf, grf);
	}
}
	mkdircache ();
	free (grc);
	return nfftprod;
}
int dirprecalc ( int numsrcpts ) { int totbpnbr , nborsvol , rank , sepmax , ncache ; cplx * grc ; MPI_Comm_rank ( MPI_COMM_WORLD , & rank ) ; nbors = nborsvol = 2 * fmaconf . numbuffer + 1 ; nborsvol *= nborsvol * nborsvol ; nfft = 2 * fmaconf . bspbox ; nfftprod = nfft * nfft * nfft ; totbpnbr = nfftprod * nborsvol ; gridints = FFTW_MALLOC ( totbpnbr * sizeof ( cplx ) ) ; fprintf ( stderr , " \n " , rank , totbpnbr * sizeof ( cplx ) ) ; fplan = FFTW_PLAN_DFT_3D ( nfft , nfft , nfft , gridints , gridints , FFTW_FORWARD , FFTW_MEASURE ) ; bplan = FFTW_PLAN_DFT_3D ( nfft , nfft , nfft , gridints , gridints , FFTW_BACKWARD , FFTW_MEASURE ) ; sepmax = nfft + fmaconf . numbuffer * fmaconf . bspbox ; ncache = PPYR ( sepmax ) ; grc = malloc ( ncache * sizeof ( cplx ) ) ; greencache ( grc , ncache , fmaconf . k0 , fmaconf . cell ) ; if ( ! rank ) fprintf ( stderr , " \n " , ncache ) ; #pragma  omp parallel default(shared) { int off [ 3 ] , l , idx [ 3 ] ; cplx * grf ; #pragma  omp for for ( l = 0 ; l < nborsvol ; ++ l ) { GRID ( idx , l , nbors , nbors ) ; grf = gridints + l * nfftprod ; off [ 0 ] = ( idx [ 0 ] - fmaconf . numbuffer ) * fmaconf . bspbox ; off [ 1 ] = ( idx [ 1 ] - fmaconf . numbuffer ) * fmaconf . bspbox ; off [ 2 ] = ( idx [ 2 ] - fmaconf . numbuffer ) * fmaconf . bspbox ; greengrid ( grf , fmaconf . bspbox , nfft , off , fmaconf . k0 , grc ) ; FFTW_EXECUTE_DFT ( fplan , grf , grf ) ; } } mkdircache ( ) ; free ( grc ) ; return nfftprod ; }
Precompute some values for the direct interactions.
Precompute some values for the direct interactions .
/* The number of neighbor boxes per dimension. */ /* The number of near-neighbor boxes total. */ /* The FFT size. */ /* Build the expanded grid. */ /* The forward FFT plan transforms all boxes in one pass. */ /* The inverse FFT plan only transforms a single box. */ /* This is the maximum single-index basis separation to be cached. */ /* This is the size of the packed-storage value cache. */ /* Allocate and fill the Green's function integration cache. */ /* Build the Green's function grid for this local box. */ /* Fourier transform the Green's function. */ /* Allocate the local cache structure. */ /* Free the integration cache. */