Host FFTW transforms and Kokkos/FFTW layout conversion. More...
#include "fft_wrapper.hpp"
Static Public Member Functions | |
| static void | bspl2fft_2d (const Kokkos::View< Real ** > &bspl_data, Kokkos::View< Complex ** > &fft_data, int nchi, int nphi) |
| Compute an unnormalized full complex 2-D FFT of a real surface. | |
| static void | bspl2fft_3d (const Kokkos::View< Real *** > &bspl_data, Kokkos::View< Complex ** > &fft_data, int ns, int nchi, int nphi, int neq_f, const Kokkos::View< int *** > *filter=nullptr, const Kokkos::View< Real * > *fftminv=nullptr, const Kokkos::View< int ** > *mmin_f=nullptr, const Kokkos::View< int ** > *mmax_f=nullptr) |
| Transform radial B-spline surfaces to packed Fourier coefficients. | |
| static std::size_t | cached_plan_count_2d_backward () |
| Inspect the number of cached backward 2-D transform sizes. | |
| static std::size_t | cached_plan_count_2d_forward () |
| Inspect the number of cached forward 2-D transform sizes. | |
| static void | copy_complex_from_fftw (fftw_complex *fftw_data, const Kokkos::View< Complex ** > &kokkos_data, int neq_f, int nphi) |
| Copy FFTW host storage into a packed complex Kokkos View. | |
| static void | copy_complex_to_fftw (const Kokkos::View< Complex ** > &kokkos_data, fftw_complex *fftw_data, int neq_f, int nphi) |
| Copy a packed complex Kokkos View to FFTW host storage. | |
| static void | copy_from_fftw (fftw_complex *fftw_data, const Kokkos::View< Real *** > &kokkos_data, int ns, int nchi, int nphi) |
| Copy real components from FFTW storage into a 3-D Kokkos View. | |
| static void | copy_to_fftw (const Kokkos::View< Real *** > &kokkos_data, fftw_complex *fftw_data, int ns, int nchi, int nphi) |
| Copy a real 3-D Kokkos View to complex FFTW host storage. | |
| static void | destroy_plan (fftw_plan plan) |
| Destroy a caller-owned FFTW plan when non-null. | |
| static void | execute_backward (fftw_plan plan) |
| Execute a previously created FFTW backward plan. | |
| static void | execute_forward (fftw_plan plan) |
| Execute a previously created FFTW forward plan. | |
| static void | fft2bspl_2d (const Kokkos::View< Complex ** > &fft_data, Kokkos::View< Real ** > &bspl_data, int nchi, int nphi) |
| Compute the normalized real inverse of a full 2-D spectrum. | |
| static void | fft2bspl_3d (const Kokkos::View< Complex ** > &fft_data, Kokkos::View< Real *** > &bspl_data, int ns, int nchi, int nphi, int neq_f, const Kokkos::View< int ** > *mmin_f=nullptr, const Kokkos::View< int ** > *mmax_f=nullptr, bool reconstruct_hermitian_toroidal=false, const char *trace_tag=nullptr) |
| Reconstruct real B-spline surfaces from packed Fourier modes. | |
| static void | init_1d_backward (int n, fftw_plan &plan_backward, fftw_complex *in, fftw_complex *out) |
| Create an unnormalized 1-D backward complex FFTW plan. | |
| static void | init_1d_forward (int n, fftw_plan &plan_forward, fftw_complex *in, fftw_complex *out) |
| Create an unnormalized 1-D forward complex FFTW plan. | |
| static void | init_2d_backward (int nchi, int nphi, fftw_plan &plan_backward, fftw_complex *in, fftw_complex *out) |
Create an unnormalized backward FFT over (chi,phi). | |
| static void | init_2d_forward (int nchi, int nphi, fftw_plan &plan_forward, fftw_complex *in, fftw_complex *out) |
Create an unnormalized forward FFT over (chi,phi). | |
Host FFTW transforms and Kokkos/FFTW layout conversion.
ORB5X stores periodic poloidal (chi) and toroidal (phi) data in Kokkos Views but currently executes transforms with double-complex FFTW plans on host buffers. Flattening is row-major with phi fastest. The raw plan helpers follow FFTW's unnormalized convention; the higher-level 2-D and 3-D pairs apply normalization as documented on each function.
Cached 2-D plans are protected by a mutex and released at process shutdown. They remain FFTW host plans and do not provide device-resident transforms.
|
static |
Compute an unnormalized full complex 2-D FFT of a real surface.
| [in] | bspl_data | Real input [chi][phi]. |
| [out] | fft_data | Full complex spectrum [chi mode][phi mode]. |
| [in] | nchi | Poloidal extent. |
| [in] | nphi | Toroidal extent. |
Referenced by orb5x::bspl2fft_2d().
|
static |
Transform radial B-spline surfaces to packed Fourier coefficients.
| [in] | bspl_data | Real coefficients [s][chi][phi]. |
| [out] | fft_data | Packed complex coefficients [equation][phi mode]. |
| [in] | ns | Number of radial surfaces. |
| [in] | nchi | Requested poloidal transform extent. |
| [in] | nphi | Requested toroidal transform extent. |
| [in] | neq_f | Number of packed radial/poloidal equations; each surface receives neq_f/ns consecutive poloidal slots. |
| [in] | filter | Optional integer multiplier [phi][s][wrapped m]; zero suppresses a mode. |
| [in] | fftminv | Optional per-phi multiplier, applied only with filter. |
| [in] | mmin_f | Optional first retained poloidal-mode metadata [s][phi]. |
| [in] | mmax_f | Must accompany mmin_f to enable mode-selected packing; currently retained for interface parity, while packed width is determined by neq_f/ns. |
The forward coefficients include 1/(nchi_fft*nphi_fft) normalization. Active extents may be reduced to the supplied metadata/filter extents.
Referenced by orb5x::bspl2fft_3d().
|
static |
Inspect the number of cached backward 2-D transform sizes.
|
static |
Inspect the number of cached forward 2-D transform sizes.
|
static |
Copy FFTW host storage into a packed complex Kokkos View.
| [in] | fftw_data | Source of at least neq_f*nphi values. |
| [out] | kokkos_data | Destination [equation][phi]. |
| [in] | neq_f | Equation extent. |
| [in] | nphi | Toroidal extent and fastest flattened index. |
|
static |
Copy a packed complex Kokkos View to FFTW host storage.
| [in] | kokkos_data | Source [equation][phi]. |
| [out] | fftw_data | Destination of at least neq_f*nphi values. |
| [in] | neq_f | Equation extent. |
| [in] | nphi | Toroidal extent and fastest flattened index. |
|
static |
Copy real components from FFTW storage into a 3-D Kokkos View.
| [in] | fftw_data | Source of ns*nchi*nphi complex values. |
| [out] | kokkos_data | Destination [s][chi][phi]. |
| [in] | ns | Radial extent. |
| [in] | nchi | Poloidal extent. |
| [in] | nphi | Toroidal extent and fastest flattened index. |
|
static |
Copy a real 3-D Kokkos View to complex FFTW host storage.
| [in] | kokkos_data | Source [s][chi][phi]. |
| [out] | fftw_data | Destination of at least ns*nchi*nphi values; the imaginary component is set to zero. |
| [in] | ns | Radial extent. |
| [in] | nchi | Poloidal extent. |
| [in] | nphi | Toroidal extent and fastest flattened index. |
|
static |
Destroy a caller-owned FFTW plan when non-null.
| [in] | plan | Plan to release; cached internal plans must not be passed. |
Referenced by orb5x::destroy_plan().
|
static |
Execute a previously created FFTW backward plan.
| [in] | plan | Valid plan still bound to live planning buffers. |
Referenced by orb5x::execute_backward().
|
static |
Execute a previously created FFTW forward plan.
| [in] | plan | Valid plan still bound to live planning buffers. |
Referenced by orb5x::execute_forward().
|
static |
Compute the normalized real inverse of a full 2-D spectrum.
| [in] | fft_data | Complex spectrum [chi mode][phi mode]. |
| [out] | bspl_data | Real part of the inverse [chi][phi]. |
| [in] | nchi | Poloidal extent. |
| [in] | nphi | Toroidal extent. |
1/(nchi*nphi) after FFTW's unnormalized backward transform. Referenced by orb5x::fft2bspl_2d().
|
static |
Reconstruct real B-spline surfaces from packed Fourier modes.
| [in] | fft_data | Packed coefficients [equation][phi mode] produced by bspl2fft_3d() or an equivalent solver. |
| [out] | bspl_data | Real output [s][chi][phi]; untouched extents are zero. |
| [in] | ns | Number of radial surfaces. |
| [in] | nchi | Poloidal inverse-transform extent. |
| [in] | nphi | Toroidal inverse-transform extent. |
| [in] | neq_f | Packed equation count. |
| [in] | mmin_f | Optional first poloidal mode [s][phi]. |
| [in] | mmax_f | Companion metadata enabling selected-mode unpacking; currently not used to set the packed width. |
| [in] | reconstruct_hermitian_toroidal | If true and the full toroidal extent is active, fill negative (m,n) modes by complex conjugacy so the inverse represents a real field. |
| [in] | trace_tag | Optional label enabling pre/post reconstruction traces for radial surface zero. |
No scale is applied after FFTW's backward transform because the matching 3-D forward routine already applies the reciprocal transform size.
Referenced by orb5x::fft2bspl_3d().
|
static |
Create an unnormalized 1-D backward complex FFTW plan.
| [in] | n | Transform length. |
| [out] | plan_backward | Newly allocated plan owned by the caller. |
| [in,out] | in | Planning/execution input buffer of at least n values. |
| [out] | out | Planning/execution output buffer of at least n values. |
Referenced by orb5x::init_1d_backward().
|
static |
Create an unnormalized 1-D forward complex FFTW plan.
| [in] | n | Transform length. |
| [out] | plan_forward | Newly allocated plan owned by the caller. |
| [in,out] | in | Planning/execution input buffer of at least n values. |
| [out] | out | Planning/execution output buffer of at least n values. |
Referenced by orb5x::init_1d_forward().
|
static |
Create an unnormalized backward FFT over (chi,phi).
| [in] | nchi | Poloidal transform length. |
| [in] | nphi | Toroidal transform length and fastest flattened dimension. |
| [out] | plan_backward | Newly allocated plan owned by the caller. |
| [in,out] | in | Buffer of at least nchi*nphi complex values. |
| [out] | out | Buffer of at least nchi*nphi complex values. |
Referenced by orb5x::init_2d_backward().
|
static |
Create an unnormalized forward FFT over (chi,phi).
| [in] | nchi | Poloidal transform length. |
| [in] | nphi | Toroidal transform length and fastest flattened dimension. |
| [out] | plan_forward | Newly allocated plan owned by the caller. |
| [in,out] | in | Buffer of at least nchi*nphi complex values. |
| [out] | out | Buffer of at least nchi*nphi complex values. |
Referenced by orb5x::init_2d_forward().