Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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:
Inheritance graph
[legend]
Collaboration diagram for Nektar::LibUtilities::NekFFTW:
Collaboration graph
[legend]

Public Member Functions

 NekFFTW (int N)
 
virtual ~NekFFTW ()
 
virtual void v_FFTFwdTrans (Array< OneD, NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
 
virtual void v_FFTBwdTrans (Array< OneD, NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
 
- Public Member Functions inherited from Nektar::LibUtilities::NektarFFT
 NektarFFT (int N)
 Initialises NektarFFT class members. More...
 
 ~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)
 

Protected Attributes

Array< OneD, NekDoublem_FFTW_w
 
Array< OneD, NekDoublem_FFTW_w_inv
 
Array< OneD, NekDoublephys
 
Array< OneD, NekDoublecoef
 
Array< OneD, NekDoublem_wsp
 
fftw_plan plan_backward
 
fftw_plan plan_forward
 

Additional Inherited Members

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

Detailed Description

Definition at line 61 of file NekFFTW.h.

Constructor & Destructor Documentation

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

Definition at line 48 of file NekFFTW.cpp.

References coef, m_FFTW_w, m_FFTW_w_inv, Nektar::LibUtilities::NektarFFT::m_N, m_wsp, phys, plan_backward, and plan_forward.

49  : NektarFFT(N)
50  {
51  m_wsp = Array<OneD, NekDouble>(m_N);
52  phys = Array<OneD,NekDouble>(m_N);
53  coef = Array<OneD,NekDouble>(m_N);
54 
55  plan_forward = fftw_plan_r2r_1d(m_N, &phys[0], &coef[0],
56  FFTW_R2HC, FFTW_ESTIMATE);
57  plan_backward = fftw_plan_r2r_1d(m_N, &coef[0], &phys[0],
58  FFTW_HC2R, FFTW_ESTIMATE);
59 
60  m_FFTW_w = Array<OneD,NekDouble>(m_N);
61  m_FFTW_w_inv = Array<OneD,NekDouble>(m_N);
62 
63  m_FFTW_w[0] = 1.0/(NekDouble)m_N;
64  m_FFTW_w[1] = 0.0;
65 
66  m_FFTW_w_inv[0] = m_N;
67  m_FFTW_w_inv[1] = 0.0;
68 
69  for(int i=2;i<m_N;i++)
70  {
71  m_FFTW_w[i] = m_FFTW_w[0]*2;
72  m_FFTW_w_inv[i] = m_FFTW_w_inv[0]/2;
73  }
74  }
Array< OneD, NekDouble > coef
Definition: NekFFTW.h:94
Array< OneD, NekDouble > m_FFTW_w_inv
Definition: NekFFTW.h:91
NektarFFT(int N)
Initialises NektarFFT class members.
Definition: NektarFFT.cpp:59
Array< OneD, NekDouble > phys
Definition: NekFFTW.h:93
Array< OneD, NekDouble > m_FFTW_w
Definition: NekFFTW.h:90
Array< OneD, NekDouble > m_wsp
Definition: NekFFTW.h:96
double NekDouble
Nektar::LibUtilities::NekFFTW::~NekFFTW ( )
virtual

Definition at line 77 of file NekFFTW.cpp.

78  {
79 
80  }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 66 of file NekFFTW.h.

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

67  {
69  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
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 111 of file NekFFTW.cpp.

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

Referenced by v_FFTFwdTrans().

112  {
113  int halfN = m_N/2;
114 
115  m_wsp[1] = coef[halfN];
116 
117  Vmath::Vcopy(halfN, coef, 1, m_wsp, 2);
118 
119  for(int i = 0; i < (halfN - 1); i++)
120  {
121  m_wsp[(m_N-1)-2*i] = coef[halfN+1+i];
122  }
123 
124  Vmath::Vmul(m_N, m_wsp, 1, m_FFTW_w, 1, coef, 1);
125 
126  return;
127  }
Array< OneD, NekDouble > m_FFTW_w
Definition: NekFFTW.h:90
Array< OneD, NekDouble > m_wsp
Definition: NekFFTW.h:96
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1047
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.cpp:169
void Nektar::LibUtilities::NekFFTW::Reshuffle_Nek2FFTW ( Array< OneD, NekDouble > &  coef)
protected

Definition at line 130 of file NekFFTW.cpp.

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

Referenced by v_FFTBwdTrans().

131  {
132  int halfN = m_N/2;
133 
134  Vmath::Vmul(m_N, coef, 1, m_FFTW_w_inv, 1, coef, 1);
135 
136  m_wsp[halfN] = coef[1];
137 
138  Vmath::Vcopy(halfN, coef, 2, m_wsp, 1);
139 
140  for(int i = 0; i < (halfN-1); i++)
141  {
142  m_wsp[halfN+1+i] = coef[(m_N-1)-2*i];
143  }
144 
145  Vmath::Smul(m_N, 1.0/m_N, m_wsp, 1, coef, 1);
146 
147  return;
148  }
Array< OneD, NekDouble > m_FFTW_w_inv
Definition: NekFFTW.h:91
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:199
Array< OneD, NekDouble > m_wsp
Definition: NekFFTW.h:96
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1047
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.cpp:169
void Nektar::LibUtilities::NekFFTW::v_FFTBwdTrans ( Array< OneD, NekDouble > &  inarray,
Array< OneD, NekDouble > &  outarray 
)
virtual

Reimplemented from Nektar::LibUtilities::NektarFFT.

Definition at line 97 of file NekFFTW.cpp.

References coef, Nektar::LibUtilities::NektarFFT::m_N, phys, plan_backward, Reshuffle_Nek2FFTW(), and Vmath::Vcopy().

100  {
101  Vmath::Vcopy(m_N, inarray, 1, coef, 1);
102 
104 
105  fftw_execute(plan_backward);
106 
107  Vmath::Vcopy(m_N, phys, 1, outarray, 1);
108  }
Array< OneD, NekDouble > coef
Definition: NekFFTW.h:94
Array< OneD, NekDouble > phys
Definition: NekFFTW.h:93
void Reshuffle_Nek2FFTW(Array< OneD, NekDouble > &coef)
Definition: NekFFTW.cpp:130
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1047
void Nektar::LibUtilities::NekFFTW::v_FFTFwdTrans ( Array< OneD, NekDouble > &  inarray,
Array< OneD, NekDouble > &  outarray 
)
virtual

Reimplemented from Nektar::LibUtilities::NektarFFT.

Definition at line 83 of file NekFFTW.cpp.

References coef, Nektar::LibUtilities::NektarFFT::m_N, phys, plan_forward, Reshuffle_FFTW2Nek(), and Vmath::Vcopy().

86  {
87  Vmath::Vcopy(m_N, inarray, 1, phys, 1);
88 
89  fftw_execute(plan_forward);
90 
92 
93  Vmath::Vcopy(m_N, coef, 1, outarray, 1);
94  }
Array< OneD, NekDouble > coef
Definition: NekFFTW.h:94
Array< OneD, NekDouble > phys
Definition: NekFFTW.h:93
void Reshuffle_FFTW2Nek(Array< OneD, NekDouble > &coef)
Definition: NekFFTW.cpp:111
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1047

Member Data Documentation

string Nektar::LibUtilities::NekFFTW::className
static
Initial value:

Name of class.

Definition at line 72 of file NekFFTW.h.

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

Definition at line 94 of file NekFFTW.h.

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

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

Definition at line 90 of file NekFFTW.h.

Referenced by NekFFTW(), and Reshuffle_FFTW2Nek().

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

Definition at line 91 of file NekFFTW.h.

Referenced by NekFFTW(), and Reshuffle_Nek2FFTW().

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

Definition at line 96 of file NekFFTW.h.

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

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

Definition at line 93 of file NekFFTW.h.

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

fftw_plan Nektar::LibUtilities::NekFFTW::plan_backward
protected

Definition at line 98 of file NekFFTW.h.

Referenced by NekFFTW(), and v_FFTBwdTrans().

fftw_plan Nektar::LibUtilities::NekFFTW::plan_forward
protected

Definition at line 99 of file NekFFTW.h.

Referenced by NekFFTW(), and v_FFTFwdTrans().