Bridge++  Ver. 2.0.2
fopr_Clover.cpp
Go to the documentation of this file.
1 
14 #include "fopr_Clover.h"
15 
16 #ifdef USE_FACTORY_AUTOREGISTER
17 namespace {
18  bool init = Fopr_Clover::register_factory();
19 }
20 #endif
21 
22 const std::string Fopr_Clover::class_name = "Fopr_Clover";
23 
24 //====================================================================
25 void Fopr_Clover::init(const Parameters& params)
26 {
28 
30  m_is_initial_step = true;
31 
32  vout.general(m_vl, "%s: construction\n", class_name.c_str());
34 
35  setup();
36 
37  std::string repr;
38  if (!params.fetch_string("gamma_matrix_type", repr)) {
39  m_repr = repr;
40  } else {
41  m_repr = "Dirac"; // default
42  vout.general(m_vl, "gamma_matrix_type is not given: defalt = %s\n",
43  m_repr.c_str());
44  }
45  if ((m_repr != "Dirac") && (m_repr != "Chiral")) {
46  vout.crucial("Error in %s: irrelevant mult mode = %s\n",
47  class_name.c_str(), m_repr.c_str());
48  exit(EXIT_FAILURE);
49  }
50 
51  set_parameters(params);
52 
53  m_fopr_w = new Fopr_Wilson(params);
54  m_fopr_csw = new Fopr_CloverTerm(params);
55 
56  m_is_initial_step = false;
57 
59  vout.general(m_vl, "%s: construction finished.\n",
60  class_name.c_str());
61 }
62 
63 
64 //====================================================================
65 void Fopr_Clover::init(const std::string repr)
66 {
68 
70  m_is_initial_step = true;
71 
72  vout.general(m_vl, "%s: construction (obsolete)\n",
73  class_name.c_str());
75 
76  setup();
77 
78  m_repr = repr;
79 
80  m_fopr_w = new Fopr_Wilson(repr);
81  m_fopr_csw = new Fopr_CloverTerm(repr);
82 
83  m_is_initial_step = false;
84 
86  vout.general(m_vl, "%s: construction finished.\n",
87  class_name.c_str());
88 }
89 
90 
91 //====================================================================
93 {
98  m_NinF = 2 * m_Nc * m_Nd;
99 
100  m_boundary.resize(m_Ndim);
101 
102  m_U = 0;
103 
104  m_v1.reset(m_NinF, m_Nvol, 1);
105  m_v2.reset(m_NinF, m_Nvol, 1);
106 }
107 
108 
109 //====================================================================
111 {
112  delete m_fopr_w;
113  delete m_fopr_csw;
114 }
115 
116 
117 //====================================================================
119 {
120 #pragma omp barrier
121  int ith = ThreadManager::get_thread_id();
122 
123  std::string vlevel;
124  if (!params.fetch_string("verbose_level", vlevel)) {
125  if (ith == 0) m_vl = vout.set_verbose_level(vlevel);
126  }
127 #pragma omp barrier
128 
129  //- fetch and check input parameters
130  double kappa, cSW;
131  std::vector<int> bc;
132 
133  int err = 0;
134  err += params.fetch_double("hopping_parameter", kappa);
135  err += params.fetch_double("clover_coefficient", cSW);
136  err += params.fetch_int_vector("boundary_condition", bc);
137 
138  if (err) {
139  vout.crucial(m_vl, "Error at %s: input parameter not found.\n",
140  class_name.c_str());
141  exit(EXIT_FAILURE);
142  }
143 
144  set_parameters(kappa, cSW, bc);
145 }
146 
147 
148 //====================================================================
149 void Fopr_Clover::set_parameters(const double kappa, const double cSW,
150  const std::vector<int> bc)
151 {
152  assert(bc.size() == m_Ndim);
153 
154 #pragma omp barrier
155  int ith = ThreadManager::get_thread_id();
156  if (ith == 0) {
157  m_kappa = kappa;
158  m_cSW = cSW;
159  m_boundary = bc;
160  }
161 #pragma omp barrier
162 
163  //- print input parameters
164  vout.general(m_vl, "%s: input parameters\n", class_name.c_str());
165  vout.general(m_vl, " gamma matrix type = %s\n", m_repr.c_str());
166  vout.general(m_vl, " kappa = %12.8f\n", m_kappa);
167  vout.general(m_vl, " cSW = %12.8f\n", m_cSW);
168  for (int mu = 0; mu < m_Ndim; ++mu) {
169  vout.general(m_vl, " boundary[%d] = %2d\n", mu, m_boundary[mu]);
170  }
171 
172  //- propagate parameters to components
173  if (!m_is_initial_step) {
174  Parameters params;
175  get_parameters(params);
176  m_fopr_w->set_parameters(params);
177  m_fopr_csw->set_parameters(params);
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 
190  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
191 }
192 
193 
194 //====================================================================
196 {
197 #pragma omp barrier
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::set_mode(const std::string mode)
209 {
210 #pragma omp barrier
211  int ith = ThreadManager::get_thread_id();
212  if (ith == 0) m_mode = mode;
213 #pragma omp barrier
214 }
215 
216 
217 //====================================================================
218 void Fopr_Clover::mult(Field& v, const Field& w)
219 {
220  if (m_mode == "D") {
221  D(v, w);
222  } else if (m_mode == "Ddag") {
223  Ddag(v, w);
224  } else if (m_mode == "DdagD") {
225  DdagD(v, w);
226  } else if (m_mode == "DDdag") {
227  DDdag(v, w);
228  } else if (m_mode == "H") {
229  H(v, w);
230  } else {
231  vout.crucial(m_vl, "Error at %s: undefined mode = %s.\n",
232  class_name.c_str(), m_mode.c_str());
233  exit(EXIT_FAILURE);
234  }
235 }
236 
237 
238 //====================================================================
240 {
241  if (m_mode == "D") {
242  Ddag(v, w);
243  } else if (m_mode == "Ddag") {
244  D(v, w);
245  } else if (m_mode == "DdagD") {
246  DdagD(v, w);
247  } else if (m_mode == "DDdag") {
248  DDdag(v, w);
249  } else if (m_mode == "H") {
250  H(v, w);
251  } else {
252  vout.crucial(m_vl, "Error at %s: undefined mode = %s.\n",
253  class_name.c_str(), m_mode.c_str());
254  exit(EXIT_FAILURE);
255  }
256 }
257 
258 
259 //====================================================================
261 {
262  m_fopr_w->mult_gm5(v, w);
263 }
264 
265 
266 //====================================================================
267 void Fopr_Clover::mult_up(const int mu, Field& v, const Field& w)
268 {
269  m_fopr_w->mult_up(mu, v, w);
270 }
271 
272 
273 //====================================================================
274 void Fopr_Clover::mult_dn(const int mu, Field& v, const Field& w)
275 {
276  m_fopr_w->mult_dn(mu, v, w);
277 }
278 
279 
280 //====================================================================
281 void Fopr_Clover::D(Field& v, const Field& w)
282 {
283  assert(w.nex() == 1);
284 
285  m_fopr_w->D(v, w);
287 
288  axpy(v, -1.0, m_v1); // w -= m_v1;
289 #pragma omp barrier
290 }
291 
292 
293 //====================================================================
294 void Fopr_Clover::Ddag(Field& v, const Field& w)
295 {
296  mult_gm5(v, w);
297  D(m_v2, v);
298  mult_gm5(v, m_v2);
299 }
300 
301 
302 //====================================================================
303 void Fopr_Clover::DdagD(Field& v, const Field& w)
304 {
305  D(m_v2, w);
306  mult_gm5(v, m_v2);
307  D(m_v2, v);
308  mult_gm5(v, m_v2);
309 }
310 
311 
312 //====================================================================
313 void Fopr_Clover::DDdag(Field& v, const Field& w)
314 {
315  mult_gm5(m_v2, w);
316  D(v, m_v2);
317  mult_gm5(m_v2, v);
318  D(v, m_v2);
319 }
320 
321 
322 //====================================================================
323 void Fopr_Clover::H(Field& v, const Field& w)
324 {
325  D(m_v2, w);
326  mult_gm5(v, m_v2);
327 }
328 
329 
330 //====================================================================
332  const int mu, const int nu)
333 {
334  m_fopr_csw->mult_isigma(v, w, mu, nu);
335 }
336 
337 
338 //====================================================================
340 {
341  // Counting of floating point operations in giga unit.
342  // defined only for D, Dag, H, DDdag, DdagD which can be called
343  // from the solver algorithms.
344  // Since the flop_count() of Fopr_Wilson_eo defines flop of
345  // (1 - Meo*Moe), flop of clover term is twice added together with
346  // contribution of addition.
347 
348  const int Nvol = CommonParameters::Nvol();
349  const int NPE = CommonParameters::NPE();
350 
351  const double gflop_w = m_fopr_w->flop_count();
352 
353  double gflop_csw = m_fopr_csw->flop_count();
354 
355  gflop_csw += 2 * m_Nc * m_Nd / Nvol / NPE / 1.0e+9;
356 
357  double gflop = gflop_w + gflop_csw;
358 
359  //- additional twice mult of clover term
360  if ((m_mode == "DdagD") || (m_mode == "DDdag")) gflop += gflop_csw;
361 
362  return gflop;
363 }
364 
365 
366 //============================================================END=====
Fopr_Clover::m_NinF
int m_NinF
internal parameters
Definition: fopr_Clover.h:58
Fopr_Clover::m_U
const Field_G * m_U
gauge configuration (pointer)
Definition: fopr_Clover.h:63
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
Fopr_Clover::m_Nvol
int m_Nvol
Definition: fopr_Clover.h:59
Fopr_Clover::H
void H(Field &, const Field &)
Definition: fopr_Clover.cpp:323
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Parameters
Class for parameters.
Definition: parameters.h:46
Fopr_Clover::mult_isigma
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
Definition: fopr_Clover.cpp:331
Fopr_Clover::m_Nc
int m_Nc
Definition: fopr_Clover.h:58
Fopr_Clover::setup
void setup()
Definition: fopr_Clover.cpp:92
Fopr_Clover::DdagD
void DdagD(Field &, const Field &)
Definition: fopr_Clover.cpp:303
fopr_Clover.h
Parameters::set_double
void set_double(const string &key, const double value)
Definition: parameters.cpp:33
Bridge::BridgeIO::decrease_indent
void decrease_indent()
Definition: bridgeIO.h:86
Fopr_Clover::tidyup
void tidyup()
Definition: fopr_Clover.cpp:110
Bridge::BridgeIO::increase_indent
void increase_indent()
Definition: bridgeIO.h:85
Field::nex
int nex() const
Definition: field.h:128
Fopr_Clover::mult_dn
void mult_dn(const int mu, Field &v, const Field &w)
downward nearest neighbor hopping term.
Definition: fopr_Clover.cpp:274
Fopr_Clover::m_boundary
std::vector< int > m_boundary
boundary conditions
Definition: fopr_Clover.h:51
Fopr_CloverTerm
Org::Fopr_CloverTerm Fopr_CloverTerm
Clover term operator.
Definition: fopr_CloverTerm.h:58
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Fopr_Clover::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_Clover.cpp:118
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
Fopr_Clover::m_mode
std::string m_mode
mode of multiplication
Definition: fopr_Clover.h:55
Org::Fopr_Wilson::mult_up
void mult_up(const int mu, Field &v, const Field &w)
upward nearest neighbor hopping term.
Definition: fopr_Wilson_impl.cpp:417
Fopr_Clover::m_v1
Field m_v1
Definition: fopr_Clover.h:65
Org::Fopr_CloverTerm::mult_isigma
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
Definition: fopr_CloverTerm_impl.cpp:296
Org::Fopr_CloverTerm::set_config
void set_config(Field *U)
sets the gauge configuration.
Definition: fopr_CloverTerm_impl.cpp:197
Fopr_Clover::set_config
void set_config(Field *U)
sets the gauge configuration.
Definition: fopr_Clover.cpp:195
Org::Fopr_CloverTerm::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_CloverTerm_impl.cpp:125
Fopr_Clover::get_parameters
void get_parameters(Parameters &params) const
gets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_Clover.cpp:183
Fopr_Clover::m_kappa
double m_kappa
hopping parameter
Definition: fopr_Clover.h:49
Org::Fopr_CloverTerm::flop_count
double flop_count()
this returns the number of floating point operations.
Definition: fopr_CloverTerm_impl.cpp:389
Fopr_Clover::m_repr
std::string m_repr
gamma matrix representation
Definition: fopr_Clover.h:52
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
Fopr_Clover::mult_up
void mult_up(const int mu, Field &v, const Field &w)
upward nearest neighbor hopping term.
Definition: fopr_Clover.cpp:267
Org::Fopr_CloverTerm::mult_sigmaF
void mult_sigmaF(Field &, const Field &)
Definition: fopr_CloverTerm_impl.cpp:310
Parameters::fetch_int_vector
int fetch_int_vector(const string &key, vector< int > &value) const
Definition: parameters.cpp:429
Fopr_Clover::mult_gm5
void mult_gm5(Field &v, const Field &w)
multiplies gamma_5 matrix.
Definition: fopr_Clover.cpp:260
Org::Fopr_Wilson::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_Wilson_impl.cpp:127
Fopr_Clover::class_name
static const std::string class_name
Definition: fopr_Clover.h:46
Fopr_Clover::m_Ndim
int m_Ndim
internal parameters
Definition: fopr_Clover.h:59
CommonParameters::NPE
static int NPE()
Definition: commonParameters.h:101
Fopr_Clover::m_Nd
int m_Nd
Definition: fopr_Clover.h:58
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
Org::Fopr_Wilson::mult_gm5
void mult_gm5(Field &v, const Field &w)
multiplies gamma_5 matrix.
Definition: fopr_Wilson_impl.cpp:370
Fopr_Clover::D
void D(Field &, const Field &)
Definition: fopr_Clover.cpp:281
Fopr_Clover::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.cpp:208
CommonParameters::Nd
static int Nd()
Definition: commonParameters.h:116
CommonParameters::Vlevel
static Bridge::VerboseLevel Vlevel()
Definition: commonParameters.h:122
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
Fopr_Clover::m_v2
Field m_v2
working field.
Definition: fopr_Clover.h:65
Fopr_Clover::m_cSW
double m_cSW
clover coefficient
Definition: fopr_Clover.h:50
Fopr_Clover::flop_count
double flop_count()
this returns the number of floating point operations.
Definition: fopr_Clover.cpp:339
Org::Fopr_Wilson::mult_dn
void mult_dn(const int mu, Field &v, const Field &w)
downward nearest neighbor hopping term.
Definition: fopr_Wilson_impl.cpp:433
Org::Fopr_Wilson::set_config
void set_config(Field *U)
sets the gauge configuration.
Definition: fopr_Wilson_impl.cpp:188
Fopr_Clover::m_fopr_w
Fopr_Wilson * m_fopr_w
Wilson fermion kernel.
Definition: fopr_Clover.h:61
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::D
void D(Field &, const Field &)
Definition: fopr_Wilson_impl.cpp:333
Fopr_Clover::m_vl
Bridge::VerboseLevel m_vl
verbose level
Definition: fopr_Clover.h:53
Fopr_Clover::mult_dag
void mult_dag(Field &v, const Field &f)
hermitian conjugate of mult.
Definition: fopr_Clover.cpp:239
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Fopr_Clover::Ddag
void Ddag(Field &, const Field &)
Definition: fopr_Clover.cpp:294
Fopr_Clover::m_is_initial_step
bool m_is_initial_step
to avoid redundant setup
Definition: fopr_Clover.h:67
Fopr_Clover::init
void init(const std::string repr)
Definition: fopr_Clover.cpp:65
Field
Container of Field-type object.
Definition: field.h:46
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
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Fopr_Clover::mult
void mult(Field &v, const Field &f)
multiplies fermion operator to a given field.
Definition: fopr_Clover.cpp:218
Fopr_Clover::m_fopr_csw
Fopr_CloverTerm * m_fopr_csw
Clover term operator.
Definition: fopr_Clover.h:62
Fopr_Clover::DDdag
void DDdag(Field &, const Field &)
Definition: fopr_Clover.cpp:313
ThreadManager::assert_single_thread
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.
Definition: threadManager.cpp:372
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
Org::Fopr_Wilson::flop_count
double flop_count()
this returns the number of floating point operations.
Definition: fopr_Wilson_impl.cpp:449
Bridge::BridgeIO::get_verbose_level
static std::string get_verbose_level(const VerboseLevel vl)
Definition: bridgeIO.cpp:154
Fopr_Wilson
Org::Fopr_Wilson Fopr_Wilson
Wilson fermion operator.
Definition: fopr_Wilson.h:50