1#ifndef PRDC_CPU_FFT_TPP
2#define PRDC_CPU_FFT_TPP
75 fftw_destroy_plan(rcfPlan_);
78 fftw_destroy_plan(criPlan_);
81 fftw_destroy_plan(ccfPlan_);
84 fftw_destroy_plan(cciPlan_);
100 for (
int i = 0; i < D; ++i) {
112 if (!kFieldCopy_.isAllocated()) {
115 if (kFieldCopy_.capacity() != kSize_) {
116 kFieldCopy_.deallocate();
140 makePlans(rField, kFieldCopy_, cFieldIn, cFieldOut);
163 fftw_execute_dft_r2c(rcfPlan_,
const_cast<double*
>(&rField[0]),
167 double scale = 1.0/double(rSize_);
168 for (
int i = 0; i < kSize_; ++i) {
169 kField[i][0] *= scale;
170 kField[i][1] *= scale;
189 fftw_execute_dft_c2r(criPlan_, &kField[0], &rField[0]);
203 kFieldCopy_ = kField;
225 fftw_execute_dft(ccfPlan_,
const_cast<fftw_complex*
>(&rField[0]),
229 double scale = 1.0/double(rSize_);
230 for (
int i = 0; i < rSize_; ++i) {
231 kField[i][0] *= scale;
232 kField[i][1] *= scale;
252 fftw_execute_dft(cciPlan_,
const_cast<fftw_complex*
>(&kField[0]),
267 for (
int i = 0; i < D; ++i) {
269 kMeshDimensions[i] = rMeshDimensions[i];
271 kMeshDimensions[i] = rMeshDimensions[i]/2 + 1;
273 kSize *= kMeshDimensions[i];
An IntVec<D, T> is a D-component vector of elements of integer type T.
Field of complex double precision values on an FFT mesh.
const IntVec< D > & meshDimensions() const
Return mesh dimensions by constant reference.
void allocate(const IntVec< D > &meshDimensions)
Allocate the underlying C array for an FFT grid.
void inverseTransformUnsafe(RFieldDft< D > &in, RField< D > &out) const
Compute inverse (complex-to-real) DFT, overwriting the input.
FFT()
Default constructor.
void forwardTransform(RField< D > const &in, RFieldDft< D > &out) const
Compute forward (real-to-complex) discrete Fourier transform (DFT).
static void computeKMesh(IntVec< D > const &rMeshDimensions, IntVec< D > &kMeshDimensions, int &kSize)
Compute dimensions and size of k-space mesh for DFT of real data.
void inverseTransform(CField< D > const &in, CField< D > &out) const
Compute complex-to-complex inverse Fourier transform.
void setup(IntVec< D > const &meshDimensions)
Setup grid dimensions, FFT plans and work space.
IntVec< D > const & meshDimensions() const
Return the dimensions of the grid for which this was setup.
virtual ~FFT()
Destructor.
void inverseTransformSafe(RFieldDft< D > const &in, RField< D > &out) const
Compute inverse (complex-to-real) DFT without overwriting input.
Fourier transform of a real field on an FFT mesh.
IntVec< D > const & meshDimensions() const
Return vector of spatial mesh dimensions by constant reference.
Field of real double precision values on an FFT mesh.
void allocate(IntVec< D > const &meshDimensions)
Allocate the underlying C array for an FFT grid.
const IntVec< D > & meshDimensions() const
Return mesh dimensions by constant reference.
int capacity() const
Return allocated size.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Fields and FFTs for periodic boundary conditions (CPU)
Periodic fields and crystallography.
PSCF package top-level namespace.