void Grid::cleanup() { #ifdef HAVE_MPI rfftwnd_mpi_destroy_plan(fft_plan); rfftwnd_mpi_destroy_plan(ifft_plan); #else rfftwnd_destroy_plan(fft_plan); rfftwnd_destroy_plan(ifft_plan); #endif // HAVE_MPI free(data); nx = ny = nz = nxloc = ixmin = nyloc_t = iymin_t = local_size = 0; data = NULL; fft_plan = ifft_plan = NULL; }
void destroy_maxwell_data(maxwell_data *d) { if (d) { int i; for (i = 0; i < d->nplans; ++i) { #if defined(HAVE_FFTW3) FFTW(destroy_plan)((fftplan) (d->plans[i])); FFTW(destroy_plan)((fftplan) (d->iplans[i])); #elif defined(HAVE_FFTW) # ifdef HAVE_MPI # ifdef SCALAR_COMPLEX fftwnd_mpi_destroy_plan((fftplan) (d->plans[i])); fftwnd_mpi_destroy_plan((fftplan) (d->iplans[i])); # else /* not SCALAR_COMPLEX */ rfftwnd_mpi_destroy_plan((fftplan) (d->plans[i])); rfftwnd_mpi_destroy_plan((fftplan) (d->iplans[i])); # endif /* not SCALAR_COMPLEX */ # else /* not HAVE_MPI */ # ifdef SCALAR_COMPLEX fftwnd_destroy_plan((fftplan) (d->plans[i])); fftwnd_destroy_plan((fftplan) (d->iplans[i])); # else /* not SCALAR_COMPLEX */ rfftwnd_destroy_plan((fftplan) (d->plans[i])); rfftwnd_destroy_plan((fftplan) (d->iplans[i])); # endif /* not SCALAR_COMPLEX */ # endif /* not HAVE_MPI */ #endif /* HAVE FFTW */ } free(d->eps_inv); #if defined(HAVE_FFTW3) FFTW(free)(d->fft_data); if (d->fft_data2 != d->fft_data) FFTW(free)(d->fft_data2); #else free(d->fft_data); #endif free(d->k_plus_G); free(d->k_plus_G_normsqr); free(d); } }
rfftwnd_mpi_plan rfftwnd_mpi_create_plan(MPI_Comm comm, int rank, const int *n, fftw_direction dir, int flags) { rfftwnd_mpi_plan p; if (rank < 2) return 0; p = (rfftwnd_mpi_plan) fftw_malloc(sizeof(rfftwnd_mpi_plan_data)); p->p_fft_x = 0; p->p_fft = 0; p->p_transpose = 0; p->p_transpose_inv = 0; p->work = 0; p->p_fft_x = fftw_create_plan(n[0], dir, flags | FFTW_IN_PLACE); p->p_fft = rfftwnd_create_plan(rank-1, n+1, dir, flags | FFTW_IN_PLACE); if (!p->p_fft) rfftwnd_mpi_destroy_plan(p); p->p_transpose = transpose_mpi_create_plan(n[0], p->p_fft->n[0], comm); if (!p->p_transpose) rfftwnd_mpi_destroy_plan(p); p->p_transpose_inv = transpose_mpi_create_plan(p->p_fft->n[0], n[0], comm); if (!p->p_transpose_inv) rfftwnd_mpi_destroy_plan(p); if (n[0] > p->p_fft->nwork) p->work = (fftw_complex *) fftw_malloc(n[0] * sizeof(fftw_complex)); return p; }