Bridge++  Version 1.4.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
index_eo.h
Go to the documentation of this file.
1 
14 #ifndef INDEX_EO_INCLUDED
15 #define INDEX_EO_INCLUDED
16 
17 #include "field_G.h"
19 #include "index_lex.h"
20 
21 #include "IO/bridgeIO.h"
22 using Bridge::vout;
23 
25 
39 class Index_eo {
40  private:
41  int Nx, Ny, Nz, Nt, Nvol;
42  int Nx2, Nvol2;
43  std::valarray<int> Leo;
44  std::valarray<int> Site_up;
45  std::valarray<int> Site_dn;
47  int m_node_eo; // {0, 1} -- local origin is on even/odd side
48 
50  public:
57  Nx2(CommonParameters::Nx() / 2),
58  Nvol2(CommonParameters::Nvol() / 2),
59  m_vl(CommonParameters::Vlevel())
60  {
61  if ((Nx % 2) == 1) {
62  vout.crucial(m_vl, "Error at Index_eo: Nx is not even.\n");
63  exit(EXIT_FAILURE);
64  }
65 
66  // grid coordinate
67  int gx = Communicator::ipe(0);
68  int gy = Communicator::ipe(1);
69  int gz = Communicator::ipe(2);
70  int gt = Communicator::ipe(3);
71 
72  // node even/odd
73  m_node_eo = (gx * Nx + gy * Ny + gz * Nz + gt * Nt) % 2;
74 
75  Leo.resize(Ny * Nz * Nt);
76  Site_up.resize(Nx2 * Ny * Nz * Nt * 2);
77  Site_dn.resize(Nx2 * Ny * Nz * Nt * 2);
78 
79  for (int t = 0; t < Nt; ++t) {
80  for (int z = 0; z < Nz; ++z) {
81  for (int y = 0; y < Ny; ++y) {
82  int t2 = t + gt * Nt;
83  int z2 = z + gz * Nz;
84  int y2 = y + gy * Ny;
85  // int t2 = Communicator::ipe(3) * Nt + t;
86  // int z2 = Communicator::ipe(2) * Nz + z;
87  // int y2 = Communicator::ipe(1) * Ny + y;
88  Leo[y + Ny * (z + Nz * t)] = (y2 + z2 + t2) % 2;
89  }
90  }
91  }
92 
93  for (int t = 0; t < Nt; ++t) {
94  for (int z = 0; z < Nz; ++z) {
95  for (int y = 0; y < Ny; ++y) {
96  int yzt = y + Ny * (z + Nz * t);
97  // int t2 = t;
98  // int z2 = z;
99  // int y2 = y;
100  for (int x2 = 0; x2 < Nx2; ++x2) {
101  int s = x2 + Nx2 * (y + Ny * (z + Nz * t));
102  Site_up[s] = ((x2 + Leo[yzt]) % Nx2) + Nx2 * (y + Ny * (z + Nz * t));
103  Site_up[s + Nvol2] = ((x2 + 1 - Leo[yzt]) % Nx2) + Nx2 * (y + Ny * (z + Nz * t));
104  Site_dn[s] = ((x2 - 1 + Leo[yzt] + Nx2) % Nx2) + Nx2 * (y + Ny * (z + Nz * t));
105  Site_dn[s + Nvol2] = ((x2 - Leo[yzt] + Nx2) % Nx2) + Nx2 * (y + Ny * (z + Nz * t));
106  }
107  }
108  }
109  }
110  }
111 
112  int leo(const int y, const int z, const int t) const
113  {
114  return Leo[y + Ny * (z + Nz * t)];
115  }
116 
117  int site(const int x2, const int y, const int z, const int t,
118  const int ieo) const
119  {
120  return x2 + Nx2 * (y + Ny * (z + Nz * t)) + Nvol2 * ieo;
121  }
122 
123  int site(const int is, const int ieo) const
124  {
125  return is + Nvol2 * ieo;
126  }
127 
128  int site_up(const int x2, const int y, const int z, const int t,
129  const int ieo) const
130  {
131  int s = x2 + Nx2 * (y + Ny * (z + Nz * t)) + Nvol2 * ieo;
132 
133  return Site_up[s] + Nvol2 * (1 - ieo);
134  }
135 
136  int site_xup(const int x2, const int y, const int z, const int t,
137  const int ieo) const
138  {
139  int s = x2 + Nx2 * (y + Ny * (z + Nz * t)) + Nvol2 * ieo;
140 
141  return Site_up[s] + Nvol2 * (1 - ieo);
142  }
143 
144  int site_dn(const int x2, const int y, const int z, const int t,
145  const int ieo) const
146  {
147  int s = x2 + Nx2 * (y + Ny * (z + Nz * t)) + Nvol2 * ieo;
148 
149  return Site_dn[s] + Nvol2 * (1 - ieo);
150  }
151 
152  int site_xdn(const int x2, const int y, const int z, const int t,
153  const int ieo) const
154  {
155  int s = x2 + Nx2 * (y + Ny * (z + Nz * t)) + Nvol2 * ieo;
156 
157  return Site_dn[s] + Nvol2 * (1 - ieo);
158  }
159 
160  int siteh(const int x2, const int y, const int z, const int t)
161  const
162  {
163  return x2 + Nx2 * (y + Ny * (z + Nz * t));
164  }
165 
166  int siteh_up(const int x2, const int y, const int z, const int t,
167  const int ieo) const
168  {
169  int s = x2 + Nx2 * (y + Ny * (z + Nz * t)) + Nvol2 * ieo;
170 
171  return Site_up[s];
172  }
173 
174  int siteh_xup(const int x2, const int y, const int z, const int t,
175  const int ieo) const
176  {
177  int s = x2 + Nx2 * (y + Ny * (z + Nz * t)) + Nvol2 * ieo;
178 
179  return Site_up[s];
180  }
181 
182  int siteh_dn(const int x2, const int y, const int z, const int t,
183  const int ieo) const
184  {
185  int s = x2 + Nx2 * (y + Ny * (z + Nz * t)) + Nvol2 * ieo;
186 
187  return Site_dn[s];
188  }
189 
190  int siteh_xdn(const int x2, const int y, const int z, const int t,
191  const int ieo) const
192  {
193  int s = x2 + Nx2 * (y + Ny * (z + Nz * t)) + Nvol2 * ieo;
194 
195  return Site_dn[s];
196  }
197 
198  void convertField(Field& eo, const Field& lex);
199  void convertField(Field& eo, const Field& lex, const int ieo);
200 
201  void reverseField(Field& lex, const Field& eo);
202  void reverseField(Field& lex, const Field& eo, const int ieo);
203 
204  void splitField(Field& e, Field& o, const Field& eo);
205 
206  void mergeField(Field& eo, const Field& e, const Field& o);
207 };
208 #endif
Index_eo()
Definition: index_eo.h:51
BridgeIO vout
Definition: bridgeIO.cpp:495
int site_xup(const int x2, const int y, const int z, const int t, const int ieo) const
Definition: index_eo.h:136
int siteh(const int x2, const int y, const int z, const int t) const
Definition: index_eo.h:160
int site(const int is, const int ieo) const
Definition: index_eo.h:123
Container of Field-type object.
Definition: field.h:39
int site(const int x2, const int y, const int z, const int t, const int ieo) const
Definition: index_eo.h:117
int site_up(const int x2, const int y, const int z, const int t, const int ieo) const
Definition: index_eo.h:128
static int ipe(const int dir)
logical coordinate of current proc.
Even-odd site index.
Definition: index_eo.h:39
void convertField(Field &eo, const Field &lex)
Definition: index_eo.cpp:20
int leo(const int y, const int z, const int t) const
Definition: index_eo.h:112
int Nt
Definition: index_eo.h:41
void mergeField(Field &eo, const Field &e, const Field &o)
Definition: index_eo.cpp:168
int siteh_up(const int x2, const int y, const int z, const int t, const int ieo) const
Definition: index_eo.h:166
int siteh_xup(const int x2, const int y, const int z, const int t, const int ieo) const
Definition: index_eo.h:174
int Nvol2
Definition: index_eo.h:42
int m_node_eo
Definition: index_eo.h:47
int siteh_xdn(const int x2, const int y, const int z, const int t, const int ieo) const
Definition: index_eo.h:190
int Nx2
Definition: index_eo.h:42
int site_xdn(const int x2, const int y, const int z, const int t, const int ieo) const
Definition: index_eo.h:152
Common parameter class: provides parameters as singleton.
Lexical site index.
Definition: index_lex.h:34
int Nx
Definition: index_eo.h:41
Bridge::VerboseLevel m_vl
Definition: index_eo.h:49
std::valarray< int > Site_up
Definition: index_eo.h:44
int site_dn(const int x2, const int y, const int z, const int t, const int ieo) const
Definition: index_eo.h:144
std::valarray< int > Site_dn
Definition: index_eo.h:45
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
Index_lex m_index_lex
Definition: index_eo.h:46
VerboseLevel
Definition: bridgeIO.h:42
int siteh_dn(const int x2, const int y, const int z, const int t, const int ieo) const
Definition: index_eo.h:182
void reverseField(Field &lex, const Field &eo)
Definition: index_eo.cpp:110
void splitField(Field &e, Field &o, const Field &eo)
Definition: index_eo.cpp:140
std::valarray< int > Leo
Definition: index_eo.h:43
int Nz
Definition: index_eo.h:41
int Nvol
Definition: index_eo.h:41
int Ny
Definition: index_eo.h:41