Bridge++  Ver.2.1.3
fopr_Wilson_SF.cpp
Go to the documentation of this file.
1 
14 #include "fopr_Wilson_SF.h"
15 
16 #include "lib/Field/field_SF.h"
18 
19 
20 #ifdef USE_FACTORY_AUTOREGISTER
21 namespace {
22  bool init = Fopr_Wilson_SF::register_factory();
23 }
24 #endif
25 
26 const std::string Fopr_Wilson_SF::class_name = "Fopr_Wilson_SF";
27 
28 //====================================================================
30 {
32 
34 
35  vout.general(m_vl, "%s: construction\n", class_name.c_str());
37 
38  m_repr = "Dirac";
39 
44  m_NinF = 2 * m_Nc * m_Nd;
45 
46  m_boundary.resize(m_Ndim);
47 
48  m_U = 0;
49 
50  m_fopr_w = new Fopr_Wilson();
51 
52  m_w1.reset(m_NinF, m_Nvol, 1);
53  m_w2.reset(m_NinF, m_Nvol, 1);
54 
56  vout.general(m_vl, "%s: construction finished.\n",
57  class_name.c_str());
58 }
59 
60 
61 //====================================================================
62 void Fopr_Wilson_SF::init(const Parameters& params)
63 {
65 
66  std::string vlevel;
67  if (!params.fetch_string("verbose_level", vlevel)) {
68  m_vl = vout.set_verbose_level(vlevel);
69  } else {
71  }
72 
73  vout.general(m_vl, "%s: construction\n", class_name.c_str());
75 
76  std::string repr;
77  if (!params.fetch_string("gamma_matrix_type", repr)) {
78  m_repr = repr;
79  } else {
80  m_repr = "Dirac"; // default
81  vout.general(m_vl, "gamma_matrix_type is not given: defalt = %s\n",
82  m_repr.c_str());
83  }
84 
85  if(m_repr != "Dirac"){
86  vout.crucial("%s: only Dirac repr. is available.\n");
87  exit(EXIT_FAILURE);
88  }
89 
94  m_NinF = 2 * m_Nc * m_Nd;
95 
96  m_boundary.resize(m_Ndim);
97 
98  set_parameters_impl(params);
99 
100  m_U = 0;
101  m_fopr_w = new Fopr_Wilson(params);
102 
103  m_w1.reset(m_NinF, m_Nvol, 1);
104  m_w2.reset(m_NinF, m_Nvol, 1);
105 
107  vout.general(m_vl, "%s: construction finished.\n",
108  class_name.c_str());
109 }
110 
111 
112 //====================================================================
114 {
115  delete m_fopr_w;
116 }
117 
118 
119 //====================================================================
121 {
122  set_parameters_impl(params);
123 
124  //- propagate parameters
125  m_fopr_w->set_parameters(params);
126 
127 }
128 
129 
130 //====================================================================
132 {
133  std::string vlevel;
134  if (!params.fetch_string("verbose_level", vlevel)) {
135  m_vl = vout.set_verbose_level(vlevel);
136  }
137 
138  //- fetch and check input parameters
139  double kappa;
140  std::vector<int> bc;
141 
142  int err = 0;
143  err += params.fetch_double("hopping_parameter", kappa);
144  err += params.fetch_int_vector("boundary_condition", bc);
145 
146  if (err) {
147  vout.crucial(m_vl, "Error at %s: input parameter not found.\n",
148  class_name.c_str());
149  exit(EXIT_FAILURE);
150  }
151 
152  set_parameters_impl(kappa, bc);
153 }
154 
155 
156 //====================================================================
157 void Fopr_Wilson_SF::set_parameters(const double kappa,
158  const std::vector<int> bc)
159 {
160  set_parameters_impl(kappa, bc);
161 
162  //- propagate parameters
163  Parameters params;
164  get_parameters(params);
165  m_fopr_w->set_parameters(params);
166 
167 }
168 
169 
170 //====================================================================
171 void Fopr_Wilson_SF::set_parameters_impl(const double kappa,
172  const std::vector<int> bc)
173 {
174 #pragma omp barrier
175 
176  assert(bc.size() == m_Ndim);
177 
178  int ith = ThreadManager::get_thread_id();
179 
180  //- store values
181  if (ith == 0) {
182  m_kappa = kappa;
183  m_boundary = bc;
184  }
185 
186 #pragma omp barrier
187 
188  //- print input parameters
189  vout.general(m_vl, "%s: parameters\n", class_name.c_str());
190  vout.general(m_vl, " kappa = %12.8f\n", m_kappa);
191  for (int dir = 0; dir < m_Ndim; ++dir) {
192  vout.general(m_vl, " boundary[%d] = %2d\n", dir, m_boundary[dir]);
193  }
194 
195 #pragma omp barrier
196 }
197 
198 
199 //====================================================================
201 {
202  params.set_double("hopping_parameter", m_kappa);
203  params.set_int_vector("boundary_condition", m_boundary);
204  params.set_string("gamma_matrix_type", m_repr);
205 
206  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
207 }
208 
209 
210 //====================================================================
212 {
213 #pragma omp barrier
214 
215  int ith = ThreadManager::get_thread_id();
216  if (ith == 0) m_U = (Field_G *)U;
217 #pragma omp barrier
218 
219  m_fopr_w->set_config(U);
220 
221 }
222 
223 
224 //====================================================================
225 void Fopr_Wilson_SF::mult(Field& v, const Field& f)
226 {
227  if (m_mode == "D") {
228  D(v, f);
229  } else if (m_mode == "DdagD") {
230  DdagD(v, f);
231  } else if (m_mode == "Ddag") {
232  Ddag(v, f);
233  } else if (m_mode == "H") {
234  H(v, f);
235  } else {
236  vout.crucial(m_vl, "Error at %s: mode undefined.\n",
237  class_name.c_str());
238  exit(EXIT_FAILURE);
239  }
240 }
241 
242 
243 //====================================================================
245 {
246  if (m_mode == "D") {
247  Ddag(v, f);
248  } else if (m_mode == "DdagD") {
249  DdagD(v, f);
250  } else if (m_mode == "Ddag") {
251  D(v, f);
252  } else if (m_mode == "H") {
253  H(v, f);
254  } else {
255  vout.crucial(m_vl, "Error at %s: mode undefined.\n",
256  class_name.c_str());
257  exit(EXIT_FAILURE);
258  }
259 }
260 
261 
262 //====================================================================
263 void Fopr_Wilson_SF::mult(Field& v, const Field& f,
264  const std::string mode)
265 {
266  if (mode == "D") {
267  D(v, f);
268  } else if (mode == "DdagD") {
269  DdagD(v, f);
270  } else if (mode == "Ddag") {
271  Ddag(v, f);
272  } else if (mode == "H") {
273  H(v, f);
274  } else {
275  vout.crucial(m_vl, "Error at %s: mode undefined.\n",
276  class_name.c_str());
277  exit(EXIT_FAILURE);
278  }
279 }
280 
281 
282 //====================================================================
284  const std::string mode)
285 {
286  if (mode == "D") {
287  Ddag(v, f);
288  } else if (mode == "DdagD") {
289  DdagD(v, f);
290  } else if (mode == "Ddag") {
291  D(v, f);
292  } else if (mode == "H") {
293  H(v, f);
294  } else {
295  vout.crucial(m_vl, "Error at %s: mode undefined.\n",
296  class_name.c_str());
297  exit(EXIT_FAILURE);
298  }
299 }
300 
301 
302 //====================================================================
303 void Fopr_Wilson_SF::set_mode(const std::string mode)
304 {
305 #pragma omp barrier
306 
307  int ith = ThreadManager::get_thread_id();
308  if (ith == 0) m_mode = mode;
309 
310 #pragma omp barrier
311 }
312 
313 
314 //====================================================================
316 {
317  D(m_w2, f);
318  mult_gm5(w, m_w2);
319  D(m_w2, w);
320  mult_gm5(w, m_w2);
321 }
322 
323 
324 //====================================================================
325 void Fopr_Wilson_SF::Ddag(Field& w, const Field& f)
326 {
327  mult_gm5(w, f);
328  D(m_w2, w);
329  mult_gm5(w, m_w2);
330 }
331 
332 
333 //====================================================================
334 void Fopr_Wilson_SF::H(Field& w, const Field& f)
335 {
336  D(m_w2, f);
337  mult_gm5(w, m_w2);
338 }
339 
340 
341 //====================================================================
343 {
344  m_fopr_w->mult_gm5(v, w);
345 }
346 
347 
348 //====================================================================
349 void Fopr_Wilson_SF::D(Field& v, const Field& w)
350 {
351 #pragma omp barrier
352 
353  copy(m_w1, w);
354 #pragma omp barrier
355 
357 
358  m_fopr_w->D(v, m_w1);
359 
361 
362 #pragma omp barrier
363 }
364 
365 
366 //====================================================================
367 void Fopr_Wilson_SF::mult_gm5p(const int mu, Field& v, const Field& w)
368 {
369  //ThreadManager::assert_single_thread(class_name);
370 #pragma omp barrier
371 
372  copy(m_w2, w);
373 #pragma omp barrier
374 
376 
377  m_fopr_w->mult_gm5p(mu, m_w1, m_w2);
378 
380 
381  copy(v, m_w1);
382 
383 #pragma omp barrier
384 }
385 
386 
387 //====================================================================
389 {
390  //- Counting of floating point operations in giga unit.
391  // not implemented, yet.
392 
393  vout.general(m_vl, "Warning at %s: flop_count() has not been implemented.\n",
394  class_name.c_str());
395 
396  const double gflop = 0;
397 
398  return gflop;
399 }
400 
401 
402 //============================================================END=====
fopr_thread-inc.h
Fopr_Wilson_SF::m_Nvol
int m_Nvol
Definition: fopr_Wilson_SF.h:59
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
Fopr_Wilson_SF::H
void H(Field &, const Field &)
Definition: fopr_Wilson_SF.cpp:334
Fopr_Wilson_SF::set_mode
void set_mode(const std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Definition: fopr_Wilson_SF.cpp:303
Fopr_Wilson_SF::flop_count
double flop_count()
this returns the number of floating point operations.
Definition: fopr_Wilson_SF.cpp:388
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Fopr_Wilson_SF::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_Wilson_SF.cpp:120
Parameters
Class for parameters.
Definition: parameters.h:46
Parameters::set_double
void set_double(const string &key, const double value)
Definition: parameters.cpp:33
Bridge::BridgeIO::decrease_indent
void decrease_indent()
Definition: bridgeIO.cpp:518
Bridge::BridgeIO::increase_indent
void increase_indent()
Definition: bridgeIO.cpp:508
Fopr_Wilson_SF::set_config
void set_config(Field *U)
sets the gauge configuration.
Definition: fopr_Wilson_SF.cpp:211
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Fopr_Wilson_SF::m_Nd
int m_Nd
Definition: fopr_Wilson_SF.h:59
fopr_Wilson_SF.h
Fopr_Wilson_SF::init
void init()
Definition: fopr_Wilson_SF.cpp:29
Fopr_Wilson_SF::m_mode
std::string m_mode
Definition: fopr_Wilson_SF.h:64
Fopr_Wilson_SF::DdagD
void DdagD(Field &, const Field &)
Definition: fopr_Wilson_SF.cpp:315
copy
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:213
Fopr_Wilson_SF::mult_gm5p
void mult_gm5p(const int mu, Field &v, const Field &w)
Definition: fopr_Wilson_SF.cpp:367
Fopr_Wilson_SF::m_w2
Field m_w2
Definition: fopr_Wilson_SF.h:69
Field_SF::set_boundary_zero
void set_boundary_zero(Field_G &u)
Definition: field_SF.cpp:96
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
Fopr_Wilson_SF::m_repr
std::string m_repr
Definition: fopr_Wilson_SF.h:62
Parameters::fetch_int_vector
int fetch_int_vector(const string &key, vector< int > &value) const
Definition: parameters.cpp:429
Org::Fopr_Wilson::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_Wilson_impl.cpp:127
Fopr_Wilson_SF::mult_gm5
void mult_gm5(Field &v, const Field &w)
multiplies gamma_5 matrix.
Definition: fopr_Wilson_SF.cpp:342
Org::Fopr_Wilson::mult_gm5p
void mult_gm5p(const int mu, Field &v, const Field &w)
Definition: fopr_Wilson_impl.cpp:406
Fopr_Wilson_SF::mult
void mult(Field &v, const Field &f)
multiplies fermion operator to a given field.
Definition: fopr_Wilson_SF.cpp:225
Fopr_Wilson_SF::m_vl
Bridge::VerboseLevel m_vl
Definition: fopr_Wilson_SF.h:57
field_SF.h
Fopr_Wilson_SF::m_U
const Field_G * m_U
Definition: fopr_Wilson_SF.h:67
Fopr_Wilson_SF::m_boundary
std::vector< int > m_boundary
Definition: fopr_Wilson_SF.h:61
Field::reset
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=Element_type::COMPLEX)
Definition: field.h:95
Parameters::set_int_vector
void set_int_vector(const string &key, const vector< int > &value)
Definition: parameters.cpp:45
Fopr_Wilson_SF::get_parameters
void get_parameters(Parameters &params) const
gets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_Wilson_SF.cpp:200
Org::Fopr_Wilson::mult_gm5
void mult_gm5(Field &v, const Field &w)
multiplies gamma_5 matrix.
Definition: fopr_Wilson_impl.cpp:370
Fopr_Wilson_SF::Ddag
void Ddag(Field &, const Field &)
Definition: fopr_Wilson_SF.cpp:325
Fopr_Wilson_SF::D
void D(Field &, const Field &)
Definition: fopr_Wilson_SF.cpp:349
Fopr_Wilson_SF::m_w1
Field m_w1
Definition: fopr_Wilson_SF.h:69
CommonParameters::Nd
static int Nd()
Definition: commonParameters.h:116
CommonParameters::Vlevel
static Bridge::VerboseLevel Vlevel()
Definition: commonParameters.h:122
Fopr_Wilson_SF::class_name
static const std::string class_name
Definition: fopr_Wilson_SF.h:54
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:195
Fopr_Wilson_SF::m_Ndim
int m_Ndim
Definition: fopr_Wilson_SF.h:59
Fopr_Wilson_SF::m_NinF
int m_NinF
Definition: fopr_Wilson_SF.h:59
Fopr_Wilson_SF::mult_dag
void mult_dag(Field &v, const Field &f)
hermitian conjugate of mult.
Definition: fopr_Wilson_SF.cpp:244
Org::Fopr_Wilson::set_config
void set_config(Field *U)
sets the gauge configuration.
Definition: fopr_Wilson_impl.cpp:188
Parameters::fetch_string
int fetch_string(const string &key, string &value) const
Definition: parameters.cpp:378
Parameters::fetch_double
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
Org::Fopr_Wilson::D
void D(Field &, const Field &)
Definition: fopr_Wilson_impl.cpp:333
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:242
Fopr_Wilson_SF::tidyup
void tidyup()
Definition: fopr_Wilson_SF.cpp:113
Field
Container of Field-type object.
Definition: field.h:46
Fopr_Wilson_SF::m_Nc
int m_Nc
Definition: fopr_Wilson_SF.h:59
ThreadManager::get_thread_id
static int get_thread_id()
returns thread id.
Definition: threadManager.cpp:253
Field_G
SU(N) gauge field.
Definition: field_G.h:38
Fopr_Wilson_SF::m_fopr_w
Fopr_Wilson * m_fopr_w
Definition: fopr_Wilson_SF.h:66
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:262
Fopr_Wilson_SF::set_parameters_impl
void set_parameters_impl(const Parameters &params)
Definition: fopr_Wilson_SF.cpp:131
ThreadManager::assert_single_thread
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.
Definition: threadManager.cpp:372
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:572
Bridge::BridgeIO::get_verbose_level
static std::string get_verbose_level(const VerboseLevel vl)
Definition: bridgeIO.cpp:216
Fopr_Wilson
Org::Fopr_Wilson Fopr_Wilson
Wilson fermion operator.
Definition: fopr_Wilson.h:50
Fopr_Wilson_SF::m_kappa
double m_kappa
Definition: fopr_Wilson_SF.h:60