Bridge++  Ver. 2.0.2
staple_eo.cpp
Go to the documentation of this file.
1 
14 #include "staple_eo.h"
15 
16 #include "Field/field_thread-inc.h"
17 
18 #ifdef USE_FACTORY_AUTOREGISTER
19 namespace {
20  bool init = Staple_eo::register_factory();
21 }
22 #endif
23 
24 const std::string Staple_eo::class_name = "Staple_eo";
25 
26 //====================================================================
28 {
30 
31  m_filename_output = "stdout";
32 
36 
37  int Ndf = 2 * m_Nc * m_Nc;
38  m_shift = new ShiftField_eo(Ndf);
39 }
40 
41 
42 //====================================================================
43 void Staple_eo::init(const Parameters& params)
44 {
46 
47  m_filename_output = "stdout";
48 
52 
53  int Ndf = 2 * m_Nc * m_Nc;
54  m_shift = new ShiftField_eo(Ndf);
55 
56  set_parameters(params);
57 }
58 
59 
60 //====================================================================
62 {
63  delete m_shift;
64 }
65 
66 
67 //====================================================================
69 {
70  m_filename_output = params.get_string("filename_output");
71  if (m_filename_output.empty()) {
72  m_filename_output = "stdout";
73  }
74 
75  std::string vlevel;
76  if (!params.fetch_string("verbose_level", vlevel)) {
77  m_vl = vout.set_verbose_level(vlevel);
78  }
79 }
80 
81 
82 //====================================================================
84 {
85  params.set_string("filename_output", m_filename_output);
86  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
87 }
88 
89 
90 //====================================================================
91 double Staple_eo::plaquette(const Field_G& U)
92 {
93  Field_G Ueo(U);
94  Index_eo index_eo;
95 
96  index_eo.convertField(Ueo, U);
97 
98  return (plaq_s(Ueo) + plaq_t(Ueo)) / 2;
99 }
100 
101 
102 //====================================================================
103 double Staple_eo::plaq_s(const Field_G& U)
104 {
105  int nth = ThreadManager::get_num_threads();
106 
107  double plaq;
108 
109  if (nth > 1) {
110  plaq = plaq_s_impl(U);
111  } else {
112  plaq = plaq_s_omp(U);
113  }
114 
115  return plaq;
116 }
117 
118 
119 //====================================================================
120 double Staple_eo::plaq_t(const Field_G& U)
121 {
122  int nth = ThreadManager::get_num_threads();
123 
124  double plaq;
125 
126  if (nth > 1) {
127  plaq = plaq_t_impl(U);
128  } else {
129  plaq = plaq_t_omp(U);
130  }
131 
132  return plaq;
133 }
134 
135 
136 //====================================================================
138 {
139  double plaq;
140 
141 #pragma omp parallel
142  {
143  double plaq1 = plaq_s_impl(U);
144 #pragma omp master
145  plaq = plaq1;
146  }
147 
148  return plaq;
149 }
150 
151 
152 //====================================================================
154 {
155  double plaq;
156 
157 #pragma omp parallel
158  {
159  double plaq1 = plaq_t_impl(U);
160 #pragma omp master
161  plaq = plaq1;
162  }
163 
164  return plaq;
165 }
166 
167 
168 //====================================================================
169 double Staple_eo::plaq_s_impl(const Field_G& Ueo)
170 {
171  const int Ndim_spc = m_Ndim - 1;
172 
173  const int NPE = CommonParameters::NPE();
174 
175  // Field_G staple;
176  double plaq = 0.0;
177 
178  for (int mu = 0; mu < Ndim_spc; ++mu) {
179  int nu = (mu + 1) % Ndim_spc;
180 
181  copy(m_v1, 0, Ueo, mu);
182 
183  upper(m_v2, Ueo, mu, nu);
184 
185  double plaq1 = real(dotc(m_v2, m_v1));
186 
187  plaq += plaq1;
188  }
189 
190  /*
191  upper(m_staple, Ueo, 0, 1);
192  for (int site = 0; site < Nvol; site++) {
193  plaq += ReTr(Ueo.mat(site, 0) * m_staple.mat_dag(site)); // P_xy
194  }
195 
196  upper(m_staple, Ueo, 1, 2);
197  for (int site = 0; site < Nvol; site++) {
198  plaq += ReTr(Ueo.mat(site, 1) * m_staple.mat_dag(site)); // P_yz
199  }
200 
201  upper(m_staple, Ueo, 2, 0);
202  for (int site = 0; site < Nvol; site++) {
203  plaq += ReTr(Ueo.mat(site, 2) * m_staple.mat_dag(site)); // P_zx
204  }
205  */
206 
207  // plaq = Communicator::reduce_sum(plaq);
208 
209  plaq *= 1.0 / (m_Nvol * m_Nc * Ndim_spc);
210  plaq *= 1.0 / NPE;
211  return plaq;
212 }
213 
214 
215 //====================================================================
216 double Staple_eo::plaq_t_impl(const Field_G& Ueo)
217 {
218  const int Ndim_spc = m_Ndim - 1;
219 
220  const int NPE = CommonParameters::NPE();
221 
222  // Field_G staple;
223  int mu = m_Ndim - 1;
224  double plaq = 0.0;
225 
226 #pragma omp barrier
227 
228  copy(m_v1, 0, Ueo, mu);
229 #pragma omp barrier
230 
231  for (int nu = 0; nu < Ndim_spc; ++nu) {
232  upper(m_v2, Ueo, mu, nu);
233  double plaq1 = real(dotc(m_v2, m_v1));
234  plaq += plaq1;
235  }
236 
237  plaq *= 1.0 / (m_Nvol * m_Nc * Ndim_spc);
238  plaq *= 1.0 / NPE;
239 
240  return plaq;
241 
242  /*
243  for (int nu = 0; nu < Ndim - 1; nu++) {
244  lower(m_staple, Ueo, 3, nu);
245  for (int site = 0; site < Nvol; site++) {
246  plaq += ReTr(Ueo.mat(site, 3) * m_staple.mat_dag(site)); // P_zx
247  }
248  }
249 
250  plaq = Communicator::reduce_sum(plaq);
251 
252  return plaq / Nvol / NPE / Nc / Ndim_spc;
253  */
254 }
255 
256 
257 //====================================================================
258 void Staple_eo::staple(Field_G& W, const Field_G& Ueo, const int mu)
259 {
260 #pragma omp barrier
261 
262  W.set(0.0);
263 #pragma omp barrier
264 
265  for (int nu = 0; nu < m_Ndim; nu++) {
266  if (nu != mu) {
267  Field_G u_tmp(W.nvol(), 1);
268 
269  upper(u_tmp, Ueo, mu, nu);
270  axpy(W, 1.0, u_tmp);
271 #pragma omp barrier
272 
273  lower(u_tmp, Ueo, mu, nu);
274  axpy(W, 1.0, u_tmp);
275 #pragma omp barrier
276  }
277  }
278 }
279 
280 
281 //====================================================================
282 void Staple_eo::upper(Field_G& c, const Field_G& Ueo,
283  const int mu, const int nu)
284 {
285  // (1) mu (2)
286  // +-->--+
287  // nu | |
288  // i+ +
289 
290 #pragma omp barrier
291 
292  copy(m_Umu, 0, Ueo, mu);
293  copy(m_Unu, 0, Ueo, nu);
294 #pragma omp barrier
295 
296  m_shift->backward(m_w2, m_Unu, mu);
297  m_shift->backward(c, m_Umu, nu);
298 
299  mult_Field_Gnd(m_w1, 0, c, 0, m_w2, 0);
300  mult_Field_Gnn(c, 0, m_Unu, 0, m_w1, 0);
301 
302 #pragma omp barrier
303 }
304 
305 
306 //====================================================================
307 void Staple_eo::lower(Field_G& c, const Field_G& Ueo,
308  const int mu, const int nu)
309 {
310  // + +
311  // nu | |
312  // i+-->--+
313  // (1) mu (2)
314 
315 #pragma omp barrier
316 
317  copy(m_Umu, 0, Ueo, mu);
318  copy(m_Unu, 0, Ueo, nu);
319 #pragma omp barrier
320 
321  m_shift->backward(m_w1, m_Unu, mu);
322  mult_Field_Gnn(m_w2, 0, m_Umu, 0, m_w1, 0);
323  mult_Field_Gdn(m_w1, 0, m_Unu, 0, m_w2, 0);
324  m_shift->forward(c, m_w1, nu);
325 }
326 
327 
328 //============================================================END=====
Staple_eo::plaq_s_omp
double plaq_s_omp(const Field_G &)
Definition: staple_eo.cpp:137
Staple_eo::set_parameters
void set_parameters(const Parameters &params)
setting parameters.
Definition: staple_eo.cpp:68
ShiftField_eo::forward
void forward(Field &, const Field &, const int mu)
Definition: shiftField_eo.cpp:175
ShiftField_eo
Methods to shift the even-odd field.
Definition: shiftField_eo.h:49
mult_Field_Gdn
void mult_Field_Gdn(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)
Definition: field_G_imp.cpp:134
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
ThreadManager::get_num_threads
static int get_num_threads()
returns available number of threads.
Definition: threadManager.cpp:246
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Staple_eo::m_vl
Bridge::VerboseLevel m_vl
Definition: staple_eo.h:39
Staple_eo::plaq_s
double plaq_s(const Field_G &)
calculates spatial plaquette value.
Definition: staple_eo.cpp:103
Field::set
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
Parameters
Class for parameters.
Definition: parameters.h:46
Staple_eo::tidyup
void tidyup()
Definition: staple_eo.cpp:61
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Index_eo
Even-odd site index.
Definition: index_eo.h:44
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
Staple_eo::m_shift
ShiftField_eo * m_shift
Definition: staple_eo.h:45
Staple_eo::plaq_s_impl
double plaq_s_impl(const Field_G &)
Definition: staple_eo.cpp:169
copy
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:212
Staple_eo::class_name
static const std::string class_name
Definition: staple_eo.h:36
Staple_eo::m_Nvol
int m_Nvol
Definition: staple_eo.h:43
Staple_eo::plaq_t
double plaq_t(const Field_G &)
calculates temporal plaquette value.
Definition: staple_eo.cpp:120
Staple_eo::m_v1
Field_G m_v1
Definition: staple_eo.h:48
Staple_eo::init
void init()
Definition: staple_eo.cpp:27
Staple_eo::plaq_t_omp
double plaq_t_omp(const Field_G &)
Definition: staple_eo.cpp:153
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
Index_eo::convertField
void convertField(Field &eo, const Field &lex)
Definition: index_eo.cpp:90
Staple_eo::m_w2
Field_G m_w2
Definition: staple_eo.h:49
Staple_eo::plaq_t_impl
double plaq_t_impl(const Field_G &)
Definition: staple_eo.cpp:216
Staple_eo::m_w1
Field_G m_w1
Definition: staple_eo.h:49
Field::nvol
int nvol() const
Definition: field.h:127
Staple_eo::upper
void upper(Field_G &, const Field_G &, const int, const int)
constructs upper staple in mu-nu plane.
Definition: staple_eo.cpp:282
dotc
dcomplex dotc(const Field &y, const Field &x)
Definition: field.cpp:712
CommonParameters::NPE
static int NPE()
Definition: commonParameters.h:101
Staple_eo::plaquette
double plaquette(const Field_G &)
calculates plaquette value.
Definition: staple_eo.cpp:91
Staple_eo::m_v2
Field_G m_v2
Definition: staple_eo.h:48
CommonParameters::Vlevel
static Bridge::VerboseLevel Vlevel()
Definition: commonParameters.h:122
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
mult_Field_Gnn
void mult_Field_Gnn(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)
Definition: field_G_imp.cpp:95
Staple_eo::get_parameters
void get_parameters(Parameters &params) const
getting parameters.
Definition: staple_eo.cpp:83
Staple_eo::m_Unu
Field_G m_Unu
Definition: staple_eo.h:50
Parameters::fetch_string
int fetch_string(const string &key, string &value) const
Definition: parameters.cpp:378
Staple_eo::m_filename_output
std::string m_filename_output
Definition: staple_eo.h:41
field_thread-inc.h
Parameters::get_string
string get_string(const string &key) const
Definition: parameters.cpp:221
ShiftField_eo::backward
void backward(Field &, const Field &, const int mu)
Definition: shiftField_eo.cpp:168
staple_eo.h
Staple_eo::lower
void lower(Field_G &, const Field_G &, const int, const int)
constructs lower staple in mu-nu plane.
Definition: staple_eo.cpp:307
Field_G
SU(N) gauge field.
Definition: field_G.h:38
Staple_eo::m_Umu
Field_G m_Umu
Definition: staple_eo.h:50
Staple_eo::staple
void staple(Field_G &, const Field_G &, const int)
constructs staple in mu-direction (summing up nu-direction).
Definition: staple_eo.cpp:258
mult_Field_Gnd
void mult_Field_Gnd(Field_G &W, const int ex, const Field_G &U1, const int ex1, const Field_G &U2, const int ex2)
Definition: field_G_imp.cpp:173
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
Bridge::BridgeIO::get_verbose_level
static std::string get_verbose_level(const VerboseLevel vl)
Definition: bridgeIO.cpp:154
Staple_eo::m_Ndim
int m_Ndim
Definition: staple_eo.h:43
Staple_eo::m_Nc
int m_Nc
Definition: staple_eo.h:43