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