PSCF v1.2
Pscf::Prdc::Cpu::FFT< D > Class Template Reference

Fourier transform wrapper. More...

#include <FFT.h>

Public Member Functions

 FFT ()
 Default constructor.
 
virtual ~FFT ()
 Destructor.
 
void setup (IntVec< D > const &meshDimensions)
 Setup grid dimensions, FFT plans and work space.
 
void forwardTransform (RField< D > const &in, RFieldDft< D > &out) const
 Compute forward (real-to-complex) discrete Fourier transform.
 
void inverseTransformUnsafe (RFieldDft< D > &in, RField< D > &out) const
 Compute inverse (complex-to-real) DFT, overwriting the input.
 
void inverseTransformSafe (RFieldDft< D > const &in, RField< D > &out) const
 Compute inverse (complex-to-real) DFT without overwriting input.
 
void forwardTransform (CField< D > const &in, CField< D > &out) const
 Compute forward (complex-to-complex) discrete Fourier transform.
 
void inverseTransform (CField< D > const &in, CField< D > &out) const
 Compute complex-to-complex inverse Fourier transform.
 
IntVec< D > const & meshDimensions () const
 Return the dimensions of the grid for which this was setup.
 
bool isSetup () const
 Has this FFT object been setup?
 

Detailed Description

template<int D>
class Pscf::Prdc::Cpu::FFT< D >

Fourier transform wrapper.

Definition at line 25 of file rpc/solvers/Mixture.h.

Constructor & Destructor Documentation

◆ FFT()

template<int D>
Pscf::Prdc::Cuda::FFT< D >::FFT ( )

Default constructor.

Definition at line 57 of file cpu/FFT.tpp.

◆ ~FFT()

template<int D>
Pscf::Prdc::Cuda::FFT< D >::~FFT ( )
virtual

Destructor.

Definition at line 72 of file cpu/FFT.tpp.

Member Function Documentation

◆ setup()

template<int D>
void Pscf::Prdc::Cuda::FFT< D >::setup ( IntVec< D > const & meshDimensions)

Setup grid dimensions, FFT plans and work space.

Parameters
meshDimensionsDimensions of real-space grid.

Definition at line 92 of file cpu/FFT.tpp.

References Pscf::Prdc::Cpu::CField< D >::allocate(), Pscf::Prdc::Cpu::RField< D >::allocate(), Util::Array< Data >::capacity(), Pscf::Prdc::Cpu::CField< D >::meshDimensions(), Pscf::Prdc::Cpu::RField< D >::meshDimensions(), and UTIL_CHECK.

◆ forwardTransform() [1/2]

template<int D>
void Pscf::Prdc::Cuda::FFT< D >::forwardTransform ( RField< D > const & in,
RFieldDft< D > & out ) const

Compute forward (real-to-complex) discrete Fourier transform.

The resulting complex array is the output of FFTW's forward transform method scaled by a factor of 1/N (where N is the number of grid points). The scaling ensures that a round-trip Fourier transform (forward + inverse) reproduces the original input array.

This function does not overwrite or corrupt the input array.

Parameters
inarray of real values on r-space grid
outarray of complex values on k-space grid

Definition at line 151 of file cpu/FFT.tpp.

References Util::Array< Data >::capacity(), Pscf::Prdc::Cpu::RField< D >::meshDimensions(), Pscf::Prdc::Cpu::RFieldDft< D >::meshDimensions(), and UTIL_CHECK.

◆ inverseTransformUnsafe()

template<int D>
void Pscf::Prdc::Cuda::FFT< D >::inverseTransformUnsafe ( RFieldDft< D > & in,
RField< D > & out ) const

Compute inverse (complex-to-real) DFT, overwriting the input.

The resulting real array is the unaltered output of FFTW's inverse transform function.

NOTE: The inverse transform generally overwrites and corrupts its input. This is the behavior of the complex-to-real (c2r) transform of the underlying FFTW library. See Sec. 2.3 of the FFTW 3 documentation at https://www.fftw.org/fftw3_doc, One-Dimensional DFTs of Real Data: "...the inverse transform (complex to real) has the side-effect of overwriting its input array, ..."

Parameters
inarray of complex values on k-space grid (overwritten)
outarray of real values on r-space grid

Definition at line 179 of file cpu/FFT.tpp.

References Util::Array< Data >::capacity(), Pscf::Prdc::Cpu::RField< D >::meshDimensions(), Pscf::Prdc::Cpu::RFieldDft< D >::meshDimensions(), and UTIL_CHECK.

◆ inverseTransformSafe()

template<int D>
void Pscf::Prdc::Cuda::FFT< D >::inverseTransformSafe ( RFieldDft< D > const & in,
RField< D > & out ) const

Compute inverse (complex-to-real) DFT without overwriting input.

The resulting real array is the unaltered output of FFTW's inverse transform function.

This function makes a copy of the input data and passes the copy to inverseTransformUnsafe to avoid overwriting the input data.

Parameters
inarray of complex values on k-space grid
outarray of real values on r-space grid

Definition at line 197 of file cpu/FFT.tpp.

References Util::Array< Data >::capacity(), and UTIL_CHECK.

◆ forwardTransform() [2/2]

template<int D>
void Pscf::Prdc::Cuda::FFT< D >::forwardTransform ( CField< D > const & in,
CField< D > & out ) const

Compute forward (complex-to-complex) discrete Fourier transform.

The resulting complex array is the output of FFTW's forward transform method scaled by a factor of 1/N (where N is the number of grid points). The scaling ensures that a round-trip Fourier transform (forward + inverse) reproduces the original input array.

This function does not overwrite or corrupt the input array.

Note that, in this transform, the k-space grid is the same size as the r-space grid, which differs from the real-to-complex transform.

Parameters
inarray of complex values on r-space grid
outarray of complex values on k-space grid

Definition at line 214 of file cpu/FFT.tpp.

References Util::Array< Data >::capacity(), Pscf::Prdc::Cpu::CField< D >::meshDimensions(), and UTIL_CHECK.

◆ inverseTransform()

template<int D>
void Pscf::Prdc::Cuda::FFT< D >::inverseTransform ( CField< D > const & in,
CField< D > & out ) const

Compute complex-to-complex inverse Fourier transform.

The resulting complex array is the unaltered output of FFTW's inverse transform function.

Note that, in this transform, the k-space grid is the same size as the r-space grid, which differs from the complex-to-real transform.

Parameters
inarray of complex values on k-space grid
outarray of complex values on r-space grid

Definition at line 241 of file cpu/FFT.tpp.

References Util::Array< Data >::capacity(), Pscf::Prdc::Cpu::CField< D >::meshDimensions(), and UTIL_CHECK.

◆ meshDimensions()

template<int D>
IntVec< D > const & Pscf::Prdc::Cuda::FFT< D >::meshDimensions ( ) const
inline

Return the dimensions of the grid for which this was setup.

Definition at line 217 of file cpu/FFT.h.

Referenced by Pscf::Rpc::Mixture< D >::associate(), Pscf::Rpg::Block< D >::associate(), and Pscf::Rpg::Mixture< D >::associate().

◆ isSetup()

template<int D>
bool Pscf::Prdc::Cuda::FFT< D >::isSetup ( ) const
inline

Has this FFT object been setup?

Definition at line 210 of file cpu/FFT.h.

Referenced by Pscf::Rpc::Mixture< D >::associate(), Pscf::Rpg::Block< D >::associate(), and Pscf::Rpg::Mixture< D >::associate().


The documentation for this class was generated from the following files: