Bridge++  Ver. 2.0.2
afopr_Clover_Chemical-tmpl.h
Go to the documentation of this file.
1 
16 
17 #ifdef USE_FACTORY_AUTOREGISTER
18 namespace {
20 }
21 #endif
22 
23 template<typename AFIELD>
25  = "AFopr_Clover_Chemical<AFIELD>";
26 
27 //====================================================================
28 template<typename AFIELD>
30 {
32 
33  m_vl = CommonParameters::Vlevel();
34  m_is_initial_step = true;
35 
36  vout.general(m_vl, "%s: construction\n", class_name.c_str());
38 
39  int Nc = CommonParameters::Nc();
40  int Nd = CommonParameters::Nd();
41  m_NinF = 2 * Nc * Nd;
42  m_Nvol = CommonParameters::Nvol();
43  m_Ndim = CommonParameters::Ndim();
44 
45  m_boundary.resize(m_Ndim);
46 
47  std::string kernel_type;
48  if (!params.fetch_string("kernel_type", kernel_type)) {
49  m_kernel_type = kernel_type;
50  } else {
51  m_kernel_type = "Clover"; // default
52  vout.general("kernel_type is set to default: %s\n",
53  m_kernel_type.c_str());
54  }
55 
56  std::string repr;
57  if (!params.fetch_string("gamma_matrix_type", repr)) {
58  m_repr = repr;
59  } else {
60  m_repr = "Dirac"; // default
61  }
62  if ((m_repr != "Dirac") && (m_repr != "Chiral")) {
63  vout.crucial("Error in %s: irrelevant mult mode = %s\n",
64  class_name.c_str(), m_repr.c_str());
65  exit(EXIT_FAILURE);
66  }
67 
68  set_parameters(params);
69 
70  m_U = 0;
71 
72  m_fopr_w = AFopr<AFIELD>::New(m_kernel_type, params);
73  m_fopr_w->set_mode("D");
74 
76 
77  m_v1.reset(m_NinF, m_Nvol, 1);
78  m_v2.reset(m_NinF, m_Nvol, 1);
79 
80  m_is_initial_step = false;
81 
82  vout.general(m_vl, "%s: construction finished.\n",
83  class_name.c_str());
84 }
85 
86 
87 //====================================================================
88 template<typename AFIELD>
89 void AFopr_Clover_Chemical<AFIELD>::init(const std::string repr)
90 {
92 
93  m_vl = CommonParameters::Vlevel();
94  m_is_initial_step = true;
95 
96  vout.general(m_vl, "%s: construction (obsolete)\n",
97  class_name.c_str());
99 
100  int Nc = CommonParameters::Nc();
101  int Nd = CommonParameters::Nd();
102  m_NinF = 2 * Nc * Nd;
103  m_Nvol = CommonParameters::Nvol();
104  m_Ndim = CommonParameters::Ndim();
105 
106  m_boundary.resize(m_Ndim);
107 
108  std::string kernel_type;
109  m_kernel_type = "Clover";
110 
111  m_repr = repr;
112  if ((m_repr != "Dirac") && (m_repr != "Chiral")) {
113  vout.crucial("Error in %s: irrelevant mult mode = %s\n",
114  class_name.c_str(), m_repr.c_str());
115  exit(EXIT_FAILURE);
116  }
117 
118  m_U = 0;
119 
120  m_fopr_w = AFopr<AFIELD>::New(m_kernel_type, m_repr);
121  m_fopr_w->set_mode("D");
122 
124 
125  m_v1.reset(m_NinF, m_Nvol, 1);
126  m_v2.reset(m_NinF, m_Nvol, 1);
127 
128  m_is_initial_step = false;
129 
130  vout.general(m_vl, "%s: construction finished.\n",
131  class_name.c_str());
132 }
133 
134 
135 //====================================================================
136 template<typename AFIELD>
138 {
139  delete m_fopr_w;
140 }
141 
142 
143 //====================================================================
144 template<typename AFIELD>
146  const Parameters& params)
147 {
148 #pragma omp barrier
149  int ith = ThreadManager::get_thread_id();
150  std::string vlevel;
151  if (!params.fetch_string("verbose_level", vlevel)) {
152  if (ith == 0) m_vl = vout.set_verbose_level(vlevel);
153  }
154 #pragma omp barrier
155 
156  //- fetch and check input parameters
157  double kappa, cSW, mu;
158  std::vector<int> bc;
159 
160  int err = 0;
161  err += params.fetch_double("hopping_parameter", kappa);
162  err += params.fetch_double("clover_coefficient", cSW);
163  err += params.fetch_double("chemical_potential", mu);
164  err += params.fetch_int_vector("boundary_condition", bc);
165 
166  if (err) {
167  vout.crucial(m_vl, "Error at %s: input parameter not found.\n",
168  class_name.c_str());
169  exit(EXIT_FAILURE);
170  }
171 
172  set_parameters_impl(real_t(kappa), real_t(cSW), real_t(mu), bc);
173 
174  if (!m_is_initial_step) {
176  m_fopr_w->set_parameters(params);
178  }
179 }
180 
181 
182 //====================================================================
183 template<typename AFIELD>
185  const real_t kappa,
186  const real_t cSW,
187  const real_t mu,
188  const std::vector<int> bc)
189 {
190  assert(bc.size() == m_Ndim);
191 
192 #pragma omp barrier
193  int ith = ThreadManager::get_thread_id();
194  if (ith == 0) {
195  m_kappa = kappa;
196  m_cSW = cSW;
197  m_mu = mu;
198  m_boundary = bc;
199  m_exp_mu = exp(mu);
200  }
201 #pragma omp barrier
202 
203  vout.general(m_vl, "%s: input parameters\n", class_name.c_str());
204  vout.general(m_vl, " kernel_type = %s\n", m_kernel_type.c_str());
205  vout.general(m_vl, " gamma matrix type = %s\n", m_repr.c_str());
206  vout.general(m_vl, " kappa = %12.8f\n", m_kappa);
207  vout.general(m_vl, " cSW = %12.8f\n", m_cSW);
208  vout.general(m_vl, " mu = %12.8f\n", m_mu);
209  for (int dir = 0; dir < m_Ndim; ++dir) {
210  vout.general(m_vl, " boundary[%d] = %2d\n", dir, m_boundary[dir]);
211  }
212 }
213 
214 
215 //====================================================================
216 template<typename AFIELD>
218  Parameters& params) const
219 {
220  params.set_double("hopping_parameter", m_kappa);
221  params.set_double("clover_coefficient", m_cSW);
222  params.set_double("chemical_potential", m_mu);
223  params.set_int_vector("boundary_condition", m_boundary);
224 
225  params.set_string("kernel_type", m_kernel_type);
226  params.set_string("gamma_matrix_type", m_repr);
227 
228  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
229 }
230 
231 
232 //====================================================================
233 template<typename AFIELD>
235 {
236 #pragma omp barrier
237 
238  int ith = ThreadManager::get_thread_id();
239  if (ith == 0) m_U = (Field_G *)U;
240 #pragma omp barrier
241 
242  m_fopr_w->set_config(U);
243 }
244 
245 
246 //====================================================================
247 template<typename AFIELD>
248 void AFopr_Clover_Chemical<AFIELD>::set_mode(const std::string mode)
249 {
250 #pragma omp barrier
251 
252  int ith = ThreadManager::get_thread_id();
253  if (ith == 0) m_mode = mode;
254 #pragma omp barrier
255 
256  m_fopr_w->set_mode("D");
257 }
258 
259 
260 //====================================================================
261 template<typename AFIELD>
263 {
264  if (m_mode == "D") {
265  D(v, w);
266  } else if (m_mode == "Ddag") {
267  Ddag(v, w);
268  } else if (m_mode == "DdagD") {
269  DdagD(v, w);
270  } else if (m_mode == "H") {
271  H(v, w);
272  } else {
273  vout.crucial(m_vl, "Error at %s: irrelevant input mode:\n",
274  class_name.c_str(), m_mode.c_str());
275  exit(EXIT_FAILURE);
276  }
277 }
278 
279 
280 //====================================================================
281 template<typename AFIELD>
283 {
284  if (m_mode == "D") {
285  Ddag(v, w);
286  } else if (m_mode == "Ddag") {
287  D(v, w);
288  } else if (m_mode == "DdagD") {
289  DdagD(v, w);
290  } else if (m_mode == "H") {
291  Hdag(v, w);
292  } else {
293  vout.crucial(m_vl, "Error at %s: irrelevant input mode:\n",
294  class_name.c_str(), m_mode.c_str());
295  exit(EXIT_FAILURE);
296  }
297 }
298 
299 
300 //====================================================================
301 template<typename AFIELD>
303 {
304  m_fopr_w->mult(v, w);
305 
306  m_v1.set(0.0);
307 #pragma omp barrier
308 
309  m_fopr_w->mult_up(3, m_v1, w);
310  axpy(v, -m_kappa * (m_exp_mu - 1.0), m_v1);
311 
312  m_v1.set(0.0);
313 #pragma omp barrier
314 
315  m_fopr_w->mult_dn(3, m_v1, w);
316  axpy(v, -m_kappa * (1.0 / m_exp_mu - 1.0), m_v1);
317 
318 #pragma omp barrier
319 }
320 
321 
322 //====================================================================
323 template<typename AFIELD>
325 {
326  m_fopr_w->mult(v, w);
327 
328  m_v1.set(0.0);
329 #pragma omp barrier
330 
331  m_fopr_w->mult_up(3, m_v1, w);
332  axpy(v, -m_kappa * (1.0 / m_exp_mu - 1.0), m_v1);
333 
334  m_v1.set(0.0);
335 #pragma omp barrier
336 
337  m_fopr_w->mult_dn(3, m_v1, w);
338  axpy(v, -m_kappa * (m_exp_mu - 1.0), m_v1);
339 
340 #pragma omp barrier
341 }
342 
343 
344 //====================================================================
345 template<typename AFIELD>
347 {
348  m_fopr_w->mult_gm5(v, w);
349 }
350 
351 
352 //====================================================================
353 template<typename AFIELD>
355  AFIELD& v, const AFIELD& w)
356 {
357  m_v1.set(0.0);
358 #pragma omp barrier
359 
360  m_fopr_w->mult_up(mu, m_v1, w);
361  m_fopr_w->mult_gm5(v, m_v1);
362 }
363 
364 
365 //====================================================================
366 template<typename AFIELD>
368 {
369  D(m_v2, w);
370  mult_gm5(v, m_v2);
371  Dminmu(m_v2, v);
372  mult_gm5(v, m_v2);
373 }
374 
375 
376 //====================================================================
377 template<typename AFIELD>
379 {
380  mult_gm5(v, w);
381  Dminmu(m_v2, v);
382  mult_gm5(v, m_v2);
383 }
384 
385 
386 //====================================================================
387 template<typename AFIELD>
389 {
390  D(m_v2, w);
391  mult_gm5(v, m_v2);
392 }
393 
394 
395 //====================================================================
396 template<typename AFIELD>
398 {
399  Dminmu(m_v2, w);
400  mult_gm5(v, m_v2);
401 }
402 
403 
404 //====================================================================
405 template<typename AFIELD>
407 {
408  int NPE = CommonParameters::NPE();
409 
410  double gflop_w = m_fopr_w->flop_count();
411 
412  double gflop_tm = 2.0 * double(m_NinF) * double(m_Nvol)
413  * double(NPE) * 1.0e-9;
414 
415  if ((m_mode == "DdagD") || (m_mode == "DDdag")) gflop_tm *= 2;
416 
417  double gflop = gflop_w + gflop_tm;
418 
419  return gflop;
420 }
421 
422 
423 //============================================================END=====
AFopr_Clover_Chemical::init
void init(const std::string repr)
Definition: afopr_Clover_Chemical-tmpl.h:89
AFopr_Clover_Chemical::D
void D(AFIELD &, const AFIELD &)
Definition: afopr_Clover_Chemical-tmpl.h:302
AFopr_Clover_Chemical::Dminmu
void Dminmu(AFIELD &, const AFIELD &)
Definition: afopr_Clover_Chemical-tmpl.h:324
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
AFopr
Definition: afopr.h:48
AFopr_Clover_Chemical::flop_count
double flop_count()
this returns the number of floating point operations.
Definition: afopr_Clover_Chemical-tmpl.h:406
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Parameters
Class for parameters.
Definition: parameters.h:46
AFopr_Clover_Chemical::real_t
AFIELD::real_t real_t
Definition: afopr_Clover_Chemical.h:39
AFopr_Clover_Chemical::get_parameters
void get_parameters(Parameters &params) const
gets parameters by a Parameter object: to be implemented in a subclass.
Definition: afopr_Clover_Chemical-tmpl.h:217
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
afopr_Clover_Chemical.h
Bridge::BridgeIO::increase_indent
void increase_indent()
Definition: bridgeIO.h:85
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
real_t
double real_t
Definition: bridgeQXS_Clover_coarse_double.cpp:16
AFopr_Clover_Chemical::DdagD
void DdagD(AFIELD &, const AFIELD &)
Definition: afopr_Clover_Chemical-tmpl.h:367
AFopr_Clover_Chemical::set_parameters_impl
void set_parameters_impl(const real_t kappa, const real_t cSW, const real_t mu, const std::vector< int > bc)
sets parameters given as values: private for composite operator.
Definition: afopr_Clover_Chemical-tmpl.h:184
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
Parameters::fetch_int_vector
int fetch_int_vector(const string &key, vector< int > &value) const
Definition: parameters.cpp:429
AFopr_Clover_Chemical::set_config
void set_config(Field *U)
sets the gauge configuration.
Definition: afopr_Clover_Chemical-tmpl.h:234
AFopr_Clover_Chemical::Ddag
void Ddag(AFIELD &, const AFIELD &)
Definition: afopr_Clover_Chemical-tmpl.h:378
threadManager.h
AFopr_Clover_Chemical::H
void H(AFIELD &, const AFIELD &)
Definition: afopr_Clover_Chemical-tmpl.h:388
AFopr_Clover_Chemical::Hdag
void Hdag(AFIELD &, const AFIELD &)
Definition: afopr_Clover_Chemical-tmpl.h:397
AFopr_Clover_Chemical::tidyup
void tidyup()
Definition: afopr_Clover_Chemical-tmpl.h:137
CommonParameters::NPE
static int NPE()
Definition: commonParameters.h:101
Parameters::set_int_vector
void set_int_vector(const string &key, const vector< int > &value)
Definition: parameters.cpp:45
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
AFopr_Clover_Chemical::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: afopr_Clover_Chemical-tmpl.h:248
AFopr_Clover_Chemical::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: afopr_Clover_Chemical-tmpl.h:145
AFopr_Clover_Chemical::mult_gm5
void mult_gm5(AFIELD &, const AFIELD &)
multiplies gamma_5 matrix.
Definition: afopr_Clover_Chemical-tmpl.h:346
Parameters::fetch_string
int fetch_string(const string &key, string &value) const
Definition: parameters.cpp:378
Parameters::fetch_double
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
AFopr_Clover_Chemical::mult_gm5p
void mult_gm5p(const int mu, AFIELD &v, const AFIELD &w)
Definition: afopr_Clover_Chemical-tmpl.h:354
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
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
AFopr_Clover_Chemical::mult
void mult(AFIELD &v, const AFIELD &w)
multiplies fermion operator to a given field.
Definition: afopr_Clover_Chemical-tmpl.h:262
AFopr_Clover_Chemical::mult_dag
void mult_dag(AFIELD &v, const AFIELD &w)
hermitian conjugate of mult.
Definition: afopr_Clover_Chemical-tmpl.h:282
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
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
Bridge::BridgeIO::get_verbose_level
static std::string get_verbose_level(const VerboseLevel vl)
Definition: bridgeIO.cpp:154
AFopr_Clover_Chemical
Clover fermion operator with chemical potential.
Definition: afopr_Clover_Chemical.h:35