Bridge++  Ver. 2.0.2
index_eo.cpp
Go to the documentation of this file.
1 
14 #include <assert.h>
15 
16 #include "Field/index_eo.h"
17 #include "Field/field_thread-inc.h"
19 
20 const std::string Index_eo::class_name = "Index_eo";
21 
22 //====================================================================
24 {
30 
31  m_Nx2 = m_Nx / 2;
32  m_Nvol2 = m_Nvol / 2;
33 
35 
36  if ((m_Nx % 2) == 1) {
37  vout.crucial("Error at %s: Nx = %d, which must be even.\n",
38  class_name.c_str());
39  exit(EXIT_FAILURE);
40  }
41 
42  // grid coordinate
43  const int ipex = Communicator::ipe(0);
44  const int ipey = Communicator::ipe(1);
45  const int ipez = Communicator::ipe(2);
46  const int ipet = Communicator::ipe(3);
47 
48  // node even/odd
49  m_node_eo
50  = (ipex * m_Nx + ipey * m_Ny + ipez * m_Nz + ipet * m_Nt) % 2;
51 
52  m_yzt_eo.resize(m_Ny * m_Nz * m_Nt);
53  m_site_up.resize(m_Nx2 * m_Ny * m_Nz * m_Nt * 2);
54  m_site_dn.resize(m_Nx2 * m_Ny * m_Nz * m_Nt * 2);
55 
56  for (int it = 0; it < m_Nt; ++it) {
57  for (int iz = 0; iz < m_Nz; ++iz) {
58  for (int iy = 0; iy < m_Ny; ++iy) {
59  int it_global = it + ipet * m_Nt;
60  int iz_global = iz + ipez * m_Nz;
61  int iy_global = iy + ipey * m_Ny;
62  m_yzt_eo[iy + m_Ny * (iz + m_Nz * it)]
63  = (iy_global + iz_global + it_global) % 2;
64  }
65  }
66  }
67 
68  for (int it = 0; it < m_Nt; ++it) {
69  for (int iz = 0; iz < m_Nz; ++iz) {
70  for (int iy = 0; iy < m_Ny; ++iy) {
71  int iyzt = iy + m_Ny * (iz + m_Nz * it);
72  for (int ix2 = 0; ix2 < m_Nx2; ++ix2) {
73  int site2 = ix2 + m_Nx2 * (iy + m_Ny * (iz + m_Nz * it));
74  m_site_up[site2]
75  = ((ix2 + m_yzt_eo[iyzt]) % m_Nx2) + m_Nx2 * iyzt;
76  m_site_up[site2 + m_Nvol2]
77  = ((ix2 + 1 - m_yzt_eo[iyzt]) % m_Nx2) + m_Nx2 * iyzt;
78  m_site_dn[site2]
79  = ((ix2 - 1 + m_yzt_eo[iyzt] + m_Nx2) % m_Nx2) + m_Nx2 * iyzt;
80  m_site_dn[site2 + m_Nvol2]
81  = ((ix2 - m_yzt_eo[iyzt] + m_Nx2) % m_Nx2) + m_Nx2 * iyzt;
82  }
83  }
84  }
85  }
86 }
87 
88 
89 //====================================================================
90 void Index_eo::convertField(Field& field_eo, const Field& field_lex)
91 {
92  const int Nin = field_lex.nin();
93  const int Nex = field_lex.nex();
94  assert(field_lex.nvol() == m_Nvol);
95  assert(field_eo.check_size(Nin, m_Nvol, Nex));
96 
97  int ith, nth, is, ns;
98  set_threadtask(ith, nth, is, ns, m_Nvol);
99 
100 #pragma omp barrier
101 
102  for (int ex = 0; ex < Nex; ++ex) {
103  for (int site = is; site < ns; ++site) {
104  int ix = site % m_Nx;
105  int iyzt = site / m_Nx;
106  int iy = iyzt % m_Ny;
107  int izt = iyzt / m_Ny;
108  int iz = izt % m_Nz;
109  int it = izt / m_Nz;
110  int ix2 = ix / 2;
111  int ieo = (ix + iy + iz + it + m_node_eo) % 2;
112  int site2 = this->site(ix2, iy, iz, it, ieo);
113  for (int in = 0; in < Nin; ++in) {
114  double vt = field_lex.cmp(in, site, ex);
115  field_eo.set(in, site2, ex, vt);
116  }
117  }
118  }
119 
120 #pragma omp barrier
121 }
122 
123 
124 //====================================================================
125 void Index_eo::convertField(Field& field_eo, const Field& field_lex,
126  const int ieo)
127 {
128  const int Nin = field_lex.nin();
129  const int Nex = field_lex.nex();
130  assert(field_lex.nvol() == m_Nvol);
131  assert(field_eo.check_size(Nin, m_Nvol2, Nex));
132 
133  int ith, nth, is, ns;
134  set_threadtask(ith, nth, is, ns, m_Nvol2);
135 
136 #pragma omp barrier
137 
138  for (int ex = 0; ex < Nex; ++ex) {
139  for (int site2 = is; site2 < ns; ++site2) {
140  int ix2 = site2 % m_Nx2;
141  int iyzt = site2 / m_Nx2;
142  int iy = iyzt % m_Ny;
143  int izt = iyzt / m_Ny;
144  int iz = izt % m_Nz;
145  int it = izt / m_Nz;
146  int keo = (iy + iz + it + m_node_eo + ieo) % 2;
147  int ix = 2 * ix2 + keo;
148  int site = m_index_lex.site(ix, iy, iz, it);
149  for (int in = 0; in < Nin; ++in) {
150  double vt = field_lex.cmp(in, site, ex);
151  field_eo.set(in, site2, ex, vt);
152  }
153  }
154  }
155 
156 #pragma omp barrier
157 }
158 
159 
160 //====================================================================
161 void Index_eo::reverseField(Field& field_lex, const Field& field_eo,
162  const int ieo)
163 {
164  const int Nin = field_lex.nin();
165  const int Nex = field_lex.nex();
166  assert(field_lex.nvol() == m_Nvol);
167  assert(field_eo.check_size(Nin, m_Nvol2, Nex));
168 
169  int ith, nth, is, ns;
170  set_threadtask(ith, nth, is, ns, m_Nvol2);
171 
172 #pragma omp barrier
173 
174  for (int ex = 0; ex < Nex; ++ex) {
175  for (int site2 = is; site2 < ns; ++site2) {
176  int ix2 = site2 % m_Nx2;
177  int iyzt = site2 / m_Nx2;
178  int iy = iyzt % m_Ny;
179  int izt = iyzt / m_Ny;
180  int iz = izt % m_Nz;
181  int it = izt / m_Nz;
182  int keo = (iy + iz + it + m_node_eo + ieo) % 2;
183  int ix = 2 * ix2 + keo;
184  int site = m_index_lex.site(ix, iy, iz, it);
185  for (int in = 0; in < Nin; ++in) {
186  double vt = field_eo.cmp(in, site2, ex);
187  field_lex.set(in, site, ex, vt);
188  }
189  }
190  }
191 
192 #pragma omp barrier
193 }
194 
195 
196 //====================================================================
197 void Index_eo::reverseField(Field& field_lex, const Field& field_eo)
198 {
199  const int Nin = field_lex.nin();
200  const int Nex = field_lex.nex();
201  assert(field_lex.nvol() == m_Nvol);
202  assert(field_eo.check_size(Nin, m_Nvol, Nex));
203 
204  int ith, nth, is, ns;
205  set_threadtask(ith, nth, is, ns, m_Nvol);
206 
207 #pragma omp barrier
208 
209  for (int ex = 0; ex < Nex; ++ex) {
210  for (int site = is; site < ns; ++site) {
211  int ix = site % m_Nx;
212  int iyzt = site / m_Nx;
213  int iy = iyzt % m_Ny;
214  int izt = iyzt / m_Ny;
215  int iz = izt % m_Nz;
216  int it = izt / m_Nz;
217  int ix2 = ix / 2;
218  int ieo = (ix + iy + iz + it + m_node_eo) % 2;
219  int site2 = this->site(ix2, iy, iz, it, ieo);
220  for (int in = 0; in < Nin; ++in) {
221  double vt = field_eo.cmp(in, site2, ex);
222  field_lex.set(in, site, ex, vt);
223  }
224  }
225  }
226 
227 #pragma omp barrier
228 }
229 
230 
231 //====================================================================
232 void Index_eo::splitField(Field& field_e, Field& field_o,
233  const Field& field_eo)
234 {
235  const int Nin = field_eo.nin();
236  const int Nex = field_eo.nex();
237  assert(field_eo.nvol() == m_Nvol);
238  assert(field_e.check_size(Nin, m_Nvol2, Nex));
239  assert(field_o.check_size(Nin, m_Nvol2, Nex));
240 
241  int ith, nth, is, ns;
242  set_threadtask(ith, nth, is, ns, m_Nvol2);
243 
244 #pragma omp barrier
245 
246  for (int ex = 0; ex < Nex; ++ex) {
247  for (int site2 = is; site2 < ns; ++site2) {
248  for (int in = 0; in < Nin; ++in) {
249  double ve = field_eo.cmp(in, site2, ex);
250  field_e.set(in, site2, ex, ve);
251  double vo = field_eo.cmp(in, site2 + m_Nvol2, ex);
252  field_o.set(in, site2, ex, vo);
253  }
254  }
255  }
256 
257 #pragma omp barrier
258 }
259 
260 
261 //====================================================================
263  const Field& field_e, const Field& field_o)
264 {
265  const int Nin = field_eo.nin();
266  const int Nex = field_eo.nex();
267  assert(field_eo.nvol() == m_Nvol);
268  assert(field_e.check_size(Nin, m_Nvol2, Nex));
269  assert(field_o.check_size(Nin, m_Nvol2, Nex));
270 
271  int ith, nth, is, ns;
272  set_threadtask(ith, nth, is, ns, m_Nvol2);
273 
274 #pragma omp barrier
275 
276  for (int ex = 0; ex < Nex; ++ex) {
277  for (int site2 = is; site2 < ns; ++site2) {
278  for (int in = 0; in < Nin; ++in) {
279  double ve = field_e.cmp(in, site2, ex);
280  field_eo.set(in, site2, ex, ve);
281  double vo = field_o.cmp(in, site2, ex);
282  field_eo.set(in, site2 + m_Nvol2, ex, vo);
283  }
284  }
285  }
286 
287 #pragma omp barrier
288 }
289 
290 
291 //============================================================END=====
Index_eo::m_site_dn
std::vector< int > m_site_dn
Definition: index_eo.h:57
CommonParameters::Ny
static int Ny()
Definition: commonParameters.h:106
CommonParameters::Nz
static int Nz()
Definition: commonParameters.h:107
Index_eo::m_Nx2
int m_Nx2
Definition: index_eo.h:52
Field::set
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
Index_eo::m_Nz
int m_Nz
Definition: index_eo.h:51
Field::nex
int nex() const
Definition: field.h:128
Index_eo::init
void init()
initial setup.
Definition: index_eo.cpp:23
Field::check_size
bool check_size(const int nin, const int nvol, const int nex) const
checking size parameters. [23 May 2016 H.Matsufuru]
Definition: field.h:135
Index_eo::m_vl
Bridge::VerboseLevel m_vl
Definition: index_eo.h:49
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Index_eo::m_node_eo
int m_node_eo
{0, 1}: local origin is on even/odd side
Definition: index_eo.h:53
Field::nin
int nin() const
Definition: field.h:126
Index_eo::m_Nx
int m_Nx
Definition: index_eo.h:51
Index_eo::m_yzt_eo
std::vector< int > m_yzt_eo
Definition: index_eo.h:55
Index_eo::m_site_up
std::vector< int > m_site_up
Definition: index_eo.h:56
Index_eo::reverseField
void reverseField(Field &lex, const Field &eo)
Definition: index_eo.cpp:197
CommonParameters::Nx
static int Nx()
Definition: commonParameters.h:105
Index_eo::site
int site(const int x2, const int y, const int z, const int t, const int ieo) const
Definition: index_eo.h:68
Index_eo::m_Nvol
int m_Nvol
Definition: index_eo.h:51
Index_eo::convertField
void convertField(Field &eo, const Field &lex)
Definition: index_eo.cpp:90
CommonParameters::Nt
static int Nt()
Definition: commonParameters.h:108
threadManager.h
Field::nvol
int nvol() const
Definition: field.h:127
Index_lex::site
int site(const int &x, const int &y, const int &z, const int &t) const
Definition: index_lex.h:55
Index_eo::class_name
static const std::string class_name
Definition: index_eo.h:46
Index_eo::m_Nt
int m_Nt
Definition: index_eo.h:51
Index_eo::splitField
void splitField(Field &e, Field &o, const Field &eo)
Definition: index_eo.cpp:232
Index_eo::mergeField
void mergeField(Field &eo, const Field &e, const Field &o)
Definition: index_eo.cpp:262
Field::cmp
double cmp(const int jin, const int site, const int jex) const
Definition: field.h:143
CommonParameters::Vlevel
static Bridge::VerboseLevel Vlevel()
Definition: commonParameters.h:122
Index_eo::m_index_lex
Index_lex m_index_lex
Definition: index_eo.h:59
Index_eo::m_Ny
int m_Ny
Definition: index_eo.h:51
Communicator::ipe
static int ipe(const int dir)
logical coordinate of current proc.
Definition: communicator.cpp:105
field_thread-inc.h
index_eo.h
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Index_eo::m_Nvol2
int m_Nvol2
Definition: index_eo.h:52
Field
Container of Field-type object.
Definition: field.h:46
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512