Bridge++  Ver. 1.2.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fopr_Clover_eo.cpp
Go to the documentation of this file.
1 
14 #include "fopr_Clover_eo.h"
15 
16 #include "threadManager_OpenMP.h"
17 
18 #ifdef USE_PARAMETERS_FACTORY
19 #include "parameters_factory.h"
20 #endif
21 
22 using std::valarray;
23 
24 //====================================================================
25 //- parameter entries
26 namespace {
27  void append_entry(Parameters& param)
28  {
29  param.Register_double("hopping_parameter", 0.0);
30  param.Register_double("clover_coefficient", 0.0);
31  param.Register_int_vector("boundary_condition", std::valarray<int>());
32 
33  param.Register_string("verbose_level", "NULL");
34  }
35 
36 
37 #ifdef USE_PARAMETERS_FACTORY
38  bool init_param = ParametersFactory::Register("Fopr.Clover_eo", append_entry);
39 #endif
40 }
41 //- end
42 
43 //- parameters class
45 //- end
46 
47 const std::string Fopr_Clover_eo::class_name = "Fopr_Clover_eo";
48 
49 //====================================================================
50 void Fopr_Clover_eo::init(const std::string repr)
51 {
55  m_NinF = 2 * m_Nc * m_Nd;
57  m_Nvol2 = m_Nvol / 2;
58 
59  m_boundary.resize(m_Ndim);
60 
61  m_Ueo = new Field_G(m_Nvol, m_Ndim);
62 
63  m_fopr_w = new Fopr_Wilson_eo(repr);
64  m_fopr_csw = new Fopr_CloverTerm_eo(repr);
65 
66  // working field (Field)
67  m_w1.reset(m_NinF, m_Nvol2, 1);
68  // m_w2.reset(m_NinF, m_Nvol2, 1);
69 
70  // working field (Field_F)
71  m_vF1.reset(m_Nvol2, 1);
72  m_vF2.reset(m_Nvol2, 1);
73  m_vF3.reset(m_Nvol2, 1);
74  // m_vF1.reset(m_NinF, m_Nvol2, 1);
75  // m_vF2.reset(m_NinF, m_Nvol2, 1);
76  // m_vF3.reset(m_NinF, m_Nvol2, 1);
77 }
78 
79 
80 //====================================================================
82 {
83  delete m_fopr_w;
84  delete m_fopr_csw;
85 
86  delete m_Ueo;
87 }
88 
89 
90 //====================================================================
92 {
93  const string str_vlevel = params.get_string("verbose_level");
94 
95  m_vl = vout.set_verbose_level(str_vlevel);
96 
97  //- fetch and check input parameters
98  double kappa, cSW;
99  valarray<int> bc;
100 
101  int err = 0;
102  err += params.fetch_double("hopping_parameter", kappa);
103  err += params.fetch_double("clover_coefficient", cSW);
104  err += params.fetch_int_vector("boundary_condition", bc);
105 
106  if (err) {
107  vout.crucial(m_vl, "%s: fetch error, input parameter not found.\n", class_name.c_str());
108  abort();
109  }
110 
111  set_parameters(kappa, cSW, bc);
112 }
113 
114 
115 //====================================================================
116 void Fopr_Clover_eo::set_parameters(const double kappa, const double cSW,
117  const std::valarray<int> bc)
118 {
119  //- print input parameters
120  vout.general(m_vl, "Parameters of %s:\n", class_name.c_str());
121  vout.general(m_vl, " kappa = %8.4f\n", kappa);
122  vout.general(m_vl, " cSW = %8.4f\n", cSW);
123  for (int mu = 0; mu < m_Ndim; ++mu) {
124  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
125  }
126 
127  //- range check
128  // NB. kappa,cSW == 0 is allowed.
129  assert(bc.size() == m_Ndim);
130 
131  //- store values
132  m_kappa = kappa;
133  m_cSW = cSW;
134 
135  assert(bc.size() == m_Ndim);
136  for (int mu = 0; mu < m_Ndim; ++mu) {
137  m_boundary[mu] = bc[mu];
138  }
139 
140  //- propagate parameters to components
143 }
144 
145 
146 //====================================================================
148 {
149  int Ndim = CommonParameters::Ndim();
150  int Nvol = CommonParameters::Nvol();
151 
152  m_idx.convertField(*m_Ueo, *U);
153 
154  m_fopr_w->set_config(U);
156 }
157 
158 
159 //====================================================================
161 {
163 }
164 
165 
166 //====================================================================
168 {
170  Field v(f.nin(), f.nvol(), f.nex());
171  MeoMoe(v, f);
172  return v;
173 }
174 
175 
176 //====================================================================
178 {
180  Field_F v(f.nvol(), f.nex());
181  D(v, f);
182  return v;
183 }
184 
185 
186 //====================================================================
188 {
190  Field_F v(f.nvol(), f.nex());
191  Ddag(v, f);
192  return v;
193 }
194 
195 
196 //====================================================================
198 {
200  Field_F v(f.nvol(), f.nex());
201  DdagD(v, f);
202  return v;
203 }
204 
205 
206 //====================================================================
208 {
210  Field_F v(f.nvol(), f.nex());
211  DDdag(v, f);
212  return v;
213 }
214 
215 
216 //====================================================================
218 {
220  Field_F v(f.nvol(), f.nex());
221  H(v, f);
222  return v;
223 }
224 
225 
226 //====================================================================
228 {
230  Field v(f.nin(), f.nvol(), f.nex());
231  m_fopr_w->mult_gm5(v, f);
232  return v;
233 }
234 
235 
236 //====================================================================
237 const Field_F Fopr_Clover_eo::Meo(const Field_F& f, const int ieo)
238 {
240  Field_F v(f.nvol(), f.nex());
241  Meo(v, f, ieo);
242  return v;
243 }
244 
245 
246 //====================================================================
247 const Field_F Fopr_Clover_eo::Meo_gm5(const Field_F& f, const int ieo)
248 {
250  Field_F v(f.nvol(), f.nex());
251  Meo_gm5(v, f, ieo);
252  return v;
253 }
254 
255 
256 //====================================================================
257 const Field_F Fopr_Clover_eo::Mdageo(const Field_F& f, const int ieo)
258 {
260  Field_F v(f.nvol(), f.nex());
261  Mdageo(v, f, ieo);
262  return v;
263 }
264 
265 
266 //====================================================================
267 void Fopr_Clover_eo::D(Field& v, const Field& f)
268 {
269  Meo(m_vF2, f, 1);
270  Meo(v, m_vF2, 0);
271  aypx(-1.0, v, f);
272 #pragma omp barrier
273 }
274 
275 
276 //====================================================================
277 void Fopr_Clover_eo::Ddag(Field& v, const Field& f)
278 {
279  Mdageo(m_vF2, f, 1);
280  Mdageo(m_vF3, m_vF2, 0);
281  copy(v, f);
282  axpy(v, -1.0, m_vF3);
283 #pragma omp barrier
284 }
285 
286 
287 //====================================================================
289 {
290  D(m_w1, f);
291  Ddag(v, m_w1);
292 }
293 
294 
295 //====================================================================
297 {
298  Ddag(m_w1, f);
299  D(v, m_w1);
300 }
301 
302 
303 //====================================================================
304 void Fopr_Clover_eo::H(Field& v, const Field& f)
305 {
306  D(m_w1, f);
307  mult_gm5(v, m_w1);
308 }
309 
310 
311 //====================================================================
313 {
314  m_fopr_w->mult_gm5(v, f);
315 }
316 
317 
318 //====================================================================
320 {
321  Meo(m_vF2, f, 1);
322  Meo(m_vF3, m_vF2, 0);
323  axpy(v, -1.0, m_vF3);
324 }
325 
326 
327 //====================================================================
329 {
330  // Counting of floating point operations.
331  // defined only for D, Dag, H, DDdag, DdagD which can be called
332  // from the solver algorithms.
333  // Since the flop_count() of Fopr_Wilson_eo defines flop of
334  // (1 - Meo*Moe), flop of clover term is twice added together with
335  // contribution of addion.
336 
337  int Lvol = CommonParameters::Lvol();
338 
339  double flop_w = m_fopr_w->flop_count();
340  // this is for aypx + Meo * 2 with Wilson_eo.
341 
342  double flop_csw = m_fopr_csw->flop_count();
343  // this is for inversion of (1 - clover term).
344 
345  double flop = flop_w + 2.0 * flop_csw;
346 
347  if ((m_mode == "DdagD") || (m_mode == "DDdag")) flop += 2.0 * flop_csw;
348  // for additional twice mult of clover term.
349 
350  return flop;
351 }
352 
353 
354 //====================================================================
355 void Fopr_Clover_eo::Meo(Field& v, const Field& f, const int ieo)
356 {
357  // ieo=0: even <-- odd
358  // ieo=1: odd <-- even
359 
360  m_fopr_w->Meo(m_vF1, f, ieo);
361  m_fopr_csw->mult_csw_inv(v, m_vF1, ieo);
362 }
363 
364 
365 //====================================================================
366 void Fopr_Clover_eo::Mdageo(Field_F& v, const Field_F& f, const int ieo)
367 {
368  m_fopr_w->mult_gm5(m_vF1, f);
369  m_fopr_w->Meo(v, m_vF1, ieo);
370  m_fopr_w->mult_gm5(m_vF1, v);
371  m_fopr_csw->mult_csw_inv(v, m_vF1, ieo);
372 }
373 
374 
375 //====================================================================
377  const Field_F& f, const int ieo)
378 {
379  m_fopr_w->Meo(v, f, ieo);
380  m_fopr_csw->mult_csw_inv(m_vF1, v, ieo);
381  mult_gm5(v, m_vF1);
382 }
383 
384 
385 //====================================================================
387  const int mu, const int nu)
388 {
389  m_fopr_csw->mult_isigma(w, f, mu, nu);
390 }
391 
392 
393 //====================================================================
395  const Field& b)
396 {
398 
399  Field_F be(m_Nvol2, 1);
400  Field_F tmp(m_Nvol2, 1);
401 
402  m_idx.convertField(tmp, b, 1);
403  m_fopr_csw->mult_csw_inv(be, tmp, 1);
404  copy(bo, be);
405 
406  m_idx.convertField(tmp, b, 0);
407  m_fopr_csw->mult_csw_inv(be, tmp, 0);
408 
409  copy(Be, be);
410  Meo(tmp, bo, 0);
411  axpy(Be, -1.0, tmp);
412 }
413 
414 
415 //====================================================================
417  const Field& xe, const Field& bo)
418 {
420 
421  assert(x.nin() == m_NinF);
422  assert(x.nvol() == m_Nvol);
423  assert(x.nex() == 1);
424 
425  Field_F xo(m_Nvol2, 1);
426 
427  Meo(xo, xe, 1);
428  aypx(-1.0, xo, bo);
429 
430  m_idx.reverseField(x, xe, 0);
431  m_idx.reverseField(x, xo, 1);
432 }
433 
434 
435 //====================================================================
437  const Field& b)
438 {
440 
441  Field_F be(m_Nvol2, 1);
442  Field_F tmp(m_Nvol2, 1);
443 
444  m_idx.convertField(tmp, b, 1);
445  m_fopr_csw->mult_csw_inv(be, tmp, 1);
446  copy(bo, be);
447 
448  m_idx.convertField(tmp, b, 0);
449  m_fopr_csw->mult_csw_inv(be, tmp, 0);
450 
451  copy(Be, be);
452  Mdageo(tmp, bo, 0);
453  axpy(Be, -1.0, tmp);
454 }
455 
456 
457 //====================================================================
459  const Field& xe, const Field& bo)
460 {
462 
463  assert(x.nin() == m_NinF);
464  assert(x.nvol() == m_Nvol);
465  assert(x.nex() == 1);
466 
467  Field_F xo(m_Nvol2, 1);
468 
469  Mdageo(xo, xe, 1);
470  aypx(-1.0, xo, bo);
471 
472  m_idx.reverseField(x, xe, 0);
473  m_idx.reverseField(x, xo, 1);
474 }
475 
476 
477 //====================================================================
478 //============================================================END=====
const Field_F Meo(const Field_F &, const int ieo)
BridgeIO vout
Definition: bridgeIO.cpp:207
void mult_isigma(Field_F &w, const Field_F &f, const int mu, const int nu)
void Register_string(const string &, const string &)
Definition: parameters.cpp:352
void set_parameters(const Parameters &params)
void mult_gm5(Field &v, const Field &f)
double flop_count()
this returns the number of floating point operations.
void general(const char *format,...)
Definition: bridgeIO.cpp:38
double m_cSW
clover coefficient.
Container of Field-type object.
Definition: field.h:37
void init(const std::string repr)
void set_parameters(const Parameters &params)
int nvol() const
Definition: field.h:101
void Mdageo(Field_F &, const Field_F &, const int ieo)
const Field mult_gm5(const Field &f)
Class for parameters.
Definition: parameters.h:40
std::string m_mode
const Field D(const Field &f)
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:409
const Field DDdag(const Field &f)
static int Lvol()
void set_parameters(const Parameters &params)
void convertField(Field &eo, const Field &lex)
Definition: index_eo.cpp:20
int fetch_int_vector(const string &key, std::valarray< int > &val) const
Definition: parameters.cpp:176
const Field MeoMoe(const Field &f)
Field_F m_vF3
working field.
const Field DdagD(const Field &f)
void prePropDag(Field &, Field &, const Field &)
Wilson-type fermion field.
Definition: field_F.h:37
void postPropDag(Field &, const Field &, const Field &)
double flop_count()
this returns the number of floating point number operations.
static const std::string class_name
int nin() const
Definition: field.h:100
const Field H(const Field &f)
const Field Ddag(const Field &f)
void Meo(Field &, const Field &, const int ieo)
SU(N) gauge field.
Definition: field_G.h:36
void reset(int Nvol, int Nex)
Definition: field_F.h:81
Field m_w1
working field.
const Field_F mult_csw_inv(const Field_F &, const int ieo)
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
Bridge::VerboseLevel m_vl
Definition: fopr.h:99
void Meo_gm5(Field_F &, const Field_F &, const int ieo)
void set_config(Field *U)
setting pointer to the gauge configuration.
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=COMPLEX)
Definition: field.h:82
void aypx(const double a, Field &y, const Field &x)
aypx(y, a, x): y := a * y + x
Definition: field.cpp:489
int nex() const
Definition: field.h:102
void assert_single_thread()
function returning Field instance must be called from single thread.
Fopr_Wilson_eo * m_fopr_w
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:193
void crucial(const char *format,...)
Definition: bridgeIO.cpp:26
Even-odd Wilson fermion operator.
double m_kappa
hopping parameter.
std::valarray< int > m_boundary
boundary condition.
static bool Register(const std::string &realm, const creator_callback &cb)
void set_config(Field *U)
setting pointer to the gauge configuration.
void reverseField(Field &lex, const Field &eo)
Definition: index_eo.cpp:110
Fopr_CloverTerm_eo * m_fopr_csw
void Register_double(const string &, const double)
Definition: parameters.cpp:324
void Register_int_vector(const string &, const std::valarray< int > &)
Definition: parameters.cpp:345
Field_G * m_Ueo
int fetch_double(const string &key, double &val) const
Definition: parameters.cpp:124
string get_string(const string &key) const
Definition: parameters.cpp:85
void prePropD(Field &, Field &, const Field &)
double flop_count()
retuns number of floating point number operations.
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:191
static void assert_single_thread(const std::string &classname)
assert currently running on single thread.
void set_config(Field *Ueo)
setting pointer to the gauge configuration.
void postPropD(Field &, const Field &, const Field &)