Bridge++  Version 1.4.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fopr_Wilson_eo_impl.cpp
Go to the documentation of this file.
1 
14 #include "fopr_Wilson_eo_impl.h"
15 
16 namespace Org {
17  const std::string Fopr_Wilson_eo::class_name = "Org::Fopr_Wilson_eo";
18 
19 //===================================================================
20  namespace {
24  void mult_Field_Gn_eo(Field_F& w, int ex,
25  const Field_G& U, const int ex1,
26  const Field_F& x, const int ex2,
27  const int ieo)
28  {
29  assert(ex < w.nex());
30  assert(ex1 < U.nex());
31  assert(ex2 < x.nex());
32  assert(U.nvol() == w.nvol() * 2);
33  assert(x.nvol() == w.nvol());
34 
35  Vec_SU_N vec(w.nc());
36 
37  for (int site = 0, nvol = w.nvol(); site < nvol; ++site) {
38  for (int s = 0, nd = w.nd(); s < nd; ++s) {
39  vec = U.mat(site + ieo * nvol, ex1) * x.vec(s, site, ex2);
40  w.set_vec(s, site, ex, vec);
41  }
42  }
43  }
44 
45 
46  //====================================================================
50  void mult_Field_Gd_eo(Field_F& w, int ex,
51  const Field_G& U, int ex1,
52  const Field_F& x, int ex2,
53  const int ieo)
54  {
55  assert(ex < w.nex());
56  assert(ex1 < U.nex());
57  assert(ex2 < x.nex());
58  assert(U.nvol() == w.nvol() * 2);
59  assert(x.nvol() == w.nvol());
60 
61  Vec_SU_N vec(w.nc());
62 
63  for (int site = 0, nvol = w.nvol(); site < nvol; ++site) {
64  for (int s = 0, nd = w.nd(); s < nd; ++s) {
65  vec = U.mat_dag(site + ieo * nvol, ex1) * x.vec(s, site, ex2);
66  w.set_vec(s, site, ex, vec);
67  }
68  }
69  }
70  }
71 
72 //====================================================================
74  {
75  const string str_vlevel = params.get_string("verbose_level");
76 
77  m_vl = vout.set_verbose_level(str_vlevel);
78 
79  //- fetch and check input parameters
80  double kappa;
81  std::vector<int> bc;
82 
83  int err = 0;
84  err += params.fetch_double("hopping_parameter", kappa);
85  err += params.fetch_int_vector("boundary_condition", bc);
86 
87  if (err) {
88  vout.crucial(m_vl, "Error at %s: fetch error, input parameter not found.\n", class_name.c_str());
89  exit(EXIT_FAILURE);
90  }
91 
92  set_parameters(kappa, bc);
93  }
94 
95 
96 //====================================================================
98  const double kappa,
99  const std::vector<int> bc)
100  {
101  //- print input parameters
102  vout.general(m_vl, "%s:\n", class_name.c_str());
103  vout.general(m_vl, " kappa = %12.8f\n", kappa);
104  for (int mu = 0; mu < m_Ndim; ++mu) {
105  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
106  }
107 
108  //- range check
109  // NB. kappa = 0 is allowed.
110  assert(bc.size() == m_Ndim);
111 
112  //- store values
113  m_kappa = kappa;
114 
115  // m_boundary.resize(m_Ndim); // already resized in init.
116  for (int mu = 0; mu < m_Ndim; ++mu) {
117  m_boundary[mu] = bc[mu];
118  }
119  }
120 
121 
122 //====================================================================
124  {
125  int Ndim = CommonParameters::Ndim();
126  int Nvol = CommonParameters::Nvol();
127 
128  m_index.convertField(*m_Ueo, *U);
129  }
130 
131 
132 //====================================================================
133  void Fopr_Wilson_eo::set_mode(std::string mode)
134  {
135  m_mode = mode;
136 
137  if (m_mode == "D") {
142  } else if (m_mode == "Ddag") {
147  } else if (m_mode == "DdagD") {
150  } else if (m_mode == "DDdag") {
153  } else if (m_mode == "H") {
156  } else {
157  vout.crucial("Error at %s: input mode is undefined.\n", class_name.c_str());
158  exit(EXIT_FAILURE);
159  }
160  }
161 
162 
163 //====================================================================
164  std::string Fopr_Wilson_eo::get_mode() const
165  {
166  return m_mode;
167  }
168 
169 
170 //====================================================================
171  void Fopr_Wilson_eo::init(const std::string repr)
172  {
173  m_repr = repr;
174 
175  m_boundary.resize(m_Ndim);
176  m_GM.resize(m_Ndim + 1);
177 
178  GammaMatrixSet *gmset = GammaMatrixSet::New(repr);
179 
180  m_GM[0] = gmset->get_GM(gmset->GAMMA1);
181  m_GM[1] = gmset->get_GM(gmset->GAMMA2);
182  m_GM[2] = gmset->get_GM(gmset->GAMMA3);
183  m_GM[3] = gmset->get_GM(gmset->GAMMA4);
184  m_GM[4] = gmset->get_GM(gmset->GAMMA5);
185 
186  m_Ueo = new Field_G(m_Nvol, m_Ndim);
187 
188  delete gmset;
189  }
190 
191 
192 //====================================================================
193  void Fopr_Wilson_eo::prePropD(Field& Be, Field& bo, const Field& b)
194  {
195 #pragma omp master
196  {
197  int Nin = b.nin();
198  int Nex = b.nex();
199 
200  Field be(Nin, m_Nvol2, Nex);
201 
202  m_index.convertField(be, b, 0);
203  m_index.convertField(bo, b, 1);
204 
205  Be.reset(Nin, m_Nvol2, Nex);
206 
207  // Be = be - (Field)Meo(bo, 0);
208  Field_F v1(m_Nvol2, Nex);
209  copy(Be, be);
210  Meo(v1, bo, 0);
211  axpy(Be, -1.0, v1);
212  }
213 #pragma omp barrier
214  }
215 
216 
217 //====================================================================
218  void Fopr_Wilson_eo::postPropD(Field& x, const Field& xe, const Field& bo)
219  {
220 #pragma omp master
221  {
222  int Nin = xe.nin();
223  int Nex = xe.nex();
224 
225  Field xo(Nin, m_Nvol2, Nex);
226 
227  // xo = bo - (Field)Meo(xe, 1);
228  Field_F v1(m_Nvol2, Nex);
229  copy(xo, bo);
230  Meo(v1, xe, 1);
231  axpy(xo, -1.0, v1);
232 
233  x.reset(Nin, m_Nvol2 * 2, Nex);
234  m_index.reverseField(x, xe, 0);
235  m_index.reverseField(x, xo, 1);
236  }
237 #pragma omp barrier
238  }
239 
240 
241 //====================================================================
242  void Fopr_Wilson_eo::prePropDag(Field& Be, Field& bo, const Field& b)
243  {
244 #pragma omp master
245  {
246  int Nin = b.nin();
247  int Nex = b.nex();
248 
249  Field be(Nin, m_Nvol2, Nex);
250 
251  m_index.convertField(be, b, 0);
252  m_index.convertField(bo, b, 1);
253 
254  Be.reset(Nin, m_Nvol2, Nex);
255 
256  // Be = be - (Field)Mdageo(bo, 0);
257  Field_F v1(m_Nvol2, Nex);
258  copy(Be, be);
259  Mdageo(v1, bo, 0);
260  axpy(Be, -1.0, v1);
261  }
262 #pragma omp barrier
263  }
264 
265 
266 //====================================================================
267  void Fopr_Wilson_eo::postPropDag(Field& x, const Field& xe, const Field& bo)
268  {
269 #pragma omp master
270  {
271  //Field bo();
272  //index.convertField(bo, b, 1);
273  int Nin = xe.nin();
274  int Nex = xe.nex();
275 
276  Field xo(Nin, m_Nvol2, Nex);
277 
278  // xo = bo - (Field)Mdageo(xe, 1);
279  Field_F v1(m_Nvol2, Nex);
280  copy(xo, bo);
281  Mdageo(v1, xe, 1);
282  axpy(xo, -1.0, v1);
283 
284  x.reset(Nin, m_Nvol2 * 2, Nex);
285  m_index.reverseField(x, xe, 0);
286  m_index.reverseField(x, xo, 1);
287  }
288 #pragma omp barrier
289  }
290 
291 
292 //====================================================================
293  void Fopr_Wilson_eo::D(Field& v, const Field& f)
294  {
295 #pragma omp master
296  {
297  assert(f.nex() == 1);
298  Field_F v1(m_Nvol2, 1), v2(m_Nvol2, 1);
299 
300  copy(v, f); // v = f;
301 
302  // v -= (Field)Meo(Meo(f, 1), 0);
303  Meo(v1, f, 1);
304  Meo(v2, v1, 0);
305  axpy(v, -1.0, v2);
306  }
307 #pragma omp barrier
308  }
309 
310 
311 //====================================================================
312  void Fopr_Wilson_eo::Ddag(Field& v, const Field& f)
313  {
314 #pragma omp master
315  {
316  Field_F v1(m_Nvol2, 1), v2(m_Nvol2, 1);
317 
318  copy(v, f); // v = f;
319 
320  // v -= (Field)Mdageo(Mdageo(f, 1), 0);
321  Mdageo(v1, f, 1);
322  Mdageo(v2, v1, 0);
323  axpy(v, -1.0, v2);
324  }
325 #pragma omp barrier
326  }
327 
328 
329 //====================================================================
330  void Fopr_Wilson_eo::DdagD(Field& v, const Field& f)
331  {
332 #pragma omp master
333  {
334  Field w(v);
335  D(w, f);
336  Ddag(v, w);
337  }
338 #pragma omp barrier
339  }
340 
341 
342 //====================================================================
343  void Fopr_Wilson_eo::DDdag(Field& v, const Field& f)
344  {
345 #pragma omp master
346  {
347  Field w(v);
348  Ddag(w, f);
349  D(v, w);
350  }
351 #pragma omp barrier
352  }
353 
354 
355 //====================================================================
356  void Fopr_Wilson_eo::H(Field& v, const Field& f)
357  {
358 #pragma omp master
359  {
360  Field w(v);
361  D(w, f);
362  mult_gm5(v, w);
363  }
364 #pragma omp barrier
365  }
366 
367 
368 //====================================================================
369  void Fopr_Wilson_eo::MeoMoe(Field& v, const Field& f)
370  {
371 #pragma omp master
372  {
373  Field_F v1(m_Nvol2, 1), v2(m_Nvol2, 1);
374 
375  // v -= (Field)Meo(Meo(f, 1), 0);
376  Meo(v1, f, 1);
377  Meo(v2, v1, 0);
378  axpy(v, -1.0, v2);
379  }
380 #pragma omp barrier
381  }
382 
383 
384 //====================================================================
386  const Field& f, const int ieo)
387  {
388 #pragma omp master
389  {
390  Field_F w2(m_Nvol2, 1), f2(m_Nvol2, 1);
391  copy(f2, f);
392  w2.set(0.0); // w2 = 0.0
393 
394  for (int mu = 0; mu < m_Ndim; ++mu) {
395  mult_p(mu, w2, f2, ieo);
396  mult_m(mu, w2, f2, ieo);
397  }
398 
399  scal(w2, -m_kappa); // w *= -m_kappa;
400 
401  copy(w, w2);
402  }
403  }
404 
405 
406 //====================================================================
408  const Field& f, const int ieo)
409  {
410 #pragma omp master
411  {
412  Field_F v(m_Nvol2, f.nex());
413 
414  mult_gm5(v, f);
415  Meo_gm5(w, v, ieo);
416  }
417  }
418 
419 
420 //====================================================================
422  const Field& f, const int ieo)
423  {
424  Field_F w(m_Nvol2, f.nex());
425 
426  Meo(w, f, ieo);
427  mult_gm5(v, w);
428  }
429 
430 
431 //====================================================================
433  {
434 #pragma omp master
435  {
436  Field_F w2 = (Field_F)f;
437  mult_GM(w2, m_GM[4], (Field_F)f);
438  w = w2;
439  }
440 #pragma omp barrier
441  }
442 
443 
444 //====================================================================
445  void Fopr_Wilson_eo::gm5p(const int mu, Field& w,
446  const Field& f)
447  {
448  Field_F vt1(f.nvol(), 1);
449  Field_F vt2(f.nvol(), 1);
450 
451  for (int ex = 0; ex < f.nex(); ++ex) {
452  vt1.setpart_ex(0, f, ex);
453  shift.backward(vt2, vt1, m_boundary[mu], mu); // vt2 = vt1(x+mu)
454  mult_GMproj2(vt1, -1, m_GM[mu], vt2); // vt1 = (1 - gamma_mu) vt2
455  mult_GM(vt2, m_GM[4], vt1); // vt2 = gamma_5 vt1
456  w.addpart_ex(ex, vt2, 0);
457  }
458  }
459 
460 
461 //====================================================================
463  Field_F& w, const Field_F& f,
464  const int ieo)
465  {
466  Field_F vt(f.nvol(), 1);
467 
468  for (int ex = 0; ex < f.nex(); ++ex) {
469  vt.setpart_ex(0, f, ex);
470  shift.backward_h(trf, vt, m_boundary[mu], mu, ieo);
471  mult_Field_Gn_eo(trf2, 0, *m_Ueo, mu, trf, 0, ieo);
472  mult_GMproj2(vt, -1, m_GM[mu], trf2);
473  w.addpart_ex(ex, vt, 0);
474  }
475  }
476 
477 
478 //=====================================================================
480  Field_F& w, const Field_F& f,
481  const int ieo)
482  {
483  Field_F vt(f.nvol(), 1);
484 
485  for (int ex = 0; ex < f.nex(); ++ex) {
486  mult_Field_Gd_eo(trf, 0, *m_Ueo, mu, f, ex, 1 - ieo);
487  shift.forward_h(trf2, trf, m_boundary[mu], mu, ieo);
488  mult_GMproj2(vt, 1, m_GM[mu], trf2);
489  w.addpart_ex(ex, vt, 0);
490  }
491  }
492 
493 
494 //====================================================================
496  {
497  // this counting is based on the Org-implementation of ver.1.2.0.
498  // Flop count of mult_GMproj2 is different for upward and downward
499  // directions due to the implemetation in Field_F.cpp.
500  // Present counting is based on rev.1130. [10 Sep 2014 H.Matsufuru]
501 
502  int Nc = m_Nc;
503  int Nd = m_Nd;
504  int Lvol = CommonParameters::Lvol();
505 
506  int flop_Meo = Nc * Nd * 2 * 8 * (4 * Nc - 1); // #(mult_Field_Gn/d)
507 
508  flop_Meo += Nc * Nd * 2 * (4 * 3 + 4 * 2); // #(mult_GMproj2)
509  flop_Meo += Nc * Nd * 2 * 8; // #(addpart_ex)
510  flop_Meo += Nc * Nd * 2; // #(scal(kappa))
511 
512  int flop_per_site = 2 * flop_Meo + Nc * Nd * 2 * 2; // #(2*Meo + axpy)
513 
514  double flop = static_cast<double>(flop_per_site) *
515  static_cast<double>(Lvol / 2);
516 
517  if ((m_mode == "DdagD") || (m_mode == "DDdag")) {
518  flop *= 2.0;
519  }
520 
521  return flop;
522  }
523 
524 
525 //====================================================================
526 }
527 //============================================================END=====
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:282
void backward(Field &, const Field &, const int mu)
BridgeIO vout
Definition: bridgeIO.cpp:495
void mult_gm5(Field &, const Field &)
gamma_5 multiplication. [31 Mar 2017 H.Matsufuru]
static const std::string class_name
void set_vec(const int s, const int site, const int e, const Vec_SU_N &F)
Definition: field_F.h:135
void general(const char *format,...)
Definition: bridgeIO.cpp:195
GammaMatrix get_GM(GMspecies spec)
Container of Field-type object.
Definition: field.h:39
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:211
void Meo_gm5(Field &, const Field &, const int ieo)
int nvol() const
Definition: field.h:116
void(Fopr_Wilson_eo::* m_preProp)(Field &, Field &, const Field &)
void prePropDag(Field &, Field &, const Field &)
void H(Field &v, const Field &f)
Class for parameters.
Definition: parameters.h:46
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:381
static int Lvol()
void convertField(Field &eo, const Field &lex)
Definition: index_eo.cpp:20
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:193
double flop_count()
this returns the number of floating point operations of Meo.
void(Fopr_Wilson_eo::* m_mult)(Field &, const Field &)
Wilson-type fermion field.
Definition: field_F.h:37
void mult_GMproj2(Field_F &y, const int pm, const GammaMatrix &gm, const Field_F &x)
projection with gamma matrix: (1 gamma)
void(Fopr_Wilson_eo::* m_postProp)(Field &, const Field &, const Field &)
int nin() const
Definition: field.h:115
SU(N) gauge field.
Definition: field_G.h:38
void postPropDag(Field &, const Field &, const Field &)
Bridge::VerboseLevel m_vl
Definition: fopr.h:128
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=COMPLEX)
Definition: field.h:84
Set of Gamma Matrices: basis class.
int nex() const
Definition: field.h:117
void DdagD(Field &v, const Field &f)
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:168
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
void init(const std::string)
std::string get_mode() const
only for Fopr_Overlap
void mult_GM(Field_F &y, const GammaMatrix &gm, const Field_F &x)
gamma matrix multiplication
void mult_p(int mu, Field_F &, const Field_F &, const int ieo)
void Ddag(Field &v, const Field &f)
int nc() const
Definition: field_F.h:90
void reverseField(Field &lex, const Field &eo)
Definition: index_eo.cpp:110
void set_mode(std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Vec_SU_N vec(const int s, const int site, const int e=0) const
Definition: field_F.h:123
Mat_SU_N mat_dag(const int site, const int mn=0) const
Definition: field_G.h:126
void set_config(Field *U)
setting pointer to the gauge configuration.
void(Fopr_Wilson_eo::* m_mult_dag)(Field &, const Field &)
void backward_h(Field &, const Field &, const int mu, const int ieo)
void set_parameters(const Parameters &params)
void postPropD(Field &, const Field &, const Field &)
int nd() const
Definition: field_F.h:92
void DDdag(Field &v, const Field &f)
void prePropD(Field &, Field &, const Field &)
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:186
void mult_m(int mu, Field_F &, const Field_F &, const int ieo)
string get_string(const string &key) const
Definition: parameters.cpp:116
int fetch_int_vector(const string &key, vector< int > &value) const
Definition: parameters.cpp:294
void MeoMoe(Field &v, const Field &f)
void gm5p(const int mu, Field &, const Field &v)
gamma_5 (1 - gamma_mu) v(x + mu)
void D(Field &v, const Field &f)
Mat_SU_N mat(const int site, const int mn=0) const
Definition: field_G.h:113
void forward_h(Field &, const Field &, const int mu, const int ieo)
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
std::vector< int > m_boundary
void Meo(Field &, const Field &, const int ieo)
void Mdageo(Field &, const Field &, const int ieo)
std::vector< GammaMatrix > m_GM