Bridge++  Version 1.4.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 
17 using std::string;
18 
19 #ifdef USE_FACTORY
20 namespace {
21  Fopr *create_object()
22  {
23  return new Fopr_Clover();
24  }
25 
26 
27  Fopr *create_object_with_arg(const std::string& repr)
28  {
29  return new Fopr_Clover(repr);
30  }
31 
32 
33  bool init1 = Fopr::Factory_noarg::Register("Clover", create_object);
34  bool init2 = Fopr::Factory_string::Register("Clover", create_object_with_arg);
35 }
36 #endif
37 
38 
39 
40 const std::string Fopr_Clover::class_name = "Fopr_Clover";
41 
42 //====================================================================
43 void Fopr_Clover::init(string repr)
44 {
49  m_NinF = 2 * m_Nc * m_Nd;
50 
51  m_boundary.resize(m_Ndim);
52 
53  m_U = 0;
54 
55  m_repr = repr;
56 
57  m_fopr_w = new Fopr_Wilson(repr);
58  m_fopr_csw = new Fopr_CloverTerm(repr);
59 
60  m_v1.reset(m_NinF, m_Nvol, 1);
61  m_v2.reset(m_NinF, m_Nvol, 1);
62 }
63 
64 
65 //====================================================================
67 {
68  delete m_fopr_w;
69  delete m_fopr_csw;
70 }
71 
72 
73 //====================================================================
75 {
76  const string str_vlevel = params.get_string("verbose_level");
77 
78  m_vl = vout.set_verbose_level(str_vlevel);
79 
80  //- fetch and check input parameters
81  double kappa, cSW;
82  std::vector<int> bc;
83 
84  int err = 0;
85  err += params.fetch_double("hopping_parameter", kappa);
86  err += params.fetch_double("clover_coefficient", cSW);
87  err += params.fetch_int_vector("boundary_condition", bc);
88 
89  if (err) {
90  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
91  exit(EXIT_FAILURE);
92  }
93 
94  set_parameters(kappa, cSW, bc);
95 }
96 
97 
98 //====================================================================
99 void Fopr_Clover::set_parameters(double kappa, double cSW, std::vector<int> bc)
100 {
101  //- print input parameters
102  vout.general(m_vl, "%s:\n", class_name.c_str());
103  vout.general(m_vl, " kappa = %12.8f\n", kappa);
104  vout.general(m_vl, " cSW = %12.8f\n", cSW);
105  for (int mu = 0; mu < m_Ndim; ++mu) {
106  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
107  }
108 
109  //- range check
110  // NB. kappa,cSW == 0 is allowed.
111  assert(bc.size() == m_Ndim);
112 
113  //- store values
114  m_kappa = kappa;
115  m_cSW = cSW;
116 
117  for (int mu = 0; mu < m_Ndim; ++mu) {
118  m_boundary[mu] = bc[mu];
119  }
120 
121  //- propagate parameters to components
124 }
125 
126 
127 //====================================================================
129 {
130  // Counting of floating point operations.
131  // defined only for D, Dag, H, DDdag, DdagD which can be called
132  // from the solver algorithms.
133  // Since the flop_count() of Fopr_Wilson_eo defines flop of
134  // (1 - Meo*Moe), flop of clover term is twice added together with
135  // contribution of addition.
136 
137  int Lvol = CommonParameters::Lvol();
138 
139  double flop_w = m_fopr_w->flop_count();
140  double flop_csw = m_fopr_csw->flop_count();
141 
142  flop_csw += static_cast<double>(2 * m_Nc * m_Nd * Lvol);
143 
144  double flop = flop_w + flop_csw;
145 
146  if ((m_mode == "DdagD") || (m_mode == "DDdag")) flop += flop_csw;
147  // for additional twice mult of clover term.
148 
149  return flop;
150 }
151 
152 
153 //====================================================================
154 void Fopr_Clover::D(Field& w, const Field& f)
155 {
156  assert(f.nex() == 1);
157 
158  m_fopr_w->D(w, f);
160  axpy(w, -1.0, m_v1); // w -= m_v1;
161 
162 #pragma omp barrier
163 }
164 
165 
166 //====================================================================
167 void Fopr_Clover::Ddag(Field& w, const Field& f)
168 {
169  mult_gm5(w, f);
170  D(m_v2, w);
171  mult_gm5(w, m_v2);
172 }
173 
174 
175 //====================================================================
176 void Fopr_Clover::DdagD(Field& w, const Field& f)
177 {
178  D(m_v2, f);
179  mult_gm5(w, m_v2);
180  D(m_v2, w);
181  mult_gm5(w, m_v2);
182 }
183 
184 
185 //====================================================================
186 void Fopr_Clover::DDdag(Field& w, const Field& f)
187 {
188  mult_gm5(m_v2, f);
189  D(w, m_v2);
190  mult_gm5(m_v2, w);
191  D(w, m_v2);
192 }
193 
194 
195 //====================================================================
196 void Fopr_Clover::H(Field& w, const Field& f)
197 {
198  D(m_v2, f);
199  mult_gm5(w, m_v2);
200 }
201 
202 
203 //====================================================================
205  const int mu, const int nu)
206 {
207  m_fopr_csw->mult_isigma(v, w, mu, nu);
208 }
209 
210 
211 //====================================================================
212 //============================================================END=====
void DDdag(Field &, const Field &)
BridgeIO vout
Definition: bridgeIO.cpp:495
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:66
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:195
Org::Fopr_CloverTerm Fopr_CloverTerm
Clover term operator.
Container of Field-type object.
Definition: field.h:39
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:211
void mult_sigmaF(Field &, const Field &)
void DdagD(Field &, const Field &)
Class for parameters.
Definition: parameters.h:46
static int Lvol()
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
Clover fermion operator.
Definition: fopr_Clover.h:42
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:128
Fopr_Wilson * m_fopr_w
Wilson fermion kernel.
Definition: fopr_Clover.h:56
static const std::string class_name
Definition: fopr_Clover.h:45
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=COMPLEX)
Definition: field.h:84
int nex() const
Definition: field.h:117
void mult_gm5(Field &v, const Field &w)
gamma_5 multiplication. [31 Mar 2017 H.Matsufuru]
Definition: fopr_Clover.h:149
void D(Field &, const Field &)
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:168
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:73
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
Base class of fermion operator family.
Definition: fopr.h:47
double flop_count()
this returns the number of floating point operations.
string get_string(const string &key) const
Definition: parameters.cpp:116
int fetch_int_vector(const string &key, vector< int > &value) const
Definition: parameters.cpp:294
double flop_count()
this returns the number of floating point operations.
void init(std::string repr)
Definition: fopr_Clover.cpp:43
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
void set_parameters(const Parameters &params)
Definition: fopr_Clover.cpp:74