Bridge++  Ver. 2.0.2
staple_lex.cpp
Go to the documentation of this file.
1 
14 #include "staple_lex.h"
15 
16 #include "Field/field_thread-inc.h"
17 
18 
19 #ifdef USE_FACTORY_AUTOREGISTER
20 namespace {
21  bool init = Staple_lex::register_factory();
22 }
23 #endif
24 
25 const std::string Staple_lex::class_name = "Staple_lex";
26 
27 //====================================================================
28 void Staple_lex::init(const Parameters& params)
29 {
30  setup();
31  set_parameters(params);
32 }
33 
34 
35 //====================================================================
37 {
38  setup();
39 }
40 
41 
42 //====================================================================
44 {
46 
50  int Ndf = 2 * m_Nc * m_Nc;
51 
52  m_shift = new ShiftField_lex(Ndf);
53 
54  m_filename_output = "stdout";
55 }
56 
57 
58 //====================================================================
60 {
61  delete m_shift;
62 }
63 
64 
65 //====================================================================
67 {
68  m_filename_output = params.get_string("filename_output");
69  if (m_filename_output.empty()) {
70  m_filename_output = "stdout";
71  }
72 
73  std::string vlevel;
74  if (!params.fetch_string("verbose_level", vlevel)) {
75  m_vl = vout.set_verbose_level(vlevel);
76  }
77 }
78 
79 
80 //====================================================================
82 {
83  params.set_string("filename_output", m_filename_output);
84  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
85 }
86 
87 
88 //====================================================================
90 {
92 
93  const double result = (plaq_s(U) + plaq_t(U)) / 2;
94 
95  std::ostream& log_file_previous = vout.getStream();
96  std::ofstream log_file;
97 
98  if (m_filename_output != "stdout") {
99  log_file.open(m_filename_output.c_str(), std::ios::app);
100  vout.init(log_file);
101  }
102 
103  vout.general(m_vl, "plaq = %20.16e\n", result);
104 
105  if (m_filename_output != "stdout") {
106  log_file.close();
107  vout.init(log_file_previous);
108  }
109 
110  return result;
111 }
112 
113 
114 //====================================================================
115 double Staple_lex::plaq_s(const Field_G& U)
116 {
117  int nth = ThreadManager::get_num_threads();
118 
119  double plaq;
120 
121  if (nth > 1) {
122  plaq = plaq_s_impl(U);
123  } else {
124  plaq = plaq_s_omp(U);
125  }
126 
127  return plaq;
128 }
129 
130 
131 //====================================================================
132 double Staple_lex::plaq_t(const Field_G& U)
133 {
134  int nth = ThreadManager::get_num_threads();
135 
136  double plaq;
137 
138  if (nth > 1) {
139  plaq = plaq_t_impl(U);
140  } else {
141  plaq = plaq_t_omp(U);
142  }
143 
144  return plaq;
145 }
146 
147 
148 //====================================================================
150 {
151  double plaq;
152 
153 #pragma omp parallel
154  {
155  double plaq1 = plaq_s_impl(U);
156 #pragma omp master
157  plaq = plaq1;
158  }
159 
160  return plaq;
161 }
162 
163 
164 //====================================================================
166 {
167  double plaq;
168 
169 #pragma omp parallel
170  {
171  double plaq1 = plaq_t_impl(U);
172 #pragma omp master
173  plaq = plaq1;
174  }
175 
176  return plaq;
177 }
178 
179 
180 //====================================================================
182 {
183  const int Ndim_spc = m_Ndim - 1;
184 
185  const int NPE = CommonParameters::NPE();
186 
187  double plaq = 0.0;
188 
189 #pragma omp barrier
190 
191  for (int mu = 0; mu < Ndim_spc; ++mu) {
192  int nu = (mu + 1) % Ndim_spc;
193 
194  copy(m_v1, 0, U, mu);
195 
196  upper(m_v2, U, mu, nu);
197 
198  double plaq1 = real(dotc(m_v2, m_v1));
199 
200  plaq += plaq1;
201  }
202 
203  plaq *= 1.0 / (m_Nvol * m_Nc * Ndim_spc);
204  plaq *= 1.0 / NPE;
205 
206  return plaq;
207 }
208 
209 
210 //====================================================================
212 {
213  const int NPE = CommonParameters::NPE();
214  const int Ndim_spc = m_Ndim - 1;
215 
216  const int mu = Ndim_spc;
217 
218 #pragma omp barrier
219 
220  copy(m_v1, 0, U, mu);
221 #pragma omp barrier
222 
223  double plaq = 0.0;
224 
225  for (int nu = 0; nu < Ndim_spc; ++nu) {
226  upper(m_v2, U, mu, nu);
227  double plaq1 = real(dotc(m_v2, m_v1));
228  plaq += plaq1;
229  }
230 
231  plaq *= 1.0 / (m_Nvol * m_Nc * Ndim_spc);
232  plaq *= 1.0 / NPE;
233 
234  return plaq;
235 }
236 
237 
238 //====================================================================
239 void Staple_lex::staple(Field_G& W, const Field_G& U, const int mu)
240 {
241  const int Ndim = CommonParameters::Ndim();
242 
243 #pragma omp barrier
244 
245  W.set(0.0);
246 #pragma omp barrier
247 
248  for (int nu = 0; nu < Ndim; ++nu) {
249  if (nu != mu) {
250  upper(m_v1, U, mu, nu);
251  axpy(W, 1.0, m_v1);
252 
253  lower(m_v1, U, mu, nu);
254  axpy(W, 1.0, m_v1);
255  }
256  }
257 
258 #pragma omp barrier
259 }
260 
261 
262 //====================================================================
263 void Staple_lex::upper(Field_G& Uup, const Field_G& U,
264  const int mu, const int nu)
265 {
266  // (1) mu (2)
267  // +-->--+
268  // nu | |
269  // i+ +
270 
271 #pragma omp barrier
272 
273  copy(m_Umu, 0, U, mu);
274  copy(m_Unu, 0, U, nu);
275 #pragma omp barrier
276 
277  m_shift->backward(m_w2, m_Unu, mu);
278  m_shift->backward(Uup, m_Umu, nu);
279 
280  mult_Field_Gnd(m_w1, 0, Uup, 0, m_w2, 0);
281  mult_Field_Gnn(Uup, 0, U, nu, m_w1, 0);
282 }
283 
284 
285 //====================================================================
286 void Staple_lex::lower(Field_G& Udn, const Field_G& U,
287  const int mu, const int nu)
288 {
289  // + +
290  // nu | |
291  // i+-->--+
292  // (1) mu (2)
293 
294 #pragma omp barrier
295 
296  copy(m_Unu, 0, U, nu);
297 
298  m_shift->backward(m_w1, m_Unu, mu);
299 
300  mult_Field_Gnn(m_w2, 0, U, mu, m_w1, 0);
301  mult_Field_Gdn(m_w1, 0, U, nu, m_w2, 0);
302 
303  m_shift->forward(Udn, m_w1, nu);
304 }
305 
306 
307 //============================================================END=====
Staple_lex::m_w1
Field_G m_w1
Definition: staple_lex.h:52
Staple_lex::plaq_s_impl
double plaq_s_impl(const Field_G &)
Definition: staple_lex.cpp:181
Bridge::BridgeIO::init
void init(const std::string &filename)
Definition: bridgeIO.cpp:53
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
Staple_lex::plaq_t
double plaq_t(const Field_G &)
calculates temporal plaquette value.
Definition: staple_lex.cpp:132
ShiftField_lex::forward
void forward(Field &, const Field &, const int mu)
Definition: shiftField_lex.cpp:79
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_lex::m_Umu
Field_G m_Umu
Definition: staple_lex.h:51
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_lex::staple
void staple(Field_G &, const Field_G &, const int mu)
constructs staple in mu-direction (summing up nu-direction).
Definition: staple_lex.cpp:239
Staple_lex::plaq_t_omp
double plaq_t_omp(const Field_G &)
Definition: staple_lex.cpp:165
Staple_lex::plaquette
double plaquette(const Field_G &)
calculates plaquette value.
Definition: staple_lex.cpp:89
Staple_lex::set_parameters
void set_parameters(const Parameters &params)
setting parameters.
Definition: staple_lex.cpp:66
Staple_lex::init
void init()
Definition: staple_lex.cpp:36
Staple_lex::m_Nvol
int m_Nvol
Definition: staple_lex.h:55
Staple_lex::m_vl
Bridge::VerboseLevel m_vl
Definition: staple_lex.h:45
Staple_lex::class_name
static const std::string class_name
Definition: staple_lex.h:42
Staple_lex::m_Nc
int m_Nc
Definition: staple_lex.h:55
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Staple_lex::lower
void lower(Field_G &, const Field_G &, const int mu, const int nu)
constructs lower staple in mu-nu plane.
Definition: staple_lex.cpp:286
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
copy
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:212
Staple_lex::plaq_t_impl
double plaq_t_impl(const Field_G &)
Definition: staple_lex.cpp:211
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
Staple_lex::m_v1
Field_G m_v1
Definition: staple_lex.h:53
Staple_lex::get_parameters
void get_parameters(Parameters &params) const
getting parameters.
Definition: staple_lex.cpp:81
Staple_lex::plaq_s_omp
double plaq_s_omp(const Field_G &)
Definition: staple_lex.cpp:149
Staple_lex::m_Unu
Field_G m_Unu
working vectors
Definition: staple_lex.h:51
Staple_lex::m_w2
Field_G m_w2
working vectors
Definition: staple_lex.h:52
staple_lex.h
dotc
dcomplex dotc(const Field &y, const Field &x)
Definition: field.cpp:712
Staple_lex::m_shift
ShiftField_lex * m_shift
Definition: staple_lex.h:49
CommonParameters::NPE
static int NPE()
Definition: commonParameters.h:101
ShiftField_lex
Methods to shift a field in the lexical site index.
Definition: shiftField_lex.h:39
Staple_lex::tidyup
void tidyup()
Definition: staple_lex.cpp:59
Staple_lex::upper
void upper(Field_G &, const Field_G &, const int mu, const int nu)
constructs upper staple in mu-nu plane.
Definition: staple_lex.cpp:263
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
ShiftField_lex::backward
void backward(Field &, const Field &, const int mu)
Definition: shiftField_lex.cpp:59
Parameters::fetch_string
int fetch_string(const string &key, string &value) const
Definition: parameters.cpp:378
Staple_lex::setup
void setup()
Definition: staple_lex.cpp:43
field_thread-inc.h
Parameters::get_string
string get_string(const string &key) const
Definition: parameters.cpp:221
Staple_lex::m_filename_output
std::string m_filename_output
Definition: staple_lex.h:47
Field_G
SU(N) gauge field.
Definition: field_G.h:38
Bridge::BridgeIO::getStream
std::ostream & getStream()
Definition: bridgeIO.cpp:396
Staple_lex::m_v2
Field_G m_v2
working vectors
Definition: staple_lex.h:53
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Staple_lex::m_Ndim
int m_Ndim
Definition: staple_lex.h:55
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
ThreadManager::assert_single_thread
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.
Definition: threadManager.cpp:372
Staple_lex::plaq_s
double plaq_s(const Field_G &)
calculates spatial plaquette value.
Definition: staple_lex.cpp:115
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