Bridge++  Version 1.4.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fopr_CloverGeneral.cpp
Go to the documentation of this file.
1 
14 #include "fopr_CloverGeneral.h"
15 
16 #ifdef USE_FACTORY
17 namespace {
18  Fopr *create_object()
19  {
20  return new Fopr_CloverGeneral();
21  }
22 
23 
24  Fopr *create_object_with_arg(const std::string& repr)
25  {
26  return new Fopr_CloverGeneral(repr);
27  }
28 
29 
30  bool init1 = Fopr::Factory_noarg::Register("CloverGeneral", create_object);
31  bool init2 = Fopr::Factory_string::Register("CloverGeneral", create_object_with_arg);
32 }
33 #endif
34 
35 
36 
37 const std::string Fopr_CloverGeneral::class_name = "Fopr_CloverGeneral";
38 
39 //====================================================================
40 void Fopr_CloverGeneral::init(std::string repr)
41 {
46  m_NinF = 2 * m_Nc * m_Nd;
47 
48  m_boundary.resize(m_Ndim);
49 
50  m_U = 0;
51 
52  m_repr = repr;
53 
54  m_fopr_w = new Fopr_WilsonGeneral(repr);
56 
57  m_v1.reset(m_NinF, m_Nvol, 1);
58  m_v2.reset(m_NinF, m_Nvol, 1);
59 }
60 
61 
62 //====================================================================
64 {
65  delete m_fopr_w;
66  delete m_fopr_csw;
67 }
68 
69 
70 //====================================================================
72 {
73  const std::string str_vlevel = params.get_string("verbose_level");
74 
75  m_vl = vout.set_verbose_level(str_vlevel);
76 
77  //- fetch and check input parameters
78  double kappa_s, kappa_t;
79  double nu_s, r_s;
80  double cSW_s, cSW_t;
81  std::vector<int> bc;
82 
83  int err = 0;
84  err += params.fetch_double("hopping_parameter_spatial", kappa_s);
85  err += params.fetch_double("hopping_parameter_temporal", kappa_t);
86  err += params.fetch_double("dispersion_parameter_spatial", nu_s);
87  err += params.fetch_double("Wilson_parameter_spatial", r_s);
88  err += params.fetch_double("clover_coefficient_spatial", cSW_s);
89  err += params.fetch_double("clover_coefficient_temporal", cSW_t);
90 
91  err += params.fetch_int_vector("boundary_condition", bc);
92 
93  if (err) {
94  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
95  exit(EXIT_FAILURE);
96  }
97 
98  set_parameters(kappa_s, kappa_t, nu_s, r_s, cSW_s, cSW_t, bc);
99 }
100 
101 
102 //====================================================================
103 void Fopr_CloverGeneral::set_parameters(double kappa_s, double kappa_t,
104  double nu_s, double r_s,
105  double cSW_s, double cSW_t,
106  std::vector<int> bc)
107 {
108  //- print input parameters
109  vout.general(m_vl, "%s:\n", class_name.c_str());
110  vout.general(m_vl, " kappa_s = %12.8f\n", kappa_s);
111  vout.general(m_vl, " kappa_t = %12.8f\n", kappa_t);
112  vout.general(m_vl, " nu_s = %12.8f\n", nu_s);
113  vout.general(m_vl, " r_s = %12.8f\n", r_s);
114  vout.general(m_vl, " cSW_s = %12.8f\n", cSW_s);
115  vout.general(m_vl, " cSW_t = %12.8f\n", cSW_t);
116  for (int mu = 0; mu < m_Ndim; ++mu) {
117  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
118  }
119 
120  //- range check
121  // NB. kappa,cSW == 0 is allowed.
122  assert(bc.size() == m_Ndim);
123 
124  //- store values
125  m_kappa_s = kappa_s;
126  m_kappa_t = kappa_t;
127  m_nu_s = nu_s;
128  m_r_s = r_s;
129  m_cSW_s = cSW_s;
130  m_cSW_t = cSW_t;
131 
132  for (int mu = 0; mu < m_Ndim; ++mu) {
133  m_boundary[mu] = bc[mu];
134  }
135 
136  //- propagate parameters to components
139 }
140 
141 
142 //====================================================================
144 {
145  // Counting of floating point operations.
146  // defined only for D, Dag, H, DDdag, DdagD which can be called
147  // from the solver algorithms.
148  // Since the flop_count() of Fopr_Wilson_eo defines flop of
149  // (1 - Meo*Moe), flop of clover term is twice added together with
150  // contribution of addition.
151 
152  int Lvol = CommonParameters::Lvol();
153 
154  double flop_w = 2 * m_fopr_w->flop_count();
155  double flop_csw = m_fopr_csw->flop_count();
156 
157  flop_csw += static_cast<double>(2 * m_Nc * m_Nd * Lvol);
158 
159  double flop = flop_w + flop_csw;
160 
161  if ((m_mode == "DdagD") || (m_mode == "DDdag")) flop += flop_csw;
162  // for additional twice mult of clover term.
163 
164  return flop;
165 }
166 
167 
168 //====================================================================
170 {
171  assert(f.nex() == 1);
172 
173  m_fopr_w->D(w, f);
175  axpy(w, -1.0, m_v1); // w -= m_v1;
176 
177 #pragma omp barrier
178 }
179 
180 
181 //====================================================================
183 {
184  mult_gm5(w, f);
185  D(m_v2, w);
186  mult_gm5(w, m_v2);
187 }
188 
189 
190 //====================================================================
192 {
193  D(m_v2, f);
194  mult_gm5(w, m_v2);
195  D(m_v2, w);
196  mult_gm5(w, m_v2);
197 }
198 
199 
200 //====================================================================
202 {
203  mult_gm5(m_v2, f);
204  D(w, m_v2);
205  mult_gm5(m_v2, w);
206  D(w, m_v2);
207 }
208 
209 
210 //====================================================================
212 {
213  D(m_v2, f);
214  mult_gm5(w, m_v2);
215 }
216 
217 
218 //====================================================================
220  const int mu, const int nu)
221 {
222  m_fopr_csw->mult_isigma(v, w, mu, nu);
223 }
224 
225 
226 //====================================================================
227 //============================================================END=====
BridgeIO vout
Definition: bridgeIO.cpp:495
Org::Fopr_CloverTerm_General Fopr_CloverTerm_General
std::string m_repr
gamma matrix representation
void general(const char *format,...)
Definition: bridgeIO.cpp:195
double m_r_s
spatial Wilson parameter
void H(Field &, const Field &)
std::vector< int > m_boundary
boundary conditions
std::string m_mode
mode of multiplication
Container of Field-type object.
Definition: field.h:39
void set_parameters(const Parameters &params)
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:211
double m_cSW_s
spatial clover coefficient
void D(Field &, const Field &)
static const std::string class_name
double m_kappa_t
temporal hopping parameter
void Ddag(Field &, const Field &)
double m_kappa_s
spatial hopping parameter
Class for parameters.
Definition: parameters.h:46
static int Lvol()
double m_cSW_t
temporal clover coefficient
Fopr_CloverTerm_General * m_fopr_csw
Clover term operator.
void set_parameters(const Parameters &params)
Wilson-type fermion field.
Definition: field_F.h:37
double flop_count()
this returns the number of floating point operations.
Field m_v2
working field.
Bridge::VerboseLevel m_vl
Definition: fopr.h:128
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
void mult_sigmaF(Field &, const Field &)
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=COMPLEX)
Definition: field.h:84
double flop_count()
this returns the number of floating point operations.
Fopr_WilsonGeneral * m_fopr_w
Wilson fermion kernel.
double m_nu_s
spatial anisotopy parameter
int nex() const
Definition: field.h:117
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:168
Clover general fermion operator.
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
void set_parameters(const Parameters &params)
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
void DDdag(Field &, const Field &)
double flop_count()
this returns the number of floating point operations.
void DdagD(Field &, const Field &)
void D(Field &v, const Field &f)
Base class of fermion operator family.
Definition: fopr.h:47
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
Org::Fopr_WilsonGeneral Fopr_WilsonGeneral
const Field_G * m_U
gauge configuration (pointer)
int m_NinF
internal parameters
void mult_gm5(Field &v, const Field &w)
gamma_5 multiplication. [31 Mar 2017 H.Matsufuru]
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
void init(std::string repr)