Bridge++  Ver. 1.3.x
fopr_Clover.cpp
Go to the documentation of this file.
1 
14 #include "fopr_Clover.h"
15 
16 #ifdef USE_PARAMETERS_FACTORY
17 #include "parameters_factory.h"
18 #endif
19 
20 using std::string;
21 
22 #ifdef USE_FACTORY
23 namespace {
24  Fopr *create_object()
25  {
26  return new Fopr_Clover();
27  }
28 
29 
30  Fopr *create_object_with_arg(const std::string& repr)
31  {
32  return new Fopr_Clover(repr);
33  }
34 
35 
36  bool init1 = Fopr::Factory_noarg::Register("Clover", create_object);
37  bool init2 = Fopr::Factory_string::Register("Clover", create_object_with_arg);
38 }
39 #endif
40 
41 //- parameter entries
42 namespace {
43  void append_entry(Parameters& param)
44  {
45  param.Register_string("gamma_matrix_type", "NULL");
46 
47  param.Register_double("hopping_parameter", 0.0);
48  param.Register_double("clover_coefficient", 0.0);
49  param.Register_int_vector("boundary_condition", std::vector<int>());
50 
51  param.Register_string("verbose_level", "NULL");
52  }
53 
54 
55 #ifdef USE_PARAMETERS_FACTORY
56  bool init_param = ParametersFactory::Register("Fopr.Clover", append_entry);
57 #endif
58 }
59 //- end
60 
61 //- parameters class
63 //- end
64 
65 const std::string Fopr_Clover::class_name = "Fopr_Clover";
66 
67 //====================================================================
68 void Fopr_Clover::init(string repr)
69 {
74  m_NinF = 2 * m_Nc * m_Nd;
75 
76  m_boundary.resize(m_Ndim);
77 
78  m_U = 0;
79 
80  m_repr = repr;
81 
82  m_fopr_w = new Fopr_Wilson(repr);
83  m_fopr_csw = new Fopr_CloverTerm(repr);
84 
85  m_v1.reset(m_NinF, m_Nvol, 1);
86  m_v2.reset(m_NinF, m_Nvol, 1);
87 }
88 
89 
90 //====================================================================
92 {
93  delete m_fopr_w;
94  delete m_fopr_csw;
95 }
96 
97 
98 //====================================================================
100 {
101  const string str_vlevel = params.get_string("verbose_level");
102 
103  m_vl = vout.set_verbose_level(str_vlevel);
104 
105  //- fetch and check input parameters
106  double kappa, cSW;
107  std::vector<int> bc;
108 
109  int err = 0;
110  err += params.fetch_double("hopping_parameter", kappa);
111  err += params.fetch_double("clover_coefficient", cSW);
112  err += params.fetch_int_vector("boundary_condition", bc);
113 
114  if (err) {
115  vout.crucial(m_vl, "%s: fetch error, input parameter not found.\n", class_name.c_str());
116  exit(EXIT_FAILURE);
117  }
118 
119  set_parameters(kappa, cSW, bc);
120 }
121 
122 
123 //====================================================================
124 void Fopr_Clover::set_parameters(double kappa, double cSW, std::vector<int> bc)
125 {
126  //- print input parameters
127  vout.general(m_vl, "Parameters of %s:\n", class_name.c_str());
128  vout.general(m_vl, " kappa = %8.4f\n", kappa);
129  vout.general(m_vl, " cSW = %8.4f\n", cSW);
130  for (int mu = 0; mu < m_Ndim; ++mu) {
131  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
132  }
133 
134  //- range check
135  // NB. kappa,cSW == 0 is allowed.
136  assert(bc.size() == m_Ndim);
137 
138  //- store values
139  m_kappa = kappa;
140  m_cSW = cSW;
141 
142  for (int mu = 0; mu < m_Ndim; ++mu) {
143  m_boundary[mu] = bc[mu];
144  }
145 
146  //- propagate parameters to components
149 }
150 
151 
152 //====================================================================
154 {
155  // Counting of floating point operations.
156  // defined only for D, Dag, H, DDdag, DdagD which can be called
157  // from the solver algorithms.
158  // Since the flop_count() of Fopr_Wilson_eo defines flop of
159  // (1 - Meo*Moe), flop of clover term is twice added together with
160  // contribution of addition.
161 
162  int Lvol = CommonParameters::Lvol();
163 
164  double flop_w = m_fopr_w->flop_count();
165  double flop_csw = m_fopr_csw->flop_count();
166 
167  flop_csw += static_cast<double>(2 * m_Nc * m_Nd * Lvol);
168 
169  double flop = flop_w + flop_csw;
170 
171  if ((m_mode == "DdagD") || (m_mode == "DDdag")) flop += flop_csw;
172  // for additional twice mult of clover term.
173 
174  return flop;
175 }
176 
177 
178 //====================================================================
179 void Fopr_Clover::D(Field& w, const Field& f)
180 {
181  assert(f.nex() == 1);
182 
183  m_fopr_w->D(w, f);
185  axpy(w, -1.0, m_v1); // w -= m_v1;
186 
187 #pragma omp barrier
188 }
189 
190 
191 //====================================================================
192 void Fopr_Clover::Ddag(Field& w, const Field& f)
193 {
194  mult_gm5(w, f);
195  D(m_v2, w);
196  mult_gm5(w, m_v2);
197 }
198 
199 
200 //====================================================================
201 void Fopr_Clover::DdagD(Field& w, const Field& f)
202 {
203  D(m_v2, f);
204  mult_gm5(w, m_v2);
205  D(m_v2, w);
206  mult_gm5(w, m_v2);
207 }
208 
209 
210 //====================================================================
211 void Fopr_Clover::DDdag(Field& w, const Field& f)
212 {
213  mult_gm5(m_v2, f);
214  D(w, m_v2);
215  mult_gm5(m_v2, w);
216  D(w, m_v2);
217 }
218 
219 
220 //====================================================================
221 void Fopr_Clover::H(Field& w, const Field& f)
222 {
223  D(m_v2, f);
224  mult_gm5(w, m_v2);
225 }
226 
227 
228 //====================================================================
230  const int mu, const int nu)
231 {
232  m_fopr_csw->mult_isigma(v, w, mu, nu);
233 }
234 
235 
236 //====================================================================
237 //============================================================END=====
void Register_int_vector(const string &, const std::vector< int > &)
Definition: parameters.cpp:344
void DDdag(Field &, const Field &)
BridgeIO vout
Definition: bridgeIO.cpp:278
void Register_string(const string &, const string &)
Definition: parameters.cpp:351
void mult_sigmaF(Field &, const Field &)
const Field_G * m_U
gauge configuration (pointer)
Definition: fopr_Clover.h:65
void tidyup()
Definition: fopr_Clover.cpp:91
void general(const char *format,...)
Definition: bridgeIO.cpp:65
void D(Field &w, const Field &v)
Container of Field-type object.
Definition: field.h:39
void set_parameters(const Parameters &params)
void DdagD(Field &, const Field &)
Class for parameters.
Definition: parameters.h:38
static int Lvol()
std::vector< int > m_boundary
boundary conditions
Definition: fopr_Clover.h:57
void H(Field &, const Field &)
std::string m_mode
mode of multiplication
Definition: fopr_Clover.h:59
Wilson-type fermion field.
Definition: field_F.h:37
std::string m_repr
gamma matrix representation
Definition: fopr_Clover.h:58
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
double m_cSW
clover coefficient
Definition: fopr_Clover.h:56
double m_kappa
hopping parameter
Definition: fopr_Clover.h:55
Bridge::VerboseLevel m_vl
Definition: fopr.h:113
Fopr_Wilson * m_fopr_w
Wilson fermion kernel.
Definition: fopr_Clover.h:63
static const std::string class_name
Definition: fopr_Clover.h:52
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=COMPLEX)
Definition: field.h:84
void set_parameters(const Parameters &params)
Definition: fopr_Wilson.cpp:65
int nex() const
Definition: field.h:117
void mult_gm5(Field &v, const Field &w)
Definition: fopr_Clover.h:156
void D(Field &, const Field &)
Field m_v1
Definition: fopr_Clover.h:68
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:168
void crucial(const char *format,...)
Definition: bridgeIO.cpp:48
double flop_count()
this returns the number of floating point operations.
Fopr_CloverTerm * m_fopr_csw
Clover term operator.
Definition: fopr_Clover.h:64
static bool Register(const std::string &realm, const creator_callback &cb)
int m_NinF
internal parameters
Definition: fopr_Clover.h:61
void Ddag(Field &, const Field &)
void Register_double(const string &, const double)
Definition: parameters.cpp:323
Field m_v2
working field.
Definition: fopr_Clover.h:68
Base class of fermion operator family.
Definition: fopr.h:49
double flop_count()
this returns the number of floating point operations.
int fetch_double(const string &key, double &val) const
Definition: parameters.cpp:124
double flop_count()
this returns the number of floating point number operations.
string get_string(const string &key) const
Definition: parameters.cpp:87
void init(std::string repr)
Definition: fopr_Clover.cpp:68
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:28
void set_parameters(const Parameters &params)
Definition: fopr_Clover.cpp:99
int fetch_int_vector(const string &key, std::vector< int > &val) const
Definition: parameters.cpp:176