Bridge++  Ver. 2.0.2
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  m_repr = "Dirac";
36 
37  vout.general(m_vl, "%s: construction\n", class_name.c_str());
38 
43  m_NinF = 2 * m_Nc * m_Nd;
44 
45  m_boundary.resize(m_Ndim);
46  m_U = 0;
47  m_fopr_w = new Fopr_Wilson;
48 
49  m_w1.reset(m_NinF, m_Nvol, 1);
50  m_w2.reset(m_NinF, m_Nvol, 1);
51 
52  vout.general(m_vl, "%s: construction finished.\n",
53  class_name.c_str());
54 }
55 
56 
57 //====================================================================
59 {
60  delete m_fopr_w;
61 }
62 
63 
64 //====================================================================
66 {
67  std::string vlevel;
68  if (!params.fetch_string("verbose_level", vlevel)) {
69  m_vl = vout.set_verbose_level(vlevel);
70  }
71 
72  //- fetch and check input parameters
73  double kappa;
74  std::vector<int> bc;
75 
76  int err = 0;
77  err += params.fetch_double("hopping_parameter", kappa);
78  err += params.fetch_int_vector("boundary_condition", bc);
79 
80  if (err) {
81  vout.crucial(m_vl, "Error at %s: input parameter not found.\n",
82  class_name.c_str());
83  exit(EXIT_FAILURE);
84  }
85 
86  set_parameters(kappa, bc);
87 }
88 
89 
90 //====================================================================
91 void Fopr_Wilson_SF::set_parameters(const double kappa,
92  const std::vector<int> bc)
93 {
94 #pragma omp barrier
95 
96  assert(bc.size() == m_Ndim);
97 
98  int ith = ThreadManager::get_thread_id();
99 
100  //- store values
101  if (ith == 0) {
102  m_kappa = kappa;
103 
104  m_boundary.resize(m_Ndim);
105  m_boundary = bc;
106  }
107 
108 #pragma omp barrier
109 
110  //- print input parameters
111  vout.general(m_vl, "%s: set parameters\n", class_name.c_str());
112  vout.general(m_vl, " kappa = %12.8f\n", m_kappa);
113  for (int dir = 0; dir < m_Ndim; ++dir) {
114  vout.general(m_vl, " boundary[%d] = %2d\n", dir, m_boundary[dir]);
115  }
116 
117  //- propagate parameters
118 
119  Parameters params;
120  get_parameters(params);
121  m_fopr_w->set_parameters(params);
122  // m_fopr_w->set_parameters(m_kappa, m_boundary);
123 
124 #pragma omp barrier
125 }
126 
127 
128 //====================================================================
130 {
131  params.set_double("hopping_parameter", m_kappa);
132  params.set_int_vector("boundary_condition", m_boundary);
133  params.set_string("gamma_matrix_type", m_repr);
134 
135  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
136 }
137 
138 
139 //====================================================================
141 {
142 #pragma omp barrier
143 
144  int ith = ThreadManager::get_thread_id();
145  if (ith == 0) m_U = (Field_G *)U;
146 #pragma omp barrier
147 
148  m_fopr_w->set_config(U);
149 }
150 
151 
152 //====================================================================
153 void Fopr_Wilson_SF::mult(Field& v, const Field& f)
154 {
155  if (m_mode == "D") {
156  D(v, f);
157  } else if (m_mode == "DdagD") {
158  DdagD(v, f);
159  } else if (m_mode == "Ddag") {
160  Ddag(v, f);
161  } else if (m_mode == "H") {
162  H(v, f);
163  } else {
164  vout.crucial(m_vl, "Error at %s: mode undefined.\n",
165  class_name.c_str());
166  exit(EXIT_FAILURE);
167  }
168 }
169 
170 
171 //====================================================================
173 {
174  if (m_mode == "D") {
175  Ddag(v, f);
176  } else if (m_mode == "DdagD") {
177  DdagD(v, f);
178  } else if (m_mode == "Ddag") {
179  D(v, f);
180  } else if (m_mode == "H") {
181  H(v, f);
182  } else {
183  vout.crucial(m_vl, "Error at %s: mode undefined.\n",
184  class_name.c_str());
185  exit(EXIT_FAILURE);
186  }
187 }
188 
189 
190 //====================================================================
191 void Fopr_Wilson_SF::mult(Field& v, const Field& f,
192  const std::string mode)
193 {
194  if (mode == "D") {
195  D(v, f);
196  } else if (mode == "DdagD") {
197  DdagD(v, f);
198  } else if (mode == "Ddag") {
199  Ddag(v, f);
200  } else if (mode == "H") {
201  H(v, f);
202  } else {
203  vout.crucial(m_vl, "Error at %s: mode undefined.\n",
204  class_name.c_str());
205  exit(EXIT_FAILURE);
206  }
207 }
208 
209 
210 //====================================================================
212  const std::string mode)
213 {
214  if (mode == "D") {
215  Ddag(v, f);
216  } else if (mode == "DdagD") {
217  DdagD(v, f);
218  } else if (mode == "Ddag") {
219  D(v, f);
220  } else if (mode == "H") {
221  H(v, f);
222  } else {
223  vout.crucial(m_vl, "Error at %s: mode undefined.\n",
224  class_name.c_str());
225  exit(EXIT_FAILURE);
226  }
227 }
228 
229 
230 //====================================================================
231 void Fopr_Wilson_SF::set_mode(const std::string mode)
232 {
233 #pragma omp barrier
234 
235  int ith = ThreadManager::get_thread_id();
236  if (ith == 0) m_mode = mode;
237 
238 #pragma omp barrier
239 }
240 
241 
242 //====================================================================
244 {
245  D(m_w2, f);
246  mult_gm5(w, m_w2);
247  D(m_w2, w);
248  mult_gm5(w, m_w2);
249 }
250 
251 
252 //====================================================================
253 void Fopr_Wilson_SF::Ddag(Field& w, const Field& f)
254 {
255  mult_gm5(w, f);
256  D(m_w2, w);
257  mult_gm5(w, m_w2);
258 }
259 
260 
261 //====================================================================
262 void Fopr_Wilson_SF::H(Field& w, const Field& f)
263 {
264  D(m_w2, f);
265  mult_gm5(w, m_w2);
266 }
267 
268 
269 //====================================================================
271 {
272  m_fopr_w->mult_gm5(v, w);
273 }
274 
275 
276 //====================================================================
277 void Fopr_Wilson_SF::D(Field& v, const Field& w)
278 {
279 #pragma omp barrier
280 
281  copy(m_w1, w);
283 
284  m_fopr_w->D(v, m_w1);
286 }
287 
288 
289 //====================================================================
290 void Fopr_Wilson_SF::mult_gm5p(const int mu, Field& v, const Field& w)
291 {
293 
294  //#pragma omp barrier
295 
296  copy(m_w2, w);
297  //#pragma omp barrier
298 
300 
301  m_fopr_w->mult_gm5p(mu, m_w1, m_w2);
302 
304  copy(v, m_w1);
305 }
306 
307 
308 //====================================================================
310 {
311  //- Counting of floating point operations in giga unit.
312  // not implemented, yet.
313 
314  vout.general(m_vl, "Warning at %s: flop_count() has not been implemented.\n",
315  class_name.c_str());
316 
317  const double gflop = 0;
318 
319  return gflop;
320 }
321 
322 
323 //============================================================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:262
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:231
Fopr_Wilson_SF::flop_count
double flop_count()
this returns the number of floating point operations.
Definition: fopr_Wilson_SF.cpp:309
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:65
Parameters
Class for parameters.
Definition: parameters.h:46
Parameters::set_double
void set_double(const string &key, const double value)
Definition: parameters.cpp:33
Fopr_Wilson_SF::set_config
void set_config(Field *U)
sets the gauge configuration.
Definition: fopr_Wilson_SF.cpp:140
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:243
copy
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:212
Fopr_Wilson_SF::mult_gm5p
void mult_gm5p(const int mu, Field &v, const Field &w)
Definition: fopr_Wilson_SF.cpp:290
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:270
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:153
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:129
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:253
Fopr_Wilson_SF::D
void D(Field &, const Field &)
Definition: fopr_Wilson_SF.cpp:277
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:133
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:172
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:180
Fopr_Wilson_SF::tidyup
void tidyup()
Definition: fopr_Wilson_SF.cpp:58
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:200
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:512
Bridge::BridgeIO::get_verbose_level
static std::string get_verbose_level(const VerboseLevel vl)
Definition: bridgeIO.cpp:154
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