Bridge++  Ver. 2.0.2
commonParameters.cpp
Go to the documentation of this file.
1 
14 #include "commonParameters.h"
15 
17 
18 #include "IO/bridgeIO.h"
19 using Bridge::vout;
20 
21 // The following setup of NC was changed [18 Mar 2021]
22 #ifdef USE_GROUP_SU3
23 #define NC 3
24 #else
25 #ifdef USE_GROUP_SU2
26 #define NC 2
27 #else
28 #ifdef USE_GROUP_SU_N
29 #define NC 0
30 #endif
31 #endif
32 #endif
33 
34 // initialize static parameters
35 // color, spinor and space-time dimension
36 int CommonParameters::m_Nc = NC; // `const' removed. [07 May 2014]
37 const int CommonParameters::m_Nd = 4;
38 const int CommonParameters::m_Ndim = 4;
39 
40 const double CommonParameters::m_epsilon_criterion = 1.0e-16;
41 
46 
47 long_t CommonParameters::m_Lvol = 0;
48 
54 
55 // note: obsolete. moved to MPI/Communicator_impl.
56 char CommonParameters::m_map_grid[] = "xyzt";
57 
63 
64 //CommonParameters* CommonParameters::m_instance = 0;
66 
68 
69 const std::string CommonParameters::class_name = "CommonParameters";
70 
71 //====================================================================
72 void CommonParameters::init(const std::vector<int>& lattice_size,
73  const std::vector<int>& grid_size)
74 {
75  init(lattice_size, grid_size, 3);
76 }
77 
78 
79 //====================================================================
80 void CommonParameters::init(const std::vector<int>& lattice_size,
81  const std::vector<int>& grid_size,
82  const int Nc)
83 {
84  if (m_initialized == true) {
85  vout.crucial("Error at %s: CommonParameters already initialized.\n", class_name.c_str());
86  exit(EXIT_FAILURE);
87  }
88 
89  m_Nc = Nc;
90 
91  m_Lx = lattice_size[0];
92  m_Ly = lattice_size[1];
93  m_Lz = lattice_size[2];
94  m_Lt = lattice_size[3];
95 
96  m_NPEx = grid_size[0];
97  m_NPEy = grid_size[1];
98  m_NPEz = grid_size[2];
99  m_NPEt = grid_size[3];
100 
101  if (check_parameters() == false) {
102  vout.crucial("Error at %s: check_parameters failed.\n", class_name.c_str());
103  exit(EXIT_FAILURE);
104  }
105 
107 
108  m_initialized = true;
109 }
110 
111 
112 //====================================================================
114 {
115  m_vlevel = vlevel;
116 }
117 
118 
119 //====================================================================
120 int CommonParameters::Lsize(const int dir)
121 {
122  switch (dir)
123  {
124  case 0:
125  return m_Lx;
126 
127  case 1:
128  return m_Ly;
129 
130  case 2:
131  return m_Lz;
132 
133  case 3:
134  return m_Lt;
135 
136  default:
137  vout.crucial("Error at %s: invalid argument value.\n",
138  class_name.c_str());
139  exit(EXIT_FAILURE);
140  return -1;
141  }
142 }
143 
144 
145 //====================================================================
146 int CommonParameters::Nsize(const int dir)
147 {
148  switch (dir)
149  {
150  case 0:
151  return m_Nx;
152 
153  case 1:
154  return m_Ny;
155 
156  case 2:
157  return m_Nz;
158 
159  case 3:
160  return m_Nt;
161 
162  default:
163  vout.crucial("Error at %s: invalid argument value.\n",
164  class_name.c_str());
165  exit(EXIT_FAILURE);
166  return -1;
167  }
168 }
169 
170 
171 //====================================================================
172 int CommonParameters::NPEsize(const int dir)
173 {
174  switch (dir)
175  {
176  case 0:
177  return m_NPEx;
178 
179  case 1:
180  return m_NPEy;
181 
182  case 2:
183  return m_NPEz;
184 
185  case 3:
186  return m_NPEt;
187 
188  default:
189  vout.crucial("Error at %s: invalid argument value.\n",
190  class_name.c_str());
191  exit(EXIT_FAILURE);
192  return -1;
193  }
194 }
195 
196 
197 //====================================================================
199 {
200  if (m_Ndim == 0) return false;
201 
202  if (m_Nc == 0) return false;
203 
204  if (m_Nd == 0) return false;
205 
206  if (m_Lx == 0) return false;
207 
208  if (m_Ly == 0) return false;
209 
210  if (m_Lz == 0) return false;
211 
212  if (m_Lt == 0) return false;
213 
214  m_Lvol = m_Lx * m_Ly * m_Lz * m_Lt;
215 
216  if (m_NPE == 1) {
217  // if (m_NPEx != 1 || m_NPEy != 1 || m_NPEz != 1 || m_NPEt != 1) {
218  // vout.general(m_vl,stderr, "assume NPE_mu = 1\n");
219  // }
220  m_NPEx = m_NPEy = m_NPEz = m_NPEt = 1;
221  }
222 
223  if ((m_Nx != 0) && (m_NPEx != 0) && (m_Lx != m_Nx * m_NPEx)) return false;
224 
225  if ((m_Ny != 0) && (m_NPEy != 0) && (m_Ly != m_Ny * m_NPEy)) return false;
226 
227  if ((m_Nz != 0) && (m_NPEz != 0) && (m_Lz != m_Nz * m_NPEz)) return false;
228 
229  if ((m_Nt != 0) && (m_NPEt != 0) && (m_Lt != m_Nt * m_NPEt)) return false;
230 
231  if ((m_Nx == 0) && (m_NPEx != 0)) {
232  if (m_Lx % m_NPEx != 0) return false; else m_Nx = m_Lx / m_NPEx;
233  }
234  if ((m_Ny == 0) && (m_NPEy != 0)) {
235  if (m_Ly % m_NPEy != 0) return false; else m_Ny = m_Ly / m_NPEy;
236  }
237  if ((m_Nz == 0) && (m_NPEz != 0)) {
238  if (m_Lz % m_NPEz != 0) return false; else m_Nz = m_Lz / m_NPEz;
239  }
240  if ((m_Nt == 0) && (m_NPEt != 0)) {
241  if (m_Lt % m_NPEt != 0) return false; else m_Nt = m_Lt / m_NPEt;
242  }
243 
244  if ((m_Nx != 0) && (m_NPEx == 0)) {
245  if (m_Lx % m_Nx != 0) return false; else m_NPEx = m_Lx / m_Nx;
246  }
247  if ((m_Ny != 0) && (m_NPEy == 0)) {
248  if (m_Ly % m_Ny != 0) return false; else m_NPEy = m_Ly / m_Ny;
249  }
250  if ((m_Nz != 0) && (m_NPEz == 0)) {
251  if (m_Lz % m_Nz != 0) return false; else m_NPEz = m_Lz / m_Nz;
252  }
253  if ((m_Nt != 0) && (m_NPEt == 0)) {
254  if (m_Lt % m_Nt != 0) return false; else m_NPEt = m_Lt / m_Nt;
255  }
256 
257  if ((m_NPEx != 0) && (m_NPEy != 0) && (m_NPEz != 0) && (m_NPEt != 0)) {
258  if ((m_NPE != 0) && (m_NPE != m_NPEx * m_NPEy * m_NPEz * m_NPEt)) return false;
259 
260  if (m_NPE == 0) m_NPE = m_NPEx * m_NPEy * m_NPEz * m_NPEt;
261  }
262 
263  if ((m_Nx != 0) && (m_Ny != 0) && (m_Nz != 0) && (m_Nt != 0)) {
264  if ((m_Nvol != 0) && (m_Nvol != m_Nx * m_Ny * m_Nz * m_Nt)) return false;
265 
266  if (m_Nvol == 0) m_Nvol = m_Nx * m_Ny * m_Nz * m_Nt;
267  }
268 
269  return true;
270 }
271 
272 
273 //====================================================================
275 {
276  vout.general("\n");
277  vout.general("Lattice parameters:\n");
278  vout.general(" Lx = %d, Ly = %d, Lz = %d, Lt = %d,\n",
279  m_Lx, m_Ly, m_Lz, m_Lt);
280  vout.general(" Nx = %d, Ny = %d, Nz = %d, Nt = %d,\n",
281  m_Nx, m_Ny, m_Nz, m_Nt);
282  vout.general(" NPEx = %d, NPEy = %d, NPEz = %d, NPEt = %d,\n",
284  vout.general(" Lvol = %ld, Nvol = %d, NPE = %d,\n",
285  m_Lvol, m_Nvol, m_NPE);
286  vout.general(" Ndim = %d\n", m_Ndim);
287  vout.general(" Nc = %d\n", m_Nc);
288  vout.general(" Nd = %d\n", m_Nd);
289  vout.general("\n");
290 }
291 
292 
293 //====================================================================
294 
295 #ifdef NC
296 #undef NC
297 #endif
298 //============================================================END=====
CommonParameters::m_map_grid
static char m_map_grid[16]
Definition: commonParameters.h:60
bridgeIO.h
CommonParameters::m_NPE
static int m_NPE
Definition: commonParameters.h:59
CommonParameters::m_NPEy
static int m_NPEy
Definition: commonParameters.h:59
CommonParameters::m_Lvol
static long_t m_Lvol
Definition: commonParameters.h:56
CommonParameters::m_Nvol
static int m_Nvol
Definition: commonParameters.h:63
Bridge::GENERAL
@ GENERAL
Definition: bridgeIO.h:45
CommonParameters::m_Lt
static int m_Lt
Definition: commonParameters.h:55
CommonParameters::class_name
static const std::string class_name
Definition: commonParameters.h:44
CommonParameters::init_Vlevel
static void init_Vlevel(Bridge::VerboseLevel vlevel)
initialization for default verbose level.
Definition: commonParameters.cpp:113
CommonParameters::m_initialized
static bool m_initialized
Definition: commonParameters.h:65
CommonParameters::m_Lx
static int m_Lx
Definition: commonParameters.h:55
CommonParameters::m_Lz
static int m_Lz
Definition: commonParameters.h:55
CommonParameters::m_NPEt
static int m_NPEt
Definition: commonParameters.h:59
CommonParameters::Nsize
static int Nsize(const int dir)
Definition: commonParameters.cpp:146
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
NC
#define NC
Definition: field_F_imp_SU2-inc.h:2
CommonParameters::m_epsilon_criterion
static const double m_epsilon_criterion
Definition: commonParameters.h:52
CommonParameters::m_Nd
static const int m_Nd
Definition: commonParameters.h:49
CommonParameters::m_Nc
static int m_Nc
Definition: commonParameters.h:48
CommonParameters::print_parameters
static void print_parameters()
Definition: commonParameters.cpp:274
CommonParameters::m_vlevel
static Bridge::VerboseLevel m_vlevel
Definition: commonParameters.h:74
CommonParameters::Lsize
static int Lsize(const int dir)
Definition: commonParameters.cpp:120
CommonParameters::m_Ly
static int m_Ly
Definition: commonParameters.h:55
CommonParameters::m_Nx
static int m_Nx
Definition: commonParameters.h:63
commonParameters.h
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
CommonParameters::NPEsize
static int NPEsize(const int dir)
Definition: commonParameters.cpp:172
CommonParameters::m_NPEx
static int m_NPEx
Definition: commonParameters.h:59
communicator.h
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
CommonParameters::check_parameters
static bool check_parameters()
Definition: commonParameters.cpp:198
CommonParameters::init
static void init(const std::vector< int > &lattice_size, const std::vector< int > &grid_size)
initialization (Nc=3 is assumed).
Definition: commonParameters.cpp:72
CommonParameters::m_Nt
static int m_Nt
Definition: commonParameters.h:63
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
CommonParameters::m_Nz
static int m_Nz
Definition: commonParameters.h:63
CommonParameters::m_NPEz
static int m_NPEz
Definition: commonParameters.h:59
CommonParameters::m_Ny
static int m_Ny
Definition: commonParameters.h:63
CommonParameters::m_Ndim
static const int m_Ndim
Definition: commonParameters.h:50
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512