Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 std::string repr)
26 {
31  m_NinF = 2 * m_Nc * m_Nd;
32 
33  m_boundary.resize(m_Ndim);
34 
35  m_U = 0;
36 
37  m_repr = repr;
38 
39  m_fopr_w = new Fopr_Wilson(repr);
40  m_fopr_csw = new Fopr_CloverTerm(repr);
41 
42  m_v1.reset(m_NinF, m_Nvol, 1);
43  m_v2.reset(m_NinF, m_Nvol, 1);
44 }
45 
46 
47 //====================================================================
49 {
50  delete m_fopr_w;
51  delete m_fopr_csw;
52 }
53 
54 
55 //====================================================================
57 {
58  const std::string str_vlevel = params.get_string("verbose_level");
59 
60  m_vl = vout.set_verbose_level(str_vlevel);
61 
62  //- fetch and check input parameters
63  double kappa, cSW;
64  std::vector<int> bc;
65 
66  int err = 0;
67  err += params.fetch_double("hopping_parameter", kappa);
68  err += params.fetch_double("clover_coefficient", cSW);
69  err += params.fetch_int_vector("boundary_condition", bc);
70 
71  if (err) {
72  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
73  exit(EXIT_FAILURE);
74  }
75 
76  set_parameters(kappa, cSW, bc);
77 }
78 
79 
80 //====================================================================
81 void Fopr_Clover::set_parameters(const double kappa, const double cSW, const std::vector<int> bc)
82 {
83  //- print input parameters
84  vout.general(m_vl, "%s:\n", class_name.c_str());
85  vout.general(m_vl, " kappa = %12.8f\n", kappa);
86  vout.general(m_vl, " cSW = %12.8f\n", cSW);
87  for (int mu = 0; mu < m_Ndim; ++mu) {
88  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
89  }
90 
91  //- range check
92  // NB. kappa,cSW == 0 is allowed.
93  assert(bc.size() == m_Ndim);
94 
95  //- store values
96  m_kappa = kappa;
97  m_cSW = cSW;
98 
99  // m_boundary.resize(m_Ndim); // NB. already resized in init.
100  m_boundary = bc;
101 
102  //- propagate parameters to components
105 }
106 
107 
108 //====================================================================
109 void Fopr_Clover::D(Field& w, const Field& f)
110 {
111  assert(f.nex() == 1);
112 
113  m_fopr_w->D(w, f);
115  axpy(w, -1.0, m_v1); // w -= m_v1;
116 
117 #pragma omp barrier
118 }
119 
120 
121 //====================================================================
122 void Fopr_Clover::Ddag(Field& w, const Field& f)
123 {
124  mult_gm5(w, f);
125  D(m_v2, w);
126  mult_gm5(w, m_v2);
127 }
128 
129 
130 //====================================================================
131 void Fopr_Clover::DdagD(Field& w, const Field& f)
132 {
133  D(m_v2, f);
134  mult_gm5(w, m_v2);
135  D(m_v2, w);
136  mult_gm5(w, m_v2);
137 }
138 
139 
140 //====================================================================
141 void Fopr_Clover::DDdag(Field& w, const Field& f)
142 {
143  mult_gm5(m_v2, f);
144  D(w, m_v2);
145  mult_gm5(m_v2, w);
146  D(w, m_v2);
147 }
148 
149 
150 //====================================================================
151 void Fopr_Clover::H(Field& w, const Field& f)
152 {
153  D(m_v2, f);
154  mult_gm5(w, m_v2);
155 }
156 
157 
158 //====================================================================
160  const int mu, const int nu)
161 {
162  m_fopr_csw->mult_isigma(v, w, mu, nu);
163 }
164 
165 
166 //====================================================================
168 {
169  // Counting of floating point operations in giga unit.
170  // defined only for D, Dag, H, DDdag, DdagD which can be called
171  // from the solver algorithms.
172  // Since the flop_count() of Fopr_Wilson_eo defines flop of
173  // (1 - Meo*Moe), flop of clover term is twice added together with
174  // contribution of addition.
175 
176  const int Nvol = CommonParameters::Nvol();
177  const int NPE = CommonParameters::NPE();
178 
179  const double gflop_w = m_fopr_w->flop_count();
180 
181  double gflop_csw = m_fopr_csw->flop_count();
182 
183  gflop_csw += 2 * m_Nc * m_Nd / Nvol / NPE / 1.0e+9;
184 
185  double gflop = gflop_w + gflop_csw;
186 
187  //- additional twice mult of clover term
188  if ((m_mode == "DdagD") || (m_mode == "DDdag")) gflop += gflop_csw;
189 
190  return gflop;
191 }
192 
193 
194 //====================================================================
195 //============================================================END=====
void DDdag(Field &, const Field &)
BridgeIO vout
Definition: bridgeIO.cpp:503
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
const Field_G * m_U
gauge configuration (pointer)
Definition: fopr_Clover.h:58
void tidyup()
Definition: fopr_Clover.cpp:48
void set_parameters(const Parameters &params)
double flop_count()
this returns the number of floating point operations.
void general(const char *format,...)
Definition: bridgeIO.cpp:197
Org::Fopr_CloverTerm Fopr_CloverTerm
Clover term operator.
Container of Field-type object.
Definition: field.h:45
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
void mult_sigmaF(Field &, const Field &)
void DdagD(Field &, const Field &)
Class for parameters.
Definition: parameters.h:46
std::vector< int > m_boundary
boundary conditions
Definition: fopr_Clover.h:50
void H(Field &, const Field &)
std::string m_mode
mode of multiplication
Definition: fopr_Clover.h:52
Wilson-type fermion field.
Definition: field_F.h:37
std::string m_repr
gamma matrix representation
Definition: fopr_Clover.h:51
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
void set_parameters(const Parameters &params)
double m_cSW
clover coefficient
Definition: fopr_Clover.h:49
void D(Field &v, const Field &f)
double m_kappa
hopping parameter
Definition: fopr_Clover.h:48
Bridge::VerboseLevel m_vl
Definition: fopr.h:127
Fopr_Wilson * m_fopr_w
Wilson fermion kernel.
Definition: fopr_Clover.h:56
static const std::string class_name
Definition: fopr_Clover.h:45
int nex() const
Definition: field.h:128
void mult_gm5(Field &v, const Field &w)
gamma_5 multiplication. [31 Mar 2017 H.Matsufuru]
Definition: fopr_Clover.h:148
void D(Field &, const Field &)
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=Element_type::COMPLEX)
Definition: field.h:95
Field m_v1
Definition: fopr_Clover.h:61
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:319
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
Fopr_CloverTerm * m_fopr_csw
Clover term operator.
Definition: fopr_Clover.h:57
Org::Fopr_Wilson Fopr_Wilson
Wilson fermion operator.
Definition: fopr_Wilson.h:60
int m_NinF
internal parameters
Definition: fopr_Clover.h:54
void Ddag(Field &, const Field &)
Field m_v2
working field.
Definition: fopr_Clover.h:61
double flop_count()
this returns the number of floating point operations.
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
double flop_count()
this returns the number of floating point operations.
void init(const std::string repr)
Definition: fopr_Clover.cpp:25
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
void set_parameters(const Parameters &params)
Definition: fopr_Clover.cpp:56