Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Nektar::LibUtilities::NekFFTW Class Reference

#include <NekFFTW.h>

Inheritance diagram for Nektar::LibUtilities::NekFFTW:
[legend]

Public Member Functions

 NekFFTW (int N)
 
 ~NekFFTW () override
 
- Public Member Functions inherited from Nektar::LibUtilities::NektarFFT
 NektarFFT (int N)
 Initialises NektarFFT class members. More...
 
virtual ~NektarFFT ()
 
void FFTFwdTrans (Array< OneD, NekDouble > &phy, Array< OneD, NekDouble > &coef)
 
void FFTBwdTrans (Array< OneD, NekDouble > &coef, Array< OneD, NekDouble > &phys)
 

Static Public Member Functions

static NektarFFTSharedPtr create (int N)
 Creates an instance of this class. More...
 

Static Public Attributes

static std::string className
 Name of class. More...
 

Protected Member Functions

void Reshuffle_FFTW2Nek (Array< OneD, NekDouble > &coef)
 
void Reshuffle_Nek2FFTW (Array< OneD, NekDouble > &coef)
 
void v_FFTFwdTrans (Array< OneD, NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
 
void v_FFTBwdTrans (Array< OneD, NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
 
virtual void v_FFTFwdTrans (Array< OneD, NekDouble > &phys, Array< OneD, NekDouble > &coef)
 
virtual void v_FFTBwdTrans (Array< OneD, NekDouble > &coef, Array< OneD, NekDouble > &phys)
 

Protected Attributes

Array< OneD, NekDoublem_FFTW_w
 
Array< OneD, NekDoublem_FFTW_w_inv
 
Array< OneD, NekDoublem_phys
 
Array< OneD, NekDoublem_coef
 
Array< OneD, NekDoublem_wsp
 
fftw_plan m_plan_backward
 
fftw_plan m_plan_forward
 

Additional Inherited Members

- Public Attributes inherited from Nektar::LibUtilities::NektarFFT
int m_N
 

Detailed Description

Definition at line 59 of file NekFFTW.h.

Constructor & Destructor Documentation

◆ NekFFTW()

Nektar::LibUtilities::NekFFTW::NekFFTW ( int  N)

Definition at line 44 of file NekFFTW.cpp.

44 : NektarFFT(N)
45{
46 m_wsp = Array<OneD, NekDouble>(m_N);
47 m_phys = Array<OneD, NekDouble>(m_N);
48 m_coef = Array<OneD, NekDouble>(m_N);
49
51 fftw_plan_r2r_1d(m_N, &m_phys[0], &m_coef[0], FFTW_R2HC, FFTW_ESTIMATE);
53 fftw_plan_r2r_1d(m_N, &m_coef[0], &m_phys[0], FFTW_HC2R, FFTW_ESTIMATE);
54
55 m_FFTW_w = Array<OneD, NekDouble>(m_N);
56 m_FFTW_w_inv = Array<OneD, NekDouble>(m_N);
57
58 m_FFTW_w[0] = 1.0 / (NekDouble)m_N;
59 m_FFTW_w[1] = 0.0;
60
61 m_FFTW_w_inv[0] = m_N;
62 m_FFTW_w_inv[1] = 0.0;
63
64 for (int i = 2; i < m_N; i++)
65 {
66 m_FFTW_w[i] = m_FFTW_w[0] * 2;
67 m_FFTW_w_inv[i] = m_FFTW_w_inv[0] / 2;
68 }
69}
Array< OneD, NekDouble > m_coef
Definition: NekFFTW.h:85
Array< OneD, NekDouble > m_phys
Definition: NekFFTW.h:84
Array< OneD, NekDouble > m_wsp
Definition: NekFFTW.h:87
Array< OneD, NekDouble > m_FFTW_w
Definition: NekFFTW.h:80
Array< OneD, NekDouble > m_FFTW_w_inv
Definition: NekFFTW.h:82
NektarFFT(int N)
Initialises NektarFFT class members.
Definition: NektarFFT.cpp:56
double NekDouble

References m_coef, m_FFTW_w, m_FFTW_w_inv, Nektar::LibUtilities::NektarFFT::m_N, m_phys, m_plan_backward, m_plan_forward, and m_wsp.

◆ ~NekFFTW()

Nektar::LibUtilities::NekFFTW::~NekFFTW ( )
override

Definition at line 72 of file NekFFTW.cpp.

73{
74}

Member Function Documentation

◆ create()

static NektarFFTSharedPtr Nektar::LibUtilities::NekFFTW::create ( int  N)
inlinestatic

Creates an instance of this class.

Definition at line 63 of file NekFFTW.h.

64 {
66 }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

◆ Reshuffle_FFTW2Nek()

void Nektar::LibUtilities::NekFFTW::Reshuffle_FFTW2Nek ( Array< OneD, NekDouble > &  coef)
protected

Reshuffling routines to put the coefficients in Nektar++/FFTW format. The routines take as an input the number of points N, the vector of coeffcients and the vector containing the weights of the numerical integration. The routines modify directly the coef vector.

Definition at line 103 of file NekFFTW.cpp.

104{
105 int halfN = m_N / 2;
106
107 m_wsp[1] = coef[halfN];
108
109 Vmath::Vcopy(halfN, coef, 1, m_wsp, 2);
110
111 for (int i = 0; i < (halfN - 1); i++)
112 {
113 m_wsp[(m_N - 1) - 2 * i] = coef[halfN + 1 + i];
114 }
115
116 Vmath::Vmul(m_N, m_wsp, 1, m_FFTW_w, 1, coef, 1);
117
118 return;
119}
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.hpp:72
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825

References m_FFTW_w, Nektar::LibUtilities::NektarFFT::m_N, m_wsp, Vmath::Vcopy(), and Vmath::Vmul().

Referenced by v_FFTFwdTrans().

◆ Reshuffle_Nek2FFTW()

void Nektar::LibUtilities::NekFFTW::Reshuffle_Nek2FFTW ( Array< OneD, NekDouble > &  coef)
protected

Definition at line 122 of file NekFFTW.cpp.

123{
124 int halfN = m_N / 2;
125
126 Vmath::Vmul(m_N, coef, 1, m_FFTW_w_inv, 1, coef, 1);
127
128 m_wsp[halfN] = coef[1];
129
130 Vmath::Vcopy(halfN, coef, 2, m_wsp, 1);
131
132 for (int i = 0; i < (halfN - 1); i++)
133 {
134 m_wsp[halfN + 1 + i] = coef[(m_N - 1) - 2 * i];
135 }
136
137 Vmath::Smul(m_N, 1.0 / m_N, m_wsp, 1, coef, 1);
138
139 return;
140}
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Definition: Vmath.hpp:100

References m_FFTW_w_inv, Nektar::LibUtilities::NektarFFT::m_N, m_wsp, Vmath::Smul(), Vmath::Vcopy(), and Vmath::Vmul().

Referenced by v_FFTBwdTrans().

◆ v_FFTBwdTrans()

void Nektar::LibUtilities::NekFFTW::v_FFTBwdTrans ( Array< OneD, NekDouble > &  inarray,
Array< OneD, NekDouble > &  outarray 
)
overrideprotectedvirtual

Reimplemented from Nektar::LibUtilities::NektarFFT.

Definition at line 90 of file NekFFTW.cpp.

92{
93 Vmath::Vcopy(m_N, inarray, 1, m_coef, 1);
94
96
97 fftw_execute(m_plan_backward);
98
99 Vmath::Vcopy(m_N, m_phys, 1, outarray, 1);
100}
void Reshuffle_Nek2FFTW(Array< OneD, NekDouble > &coef)
Definition: NekFFTW.cpp:122

References m_coef, Nektar::LibUtilities::NektarFFT::m_N, m_phys, m_plan_backward, Reshuffle_Nek2FFTW(), and Vmath::Vcopy().

◆ v_FFTFwdTrans()

void Nektar::LibUtilities::NekFFTW::v_FFTFwdTrans ( Array< OneD, NekDouble > &  inarray,
Array< OneD, NekDouble > &  outarray 
)
overrideprotectedvirtual

Reimplemented from Nektar::LibUtilities::NektarFFT.

Definition at line 77 of file NekFFTW.cpp.

79{
80 Vmath::Vcopy(m_N, inarray, 1, m_phys, 1);
81
82 fftw_execute(m_plan_forward);
83
85
86 Vmath::Vcopy(m_N, m_coef, 1, outarray, 1);
87}
void Reshuffle_FFTW2Nek(Array< OneD, NekDouble > &coef)
Definition: NekFFTW.cpp:103

References m_coef, Nektar::LibUtilities::NektarFFT::m_N, m_phys, m_plan_forward, Reshuffle_FFTW2Nek(), and Vmath::Vcopy().

Member Data Documentation

◆ className

std::string Nektar::LibUtilities::NekFFTW::className
static
Initial value:
=
static NektarFFTSharedPtr create(int N)
Creates an instance of this class.
Definition: NekFFTW.h:63
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:197
NektarFFTFactory & GetNektarFFTFactory()
Definition: NektarFFT.cpp:65

Name of class.

Definition at line 69 of file NekFFTW.h.

◆ m_coef

Array<OneD, NekDouble> Nektar::LibUtilities::NekFFTW::m_coef
protected

Definition at line 85 of file NekFFTW.h.

Referenced by NekFFTW(), v_FFTBwdTrans(), and v_FFTFwdTrans().

◆ m_FFTW_w

Array<OneD, NekDouble> Nektar::LibUtilities::NekFFTW::m_FFTW_w
protected

Definition at line 80 of file NekFFTW.h.

Referenced by NekFFTW(), and Reshuffle_FFTW2Nek().

◆ m_FFTW_w_inv

Array<OneD, NekDouble> Nektar::LibUtilities::NekFFTW::m_FFTW_w_inv
protected

Definition at line 82 of file NekFFTW.h.

Referenced by NekFFTW(), and Reshuffle_Nek2FFTW().

◆ m_phys

Array<OneD, NekDouble> Nektar::LibUtilities::NekFFTW::m_phys
protected

Definition at line 84 of file NekFFTW.h.

Referenced by NekFFTW(), v_FFTBwdTrans(), and v_FFTFwdTrans().

◆ m_plan_backward

fftw_plan Nektar::LibUtilities::NekFFTW::m_plan_backward
protected

Definition at line 89 of file NekFFTW.h.

Referenced by NekFFTW(), and v_FFTBwdTrans().

◆ m_plan_forward

fftw_plan Nektar::LibUtilities::NekFFTW::m_plan_forward
protected

Definition at line 90 of file NekFFTW.h.

Referenced by NekFFTW(), and v_FFTFwdTrans().

◆ m_wsp

Array<OneD, NekDouble> Nektar::LibUtilities::NekFFTW::m_wsp
protected

Definition at line 87 of file NekFFTW.h.

Referenced by NekFFTW(), Reshuffle_FFTW2Nek(), and Reshuffle_Nek2FFTW().