Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fft_3d_parallel3d.h
Go to the documentation of this file.
1 
14 #ifndef FFT_3D_PARALLEL3D_INCLUDED
15 #define FFT_3D_PARALLEL3D_INCLUDED
16 
17 // requires FFTW library
18 #ifdef USE_FFTWLIB
19 
20 // requires MPI
21 #ifdef USE_MPI
22 
23 #include <fftw3.h>
24 
25 #include "fft.h"
26 #include "Parameters/parameters.h"
28 
29 class FFT_3d_parallel3d : public FFT
30 {
31  public:
32  static const std::string class_name;
33 
34  public:
35  FFT_3d_parallel3d();
36  virtual ~FFT_3d_parallel3d();
37 
38  void fft(Field& dst, const Field& src, enum Direction dir);
39  void fft(Field& dst, const Field& src);
40  void fft(Field& field);
41 
42  void set_parameters(const Parameters& params);
43  void set_parameters(const std::string& direction);
44 
45  private:
46 
47  bool check_ok();
48 
49  void initialize();
50  void finalize();
51 
52  bool need_create_plan(const Field&);
53 
54  void create_plan(int site_dof);
55  void release_plan();
56 
57  void create_mpi_datatype(int site_dof);
58  void release_mpi_datatype();
59 
60  void create_fft_plan(int site_dof);
61  void release_fft_plan();
62 
63  // utility functions
64  std::vector<int> grid_rank_to_coord(int r);
65  int find_global_index(const std::vector<int>& coord);
66 
67  int m_site_dof;
68 
69  // {x,y,z} subcommunicator
70  MPI_Comm m_comm;
71 
72  int m_local_rank;
73  int m_local_ipe_x;
74  int m_local_ipe_y;
75  int m_local_ipe_z;
76 
77  // geometry and grid info of xyz-plane
78  int m_ndims;
79 
80  std::vector<int> m_grid_size;
81  int m_grid_vol;
82 
83  std::vector<int> m_lattice_size;
84  int m_lattice_vol;
85 
86  std::vector<int> m_local_size;
87  int m_local_vol;
88 
89  // datatypes for gather/scatter
90  MPI_Datatype m_site_vector_type;
91  MPI_Datatype m_local_patch_type;
92  MPI_Datatype m_subarray_type;
93 
94  std::vector<int> m_sendcounts;
95  std::vector<int> m_subarray_displs;
96  std::vector<int> m_local_patch_displs;
97 
98  // fft workspace. do fft on-the-fly.
99  fftw_complex *m_buf;
100 
101  fftw_plan m_plan_fw;
102  fftw_plan m_plan_bw;
103 
104  bool m_initialized;
105 
106  // for compatibility with FFT_xyz classes
107  Direction m_direction;
108 
109 
110 #ifdef USE_FACTORY
111  private:
112  static FFT *create_object()
113  {
114  return new FFT_3d_parallel3d();
115  }
116 
117  public:
118  static bool register_factory()
119  {
120  return FFT::Factory::Register("FFT_3d_parallel_3dim", create_object);
121  }
122 #endif
123 };
124 
125 #endif /* USE_MPI */
126 #endif /* USE_FFTWLIB */
127 
128 #endif /* FFT_3D_PARALLEL3D_INCLUDED */
Container of Field-type object.
Definition: field.h:45
Class for parameters.
Definition: parameters.h:46
Direction
Definition: bridge_defs.h:24