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