Overture  Version 25
FourierOperators.h
Go to the documentation of this file.
1 #ifndef FOURIER_OPERATORS_H
2 #define FOURIER_OPERATORS_H
3 
4 #include "Overture.h"
5 
6 
7 // ===================================================================================
8 // Apply Fourier operations:
9 // o forward and reverse transforms
10 // o derivatives and integrals in fourier space
11 //
12 // arrays are assumed to be of the form
13 // u(nx,ny,nz,C0) : C0=optional components
14 //
15 // ===================================================================================
17 {
18  public:
19  FourierOperators(const int & numberOfDimensions, const int & nx, const int & ny=1, const int & nz=1);
21 
22  void setDimensions(const int & numberOfDimensions, const int & nx, const int & ny=1, const int & nz=1);
23 
24  void setPeriod(const real & xPeriod,
25  const real & yPeriod=twoPi,
26  const real & zPeriod=twoPi ); // set period, default is 2*pi
27 
28  // Change the Ranges over which the transforms are performed. This will also change
29  // the number of points.
30  void setDefaultRanges(const Range & R1, // use this instead of default Range(0,nx-1)
31  const Range & R2=nullRange, // use this instead of default Range(0,ny-1)
32  const Range & R3=nullRange );
33 
34  // real space to fourier space (forward transform)
35  void realToFourier( const RealArray & u, RealArray & uHat, const Range & Components=nullRange );
36 
37  // fourier space to real space (backward transform)
38  void fourierToReal(const RealArray & uHat,
39  RealArray & u,
40  const Range & Components=nullRange );
41 
42  // compute a derivative (or integral) in Fourier space
43  void fourierDerivative(const RealArray & uHat,
44  RealArray & uHatDerivative,
45  const int & xDerivative=1,
46  const int & yDerivative=0,
47  const int & zDerivative=0,
48  const Range & Components=nullRange );
49 
50  // compute
51  // (Laplacian)^power uHat
52  // where power can be positive or negative
53  void fourierLaplacian(const RealArray & uHat,
54  RealArray & uHatLaplacian,
55  const int & power=1,
56  const Range & Components=nullRange );
57 
58  void transform(const int & forwardOrBackward,
59  const RealArray & u,
60  RealArray & uHat,
61  const Range & Components );
62 
63 // --- define versions taking distributed arrays ---
64 #ifdef USE_PPP
65  // real space to fourier space (forward transform)
66  void realToFourier( const RealDistributedArray & u, RealDistributedArray & uHat, const Range & Components=nullRange );
67 
68  // fourier space to real space (backward transform)
69  void fourierToReal(const RealDistributedArray & uHat,
71  const Range & Components=nullRange );
72 
73  // compute a derivative (or integral) in Fourier space
74  void fourierDerivative(const RealDistributedArray & uHat,
75  RealDistributedArray & uHatDerivative,
76  const int & xDerivative=1,
77  const int & yDerivative=0,
78  const int & zDerivative=0,
79  const Range & Components=nullRange );
80 
81  // compute
82  // (Laplacian)^power uHat
83  // where power can be positive or negative
84  void fourierLaplacian(const RealDistributedArray & uHat,
85  RealDistributedArray & uHatLaplacian,
86  const int & power=1,
87  const Range & Components=nullRange );
88 
89  void transform(const int & forwardOrBackward,
90  const RealDistributedArray & u,
91  RealDistributedArray & uHat,
92  const Range & Components );
93 #endif
94 
95  private:
96  int numberOfDimensions,nx,ny,nz;
97  real xPeriod, yPeriod, zPeriod;
98  Range R1,R2,R3;
99  bool initialized;
100  void initialize();
101  RealArray uTemp;
102  RealArray wsavex,wsavey,wsavez;
103  RealArray kSquared,kxDerivative,kyDerivative,kzDerivative;
104 };
105 
106 #endif