Bridge++  Ver. 2.0.2
fft_3d.h
Go to the documentation of this file.
1 
13 #ifndef FFT_3D_INCLUDED
14 #define FFT_3D_INCLUDED
15 
16 #ifdef USE_FFTWLIB
17 
18 // implementations
19 #include "fft.h"
20 #include "fft_3d_local.h"
21 #ifdef USE_MPI
22 #include "fft_3d_parallel1d.h"
23 #include "fft_3d_parallel3d.h"
24 #endif
25 
27 
28 #include "IO/bridgeIO.h"
29 using Bridge::vout;
30 
31 #ifdef USE_FACTORY
32 #include "factory.h"
33 #endif
34 
35 
37 
46 class FFT_3d
47 {
48 #ifdef USE_FACTORY
49  private:
50  static FFT *create_object()
51  {
52  // auto-select
53 
54  int npe_x = Communicator::npe(0);
55  int npe_y = Communicator::npe(1);
56  int npe_z = Communicator::npe(2);
57  int npe_t = Communicator::npe(3);
58 
59  if ((npe_x == 1) && (npe_y == 1) && (npe_z == 1)) {
60  // no parallelization in xyz-directions
61  return new FFT_3d_local;
62 
63 #ifdef USE_MPI
64  } else if ((npe_x == 1) && (npe_y == 1)) {
65  // parallelization only in z-direction
66  return new FFT_3d_parallel1d;
67  } else {
68  // most general case
69  return new FFT_3d_parallel3d;
70 #endif
71  }
72 
73  // default
74  return NULL;
75  }
76 
77  static FFT *create_object_with_params(const Parameters& params)
78  {
79  // auto-select
80 
81  int npe_x = Communicator::npe(0);
82  int npe_y = Communicator::npe(1);
83  int npe_z = Communicator::npe(2);
84  int npe_t = Communicator::npe(3);
85 
86  if ((npe_x == 1) && (npe_y == 1) && (npe_z == 1)) {
87  // no parallelization in xyz-directions
88  return new FFT_3d_local(params);
89 
90 #ifdef USE_MPI
91  } else if ((npe_x == 1) && (npe_y == 1)) {
92  // parallelization only in z-direction
93  return new FFT_3d_parallel1d(params);
94  } else {
95  // most general case
96  return new FFT_3d_parallel3d(params);
97 #endif
98  }
99 
100  // default
101  return NULL;
102  }
103 
104  public:
105  static bool register_factory()
106  {
107  bool init = true;
108  init &= FFT::Factory::Register("auto", create_object);
109  init &= FFT::Factory_params::Register("auto", create_object_with_params);
110  return init;
111  }
112 #endif
113 };
114 
115 //- #endif of #ifdef USE_FFTWLIB
116 #endif
117 #endif
bridgeIO.h
factory.h
Parameters
Class for parameters.
Definition: parameters.h:46
fft_3d_parallel3d.h
Communicator::npe
static int npe(const int dir)
logical grid extent
Definition: communicator.cpp:112
fft.h
communicator.h
fft_3d_parallel1d.h
fft_3d_local.h
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512