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