Bridge++  Ver. 1.3.x
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 #ifdef USE_FACTORY
23 namespace {
24  Fopr *create_object_with_repr(const std::string& repr)
25  {
26  return new Fopr_Clover_eo(repr);
27  }
28 
29 
30  bool init = Fopr::Factory_string::Register("Clover_eo", create_object_with_repr);
31 }
32 #endif
33 
34 //====================================================================
35 //- parameter entries
36 namespace {
37  void append_entry(Parameters& param)
38  {
39  param.Register_double("hopping_parameter", 0.0);
40  param.Register_double("clover_coefficient", 0.0);
41  param.Register_int_vector("boundary_condition", std::vector<int>());
42 
43  param.Register_string("verbose_level", "NULL");
44  }
45 
46 
47 #ifdef USE_PARAMETERS_FACTORY
48  bool init_param = ParametersFactory::Register("Fopr.Clover_eo", append_entry);
49 #endif
50 }
51 //- end
52 
53 //- parameters class
55 //- end
56 
57 const std::string Fopr_Clover_eo::class_name = "Fopr_Clover_eo";
58 
59 //====================================================================
60 void Fopr_Clover_eo::init(const std::string repr)
61 {
65  m_NinF = 2 * m_Nc * m_Nd;
67  m_Nvol2 = m_Nvol / 2;
68 
69  m_boundary.resize(m_Ndim);
70 
71  m_Ueo = new Field_G(m_Nvol, m_Ndim);
72 
73  m_fopr_w = new Fopr_Wilson_eo(repr);
74  m_fopr_csw = new Fopr_CloverTerm_eo(repr);
75 
76  // working field (Field)
77  m_w1.reset(m_NinF, m_Nvol2, 1);
78 
79  // working field (Field_F)
80  m_vF1.reset(m_Nvol2, 1);
81  m_vF2.reset(m_Nvol2, 1);
82  m_vF3.reset(m_Nvol2, 1);
83 }
84 
85 
86 //====================================================================
88 {
89  delete m_fopr_w;
90  delete m_fopr_csw;
91 
92  delete m_Ueo;
93 }
94 
95 
96 //====================================================================
98 {
99  const string str_vlevel = params.get_string("verbose_level");
100 
101  m_vl = vout.set_verbose_level(str_vlevel);
102 
103  //- fetch and check input parameters
104  double kappa, cSW;
105  std::vector<int> bc;
106 
107  int err = 0;
108  err += params.fetch_double("hopping_parameter", kappa);
109  err += params.fetch_double("clover_coefficient", cSW);
110  err += params.fetch_int_vector("boundary_condition", bc);
111 
112  if (err) {
113  vout.crucial(m_vl, "%s: fetch error, input parameter not found.\n", class_name.c_str());
114  exit(EXIT_FAILURE);
115  }
116 
117  set_parameters(kappa, cSW, bc);
118 }
119 
120 
121 //====================================================================
122 void Fopr_Clover_eo::set_parameters(const double kappa, const double cSW,
123  const std::vector<int> bc)
124 {
125  //- print input parameters
126  vout.general(m_vl, "Parameters of %s:\n", class_name.c_str());
127  vout.general(m_vl, " kappa = %8.4f\n", kappa);
128  vout.general(m_vl, " cSW = %8.4f\n", cSW);
129  for (int mu = 0; mu < m_Ndim; ++mu) {
130  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
131  }
132 
133  //- range check
134  // NB. kappa,cSW == 0 is allowed.
135  assert(bc.size() == m_Ndim);
136 
137  //- store values
138  m_kappa = kappa;
139  m_cSW = cSW;
140 
141  assert(bc.size() == m_Ndim);
142  for (int mu = 0; mu < m_Ndim; ++mu) {
143  m_boundary[mu] = bc[mu];
144  }
145 
146  //- propagate parameters to components
149 }
150 
151 
152 //====================================================================
154 {
155  int Ndim = CommonParameters::Ndim();
156  int Nvol = CommonParameters::Nvol();
157 
158  m_idx.convertField(*m_Ueo, *U);
159 
160  m_fopr_w->set_config(U);
162 }
163 
164 
165 //====================================================================
166 void Fopr_Clover_eo::D(Field& v, const Field& f)
167 {
168  Meo(m_vF2, f, 1);
169  Meo(v, m_vF2, 0);
170  aypx(-1.0, v, f);
171 
172 #pragma omp barrier
173 }
174 
175 
176 //====================================================================
177 void Fopr_Clover_eo::Ddag(Field& v, const Field& f)
178 {
179  Mdageo(m_vF2, f, 1);
180  Mdageo(m_vF3, m_vF2, 0);
181  copy(v, f);
182  axpy(v, -1.0, m_vF3);
183 
184 #pragma omp barrier
185 }
186 
187 
188 //====================================================================
190 {
191  D(m_w1, f);
192  Ddag(v, m_w1);
193 }
194 
195 
196 //====================================================================
198 {
199  Ddag(m_w1, f);
200  D(v, m_w1);
201 }
202 
203 
204 //====================================================================
205 void Fopr_Clover_eo::H(Field& v, const Field& f)
206 {
207  D(m_w1, f);
208  mult_gm5(v, m_w1);
209 }
210 
211 
212 //====================================================================
214 {
215  m_fopr_w->mult_gm5(v, f);
216 }
217 
218 
219 //====================================================================
221 {
222  Meo(m_vF2, f, 1);
223  Meo(m_vF3, m_vF2, 0);
224  axpy(v, -1.0, m_vF3);
225 
226 #pragma omp barrier
227 }
228 
229 
230 //====================================================================
232 {
233  // Counting of floating point operations.
234  // defined only for D, Dag, H, DDdag, DdagD which can be called
235  // from the solver algorithms.
236  // Since the flop_count() of Fopr_Wilson_eo defines flop of
237  // (1 - Meo*Moe), flop of clover term is twice added together with
238  // contribution of addition.
239 
240  int Lvol = CommonParameters::Lvol();
241 
242  double flop_w = m_fopr_w->flop_count();
243  // this is for aypx + Meo * 2 with Wilson_eo.
244 
245  double flop_csw = m_fopr_csw->flop_count();
246  // this is for inversion of (1 - clover term).
247 
248  double flop = flop_w + 2.0 * flop_csw;
249 
250  if ((m_mode == "DdagD") || (m_mode == "DDdag")) flop += 2.0 * flop_csw;
251  // for additional twice mult of clover term.
252 
253  return flop;
254 }
255 
256 
257 //====================================================================
258 void Fopr_Clover_eo::Meo(Field& v, const Field& f, const int ieo)
259 {
260  // ieo=0: even <-- odd
261  // ieo=1: odd <-- even
262 
263  m_fopr_w->Meo(m_vF1, f, ieo);
264  m_fopr_csw->mult_csw_inv(v, m_vF1, ieo);
265 }
266 
267 
268 //====================================================================
269 void Fopr_Clover_eo::Mdageo(Field_F& v, const Field_F& f, const int ieo)
270 {
271  m_fopr_w->mult_gm5(m_vF1, f);
272  m_fopr_w->Meo(v, m_vF1, ieo);
273  m_fopr_w->mult_gm5(m_vF1, v);
274 
275  m_fopr_csw->mult_csw_inv(v, m_vF1, ieo);
276 }
277 
278 
279 //====================================================================
281  const Field_F& f, const int ieo)
282 {
283  m_fopr_w->Meo(v, f, ieo);
284  m_fopr_csw->mult_csw_inv(m_vF1, v, ieo);
285 
286  mult_gm5(v, m_vF1);
287 }
288 
289 
290 //====================================================================
292  const int mu, const int nu)
293 {
294  m_fopr_csw->mult_isigma(w, f, mu, nu);
295 }
296 
297 
298 //====================================================================
300  const Field& b)
301 {
303 
304  Field_F be(m_Nvol2, 1);
305  Field_F tmp(m_Nvol2, 1);
306 
307  m_idx.convertField(tmp, b, 1);
308  m_fopr_csw->mult_csw_inv(be, tmp, 1);
309  copy(bo, be);
310 
311  m_idx.convertField(tmp, b, 0);
312  m_fopr_csw->mult_csw_inv(be, tmp, 0);
313 
314  copy(Be, be);
315  Meo(tmp, bo, 0);
316  axpy(Be, -1.0, tmp);
317 
318 #pragma omp barrier
319 }
320 
321 
322 //====================================================================
324  const Field& xe, const Field& bo)
325 {
327 
328  assert(x.nin() == m_NinF);
329  assert(x.nvol() == m_Nvol);
330  assert(x.nex() == 1);
331 
332  Field_F xo(m_Nvol2, 1);
333 
334  Meo(xo, xe, 1);
335  aypx(-1.0, xo, bo);
336 
337  m_idx.reverseField(x, xe, 0);
338  m_idx.reverseField(x, xo, 1);
339 
340 #pragma omp barrier
341 }
342 
343 
344 //====================================================================
346  const Field& b)
347 {
349 
350  Field_F be(m_Nvol2, 1);
351  Field_F tmp(m_Nvol2, 1);
352 
353  m_idx.convertField(tmp, b, 1);
354  m_fopr_csw->mult_csw_inv(be, tmp, 1);
355  copy(bo, be);
356 
357  m_idx.convertField(tmp, b, 0);
358  m_fopr_csw->mult_csw_inv(be, tmp, 0);
359 
360  copy(Be, be);
361  Mdageo(tmp, bo, 0);
362  axpy(Be, -1.0, tmp);
363 
364 #pragma omp barrier
365 }
366 
367 
368 //====================================================================
370  const Field& xe, const Field& bo)
371 {
373 
374  assert(x.nin() == m_NinF);
375  assert(x.nvol() == m_Nvol);
376  assert(x.nex() == 1);
377 
378  Field_F xo(m_Nvol2, 1);
379 
380  Mdageo(xo, xe, 1);
381  aypx(-1.0, xo, bo);
382 
383  m_idx.reverseField(x, xe, 0);
384  m_idx.reverseField(x, xo, 1);
385 
386 #pragma omp barrier
387 }
388 
389 
390 //====================================================================
391 //============================================================END=====
void Register_int_vector(const string &, const std::vector< int > &)
Definition: parameters.cpp:344
BridgeIO vout
Definition: bridgeIO.cpp:278
void mult_isigma(Field_F &w, const Field_F &f, const int mu, const int nu)
void MeoMoe(Field &v, const Field &f)
void Register_string(const string &, const string &)
Definition: parameters.cpp:351
void set_parameters(const Parameters &params)
void mult_gm5(Field &v, const Field &f)
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:65
double m_cSW
clover coefficient.
Container of Field-type object.
Definition: field.h:39
std::vector< int > m_boundary
boundary condition.
void init(const std::string repr)
void set_parameters(const Parameters &params)
int nvol() const
Definition: field.h:116
void Mdageo(Field_F &, const Field_F &, const int ieo)
Class for parameters.
Definition: parameters.h:38
std::string m_mode
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:381
static int Lvol()
void set_parameters(const Parameters &params)
void convertField(Field &eo, const Field &lex)
Definition: index_eo.cpp:20
void mult_csw_inv(Field &, const Field &, const int ieo)
void H(Field &v, const Field &f)
Field_F m_vF3
working field.
void prePropDag(Field &, Field &, const Field &)
Wilson-type fermion field.
Definition: field_F.h:37
void DdagD(Field &v, const Field &f)
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:115
void Meo(Field &, const Field &, const int ieo)
SU(N) gauge field.
Definition: field_G.h:38
void reset(int Nvol, int Nex)
Definition: field_F.h:81
Field m_w1
working field.
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
void DDdag(Field &v, const Field &f)
Bridge::VerboseLevel m_vl
Definition: fopr.h:113
void Meo_gm5(Field_F &, const Field_F &, const int ieo)
void set_config(Field *U)
setting pointer to the gauge configuration.
Even-odd Clover fermion operator.
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=COMPLEX)
Definition: field.h:84
void aypx(const double a, Field &y, const Field &x)
aypx(y, a, x): y := a * y + x
Definition: field.cpp:461
int nex() const
Definition: field.h:117
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:168
void crucial(const char *format,...)
Definition: bridgeIO.cpp:48
Even-odd Wilson fermion operator.
double m_kappa
hopping parameter.
static bool Register(const std::string &realm, const creator_callback &cb)
void set_config(Field *U)
setting pointer to the gauge configuration.
void Meo(Field &, const Field &, const int ieo)
even-odd operatior: ieo=0: even <– odd, ieo=1: odd <– even
void D(Field &v, const Field &f)
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:323
void Ddag(Field &v, const Field &f)
Field_G * m_Ueo
Base class of fermion operator family.
Definition: fopr.h:49
int fetch_double(const string &key, double &val) const
Definition: parameters.cpp:124
string get_string(const string &key) const
Definition: parameters.cpp:87
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:28
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.
int fetch_int_vector(const string &key, std::vector< int > &val) const
Definition: parameters.cpp:176
void postPropD(Field &, const Field &, const Field &)