struct ath_3d_fft_plan *ath_3d_fft_create_plan(DomainS *pD, int gnx3, int gnx2, int gnx1, int gks, int gke, int gjs, int gje, int gis, int gie, ath_fft_data *data, int al, ath_fft_direction dir) { int nbuf, tmp; struct ath_3d_fft_plan *ath_plan; if ((dir != ATH_FFT_FORWARD) && (dir != ATH_FFT_BACKWARD)) { ath_error("Invalid Athena FFT direction.\n"); } /* Allocate memory for the plan */ ath_plan = (struct ath_3d_fft_plan *)malloc(sizeof(struct ath_3d_fft_plan)); if (ath_plan == NULL) { ath_error("[ath_3d_fft_plan] Couldn't malloc for FFT plan.\n"); } /* Set forward/backward FFT */ ath_plan->dir = dir; /* Set element count (for easy malloc and memset) */ ath_plan->cnt = (gke-gks+1)*(gje-gjs+1)*(gie-gis+1); ath_plan->gcnt = gnx3*gnx2*gnx1; tmp = (al==0 ? 1 : 0); if (data != NULL) tmp = 0; /* If data == NULL, then allocate something (temporarily if tmp=1) */ if (data == NULL) data = (ath_fft_data *)ath_3d_fft_malloc(ath_plan); if (data == NULL) ath_error("[ath_3d_fft_plan] Couln't malloc for FFT plan data.\n"); /* Create the plan */ #ifdef FFT_BLOCK_DECOMP /* Block decomp library plans don't care if forward or backward */ ath_plan->plan = fft_3d_create_plan(pD->Comm_Domain, gnx3, gnx2, gnx1, gks, gke, gjs, gje, gis, gie, gks, gke, gjs, gje, gis, gie, 0, 0, &nbuf); #else /* FFT_BLOCK_DECOMP */ if (dir == ATH_FFT_FORWARD) { ath_plan->plan = fftw_plan_dft_3d(gnx1, gnx2, gnx3, data, data, FFTW_FORWARD, FFTW_MEASURE); } else { ath_plan->plan = fftw_plan_dft_3d(gnx1, gnx2, gnx3, data, data, FFTW_BACKWARD, FFTW_MEASURE); } #endif /* FFT_BLOCK_DECOMP */ if (tmp) ath_3d_fft_free(data); return ath_plan; }
struct fft_plan_3d *call_fft_plan_3d(cow_domain *d, int *nbuf) { const int i0 = cow_domain_getglobalstartindex(d, 0); const int i1 = cow_domain_getnumlocalzonesinterior(d, 0) + i0 - 1; const int j0 = cow_domain_getglobalstartindex(d, 1); const int j1 = cow_domain_getnumlocalzonesinterior(d, 1) + j0 - 1; const int k0 = cow_domain_getglobalstartindex(d, 2); const int k1 = cow_domain_getnumlocalzonesinterior(d, 2) + k0 - 1; const int Nx = cow_domain_getnumglobalzones(d, 0); const int Ny = cow_domain_getnumglobalzones(d, 1); const int Nz = cow_domain_getnumglobalzones(d, 2); return fft_3d_create_plan(d->mpi_cart, Nz, Ny, Nx, k0,k1, j0,j1, i0,i1, k0,k1, j0,j1, i0,i1, SCALED_NOT, PERMUTE_NONE, nbuf); }