Bridge++  Ver. 2.0.4
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  const bool use_outputfile = (m_filename_output != "stdout");
96  if (use_outputfile) {
97  int rank_io = 0;
98  vout.init(m_filename_output, rank_io, std::ios::app);
99  }
100 
101  vout.general(m_vl, "plaq = %20.16e\n", result);
102 
103  if (use_outputfile) {
104  vout.unset();
105  }
106 
107  return result;
108 }
109 
110 
111 //====================================================================
112 double Staple_lex::plaq_s(const Field_G& U)
113 {
114  int nth = ThreadManager::get_num_threads();
115 
116  double plaq;
117 
118  if (nth > 1) {
119  plaq = plaq_s_impl(U);
120  } else {
121  plaq = plaq_s_omp(U);
122  }
123 
124  return plaq;
125 }
126 
127 
128 //====================================================================
129 double Staple_lex::plaq_t(const Field_G& U)
130 {
131  int nth = ThreadManager::get_num_threads();
132 
133  double plaq;
134 
135  if (nth > 1) {
136  plaq = plaq_t_impl(U);
137  } else {
138  plaq = plaq_t_omp(U);
139  }
140 
141  return plaq;
142 }
143 
144 
145 //====================================================================
147 {
148  double plaq;
149 
150 #pragma omp parallel
151  {
152  double plaq1 = plaq_s_impl(U);
153 #pragma omp master
154  plaq = plaq1;
155  }
156 
157  return plaq;
158 }
159 
160 
161 //====================================================================
163 {
164  double plaq;
165 
166 #pragma omp parallel
167  {
168  double plaq1 = plaq_t_impl(U);
169 #pragma omp master
170  plaq = plaq1;
171  }
172 
173  return plaq;
174 }
175 
176 
177 //====================================================================
179 {
180  const int Ndim_spc = m_Ndim - 1;
181 
182  const int NPE = CommonParameters::NPE();
183 
184  double plaq = 0.0;
185 
186 #pragma omp barrier
187 
188  for (int mu = 0; mu < Ndim_spc; ++mu) {
189  int nu = (mu + 1) % Ndim_spc;
190 
191  copy(m_v1, 0, U, mu);
192 
193  upper(m_v2, U, mu, nu);
194 
195  double plaq1 = real(dotc(m_v2, m_v1));
196 
197  plaq += plaq1;
198  }
199 
200  plaq *= 1.0 / (m_Nvol * m_Nc * Ndim_spc);
201  plaq *= 1.0 / NPE;
202 
203  return plaq;
204 }
205 
206 
207 //====================================================================
209 {
210  const int NPE = CommonParameters::NPE();
211  const int Ndim_spc = m_Ndim - 1;
212 
213  const int mu = Ndim_spc;
214 
215 #pragma omp barrier
216 
217  copy(m_v1, 0, U, mu);
218 #pragma omp barrier
219 
220  double plaq = 0.0;
221 
222  for (int nu = 0; nu < Ndim_spc; ++nu) {
223  upper(m_v2, U, mu, nu);
224  double plaq1 = real(dotc(m_v2, m_v1));
225  plaq += plaq1;
226  }
227 
228  plaq *= 1.0 / (m_Nvol * m_Nc * Ndim_spc);
229  plaq *= 1.0 / NPE;
230 
231  return plaq;
232 }
233 
234 
235 //====================================================================
236 void Staple_lex::staple(Field_G& W, const Field_G& U, const int mu)
237 {
238  const int Ndim = CommonParameters::Ndim();
239 
240 #pragma omp barrier
241 
242  W.set(0.0);
243 #pragma omp barrier
244 
245  for (int nu = 0; nu < Ndim; ++nu) {
246  if (nu != mu) {
247  upper(m_v1, U, mu, nu);
248  axpy(W, 1.0, m_v1);
249 
250  lower(m_v1, U, mu, nu);
251  axpy(W, 1.0, m_v1);
252  }
253  }
254 
255 #pragma omp barrier
256 }
257 
258 
259 //====================================================================
260 void Staple_lex::upper(Field_G& Uup, const Field_G& U,
261  const int mu, const int nu)
262 {
263  // (1) mu (2)
264  // +-->--+
265  // nu | |
266  // i+ +
267 
268 #pragma omp barrier
269 
270  copy(m_Umu, 0, U, mu);
271  copy(m_Unu, 0, U, nu);
272 #pragma omp barrier
273 
274  m_shift->backward(m_w2, m_Unu, mu);
275  m_shift->backward(Uup, m_Umu, nu);
276 
277  mult_Field_Gnd(m_w1, 0, Uup, 0, m_w2, 0);
278  mult_Field_Gnn(Uup, 0, U, nu, m_w1, 0);
279 }
280 
281 
282 //====================================================================
283 void Staple_lex::lower(Field_G& Udn, const Field_G& U,
284  const int mu, const int nu)
285 {
286  // + +
287  // nu | |
288  // i+-->--+
289  // (1) mu (2)
290 
291 #pragma omp barrier
292 
293  copy(m_Unu, 0, U, nu);
294 
295  m_shift->backward(m_w1, m_Unu, mu);
296 
297  mult_Field_Gnn(m_w2, 0, U, mu, m_w1, 0);
298  mult_Field_Gdn(m_w1, 0, U, nu, m_w2, 0);
299 
300  m_shift->forward(Udn, m_w1, nu);
301 }
302 
303 
304 //============================================================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:178
Bridge::BridgeIO::init
void init(const std::string &filename)
Definition: bridgeIO.cpp:62
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:129
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:236
Staple_lex::plaq_t_omp
double plaq_t_omp(const Field_G &)
Definition: staple_lex.cpp:162
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
Bridge::BridgeIO::unset
void unset()
Definition: bridgeIO.cpp:142
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:283
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:208
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:146
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:260
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:195
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
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:262
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:112
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:569
Bridge::BridgeIO::get_verbose_level
static std::string get_verbose_level(const VerboseLevel vl)
Definition: bridgeIO.cpp:216