Bridge++  Ver. 2.0.2
shiftField_eo.cpp
Go to the documentation of this file.
1 
14 #include "Field/shiftField_eo.h"
15 #include "Field/field_thread-inc.h"
17 
18 const std::string ShiftField_eo::class_name = "ShiftField_eo";
19 
20 //====================================================================
21 void ShiftField_eo::init(const int Nin)
22 {
24 
25  vout.paranoiac(m_vl, "%s: construction\n", class_name.c_str());
26 
31  m_Nvol = m_Nx * m_Ny * m_Nz * m_Nt;
32 
33  if ((m_Nx % 2) != 0) {
34  vout.crucial("error in %s: Nx must be even.\n",
35  class_name.c_str());
36  exit(EXIT_FAILURE);
37  }
38 
39  m_Nx2 = m_Nx / 2;
40  m_Nvol2 = m_Nvol / 2;
41 
42  m_Nin = Nin;
43 
44  m_yzt_eo.resize(m_Ny * m_Nz * m_Nt);
45  for (int it = 0; it < m_Nt; ++it) {
46  for (int iz = 0; iz < m_Nz; ++iz) {
47  for (int iy = 0; iy < m_Ny; ++iy) {
48  int it_global = it + Communicator::ipe(3) * m_Nt;
49  int iz_global = iz + Communicator::ipe(2) * m_Nz;
50  int iy_global = iy + Communicator::ipe(1) * m_Ny;
51  m_yzt_eo[iy + m_Ny * (iz + m_Nz * it)]
52  = (iy_global + iz_global + it_global) % 2;
53  }
54  }
55  }
56 
57  if (m_Nin > 0) {
58  vout.paranoiac(m_vl, " Nin = %d: resetting working vectors.\n",
59  m_Nin);
60 
61  int Nvbufx = (m_Ny * m_Nz * m_Nt + 1) / 2;
62  m_wt_x.reset(m_Nin, Nvbufx, 1);
63  m_vt_x.reset(m_Nin, Nvbufx, 1);
64  m_wt_y.reset(m_Nin, m_Nvol2 / m_Ny, 1);
65  m_vt_y.reset(m_Nin, m_Nvol2 / m_Ny, 1);
66  m_wt_z.reset(m_Nin, m_Nvol2 / m_Nz, 1);
67  m_vt_z.reset(m_Nin, m_Nvol2 / m_Nz, 1);
68  m_wt_t.reset(m_Nin, m_Nvol2 / m_Nt, 1);
69  m_vt_t.reset(m_Nin, m_Nvol2 / m_Nt, 1);
70 
71  m_we.reset(m_Nin, m_Nvol2, 1);
72  m_wo.reset(m_Nin, m_Nvol2, 1);
73  m_ve.reset(m_Nin, m_Nvol2, 1);
74  m_vo.reset(m_Nin, m_Nvol2, 1);
75 
76  m_w1.reset(m_Nin, m_Nvol, 1);
77  } else {
78  vout.paranoiac(m_vl, " Nin = %d: working vectors are not set.\n",
79  m_Nin);
80  }
81 
82  vout.paranoiac(m_vl, "%s: construction finished.\n",
83  class_name.c_str());
84 }
85 
86 
87 //====================================================================
89  const int mu, const int ieo)
90 {
91  const int boundary_condition = 1;
92 
93  if (mu == 0) { // x-direction
94  up_xh(v, w, boundary_condition, ieo);
95  } else if (mu == 1) { // y-direction
96  up_yh(v, w, boundary_condition, ieo);
97  } else if (mu == 2) { // z-direction
98  up_zh(v, w, boundary_condition, ieo);
99  } else if (mu == 3) { // t-direction
100  up_th(v, w, boundary_condition, ieo);
101  } else {
102  vout.crucial(m_vl, "Error at %s: wrong mu = %d\n", class_name.c_str(), mu);
103  exit(EXIT_FAILURE);
104  }
105 }
106 
107 
108 //====================================================================
110  const int mu, const int ieo)
111 {
112  const int boundary_condition = 1;
113 
114  if (mu == 0) { // x-direction
115  dn_xh(v, w, boundary_condition, ieo);
116  } else if (mu == 1) { // y-direction
117  dn_yh(v, w, boundary_condition, ieo);
118  } else if (mu == 2) { // z-direction
119  dn_zh(v, w, boundary_condition, ieo);
120  } else if (mu == 3) { // t-direction
121  dn_th(v, w, boundary_condition, ieo);
122  } else {
123  vout.crucial(m_vl, "Error at %s: wrong mu = %d\n", class_name.c_str(), mu);
124  exit(EXIT_FAILURE);
125  }
126 }
127 
128 
129 //====================================================================
131  const int boundary_condition, const int mu, const int ieo)
132 {
133  if (mu == 0) { // x-direction
134  up_xh(v, w, boundary_condition, ieo);
135  } else if (mu == 1) { // y-direction
136  up_yh(v, w, boundary_condition, ieo);
137  } else if (mu == 2) { // z-direction
138  up_zh(v, w, boundary_condition, ieo);
139  } else if (mu == 3) { // t-direction
140  up_th(v, w, boundary_condition, ieo);
141  } else {
142  vout.crucial(m_vl, "Error at %s: wrong mu = %d\n", class_name.c_str(), mu);
143  exit(EXIT_FAILURE);
144  }
145 }
146 
147 
148 //====================================================================
150  const int boundary_condition, const int mu, const int ieo)
151 {
152  if (mu == 0) { // x-direction
153  dn_xh(v, w, boundary_condition, ieo);
154  } else if (mu == 1) { // y-direction
155  dn_yh(v, w, boundary_condition, ieo);
156  } else if (mu == 2) { // z-direction
157  dn_zh(v, w, boundary_condition, ieo);
158  } else if (mu == 3) { // t-direction
159  dn_th(v, w, boundary_condition, ieo);
160  } else {
161  vout.crucial(m_vl, "Error at %s: wrong mu = %d\n", class_name.c_str(), mu);
162  exit(EXIT_FAILURE);
163  }
164 }
165 
166 
167 //====================================================================
168 void ShiftField_eo::backward(Field& v, const Field& w, const int mu)
169 {
170  backward(v, w, 1, mu);
171 }
172 
173 
174 //====================================================================
175 void ShiftField_eo::forward(Field& v, const Field& w, const int mu)
176 {
177  forward(v, w, 1, mu);
178 }
179 
180 
181 //====================================================================
183  const int boundary_condition, const int mu)
184 {
185  const int Nex = w.nex();
186 
187  if (m_Nin > 0) {
188  assert(w.check_size(m_Nin, m_Nvol, Nex));
189  assert(v.check_size(m_Nin, m_Nvol, Nex));
190 
191  for (int ex = 0; ex < Nex; ++ex) {
192  copy(m_w1, 0, w, ex);
193 #pragma omp barrier
194 
196 
197  backward_h(m_ve, m_wo, boundary_condition, mu, 0);
198  backward_h(m_vo, m_we, boundary_condition, mu, 1);
199 
201 
202  copy(v, ex, m_w1, 0);
203 #pragma omp barrier
204  }
205  } else {
207 
208  const int Nin = w.nin();
209  const int Nvol2 = w.nvol() / 2;
210 
211  Field field_e(Nin, Nvol2, Nex);
212  Field field_o(Nin, Nvol2, Nex);
213 
214  Field field_se(Nin, Nvol2, Nex);
215  Field field_so(Nin, Nvol2, Nex);
216 
217  m_index_eo.splitField(field_e, field_o, w);
218 
219  backward_h(field_se, field_o, boundary_condition, mu, 0);
220  backward_h(field_so, field_e, boundary_condition, mu, 1);
221 
222  m_index_eo.mergeField(v, field_se, field_so);
223  }
224 }
225 
226 
227 //====================================================================
229  const int boundary_condition, const int mu)
230 {
231  const int Nex = w.nex();
232 
233  if (m_Nin > 0) {
234  assert(w.check_size(m_Nin, m_Nvol, Nex));
235  assert(v.check_size(m_Nin, m_Nvol, Nex));
236 
237  for (int ex = 0; ex < Nex; ++ex) {
238  copy(m_w1, 0, w, ex);
239 #pragma omp barrier
240 
242 
243  forward_h(m_ve, m_wo, boundary_condition, mu, 0);
244  forward_h(m_vo, m_we, boundary_condition, mu, 1);
245 
247 
248  copy(v, ex, m_w1, 0);
249 #pragma omp barrier
250  }
251  } else {
253 
254  const int Nin = w.nin();
255  const int Nvol2 = w.nvol() / 2;
256  const int Nex = w.nex();
257  assert(v.nvol() == m_Nvol2);
258  assert(v.check_size(Nin, m_Nvol, Nex));
259 
260  Field wt_e(Nin, Nvol2, Nex);
261  Field wt_o(Nin, Nvol2, Nex);
262 
263  Field vt_e(Nin, Nvol2, Nex);
264  Field vt_o(Nin, Nvol2, Nex);
265 
266  m_index_eo.splitField(wt_e, wt_o, w);
267 
268  forward_h(vt_e, wt_o, mu, 0);
269  forward_h(vt_o, wt_e, mu, 1);
270 
271  m_index_eo.mergeField(v, vt_e, vt_o);
272  }
273 }
274 
275 
276 //====================================================================
277 void ShiftField_eo::up_xh(Field& v, const Field& w,
278  const int bc, const int ieo)
279 {
280  double bc2 = 1.0;
281  if (Communicator::ipe(0) == 0) bc2 = bc;
282 
283  int Nin;
284  int Nex = w.nex();
285  int Nvbufx = (m_Ny * m_Nz * m_Nt + 1) / 2;
286 
287  int ith, nth, is, ns;
288  set_threadtask(ith, nth, is, ns, m_Nvol2);
289 
290  double *wt, *vt;
291 
292 #pragma omp barrier
293 
294  if (m_Nin > 0) {
295  wt = m_wt_x.ptr(0);
296  vt = m_vt_x.ptr(0);
297  Nin = m_Nin;
298  } else {
299  is = 0;
300  Nin = w.nin();
301  if (ith == 0) {
302  wt = new double[Nin * Nvbufx];
303  vt = new double[Nin * Nvbufx];
304  ns = m_Nvol2;
305  } else {
306  wt = 0;
307  vt = 0;
308  ns = 0;
309  }
310  }
311 
312  for (int ex = 0; ex < Nex; ++ex) {
313  double *vp = v.ptr(Nin * m_Nvol2 * ex);
314  const double *wp = w.ptr(Nin * m_Nvol2 * ex);
315 
316  for (int site = is; site < ns; ++site) {
317  int ix2 = site % m_Nx2;
318  int iyzt = site / m_Nx2;
319  int keo = (ieo + m_yzt_eo[iyzt]) % 2;
320  if ((ix2 == 0) && (keo == 1)) {
321  int iyzt2 = iyzt / 2;
322  for (int in = 0; in < Nin; ++in) {
323  wt[in + Nin * iyzt2] = bc2 * wp[in + Nin * site];
324  }
325  }
326  }
327 
328 #pragma omp barrier
329 
330 #pragma omp master
331  {
332  int size = Nin * Nvbufx;
333  Communicator::exchange(size, &vt[0], &wt[0], 0, 1, 0);
334  }
335 
336 #pragma omp barrier
337 
338  for (int site = is; site < ns; ++site) {
339  int ix2 = site % m_Nx2;
340  int iyzt = site / m_Nx2;
341  int keo = (ieo + m_yzt_eo[iyzt]) % 2;
342  int ix2n = ix2 + keo;
343  int nei = ix2n + m_Nx2 * iyzt;
344  if (ix2n < m_Nx2) {
345  for (int in = 0; in < Nin; ++in) {
346  vp[in + Nin * site] = wp[in + Nin * nei];
347  }
348  } else {
349  int iyzt2 = iyzt / 2;
350  for (int in = 0; in < Nin; ++in) {
351  vp[in + Nin * site] = vt[in + Nin * iyzt2];
352  }
353  }
354  }
355  }
356 
357  if ((m_Nin == 0) && (ith == 0)) {
358  delete[] wt;
359  delete[] vt;
360  }
361 
362 #pragma omp barrier
363 }
364 
365 
366 //====================================================================
367 void ShiftField_eo::dn_xh(Field& v, const Field& w,
368  const int bc, const int ieo)
369 {
370  double bc2 = 1.0;
371  if (Communicator::ipe(0) == 0) bc2 = bc;
372 
373  int Nin;
374  int Nex = w.nex();
375  int Nvbufx = (m_Ny * m_Nz * m_Nt + 1) / 2;
376 
377  int ith, nth, is, ns;
378  set_threadtask(ith, nth, is, ns, m_Nvol2);
379 
380  double *wt, *vt;
381 
382 #pragma omp barrier
383 
384  if (m_Nin > 0) {
385  wt = m_wt_x.ptr(0);
386  vt = m_vt_x.ptr(0);
387  Nin = m_Nin;
388  } else {
389  is = 0;
390  Nin = w.nin();
391  if (ith == 0) {
392  wt = new double[Nin * Nvbufx];
393  vt = new double[Nin * Nvbufx];
394  ns = m_Nvol2;
395  } else {
396  wt = 0;
397  vt = 0;
398  ns = 0;
399  }
400  }
401 
402  for (int ex = 0; ex < Nex; ++ex) {
403  double *vp = v.ptr(Nin * m_Nvol2 * ex);
404  const double *wp = w.ptr(Nin * m_Nvol2 * ex);
405 
406  for (int site = is; site < ns; ++site) {
407  int ix2 = site % m_Nx2;
408  int iyzt = site / m_Nx2;
409  int keo = (ieo + m_yzt_eo[iyzt]) % 2;
410  if ((ix2 == m_Nx2 - 1) && (keo == 0)) {
411  int iyzt2 = iyzt / 2;
412  for (int in = 0; in < Nin; ++in) {
413  wt[in + Nin * iyzt2] = wp[in + Nin * site];
414  }
415  }
416  }
417 
418 #pragma omp barrier
419 
420 #pragma omp master
421  {
422  int size = Nin * Nvbufx;
423  Communicator::exchange(size, &vt[0], &wt[0], 0, -1, 4);
424  }
425 
426 #pragma omp barrier
427 
428  for (int site = is; site < ns; ++site) {
429  int ix2 = site % m_Nx2;
430  int iyzt = site / m_Nx2;
431  int keo = (ieo + m_yzt_eo[iyzt]) % 2;
432  int ix2n = ix2 - (1 - keo);
433  int nei = ix2n + m_Nx2 * iyzt;
434  if (ix2n >= 0) {
435  for (int in = 0; in < Nin; ++in) {
436  vp[in + Nin * site] = wp[in + Nin * nei];
437  }
438  } else {
439  int iyzt2 = iyzt / 2;
440  for (int in = 0; in < Nin; ++in) {
441  vp[in + Nin * site] = bc2 * vt[in + Nin * iyzt2];
442  }
443  }
444  }
445  }
446 
447  if ((m_Nin == 0) && (ith == 0)) {
448  delete[] wt;
449  delete[] vt;
450  }
451 
452 #pragma omp barrier
453 }
454 
455 
456 //====================================================================
457 void ShiftField_eo::up_yh(Field& v, const Field& w,
458  const int bc, const int ieo)
459 {
460  double bc2 = 1.0;
461  if (Communicator::ipe(1) == 0) bc2 = bc;
462 
463  int Nin;
464  int Nex = w.nex();
465 
466  int ith, nth, is, ns;
467  set_threadtask(ith, nth, is, ns, m_Nvol2);
468 
469  double *wt, *vt;
470 
471 #pragma omp barrier
472 
473  if (m_Nin > 0) {
474  wt = m_wt_y.ptr(0);
475  vt = m_vt_y.ptr(0);
476  Nin = m_Nin;
477  } else {
478  is = 0;
479  Nin = w.nin();
480  if (ith == 0) {
481  wt = new double[Nin * (m_Nvol2 / m_Ny)];
482  vt = new double[Nin * (m_Nvol2 / m_Ny)];
483  ns = m_Nvol2;
484  } else {
485  wt = 0;
486  vt = 0;
487  ns = 0;
488  }
489  }
490 
491  for (int ex = 0; ex < Nex; ++ex) {
492  double *vp = v.ptr(Nin * m_Nvol2 * ex);
493  const double *wp = w.ptr(Nin * m_Nvol2 * ex);
494 
495  for (int site = is; site < ns; ++site) {
496  int ix2 = site % m_Nx2;
497  int iyzt = site / m_Nx2;
498  int iy = iyzt % m_Ny;
499  int izt = iyzt / m_Ny;
500  int ixzt = ix2 + m_Nx2 * izt;
501  if (iy == 0) {
502  for (int in = 0; in < Nin; ++in) {
503  wt[in + Nin * ixzt] = bc2 * wp[in + Nin * site];
504  }
505  }
506  }
507 
508 #pragma omp barrier
509 
510 #pragma omp master
511  {
512  const int size = Nin * (m_Nvol2 / m_Ny);
513  Communicator::exchange(size, &vt[0], &wt[0], 1, 1, 1);
514  }
515 
516 #pragma omp barrier
517 
518  for (int site = is; site < ns; ++site) {
519  int ix2 = site % m_Nx2;
520  int iyzt = site / m_Nx2;
521  int iy = iyzt % m_Ny;
522  int izt = iyzt / m_Ny;
523  int ixzt = ix2 + m_Nx2 * izt;
524  int nei = ix2 + m_Nx2 * (iy + 1 + m_Ny * izt);
525 
526  if (iy < m_Ny - 1) {
527  for (int in = 0; in < Nin; ++in) {
528  vp[in + Nin * site] = wp[in + Nin * nei];
529  }
530  } else {
531  for (int in = 0; in < Nin; ++in) {
532  vp[in + Nin * site] = vt[in + Nin * ixzt];
533  }
534  }
535  }
536  }
537 
538  if ((m_Nin == 0) && (ith == 0)) {
539  delete[] wt;
540  delete[] vt;
541  }
542 
543 #pragma omp barrier
544 }
545 
546 
547 //====================================================================
548 void ShiftField_eo::dn_yh(Field& v, const Field& w,
549  const int bc, const int ieo)
550 {
551  double bc2 = 1.0;
552  if (Communicator::ipe(1) == 0) bc2 = bc;
553 
554  int Nin;
555  int Nex = w.nex();
556 
557  int ith, nth, is, ns;
558  set_threadtask(ith, nth, is, ns, m_Nvol2);
559 
560  double *wt, *vt;
561 
562 #pragma omp barrier
563 
564  if (m_Nin > 0) {
565  wt = m_wt_y.ptr(0);
566  vt = m_vt_y.ptr(0);
567  Nin = m_Nin;
568  } else {
569  is = 0;
570  Nin = w.nin();
571  if (ith == 0) {
572  wt = new double[Nin * (m_Nvol2 / m_Ny)];
573  vt = new double[Nin * (m_Nvol2 / m_Ny)];
574  ns = m_Nvol2;
575  } else {
576  wt = 0;
577  vt = 0;
578  ns = 0;
579  }
580  }
581 
582  for (int ex = 0; ex < Nex; ++ex) {
583  double *vp = v.ptr(Nin * m_Nvol2 * ex);
584  const double *wp = w.ptr(Nin * m_Nvol2 * ex);
585 
586  for (int site = is; site < ns; ++site) {
587  int ix2 = site % m_Nx2;
588  int iyzt = site / m_Nx2;
589  int iy = iyzt % m_Ny;
590  int izt = iyzt / m_Ny;
591  int ixzt = ix2 + m_Nx2 * izt;
592  if (iy == m_Ny - 1) {
593  for (int in = 0; in < Nin; ++in) {
594  wt[in + Nin * ixzt] = wp[in + Nin * site];
595  }
596  }
597  }
598 
599 #pragma omp barrier
600 
601 #pragma omp master
602  {
603  const int size = Nin * (m_Nvol2 / m_Ny);
604  Communicator::exchange(size, &vt[0], &wt[0], 1, -1, 5);
605  }
606 
607 #pragma omp barrier
608 
609  for (int site = is; site < ns; ++site) {
610  int ix2 = site % m_Nx2;
611  int iyzt = site / m_Nx2;
612  int iy = iyzt % m_Ny;
613  int izt = iyzt / m_Ny;
614  int ixzt = ix2 + m_Nx2 * izt;
615  int nei = ix2 + m_Nx2 * (iy - 1 + m_Ny * izt);
616 
617  if (iy > 0) {
618  for (int in = 0; in < Nin; ++in) {
619  vp[in + Nin * site] = wp[in + Nin * nei];
620  }
621  } else {
622  for (int in = 0; in < Nin; ++in) {
623  vp[in + Nin * site] = bc2 * vt[in + Nin * ixzt];
624  }
625  }
626  }
627  }
628 
629  if ((m_Nin == 0) && (ith == 0)) {
630  delete[] wt;
631  delete[] vt;
632  }
633 
634 #pragma omp barrier
635 }
636 
637 
638 //====================================================================
639 void ShiftField_eo::up_zh(Field& v, const Field& w,
640  const int bc, const int ieo)
641 {
642  double bc2 = 1.0;
643  if (Communicator::ipe(2) == 0) bc2 = bc;
644 
645  int Nin;
646  int Nex = w.nex();
647 
648  int ith, nth, is, ns;
649  set_threadtask(ith, nth, is, ns, m_Nvol2);
650 
651  double *wt, *vt;
652 
653  int Nxy = m_Nx2 * m_Ny;
654 
655 #pragma omp barrier
656 
657  if (m_Nin > 0) {
658  wt = m_wt_z.ptr(0);
659  vt = m_vt_z.ptr(0);
660  Nin = m_Nin;
661  } else {
662  is = 0;
663  Nin = w.nin();
664  if (ith == 0) {
665  wt = new double[Nin * (m_Nvol2 / m_Nz)];
666  vt = new double[Nin * (m_Nvol2 / m_Nz)];
667  ns = m_Nvol2;
668  } else {
669  wt = 0;
670  vt = 0;
671  ns = 0;
672  }
673  }
674 
675  for (int ex = 0; ex < Nex; ++ex) {
676  double *vp = v.ptr(Nin * m_Nvol2 * ex);
677  const double *wp = w.ptr(Nin * m_Nvol2 * ex);
678 
679  for (int site = is; site < ns; ++site) {
680  int ixy = site % Nxy;
681  int izt = site / Nxy;
682  int iz = izt % m_Nz;
683  int it = izt / m_Nz;
684  int ixyt = ixy + Nxy * it;
685  if (iz == 0) {
686  for (int in = 0; in < Nin; ++in) {
687  wt[in + Nin * ixyt] = bc2 * wp[in + Nin * site];
688  }
689  }
690  }
691 
692 #pragma omp barrier
693 
694 #pragma omp master
695  {
696  const int size = Nin * (m_Nvol2 / m_Nz);
697  Communicator::exchange(size, &vt[0], &wt[0], 2, 1, 2);
698  }
699 
700 #pragma omp barrier
701 
702  for (int site = is; site < ns; ++site) {
703  int ixy = site % Nxy;
704  int izt = site / Nxy;
705  int iz = izt % m_Nz;
706  int it = izt / m_Nz;
707  int ixyt = ixy + Nxy * it;
708  int nei = ixy + Nxy * (iz + 1 + m_Nz * it);
709 
710  if (iz < m_Nz - 1) {
711  for (int in = 0; in < Nin; ++in) {
712  vp[in + Nin * site] = wp[in + Nin * nei];
713  }
714  } else {
715  for (int in = 0; in < Nin; ++in) {
716  vp[in + Nin * site] = vt[in + Nin * ixyt];
717  }
718  }
719  }
720  }
721 
722  if ((m_Nin == 0) && (ith == 0)) {
723  delete[] wt;
724  delete[] vt;
725  }
726 
727 #pragma omp barrier
728 }
729 
730 
731 //====================================================================
732 void ShiftField_eo::dn_zh(Field& v, const Field& w,
733  const int bc, const int ieo)
734 {
735  double bc2 = 1.0;
736  if (Communicator::ipe(2) == 0) bc2 = bc;
737 
738  int Nin;
739  int Nex = w.nex();
740 
741  int ith, nth, is, ns;
742  set_threadtask(ith, nth, is, ns, m_Nvol2);
743 
744  double *wt, *vt;
745 
746  int Nxy = m_Nx2 * m_Ny;
747 
748 #pragma omp barrier
749 
750  if (m_Nin > 0) {
751  wt = m_wt_z.ptr(0);
752  vt = m_vt_z.ptr(0);
753  Nin = m_Nin;
754  } else {
755  is = 0;
756  Nin = w.nin();
757  if (ith == 0) {
758  wt = new double[Nin * (m_Nvol2 / m_Nz)];
759  vt = new double[Nin * (m_Nvol2 / m_Nz)];
760  ns = m_Nvol2;
761  } else {
762  wt = 0;
763  vt = 0;
764  ns = 0;
765  }
766  }
767 
768  for (int ex = 0; ex < Nex; ++ex) {
769  double *vp = v.ptr(Nin * m_Nvol2 * ex);
770  const double *wp = w.ptr(Nin * m_Nvol2 * ex);
771 
772  for (int site = is; site < ns; ++site) {
773  int ixy = site % Nxy;
774  int izt = site / Nxy;
775  int iz = izt % m_Nz;
776  int it = izt / m_Nz;
777  int ixyt = ixy + Nxy * it;
778  if (iz == m_Nz - 1) {
779  for (int in = 0; in < Nin; ++in) {
780  wt[in + Nin * ixyt] = wp[in + Nin * site];
781  }
782  }
783  }
784 
785 #pragma omp barrier
786 
787 #pragma omp master
788  {
789  const int size = Nin * (m_Nvol2 / m_Nz);
790  Communicator::exchange(size, &vt[0], &wt[0], 2, -1, 6);
791  }
792 
793 #pragma omp barrier
794 
795  for (int site = is; site < ns; ++site) {
796  int ixy = site % Nxy;
797  int izt = site / Nxy;
798  int iz = izt % m_Nz;
799  int it = izt / m_Nz;
800  int ixyt = ixy + Nxy * it;
801  int nei = ixy + Nxy * (iz - 1 + m_Nz * it);
802 
803  if (iz > 0) {
804  for (int in = 0; in < Nin; ++in) {
805  vp[in + Nin * site] = wp[in + Nin * nei];
806  }
807  } else {
808  for (int in = 0; in < Nin; ++in) {
809  vp[in + Nin * site] = bc2 * vt[in + Nin * ixyt];
810  }
811  }
812  }
813  }
814 
815  if ((m_Nin == 0) && (ith == 0)) {
816  delete[] wt;
817  delete[] vt;
818  }
819 
820 #pragma omp barrier
821 }
822 
823 
824 //====================================================================
825 void ShiftField_eo::up_th(Field& v, const Field& w,
826  const int bc, const int ieo)
827 {
828  double bc2 = 1.0;
829  if (Communicator::ipe(3) == 0) bc2 = bc;
830 
831  int Nin;
832  int Nex = w.nex();
833 
834  int ith, nth, is, ns;
835  set_threadtask(ith, nth, is, ns, m_Nvol2);
836 
837  double *wt, *vt;
838 
839  int Nxyz = m_Nx2 * m_Ny * m_Nz;
840 
841 #pragma omp barrier
842 
843  if (m_Nin > 0) {
844  wt = m_wt_t.ptr(0);
845  vt = m_vt_t.ptr(0);
846  Nin = m_Nin;
847  } else {
848  is = 0;
849  Nin = w.nin();
850  if (ith == 0) {
851  wt = new double[Nin * (m_Nvol2 / m_Nt)];
852  vt = new double[Nin * (m_Nvol2 / m_Nt)];
853  ns = m_Nvol2;
854  } else {
855  wt = 0;
856  vt = 0;
857  ns = 0;
858  }
859  }
860 
861  for (int ex = 0; ex < Nex; ++ex) {
862  double *vp = v.ptr(Nin * m_Nvol2 * ex);
863  const double *wp = w.ptr(Nin * m_Nvol2 * ex);
864 
865  for (int site = is; site < ns; ++site) {
866  int ixyz = site % Nxyz;
867  int it = site / Nxyz;
868  if (it == 0) {
869  for (int in = 0; in < Nin; ++in) {
870  wt[in + Nin * ixyz] = bc2 * wp[in + Nin * site];
871  }
872  }
873  }
874 
875 #pragma omp barrier
876 
877 #pragma omp master
878  {
879  const int size = Nin * (m_Nvol2 / m_Nt);
880  Communicator::exchange(size, &vt[0], &wt[0], 3, 1, 3);
881  }
882 
883 #pragma omp barrier
884 
885  for (int site = is; site < ns; ++site) {
886  int ixyz = site % Nxyz;
887  int it = site / Nxyz;
888  int nei = ixyz + Nxyz * (it + 1);
889 
890  if (it < m_Nt - 1) {
891  for (int in = 0; in < Nin; ++in) {
892  vp[in + Nin * site] = wp[in + Nin * nei];
893  }
894  } else {
895  for (int in = 0; in < Nin; ++in) {
896  vp[in + Nin * site] = vt[in + Nin * ixyz];
897  }
898  }
899  }
900  }
901 
902  if ((m_Nin == 0) && (ith == 0)) {
903  delete[] wt;
904  delete[] vt;
905  }
906 
907 #pragma omp barrier
908 }
909 
910 
911 //====================================================================
912 void ShiftField_eo::dn_th(Field& v, const Field& w,
913  const int bc, const int ieo)
914 {
915  double bc2 = 1.0;
916  if (Communicator::ipe(3) == 0) bc2 = bc;
917 
918  int Nin;
919  int Nex = w.nex();
920 
921  int ith, nth, is, ns;
922  set_threadtask(ith, nth, is, ns, m_Nvol2);
923 
924  double *wt, *vt;
925 
926  int Nxyz = m_Nx2 * m_Ny * m_Nz;
927 
928 #pragma omp barrier
929 
930  if (m_Nin > 0) {
931  wt = m_wt_t.ptr(0);
932  vt = m_vt_t.ptr(0);
933  Nin = m_Nin;
934  } else {
935  is = 0;
936  Nin = w.nin();
937  if (ith == 0) {
938  wt = new double[Nin * (m_Nvol2 / m_Nt)];
939  vt = new double[Nin * (m_Nvol2 / m_Nt)];
940  ns = m_Nvol2;
941  } else {
942  wt = 0;
943  vt = 0;
944  ns = 0;
945  }
946  }
947 
948  for (int ex = 0; ex < Nex; ++ex) {
949  double *vp = v.ptr(Nin * m_Nvol2 * ex);
950  const double *wp = w.ptr(Nin * m_Nvol2 * ex);
951 
952  for (int site = is; site < ns; ++site) {
953  int ixyz = site % Nxyz;
954  int it = site / Nxyz;
955  if (it == m_Nt - 1) {
956  for (int in = 0; in < Nin; ++in) {
957  wt[in + Nin * ixyz] = wp[in + Nin * site];
958  }
959  }
960  }
961 
962 #pragma omp barrier
963 
964 #pragma omp master
965  {
966  const int size = Nin * (m_Nvol2 / m_Nt);
967  Communicator::exchange(size, &vt[0], &wt[0], 3, -1, 7);
968  }
969 
970 #pragma omp barrier
971 
972  for (int site = is; site < ns; ++site) {
973  int ixyz = site % Nxyz;
974  int it = site / Nxyz;
975  int nei = ixyz + Nxyz * (it - 1);
976 
977  if (it > 0) {
978  for (int in = 0; in < Nin; ++in) {
979  vp[in + Nin * site] = wp[in + Nin * nei];
980  }
981  } else {
982  for (int in = 0; in < Nin; ++in) {
983  vp[in + Nin * site] = bc2 * vt[in + Nin * ixyz];
984  }
985  }
986  }
987  }
988 
989  if ((m_Nin == 0) && (ith == 0)) {
990  delete[] wt;
991  delete[] vt;
992  }
993 
994 #pragma omp barrier
995 }
996 
997 
998 //============================================================END=====
CommonParameters::Ny
static int Ny()
Definition: commonParameters.h:106
ShiftField_eo::dn_th
void dn_th(Field &, const Field &, const int, const int)
Definition: shiftField_eo.cpp:912
ShiftField_eo::forward_h
void forward_h(Field &, const Field &, const int mu, const int ieo)
Definition: shiftField_eo.cpp:109
CommonParameters::Nz
static int Nz()
Definition: commonParameters.h:107
ShiftField_eo::forward
void forward(Field &, const Field &, const int mu)
Definition: shiftField_eo.cpp:175
ShiftField_eo::m_Nx2
int m_Nx2
Definition: shiftField_eo.h:57
ShiftField_eo::m_Nt
int m_Nt
Definition: shiftField_eo.h:55
ShiftField_eo::m_Nin
int m_Nin
Definition: shiftField_eo.h:54
ShiftField_eo::m_wt_x
Field m_wt_x
Definition: shiftField_eo.h:65
ShiftField_eo::m_vo
Field m_vo
working field (even/odd)
Definition: shiftField_eo.h:71
ShiftField_eo::m_vl
Bridge::VerboseLevel m_vl
Definition: shiftField_eo.h:61
ShiftField_eo::dn_zh
void dn_zh(Field &, const Field &, const int, const int)
Definition: shiftField_eo.cpp:732
Field::nex
int nex() const
Definition: field.h:128
ShiftField_eo::m_w1
Field m_w1
working field (lexical)
Definition: shiftField_eo.h:72
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
ShiftField_eo::m_vt_y
Field m_vt_y
comm. buffer in y-direction
Definition: shiftField_eo.h:66
ShiftField_eo::up_yh
void up_yh(Field &, const Field &, const int, const int)
Definition: shiftField_eo.cpp:457
ShiftField_eo::up_th
void up_th(Field &, const Field &, const int, const int)
Definition: shiftField_eo.cpp:825
Field::nin
int nin() const
Definition: field.h:126
copy
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:212
ShiftField_eo::up_xh
void up_xh(Field &, const Field &, const int, const int)
Definition: shiftField_eo.cpp:277
ShiftField_eo::m_wt_t
Field m_wt_t
Definition: shiftField_eo.h:68
ShiftField_eo::init
void init(const int Nin=0)
Definition: shiftField_eo.cpp:21
Bridge::BridgeIO::paranoiac
void paranoiac(const char *format,...)
Definition: bridgeIO.cpp:238
shiftField_eo.h
ShiftField_eo::dn_yh
void dn_yh(Field &, const Field &, const int, const int)
Definition: shiftField_eo.cpp:548
CommonParameters::Nx
static int Nx()
Definition: commonParameters.h:105
ShiftField_eo::class_name
static const std::string class_name
Definition: shiftField_eo.h:51
ShiftField_eo::m_ve
Field m_ve
Definition: shiftField_eo.h:71
ShiftField_eo::m_vt_t
Field m_vt_t
comm. buffer in t-direction
Definition: shiftField_eo.h:68
ShiftField_eo::m_index_eo
Index_eo m_index_eo
Definition: shiftField_eo.h:59
ShiftField_eo::m_wo
Field m_wo
working field (even/odd)
Definition: shiftField_eo.h:70
ShiftField_eo::m_vt_x
Field m_vt_x
comm. buffer in x-direction
Definition: shiftField_eo.h:65
CommonParameters::Nt
static int Nt()
Definition: commonParameters.h:108
ShiftField_eo::backward_h
void backward_h(Field &, const Field &, const int mu, const int ieo)
Definition: shiftField_eo.cpp:88
ShiftField_eo::up_zh
void up_zh(Field &, const Field &, const int, const int)
Definition: shiftField_eo.cpp:639
threadManager.h
ShiftField_eo::m_wt_y
Field m_wt_y
Definition: shiftField_eo.h:66
ShiftField_eo::m_Ny
int m_Ny
Definition: shiftField_eo.h:55
Field::nvol
int nvol() const
Definition: field.h:127
Field::reset
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=Element_type::COMPLEX)
Definition: field.h:95
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::ptr
const double * ptr(const int jin, const int site, const int jex) const
Definition: field.h:153
ShiftField_eo::m_vt_z
Field m_vt_z
comm. buffer in z-direction
Definition: shiftField_eo.h:67
ShiftField_eo::m_Nvol2
int m_Nvol2
Definition: shiftField_eo.h:57
CommonParameters::Vlevel
static Bridge::VerboseLevel Vlevel()
Definition: commonParameters.h:122
Communicator::ipe
static int ipe(const int dir)
logical coordinate of current proc.
Definition: communicator.cpp:105
ShiftField_eo::dn_xh
void dn_xh(Field &, const Field &, const int, const int)
Definition: shiftField_eo.cpp:367
field_thread-inc.h
ShiftField_eo::backward
void backward(Field &, const Field &, const int mu)
Definition: shiftField_eo.cpp:168
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
ShiftField_eo::m_Nz
int m_Nz
Definition: shiftField_eo.h:55
ShiftField_eo::m_we
Field m_we
Definition: shiftField_eo.h:70
Field
Container of Field-type object.
Definition: field.h:46
Communicator::exchange
static int exchange(int count, dcomplex *recv_buf, dcomplex *send_buf, int idir, int ipm, int tag)
receive array of dcomplex from upstream specified by idir and ipm, and send array to downstream.
Definition: communicator.cpp:207
ShiftField_eo::m_Nvol
int m_Nvol
Definition: shiftField_eo.h:56
ShiftField_eo::m_Nx
int m_Nx
Definition: shiftField_eo.h:55
ThreadManager::assert_single_thread
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.
Definition: threadManager.cpp:372
ShiftField_eo::m_yzt_eo
std::vector< int > m_yzt_eo
Definition: shiftField_eo.h:63
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
ShiftField_eo::m_wt_z
Field m_wt_z
Definition: shiftField_eo.h:67