Bridge++  Version 1.5.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 #ifdef USE_FACTORY_AUTOREGISTER
19 namespace {
20  bool init = Fopr_Clover_eo::register_factory();
21 }
22 #endif
23 
24 //====================================================================
25 
26 const std::string Fopr_Clover_eo::class_name = "Fopr_Clover_eo";
27 
28 //====================================================================
29 void Fopr_Clover_eo::init(const std::string repr)
30 {
34  m_NinF = 2 * m_Nc * m_Nd;
36  m_Nvol2 = m_Nvol / 2;
37 
38  m_boundary.resize(m_Ndim);
39 
40  m_Ueo = new Field_G(m_Nvol, m_Ndim);
41 
42  m_fopr_w = new Fopr_Wilson_eo(repr);
43  m_fopr_csw = new Fopr_CloverTerm_eo(repr);
44 
45  // working field (Field)
46  m_w1.reset(m_NinF, m_Nvol2, 1);
47 
48  // working field (Field_F)
49  m_vF1.reset(m_Nvol2, 1);
50  m_vF2.reset(m_Nvol2, 1);
51  m_vF3.reset(m_Nvol2, 1);
52 }
53 
54 
55 //====================================================================
57 {
58  delete m_fopr_w;
59  delete m_fopr_csw;
60 
61  delete m_Ueo;
62 }
63 
64 
65 //====================================================================
67 {
68  const string str_vlevel = params.get_string("verbose_level");
69 
70  m_vl = vout.set_verbose_level(str_vlevel);
71 
72  //- fetch and check input parameters
73  double kappa, cSW;
74  std::vector<int> bc;
75 
76  int err = 0;
77  err += params.fetch_double("hopping_parameter", kappa);
78  err += params.fetch_double("clover_coefficient", cSW);
79  err += params.fetch_int_vector("boundary_condition", bc);
80 
81  if (err) {
82  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
83  exit(EXIT_FAILURE);
84  }
85 
86  set_parameters(kappa, cSW, bc);
87 }
88 
89 
90 //====================================================================
91 void Fopr_Clover_eo::set_parameters(const double kappa, const double cSW,
92  const std::vector<int> bc)
93 {
94  //- print input parameters
95  vout.general(m_vl, "%s:\n", class_name.c_str());
96  vout.general(m_vl, " kappa = %12.8f\n", kappa);
97  vout.general(m_vl, " cSW = %12.8f\n", cSW);
98  for (int mu = 0; mu < m_Ndim; ++mu) {
99  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
100  }
101 
102  //- range check
103  // NB. kappa,cSW == 0 is allowed.
104  assert(bc.size() == m_Ndim);
105 
106  //- store values
107  m_kappa = kappa;
108  m_cSW = cSW;
109 
110  // m_boundary.resize(m_Ndim); // NB. already resized in init.
111  m_boundary = bc;
112 
113  //- propagate parameters to components
116 }
117 
118 
119 //====================================================================
121 {
122  const int Ndim = CommonParameters::Ndim();
123  const int Nvol = CommonParameters::Nvol();
124 
125  m_idx.convertField(*m_Ueo, *U);
126 
127  m_fopr_w->set_config(U);
129 }
130 
131 
132 //====================================================================
133 void Fopr_Clover_eo::D(Field& v, const Field& f)
134 {
135  Meo(m_vF2, f, 1);
136  Meo(v, m_vF2, 0);
137  aypx(-1.0, v, f);
138 
139 #pragma omp barrier
140 }
141 
142 
143 //====================================================================
144 void Fopr_Clover_eo::Ddag(Field& v, const Field& f)
145 {
146  Mdageo(m_vF2, f, 1);
147  Mdageo(m_vF3, m_vF2, 0);
148  copy(v, f);
149  axpy(v, -1.0, m_vF3);
150 
151 #pragma omp barrier
152 }
153 
154 
155 //====================================================================
157 {
158  D(m_w1, f);
159  Ddag(v, m_w1);
160 }
161 
162 
163 //====================================================================
165 {
166  Ddag(m_w1, f);
167  D(v, m_w1);
168 }
169 
170 
171 //====================================================================
172 void Fopr_Clover_eo::H(Field& v, const Field& f)
173 {
174  D(m_w1, f);
175  mult_gm5(v, m_w1);
176 }
177 
178 
179 //====================================================================
181 {
182  m_fopr_w->mult_gm5(v, f);
183 }
184 
185 
186 //====================================================================
188 {
189  Meo(m_vF2, f, 1);
190  Meo(m_vF3, m_vF2, 0);
191  axpy(v, -1.0, m_vF3);
192 
193 #pragma omp barrier
194 }
195 
196 
197 //====================================================================
198 void Fopr_Clover_eo::Meo(Field& v, const Field& f, const int ieo)
199 {
200  // ieo=0: even <-- odd
201  // ieo=1: odd <-- even
202 
203  m_fopr_w->Meo(m_vF1, f, ieo);
204  m_fopr_csw->mult_csw_inv(v, m_vF1, ieo);
205 }
206 
207 
208 //====================================================================
209 void Fopr_Clover_eo::Mdageo(Field_F& v, const Field_F& f, const int ieo)
210 {
211  m_fopr_w->mult_gm5(m_vF1, f);
212  m_fopr_w->Meo(v, m_vF1, ieo);
213  m_fopr_w->mult_gm5(m_vF1, v);
214 
215  m_fopr_csw->mult_csw_inv(v, m_vF1, ieo);
216 }
217 
218 
219 //====================================================================
221  const Field_F& f, const int ieo)
222 {
223  m_fopr_w->Meo(v, f, ieo);
224  m_fopr_csw->mult_csw_inv(m_vF1, v, ieo);
225 
226  mult_gm5(v, m_vF1);
227 }
228 
229 
230 //====================================================================
232  const int mu, const int nu)
233 {
234  m_fopr_csw->mult_isigma(w, f, mu, nu);
235 }
236 
237 
238 //====================================================================
240  const Field& b)
241 {
243 
244  Field_F be(m_Nvol2, 1);
245  Field_F tmp(m_Nvol2, 1);
246 
247  m_idx.convertField(tmp, b, 1);
248  m_fopr_csw->mult_csw_inv(be, tmp, 1);
249  copy(bo, be);
250 
251  m_idx.convertField(tmp, b, 0);
252  m_fopr_csw->mult_csw_inv(be, tmp, 0);
253 
254  copy(Be, be);
255  Meo(tmp, bo, 0);
256  axpy(Be, -1.0, tmp);
257 
258 #pragma omp barrier
259 }
260 
261 
262 //====================================================================
264  const Field& xe, const Field& bo)
265 {
267 
268  assert(x.nin() == m_NinF);
269  assert(x.nvol() == m_Nvol);
270  assert(x.nex() == 1);
271 
272  Field_F xo(m_Nvol2, 1);
273 
274  Meo(xo, xe, 1);
275  aypx(-1.0, xo, bo);
276 
277  m_idx.reverseField(x, xe, 0);
278  m_idx.reverseField(x, xo, 1);
279 
280 #pragma omp barrier
281 }
282 
283 
284 //====================================================================
286  const Field& b)
287 {
289 
290  Field_F be(m_Nvol2, 1);
291  Field_F tmp(m_Nvol2, 1);
292 
293  m_idx.convertField(tmp, b, 1);
294  m_fopr_csw->mult_csw_inv(be, tmp, 1);
295  copy(bo, be);
296 
297  m_idx.convertField(tmp, b, 0);
298  m_fopr_csw->mult_csw_inv(be, tmp, 0);
299 
300  copy(Be, be);
301  Mdageo(tmp, bo, 0);
302  axpy(Be, -1.0, tmp);
303 
304 #pragma omp barrier
305 }
306 
307 
308 //====================================================================
310  const Field& xe, const Field& bo)
311 {
313 
314  assert(x.nin() == m_NinF);
315  assert(x.nvol() == m_Nvol);
316  assert(x.nex() == 1);
317 
318  Field_F xo(m_Nvol2, 1);
319 
320  Mdageo(xo, xe, 1);
321  aypx(-1.0, xo, bo);
322 
323  m_idx.reverseField(x, xe, 0);
324  m_idx.reverseField(x, xo, 1);
325 
326 #pragma omp barrier
327 }
328 
329 
330 //====================================================================
332 {
333  // Counting of floating point operations in giga unit.
334  // defined only for D, Dag, H, DDdag, DdagD which can be called
335  // from the solver algorithms.
336  // Since the flop_count() of Fopr_Wilson_eo defines flop of
337  // (1 - Meo*Moe), flop of clover term is twice added together with
338  // contribution of addition.
339 
340  // this is for aypx + Meo * 2 with Wilson_eo
341  const double gflop_w = m_fopr_w->flop_count();
342 
343  // this is for inversion of (1 - clover term)
344  const double gflop_csw = m_fopr_csw->flop_count();
345 
346  double gflop = gflop_w + 2 * gflop_csw;
347 
348  // Additional twice mult of clover term
349  if ((m_mode == "DdagD") || (m_mode == "DDdag")) gflop += 2 * gflop_csw;
350 
351  return gflop;
352 }
353 
354 
355 //====================================================================
356 //============================================================END=====
BridgeIO vout
Definition: bridgeIO.cpp:503
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:197
double m_cSW
clover coefficient.
Container of Field-type object.
Definition: field.h:45
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
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:127
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:532
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:126
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:80
Field m_w1
working field.
void DDdag(Field &v, const Field &f)
Bridge::VerboseLevel m_vl
Definition: fopr.h:127
void Meo_gm5(Field_F &, const Field_F &, const int ieo)
void aypx(const double a, Field &y, const Field &x)
aypx(y, a, x): y := a * y + x
Definition: field.cpp:612
int nex() const
Definition: field.h:128
Fopr_Wilson_eo * m_fopr_w
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=Element_type::COMPLEX)
Definition: field.h:95
double flop_count()
returns number of floating point operations.
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:319
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:112
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.
string get_string(const string &key) const
Definition: parameters.cpp:221
int fetch_int_vector(const string &key, vector< int > &value) const
Definition: parameters.cpp:429
void prePropD(Field &, Field &, const Field &)
void mult_csw_inv(Field &, const Field &, const int ieo)
multiplies [1 - csw kappa sigma_{mu nu} F_{mu nu} ]^{-1}
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 &)