Block-Structured AMR Software Framework
amrex::FFT::R2C< T, D, DomainStrategy > Class Template Reference

Parallel Discrete Fourier Transform. More...

#include <AMReX_FFT_R2C.H>

Public Types

using MF = std::conditional_t< std::is_same_v< T, Real >, MultiFab, FabArray< BaseFab< T > > >
 
using cMF = FabArray< BaseFab< GpuComplex< T > > >
 

Public Member Functions

 R2C (Box const &domain, Info const &info=Info{})
 Constructor. More...
 
 ~R2C ()
 
 R2C (R2C const &)=delete
 
 R2C (R2C &&)=delete
 
R2Coperator= (R2C const &)=delete
 
R2Coperator= (R2C &&)=delete
 
template<typename F , Direction DIR = D, std::enable_if_t< DIR==Direction::both, int > = 0>
void forwardThenBackward (MF const &inmf, MF &outmf, F const &post_forward)
 Forward and then backward transform. More...
 
template<Direction DIR = D, std::enable_if_t< DIR==Direction::forward||DIR==Direction::both, int > = 0>
void forward (MF const &inmf)
 Forward transform. More...
 
template<Direction DIR = D, std::enable_if_t< DIR==Direction::forward||DIR==Direction::both, int > = 0>
void forward (MF const &inmf, cMF &outmf)
 Forward transform. More...
 
template<Direction DIR = D, std::enable_if_t< DIR==Direction::both, int > = 0>
void backward (MF &outmf)
 Backward transform. More...
 
template<Direction DIR = D, std::enable_if_t< DIR==Direction::backward||DIR==Direction::both, int > = 0>
void backward (cMF const &inmf, MF &outmf)
 Backward transform. More...
 
scalingFactor () const
 
template<Direction DIR = D, std::enable_if_t< DIR==Direction::forward||DIR==Direction::both, int > = 0>
std::pair< cMF *, IntVectgetSpectralData ()
 Get the internal spectral data. More...
 
std::pair< BoxArray, DistributionMappinggetSpectralDataLayout () const
 Get BoxArray and DistributionMapping for spectral data. More...
 
template<typename F >
void post_forward_doit (F const &post_forward)
 
void prepare_openbc ()
 
void backward_doit (MF &outmf, IntVect const &ngout=IntVect(0))
 
template<Direction DIR, std::enable_if_t< DIR==Direction::forward||DIR==Direction::both, int > >
std::pair< typename R2C< T, D, S >::cMF *, IntVectgetSpectralData ()
 

Static Private Member Functions

static std::pair< Plan< T >, Plan< T > > make_c2c_plans (cMF &inout)
 

Private Attributes

Plan< T > m_fft_fwd_x {}
 
Plan< T > m_fft_bwd_x {}
 
Plan< T > m_fft_fwd_y {}
 
Plan< T > m_fft_bwd_y {}
 
Plan< T > m_fft_fwd_z {}
 
Plan< T > m_fft_bwd_z {}
 
Plan< T > m_fft_fwd_x_half {}
 
Plan< T > m_fft_bwd_x_half {}
 
std::unique_ptr< MultiBlockCommMetaDatam_cmd_x2y
 
std::unique_ptr< MultiBlockCommMetaDatam_cmd_y2x
 
std::unique_ptr< MultiBlockCommMetaDatam_cmd_y2z
 
std::unique_ptr< MultiBlockCommMetaDatam_cmd_z2y
 
std::unique_ptr< MultiBlockCommMetaDatam_cmd_x2z
 
std::unique_ptr< MultiBlockCommMetaDatam_cmd_z2x
 
std::unique_ptr< MultiBlockCommMetaDatam_cmd_x2z_half
 
std::unique_ptr< MultiBlockCommMetaDatam_cmd_z2x_half
 
Swap01 m_dtos_x2y {}
 
Swap01 m_dtos_y2x {}
 
Swap02 m_dtos_y2z {}
 
Swap02 m_dtos_z2y {}
 
RotateFwd m_dtos_x2z {}
 
RotateBwd m_dtos_z2x {}
 
MF m_rx
 
cMF m_cx
 
cMF m_cy
 
cMF m_cz
 
std::unique_ptr< char, DataDeleterm_data_1
 
std::unique_ptr< char, DataDeleterm_data_2
 
Box m_real_domain
 
Box m_spectral_domain_x
 
Box m_spectral_domain_y
 
Box m_spectral_domain_z
 
Info m_info
 
bool m_do_alld_fft = false
 
bool m_slab_decomp = false
 
bool m_openbc_half = false
 

Friends

template<typename U >
class OpenBCSolver
 

Detailed Description

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
class amrex::FFT::R2C< T, D, DomainStrategy >

Parallel Discrete Fourier Transform.

This class supports Fourier transforms between real and complex data. The name R2C indicates that the forward transform converts real data to complex data, while the backward transform converts complex data to real data. It should be noted that both directions of transformation are supported, not just from real to complex. The scaling follows the FFTW convention, where applying the forward transform followed by the backward transform scales the original data by the size of the input array.

For more details, we refer the users to https://amrex-codes.github.io/amrex/docs_html/FFT_Chapter.html.

Member Typedef Documentation

◆ cMF

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
using amrex::FFT::R2C< T, D, DomainStrategy >::cMF = FabArray<BaseFab<GpuComplex<T> > >

◆ MF

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
using amrex::FFT::R2C< T, D, DomainStrategy >::MF = std::conditional_t<std::is_same_v<T,Real>, MultiFab, FabArray<BaseFab<T> > >

Constructor & Destructor Documentation

◆ R2C() [1/3]

template<typename T , Direction D, DomainStrategy S>
amrex::FFT::R2C< T, D, S >::R2C ( Box const &  domain,
Info const &  info = Info{} 
)
explicit

Constructor.

Parameters
domainthe forward domain (i.e., the domain of the real data)
infooptional information

◆ ~R2C()

template<typename T , Direction D, DomainStrategy S>
amrex::FFT::R2C< T, D, S >::~R2C< T, D, S >

◆ R2C() [2/3]

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
amrex::FFT::R2C< T, D, DomainStrategy >::R2C ( R2C< T, D, DomainStrategy > const &  )
delete

◆ R2C() [3/3]

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
amrex::FFT::R2C< T, D, DomainStrategy >::R2C ( R2C< T, D, DomainStrategy > &&  )
delete

Member Function Documentation

◆ backward() [1/2]

template<typename T , Direction D, DomainStrategy S>
template<Direction DIR, std::enable_if_t< DIR==Direction::backward||DIR==Direction::both, int > >
void amrex::FFT::R2C< T, D, S >::backward ( cMF const &  inmf,
MF outmf 
)

Backward transform.

This function is not available when this class template is instantiated for forward-only transform.

Parameters
inmfinput data in FabArray<BaseFab<GpuComplex<T>>>
outmfoutput data in MultiFab or FabArray<BaseFab<float>>

◆ backward() [2/2]

template<typename T , Direction D, DomainStrategy S>
template<Direction DIR, std::enable_if_t< DIR==Direction::both, int > >
void amrex::FFT::R2C< T, D, S >::backward ( MF outmf)

Backward transform.

This function is available only when this class template is instantiated for transforms in both directions.

Parameters
outmfoutput data in MultiFab or FabArray<BaseFab<float>>

◆ backward_doit()

template<typename T , Direction D, DomainStrategy S>
void amrex::FFT::R2C< T, D, S >::backward_doit ( MF outmf,
IntVect const &  ngout = IntVect(0) 
)

◆ forward() [1/2]

template<typename T , Direction D, DomainStrategy S>
template<Direction DIR, std::enable_if_t< DIR==Direction::forward||DIR==Direction::both, int > >
void amrex::FFT::R2C< T, D, S >::forward ( MF const &  inmf)

Forward transform.

The output is stored in this object's internal data. This function is not available when this class template is instantiated for backward-only transform.

Parameters
inmfinput data in MultiFab or FabArray<BaseFab<float>>

◆ forward() [2/2]

template<typename T , Direction D, DomainStrategy S>
template<Direction DIR, std::enable_if_t< DIR==Direction::forward||DIR==Direction::both, int > >
void amrex::FFT::R2C< T, D, S >::forward ( MF const &  inmf,
cMF outmf 
)

Forward transform.

This function is not available when this class template is instantiated for backward-only transform.

Parameters
inmfinput data in MultiFab or FabArray<BaseFab<float>>
outmfoutput data in FabArray<BaseFab<GpuComplex<T>>>

◆ forwardThenBackward()

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
template<typename F , Direction DIR = D, std::enable_if_t< DIR==Direction::both, int > = 0>
void amrex::FFT::R2C< T, D, DomainStrategy >::forwardThenBackward ( MF const &  inmf,
MF outmf,
F const &  post_forward 
)
inline

Forward and then backward transform.

This function is available only when this class template is instantiated for transforms in both directions. It's more efficient than calling the forward function that stores the spectral data in a caller provided container followed by the backward function, because this can avoid parallel communication between the internal data and the caller's data container.

Parameters
inmfinput data in MultiFab or FabArray<BaseFab<float>>
outmfoutput data in MultiFab or FabArray<BaseFab<float>>
post_forwarda callable object for processing the post-forward data before the backward transform. Its interface is (int,int,int,GpuComplex<T>&), where the integers are indices in the spectral space, and the reference to the complex number allows for the modification of the spectral data at that location.

◆ getSpectralData() [1/2]

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
template<Direction DIR = D, std::enable_if_t< DIR==Direction::forward||DIR==Direction::both, int > = 0>
std::pair<cMF*,IntVect> amrex::FFT::R2C< T, D, DomainStrategy >::getSpectralData ( )

Get the internal spectral data.

This function is not available when this class template is instantiated for backward-only transform. For performance reasons, the returned data array does not have the usual ordering of (x,y,z). The order is specified in the second part of the return value.

◆ getSpectralData() [2/2]

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
template<Direction DIR, std::enable_if_t< DIR==Direction::forward||DIR==Direction::both, int > >
std::pair<typename R2C<T,D,S>::cMF *, IntVect> amrex::FFT::R2C< T, D, DomainStrategy >::getSpectralData ( )

◆ getSpectralDataLayout()

template<typename T , Direction D, DomainStrategy S>
std::pair< BoxArray, DistributionMapping > amrex::FFT::R2C< T, D, S >::getSpectralDataLayout

Get BoxArray and DistributionMapping for spectral data.

The returned BoxArray and DistributionMapping can be used to build FabArray<BaseFab<GpuComplex<T>>> for spectral data. The returned BoxArray has the usual order of (x,y,z).

◆ make_c2c_plans()

template<typename T , Direction D, DomainStrategy S>
std::pair< Plan< T >, Plan< T > > amrex::FFT::R2C< T, D, S >::make_c2c_plans ( cMF inout)
staticprivate

◆ operator=() [1/2]

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
R2C& amrex::FFT::R2C< T, D, DomainStrategy >::operator= ( R2C< T, D, DomainStrategy > &&  )
delete

◆ operator=() [2/2]

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
R2C& amrex::FFT::R2C< T, D, DomainStrategy >::operator= ( R2C< T, D, DomainStrategy > const &  )
delete

◆ post_forward_doit()

template<typename T , Direction D, DomainStrategy S>
template<typename F >
void amrex::FFT::R2C< T, D, S >::post_forward_doit ( F const &  post_forward)

◆ prepare_openbc()

template<typename T , Direction D, DomainStrategy S>
void amrex::FFT::R2C< T, D, S >::prepare_openbc

◆ scalingFactor()

template<typename T , Direction D, DomainStrategy S>
T amrex::FFT::R2C< T, D, S >::scalingFactor

Scaling factor. If the data goes through forward and then backward, the result multiplied by the scaling factor is equal to the original data.

Friends And Related Function Documentation

◆ OpenBCSolver

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
template<typename U >
friend class OpenBCSolver
friend

Member Data Documentation

◆ m_cmd_x2y

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
std::unique_ptr<MultiBlockCommMetaData> amrex::FFT::R2C< T, D, DomainStrategy >::m_cmd_x2y
private

◆ m_cmd_x2z

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
std::unique_ptr<MultiBlockCommMetaData> amrex::FFT::R2C< T, D, DomainStrategy >::m_cmd_x2z
private

◆ m_cmd_x2z_half

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
std::unique_ptr<MultiBlockCommMetaData> amrex::FFT::R2C< T, D, DomainStrategy >::m_cmd_x2z_half
private

◆ m_cmd_y2x

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
std::unique_ptr<MultiBlockCommMetaData> amrex::FFT::R2C< T, D, DomainStrategy >::m_cmd_y2x
private

◆ m_cmd_y2z

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
std::unique_ptr<MultiBlockCommMetaData> amrex::FFT::R2C< T, D, DomainStrategy >::m_cmd_y2z
private

◆ m_cmd_z2x

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
std::unique_ptr<MultiBlockCommMetaData> amrex::FFT::R2C< T, D, DomainStrategy >::m_cmd_z2x
private

◆ m_cmd_z2x_half

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
std::unique_ptr<MultiBlockCommMetaData> amrex::FFT::R2C< T, D, DomainStrategy >::m_cmd_z2x_half
private

◆ m_cmd_z2y

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
std::unique_ptr<MultiBlockCommMetaData> amrex::FFT::R2C< T, D, DomainStrategy >::m_cmd_z2y
private

◆ m_cx

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
cMF amrex::FFT::R2C< T, D, DomainStrategy >::m_cx
private

◆ m_cy

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
cMF amrex::FFT::R2C< T, D, DomainStrategy >::m_cy
private

◆ m_cz

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
cMF amrex::FFT::R2C< T, D, DomainStrategy >::m_cz
private

◆ m_data_1

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
std::unique_ptr<char,DataDeleter> amrex::FFT::R2C< T, D, DomainStrategy >::m_data_1
private

◆ m_data_2

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
std::unique_ptr<char,DataDeleter> amrex::FFT::R2C< T, D, DomainStrategy >::m_data_2
private

◆ m_do_alld_fft

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
bool amrex::FFT::R2C< T, D, DomainStrategy >::m_do_alld_fft = false
private

◆ m_dtos_x2y

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
Swap01 amrex::FFT::R2C< T, D, DomainStrategy >::m_dtos_x2y {}
private

◆ m_dtos_x2z

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
RotateFwd amrex::FFT::R2C< T, D, DomainStrategy >::m_dtos_x2z {}
private

◆ m_dtos_y2x

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
Swap01 amrex::FFT::R2C< T, D, DomainStrategy >::m_dtos_y2x {}
private

◆ m_dtos_y2z

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
Swap02 amrex::FFT::R2C< T, D, DomainStrategy >::m_dtos_y2z {}
private

◆ m_dtos_z2x

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
RotateBwd amrex::FFT::R2C< T, D, DomainStrategy >::m_dtos_z2x {}
private

◆ m_dtos_z2y

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
Swap02 amrex::FFT::R2C< T, D, DomainStrategy >::m_dtos_z2y {}
private

◆ m_fft_bwd_x

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
Plan<T> amrex::FFT::R2C< T, D, DomainStrategy >::m_fft_bwd_x {}
private

◆ m_fft_bwd_x_half

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
Plan<T> amrex::FFT::R2C< T, D, DomainStrategy >::m_fft_bwd_x_half {}
private

◆ m_fft_bwd_y

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
Plan<T> amrex::FFT::R2C< T, D, DomainStrategy >::m_fft_bwd_y {}
private

◆ m_fft_bwd_z

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
Plan<T> amrex::FFT::R2C< T, D, DomainStrategy >::m_fft_bwd_z {}
private

◆ m_fft_fwd_x

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
Plan<T> amrex::FFT::R2C< T, D, DomainStrategy >::m_fft_fwd_x {}
private

◆ m_fft_fwd_x_half

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
Plan<T> amrex::FFT::R2C< T, D, DomainStrategy >::m_fft_fwd_x_half {}
private

◆ m_fft_fwd_y

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
Plan<T> amrex::FFT::R2C< T, D, DomainStrategy >::m_fft_fwd_y {}
private

◆ m_fft_fwd_z

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
Plan<T> amrex::FFT::R2C< T, D, DomainStrategy >::m_fft_fwd_z {}
private

◆ m_info

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
Info amrex::FFT::R2C< T, D, DomainStrategy >::m_info
private

◆ m_openbc_half

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
bool amrex::FFT::R2C< T, D, DomainStrategy >::m_openbc_half = false
private

◆ m_real_domain

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
Box amrex::FFT::R2C< T, D, DomainStrategy >::m_real_domain
private

◆ m_rx

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
MF amrex::FFT::R2C< T, D, DomainStrategy >::m_rx
private

◆ m_slab_decomp

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
bool amrex::FFT::R2C< T, D, DomainStrategy >::m_slab_decomp = false
private

◆ m_spectral_domain_x

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
Box amrex::FFT::R2C< T, D, DomainStrategy >::m_spectral_domain_x
private

◆ m_spectral_domain_y

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
Box amrex::FFT::R2C< T, D, DomainStrategy >::m_spectral_domain_y
private

◆ m_spectral_domain_z

template<typename T = Real, FFT::Direction D = FFT::Direction::both, FFT::DomainStrategy = FFT::DomainStrategy::slab>
Box amrex::FFT::R2C< T, D, DomainStrategy >::m_spectral_domain_z
private

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