Bridge++  Ver. 2.0.2
fopr_Clover_eo.cpp
Go to the documentation of this file.
1 
14 #include "fopr_Clover_eo.h"
15 
16 #include "Fopr/fopr_thread-inc.h"
17 
18 
19 #ifdef USE_FACTORY_AUTOREGISTER
20 namespace {
21  bool init = Fopr_Clover_eo::register_factory();
22 }
23 #endif
24 
25 
26 const std::string Fopr_Clover_eo::class_name = "Fopr_Clover_eo";
27 
28 //====================================================================
29 void Fopr_Clover_eo::init(const Parameters& params)
30 {
32 
34  m_is_initial_step = true;
35 
36  vout.general(m_vl, "%s: construction\n", class_name.c_str());
38 
39  setup();
40 
41  std::string repr;
42  if (!params.fetch_string("gamma_matrix_type", repr)) {
43  m_repr = repr;
44  } else {
45  m_repr = "Dirac"; // default
46  }
47  if ((m_repr != "Dirac") && (m_repr != "Chiral")) {
48  vout.crucial("Error in %s: irrelevant mult mode = %s\n",
49  class_name.c_str(), m_repr.c_str());
50  exit(EXIT_FAILURE);
51  }
52 
53  set_parameters(params);
54 
55  m_fopr_w = new Fopr_Wilson_eo(params);
56  m_fopr_csw = new Fopr_CloverTerm_eo(params);
57 
58  m_is_initial_step = false;
59 
61  vout.general(m_vl, "%s: construction finished.\n",
62  class_name.c_str());
63 }
64 
65 
66 //====================================================================
67 void Fopr_Clover_eo::init(const std::string repr)
68 {
70 
72  m_is_initial_step = true;
73 
74  vout.general(m_vl, "%s: construction (obsolete)\n",
75  class_name.c_str());
77 
78  setup();
79 
80  m_repr = repr;
81 
84 
85  m_is_initial_step = false;
86 
88  vout.general(m_vl, "%s: construction finished.\n",
89  class_name.c_str());
90 }
91 
92 
93 //====================================================================
95 {
99  m_NinF = 2 * m_Nc * m_Nd;
101  m_Nvol2 = m_Nvol / 2;
102 
103  m_boundary.resize(m_Ndim);
104 
105  m_w1.reset(m_NinF, m_Nvol2, 1);
106  m_w2.reset(m_NinF, m_Nvol2, 1);
107 
108  m_v1.reset(m_NinF, m_Nvol2, 1);
109 }
110 
111 
112 //====================================================================
114 {
115  delete m_fopr_w;
116  delete m_fopr_csw;
117 }
118 
119 
120 //====================================================================
122 {
123 #pragma omp barrier
124  int ith = ThreadManager::get_thread_id();
125  std::string vlevel;
126  if (!params.fetch_string("verbose_level", vlevel)) {
127  if (ith == 0) m_vl = vout.set_verbose_level(vlevel);
128  }
129 #pragma omp barrier
130 
131  //- fetch and check input parameters
132  double kappa, cSW;
133  std::vector<int> bc;
134 
135  int err = 0;
136  err += params.fetch_double("hopping_parameter", kappa);
137  err += params.fetch_double("clover_coefficient", cSW);
138  err += params.fetch_int_vector("boundary_condition", bc);
139 
140  if (err) {
141  vout.crucial(m_vl, "Error at %s: input parameter not found.\n",
142  class_name.c_str());
143  exit(EXIT_FAILURE);
144  }
145 
146  set_parameters(kappa, cSW, bc);
147 
148  //- propagate parameters to components
149  if (!m_is_initial_step) {
150  m_fopr_w->set_parameters(params);
151  m_fopr_csw->set_parameters(params);
152  }
153 }
154 
155 
156 //====================================================================
157 void Fopr_Clover_eo::set_parameters(const double kappa,
158  const double cSW,
159  const std::vector<int> bc)
160 {
161  assert(bc.size() == m_Ndim);
162 
163 #pragma omp barrier
164  int ith = ThreadManager::get_thread_id();
165  if (ith == 0) {
166  m_kappa = kappa;
167  m_cSW = cSW;
168  m_boundary = bc;
169  }
170 #pragma omp barrier
171 
172  vout.general(m_vl, "%s: input parameters\n", class_name.c_str());
173  vout.general(m_vl, " gamma matrix type = %s\n", m_repr.c_str());
174  vout.general(m_vl, " kappa = %12.8f\n", kappa);
175  vout.general(m_vl, " cSW = %12.8f\n", cSW);
176  for (int mu = 0; mu < m_Ndim; ++mu) {
177  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
178  }
179 }
180 
181 
182 //====================================================================
184 {
185  params.set_double("hopping_parameter", m_kappa);
186  params.set_double("clover_coefficient", m_cSW);
187  params.set_int_vector("boundary_condition", m_boundary);
188  params.set_string("gamma_matrix_type", m_repr);
189  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
190 }
191 
192 
193 //====================================================================
195 {
196 #pragma omp barrier
197 
198  int ith = ThreadManager::get_thread_id();
199  if (ith == 0) m_U = (Field_G *)U;
200 #pragma omp barrier
201 
202  m_fopr_w->set_config(U);
204 }
205 
206 
207 //====================================================================
208 void Fopr_Clover_eo::set_mode(const std::string mode)
209 {
210 #pragma omp barrier
211 
212  int ith = ThreadManager::get_thread_id();
213  if (ith == 0) m_mode = mode;
214 
215 #pragma omp barrier
216 }
217 
218 
219 //====================================================================
220 void Fopr_Clover_eo::mult(Field& v, const Field& w)
221 {
222  if (m_mode == "D") {
223  D(v, w);
224  } else if (m_mode == "Ddag") {
225  Ddag(v, w);
226  } else if (m_mode == "DdagD") {
227  DdagD(v, w);
228  } else if (m_mode == "DDdag") {
229  DDdag(v, w);
230  } else if (m_mode == "H") {
231  H(v, w);
232  } else {
233  vout.crucial(m_vl, "Error at %s: undefined mode = %s.\n",
234  class_name.c_str(), m_mode.c_str());
235  exit(EXIT_FAILURE);
236  }
237 }
238 
239 
240 //====================================================================
242 {
243  if (m_mode == "D") {
244  Ddag(v, w);
245  } else if (m_mode == "Ddag") {
246  D(v, w);
247  } else if (m_mode == "DdagD") {
248  DdagD(v, w);
249  } else if (m_mode == "DDdag") {
250  DDdag(v, w);
251  } else if (m_mode == "H") {
252  H(v, w);
253  } else {
254  vout.crucial(m_vl, "Error at %s: undefined mode = %s.\n",
255  class_name.c_str(), m_mode.c_str());
256  exit(EXIT_FAILURE);
257  }
258 }
259 
260 
261 //====================================================================
263 {
264  m_fopr_w->mult_gm5(v, w);
265 }
266 
267 
268 //====================================================================
269 void Fopr_Clover_eo::preProp(Field& Be, Field& bo, const Field& b)
270 {
271  m_idx.convertField(m_w1, b, 1);
272  m_fopr_csw->mult_csw_inv(bo, m_w1, 1);
273 
274  m_idx.convertField(m_w1, b, 0);
275  m_fopr_csw->mult_csw_inv(Be, m_w1, 0);
276 
277  if (m_mode == "D") {
278  Meo(m_w1, bo, 0);
279  } else {
280  Mdageo(m_w1, bo, 0);
281  }
282  axpy(Be, -1.0, m_w1);
283 #pragma omp barrier
284 }
285 
286 
287 //====================================================================
289  const Field& xe, const Field& bo)
290 {
291  if (m_mode == "D") {
292  Meo(m_w1, xe, 1);
293  } else {
294  Mdageo(m_w1, xe, 1);
295  }
296 
297  aypx(-1.0, m_w1, bo);
298 #pragma omp barrier
299 
300  m_idx.reverseField(x, xe, 0);
301  m_idx.reverseField(x, m_w1, 1);
302 
303 #pragma omp barrier
304 }
305 
306 
307 //====================================================================
309 {
310  D(m_w1, w);
311  Ddag(v, m_w1);
312 }
313 
314 
315 //====================================================================
317 {
318  Ddag(m_w1, w);
319  D(v, m_w1);
320 }
321 
322 
323 //====================================================================
324 void Fopr_Clover_eo::H(Field& v, const Field& w)
325 {
326  D(m_w1, w);
327  mult_gm5(v, m_w1);
328 }
329 
330 
331 //====================================================================
332 void Fopr_Clover_eo::D(Field& v, const Field& w)
333 {
334  Meo(m_w2, w, 1);
335  Meo(v, m_w2, 0);
336  aypx(-1.0, v, w);
337 
338 #pragma omp barrier
339 }
340 
341 
342 //====================================================================
343 void Fopr_Clover_eo::Ddag(Field& v, const Field& w)
344 {
345  Mdageo(m_w2, w, 1);
346  Mdageo(v, m_w2, 0);
347  aypx(-1.0, v, w);
348 
349 #pragma omp barrier
350 }
351 
352 
353 //====================================================================
354 void Fopr_Clover_eo::Meo(Field& v, const Field& f, const int ieo)
355 {
356  // ieo=0: even <-- odd
357  // ieo=1: odd <-- even
358 
359  m_fopr_w->Meo(m_v1, f, ieo);
360  m_fopr_csw->mult_csw_inv(v, m_v1, ieo);
361 }
362 
363 
364 //====================================================================
365 void Fopr_Clover_eo::Mdageo(Field& v, const Field& w, const int ieo)
366 {
367  m_fopr_w->mult_gm5(m_v1, w);
368  m_fopr_w->Meo(v, m_v1, ieo);
369  m_fopr_w->mult_gm5(m_v1, v);
370 
371  m_fopr_csw->mult_csw_inv(v, m_v1, ieo);
372 }
373 
374 
375 //====================================================================
377  const int mu, const int nu)
378 {
379  m_fopr_csw->mult_isigma(w, f, mu, nu);
380 }
381 
382 
383 //====================================================================
385 {
386  // Counting of floating point operations in giga unit.
387  // defined only for D, Dag, H, DDdag, DdagD which can be called
388  // from the solver algorithms.
389  // Since the flop_count() of Fopr_Wilson_eo defines flop of
390  // (1 - Meo*Moe), flop of clover term is twice added together with
391  // contribution of addition.
392 
393  // this is for aypx + Meo * 2 with Wilson_eo
394  const double gflop_w = m_fopr_w->flop_count();
395 
396  // this is for inversion of (1 - clover term)
397  const double gflop_csw = m_fopr_csw->flop_count();
398 
399  double gflop = gflop_w + 2 * gflop_csw;
400 
401  // Additional twice mult of clover term
402  if ((m_mode == "DdagD") || (m_mode == "DDdag")) gflop += 2 * gflop_csw;
403 
404  return gflop;
405 }
406 
407 
408 //====================================================================
409 //============================================================END=====
Fopr_Clover_eo::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_Clover_eo.cpp:121
Fopr_Wilson_eo
Org::Fopr_Wilson_eo Fopr_Wilson_eo
Even-odd Wilson fermion operator.
Definition: fopr_Wilson_eo.h:51
Fopr_Clover_eo::m_boundary
std::vector< int > m_boundary
boundary condition.
Definition: fopr_Clover_eo.h:52
fopr_thread-inc.h
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
Fopr_Clover_eo::m_cSW
double m_cSW
clover coefficient.
Definition: fopr_Clover_eo.h:51
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Fopr_Clover_eo::mult
void mult(Field &v, const Field &f)
multiplies fermion operator to a given field (2nd argument)
Definition: fopr_Clover_eo.cpp:220
Parameters
Class for parameters.
Definition: parameters.h:46
Fopr_Clover_eo::init
void init(const std::string repr)
Definition: fopr_Clover_eo.cpp:67
Org::Fopr_CloverTerm_eo::flop_count
double flop_count()
returns number of floating point operations.
Definition: fopr_CloverTerm_eo_impl.cpp:568
Parameters::set_double
void set_double(const string &key, const double value)
Definition: parameters.cpp:33
Org::Fopr_Wilson_eo::flop_count
double flop_count()
this returns the number of floating point operations of Meo.
Definition: fopr_Wilson_eo_impl.cpp:543
Bridge::BridgeIO::decrease_indent
void decrease_indent()
Definition: bridgeIO.h:86
Bridge::BridgeIO::increase_indent
void increase_indent()
Definition: bridgeIO.h:85
Fopr_Clover_eo::postProp
void postProp(Field &x, const Field &xe, const Field &bo)
Definition: fopr_Clover_eo.cpp:288
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Fopr_Clover_eo::Meo
void Meo(Field &, const Field &, const int ieo)
Definition: fopr_Clover_eo.cpp:354
Fopr_Clover_eo::m_idx
Index_eo m_idx
Definition: fopr_Clover_eo.h:65
aypx
void aypx(const double a, Field &y, const Field &x)
aypx(y, a, x): y := a * y + x
Definition: field.cpp:509
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
Org::Fopr_CloverTerm_eo::mult_isigma
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
Definition: fopr_CloverTerm_eo_impl.cpp:421
Fopr_Clover_eo::m_w1
Field m_w1
Definition: fopr_Clover_eo.h:68
Fopr_Clover_eo::m_Nc
int m_Nc
Definition: fopr_Clover_eo.h:59
Fopr_Clover_eo::m_Nd
int m_Nd
Definition: fopr_Clover_eo.h:59
Org::Fopr_CloverTerm_eo::set_config
void set_config(Field *U)
sets the gauge configuration.
Definition: fopr_CloverTerm_eo_impl.cpp:241
Fopr_Clover_eo::m_U
Field_G * m_U
Definition: fopr_Clover_eo.h:66
Fopr_Clover_eo::m_repr
std::string m_repr
gamma-matrix type
Definition: fopr_Clover_eo.h:53
Index_eo::reverseField
void reverseField(Field &lex, const Field &eo)
Definition: index_eo.cpp:197
Fopr_Clover_eo::get_parameters
void get_parameters(Parameters &params) const
gets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_Clover_eo.cpp:183
Fopr_Clover_eo::m_mode
std::string m_mode
Definition: fopr_Clover_eo.h:56
Fopr_Clover_eo::tidyup
void tidyup()
Definition: fopr_Clover_eo.cpp:113
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
Org::Fopr_CloverTerm_eo::mult_csw_inv
void mult_csw_inv(Field &, const Field &, const int ieo)
multiplies [1 - csw kappa sigma_{mu nu} F_{mu nu} ]^{-1}
Definition: fopr_CloverTerm_eo_impl.cpp:364
Fopr_Clover_eo::m_Nvol2
int m_Nvol2
Definition: fopr_Clover_eo.h:60
Fopr_Clover_eo::H
void H(Field &v, const Field &f)
Definition: fopr_Clover_eo.cpp:324
Index_eo::convertField
void convertField(Field &eo, const Field &lex)
Definition: index_eo.cpp:90
Fopr_Clover_eo::mult_gm5
void mult_gm5(Field &, const Field &)
multiplies gamma_5 matrix.
Definition: fopr_Clover_eo.cpp:262
Parameters::fetch_int_vector
int fetch_int_vector(const string &key, vector< int > &value) const
Definition: parameters.cpp:429
Fopr_Clover_eo::DdagD
void DdagD(Field &v, const Field &f)
Definition: fopr_Clover_eo.cpp:308
Fopr_Clover_eo::class_name
static const std::string class_name
Definition: fopr_Clover_eo.h:46
Fopr_Clover_eo::m_vl
Bridge::VerboseLevel m_vl
verbose level
Definition: fopr_Clover_eo.h:54
Org::Fopr_CloverTerm_eo::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_CloverTerm_eo_impl.cpp:175
Fopr_Clover_eo::set_config
void set_config(Field *U)
setting pointer to the gauge configuration.
Definition: fopr_Clover_eo.cpp:194
Fopr_CloverTerm_eo
Org::Fopr_CloverTerm_eo Fopr_CloverTerm_eo
Definition: fopr_CloverTerm_eo.h:32
Fopr_Clover_eo::m_NinF
int m_NinF
Definition: fopr_Clover_eo.h:59
Fopr_Clover_eo::DDdag
void DDdag(Field &v, const Field &f)
Definition: fopr_Clover_eo.cpp:316
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_Clover_eo::Ddag
void Ddag(Field &v, const Field &f)
Definition: fopr_Clover_eo.cpp:343
Fopr_Clover_eo::D
void D(Field &v, const Field &f)
Definition: fopr_Clover_eo.cpp:332
Fopr_Clover_eo::m_Ndim
int m_Ndim
Definition: fopr_Clover_eo.h:59
Org::Fopr_Wilson_eo::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_Wilson_eo_impl.cpp:136
Fopr_Clover_eo::m_fopr_csw
Fopr_CloverTerm_eo * m_fopr_csw
Definition: fopr_Clover_eo.h:63
Fopr_Clover_eo::Mdageo
void Mdageo(Field &, const Field &, const int ieo)
Definition: fopr_Clover_eo.cpp:365
Fopr_Clover_eo::m_Nvol
int m_Nvol
Definition: fopr_Clover_eo.h:60
Fopr_Clover_eo::preProp
void preProp(Field &Be, Field &bo, const Field &b)
Definition: fopr_Clover_eo.cpp:269
Fopr_Clover_eo::setup
void setup()
Definition: fopr_Clover_eo.cpp:94
CommonParameters::Nd
static int Nd()
Definition: commonParameters.h:116
Fopr_Clover_eo::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_Clover_eo.cpp:208
CommonParameters::Vlevel
static Bridge::VerboseLevel Vlevel()
Definition: commonParameters.h:122
fopr_Clover_eo.h
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
Fopr_Clover_eo::m_fopr_w
Fopr_Wilson_eo * m_fopr_w
Definition: fopr_Clover_eo.h:62
Fopr_Clover_eo::m_w2
Field m_w2
working field
Definition: fopr_Clover_eo.h:68
Parameters::fetch_string
int fetch_string(const string &key, string &value) const
Definition: parameters.cpp:378
Field_F
Wilson-type fermion field.
Definition: field_F.h:37
Parameters::fetch_double
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
Org::Fopr_Wilson_eo::Meo
void Meo(Field &, const Field &, const int ieo)
Definition: fopr_Wilson_eo_impl.cpp:434
Fopr_Clover_eo::m_kappa
double m_kappa
hopping parameter.
Definition: fopr_Clover_eo.h:50
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Field
Container of Field-type object.
Definition: field.h:46
Fopr_Clover_eo::mult_dag
void mult_dag(Field &v, const Field &f)
hermitian conjugate of mult(Field&, const Field&).
Definition: fopr_Clover_eo.cpp:241
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_Clover_eo::m_v1
Field m_v1
working field
Definition: fopr_Clover_eo.h:69
Org::Fopr_Wilson_eo::mult_gm5
void mult_gm5(Field &, const Field &)
multiplies gamma_5 matrix.
Definition: fopr_Wilson_eo_impl.cpp:295
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Org::Fopr_Wilson_eo::set_config
void set_config(Field *U)
setting pointer to the gauge configuration.
Definition: fopr_Wilson_eo_impl.cpp:202
ThreadManager::assert_single_thread
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.
Definition: threadManager.cpp:372
Fopr_Clover_eo::flop_count
double flop_count()
this returns the number of floating point operations.
Definition: fopr_Clover_eo.cpp:384
Fopr_Clover_eo::mult_isigma
void mult_isigma(Field_F &w, const Field_F &f, const int mu, const int nu)
Definition: fopr_Clover_eo.cpp:376
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
Fopr_Clover_eo::m_is_initial_step
bool m_is_initial_step
to avoid redundant setup
Definition: fopr_Clover_eo.h:71
Bridge::BridgeIO::get_verbose_level
static std::string get_verbose_level(const VerboseLevel vl)
Definition: bridgeIO.cpp:154