Bridge++  Ver. 2.0.2
fopr_CloverGeneral.cpp
Go to the documentation of this file.
1 
14 #include "fopr_CloverGeneral.h"
15 
16 #ifdef USE_FACTORY_AUTOREGISTER
17 namespace {
18  bool init = Fopr_CloverGeneral::register_factory();
19 }
20 #endif
21 
22 const std::string Fopr_CloverGeneral::class_name = "Fopr_CloverGeneral";
23 
24 //====================================================================
25 void Fopr_CloverGeneral::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_WilsonGeneral(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  std::string vlevel;
59  if (!params.fetch_string("verbose_level", vlevel)) {
60  m_vl = vout.set_verbose_level(vlevel);
61  }
62 
63  //- fetch and check input parameters
64  double kappa_s, kappa_t;
65  double nu_s, r_s;
66  double cSW_s, cSW_t;
67  std::vector<int> bc;
68 
69  int err = 0;
70  err += params.fetch_double("hopping_parameter_spatial", kappa_s);
71  err += params.fetch_double("hopping_parameter_temporal", kappa_t);
72  err += params.fetch_double("dispersion_parameter_spatial", nu_s);
73  err += params.fetch_double("Wilson_parameter_spatial", r_s);
74  err += params.fetch_double("clover_coefficient_spatial", cSW_s);
75  err += params.fetch_double("clover_coefficient_temporal", cSW_t);
76 
77  err += params.fetch_int_vector("boundary_condition", bc);
78 
79  if (err) {
80  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
81  exit(EXIT_FAILURE);
82  }
83 
84  set_parameters(kappa_s, kappa_t, nu_s, r_s, cSW_s, cSW_t, bc);
85 }
86 
87 
88 //====================================================================
90 {
91  params.set_double("hopping_parameter_spatial", m_kappa_s);
92  params.set_double("hopping_parameter_temporal", m_kappa_t);
93  params.set_double("dispersion_parameter_spatial", m_nu_s);
94  params.set_double("Wilson_parameter_spatial", m_r_s);
95  params.set_double("clover_coefficient_spatial", m_cSW_s);
96  params.set_double("clover_coefficient_temporal", m_cSW_t);
97 
98  params.set_int_vector("boundary_condition", m_boundary);
99 
100  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
101 }
102 
103 
104 //====================================================================
105 void Fopr_CloverGeneral::set_parameters(const double kappa_s, const double kappa_t,
106  const double nu_s, const double r_s,
107  const double cSW_s, const double cSW_t,
108  const std::vector<int> bc)
109 {
110  //- print input parameters
111  vout.general(m_vl, "%s:\n", class_name.c_str());
112  vout.general(m_vl, " kappa_s = %12.8f\n", kappa_s);
113  vout.general(m_vl, " kappa_t = %12.8f\n", kappa_t);
114  vout.general(m_vl, " nu_s = %12.8f\n", nu_s);
115  vout.general(m_vl, " r_s = %12.8f\n", r_s);
116  vout.general(m_vl, " cSW_s = %12.8f\n", cSW_s);
117  vout.general(m_vl, " cSW_t = %12.8f\n", cSW_t);
118  for (int mu = 0; mu < m_Ndim; ++mu) {
119  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
120  }
121 
122  //- range check
123  // NB. kappa,cSW == 0 is allowed.
124  assert(bc.size() == m_Ndim);
125 
126  //- store values
127  m_kappa_s = kappa_s;
128  m_kappa_t = kappa_t;
129  m_nu_s = nu_s;
130  m_r_s = r_s;
131  m_cSW_s = cSW_s;
132  m_cSW_t = cSW_t;
133 
134  // m_boundary.resize(m_Ndim); // NB. already resized in init.
135  m_boundary = bc;
136 
137  //- propagate parameters to components
140 }
141 
142 
143 //====================================================================
144 void Fopr_CloverGeneral::set_mode(const std::string mode)
145 {
146 #pragma omp barrier
147 
148  int ith = ThreadManager::get_thread_id();
149  if (ith == 0) m_mode = mode;
150 
151 #pragma omp barrier
152 }
153 
154 
155 //====================================================================
157 {
158  assert(f.nex() == 1);
159 
160  m_fopr_w->D(w, f);
162  axpy(w, -1.0, m_v1); // w -= m_v1;
163 
164 #pragma omp barrier
165 }
166 
167 
168 //====================================================================
170 {
171  mult_gm5(w, f);
172  D(m_v2, w);
173  mult_gm5(w, m_v2);
174 }
175 
176 
177 //====================================================================
179 {
180  D(m_v2, f);
181  mult_gm5(w, m_v2);
182  D(m_v2, w);
183  mult_gm5(w, m_v2);
184 }
185 
186 
187 //====================================================================
189 {
190  mult_gm5(m_v2, f);
191  D(w, m_v2);
192  mult_gm5(m_v2, w);
193  D(w, m_v2);
194 }
195 
196 
197 //====================================================================
199 {
200  D(m_v2, f);
201  mult_gm5(w, m_v2);
202 }
203 
204 
205 //====================================================================
207  const int mu, const int nu)
208 {
209  m_fopr_csw->mult_isigma(v, w, mu, nu);
210 }
211 
212 
213 //====================================================================
215 {
216  // Counting of floating point operations in giga unit.
217  // defined only for D, Dag, H, DDdag, DdagD which can be called
218  // from the solver algorithms.
219  // Since the flop_count() of Fopr_Wilson_eo defines flop of
220  // (1 - Meo*Moe), flop of clover term is twice added together with
221  // contribution of addition.
222 
223  const int Nvol = CommonParameters::Nvol();
224  const int NPE = CommonParameters::NPE();
225 
226  const double gflop_w = 2 * m_fopr_w->flop_count();
227 
228  double gflop_csw = m_fopr_csw->flop_count();
229 
230  gflop_csw += 2 * m_Nc * m_Nd / Nvol / NPE / 1.0e+9;
231 
232  double gflop = gflop_w + gflop_csw;
233 
234  // Additional twice mult of clover term
235  if ((m_mode == "DdagD") || (m_mode == "DDdag")) gflop += gflop_csw;
236 
237  return gflop;
238 }
239 
240 
241 //====================================================================
242 //============================================================END=====
Fopr_CloverGeneral::m_Nc
int m_Nc
Definition: fopr_CloverGeneral.h:55
Fopr_WilsonGeneral
Org::Fopr_WilsonGeneral Fopr_WilsonGeneral
Definition: fopr_WilsonGeneral.h:32
Fopr_CloverGeneral::m_Nvol
int m_Nvol
Definition: fopr_CloverGeneral.h:55
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
Fopr_CloverTerm_General
Org::Fopr_CloverTerm_General Fopr_CloverTerm_General
Definition: fopr_CloverTerm_General.h:32
Org::Fopr_CloverTerm_General::mult_isigma
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
Definition: fopr_CloverTerm_General_impl.cpp:167
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Fopr_CloverGeneral::set_mode
void set_mode(const std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Definition: fopr_CloverGeneral.cpp:144
Fopr_CloverGeneral::m_v2
Field m_v2
working field.
Definition: fopr_CloverGeneral.h:62
Parameters
Class for parameters.
Definition: parameters.h:46
Fopr_CloverGeneral::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_CloverGeneral.cpp:56
Parameters::set_double
void set_double(const string &key, const double value)
Definition: parameters.cpp:33
Fopr_CloverGeneral::m_Nd
int m_Nd
Definition: fopr_CloverGeneral.h:55
Fopr_CloverGeneral::H
void H(Field &, const Field &)
Definition: fopr_CloverGeneral.cpp:198
Field::nex
int nex() const
Definition: field.h:128
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
Fopr_CloverGeneral::m_r_s
double m_r_s
spatial Wilson parameter
Definition: fopr_CloverGeneral.h:48
Fopr_CloverGeneral::m_kappa_t
double m_kappa_t
temporal hopping parameter
Definition: fopr_CloverGeneral.h:46
Fopr_CloverGeneral::m_v1
Field m_v1
Definition: fopr_CloverGeneral.h:62
Fopr_CloverGeneral::m_cSW_t
double m_cSW_t
temporal clover coefficient
Definition: fopr_CloverGeneral.h:50
Fopr_CloverGeneral::Ddag
void Ddag(Field &, const Field &)
Definition: fopr_CloverGeneral.cpp:169
Org::Fopr_WilsonGeneral::D
void D(Field &v, const Field &f)
Definition: fopr_WilsonGeneral_impl.cpp:167
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
Fopr_CloverGeneral::get_parameters
void get_parameters(Parameters &params) const
gets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_CloverGeneral.cpp:89
Fopr_CloverGeneral::tidyup
void tidyup()
Definition: fopr_CloverGeneral.cpp:48
Fopr_CloverGeneral::m_U
const Field_G * m_U
gauge configuration (pointer)
Definition: fopr_CloverGeneral.h:59
Fopr_CloverGeneral::m_NinF
int m_NinF
internal parameters
Definition: fopr_CloverGeneral.h:55
Parameters::fetch_int_vector
int fetch_int_vector(const string &key, vector< int > &value) const
Definition: parameters.cpp:429
Org::Fopr_WilsonGeneral::flop_count
double flop_count()
this returns the number of floating point operations.
Definition: fopr_WilsonGeneral_impl.cpp:336
fopr_CloverGeneral.h
Fopr_CloverGeneral::class_name
static const std::string class_name
Definition: fopr_CloverGeneral.h:40
Org::Fopr_CloverTerm_General::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_CloverTerm_General_impl.cpp:22
Fopr_CloverGeneral::m_fopr_csw
Fopr_CloverTerm_General * m_fopr_csw
Clover term operator.
Definition: fopr_CloverGeneral.h:58
Fopr_CloverGeneral::m_kappa_s
double m_kappa_s
spatial hopping parameter
Definition: fopr_CloverGeneral.h:45
Fopr_CloverGeneral::m_nu_s
double m_nu_s
spatial anisotopy parameter
Definition: fopr_CloverGeneral.h:47
Fopr_CloverGeneral::mult_isigma
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
Definition: fopr_CloverGeneral.cpp:206
Fopr_CloverGeneral::m_cSW_s
double m_cSW_s
spatial clover coefficient
Definition: fopr_CloverGeneral.h:49
Fopr_CloverGeneral::mult_gm5
void mult_gm5(Field &v, const Field &w)
multiplies gamma_5 matrix.
Definition: fopr_CloverGeneral.h:154
Fopr_CloverGeneral::m_Ndim
int m_Ndim
Definition: fopr_CloverGeneral.h:55
Fopr_CloverGeneral::m_repr
std::string m_repr
gamma matrix representation
Definition: fopr_CloverGeneral.h:52
CommonParameters::NPE
static int NPE()
Definition: commonParameters.h:101
Field::reset
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=Element_type::COMPLEX)
Definition: field.h:95
Parameters::set_int_vector
void set_int_vector(const string &key, const vector< int > &value)
Definition: parameters.cpp:45
Fopr_CloverGeneral::m_fopr_w
Fopr_WilsonGeneral * m_fopr_w
Wilson fermion kernel.
Definition: fopr_CloverGeneral.h:57
CommonParameters::Nd
static int Nd()
Definition: commonParameters.h:116
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
Fopr_CloverGeneral::m_boundary
std::vector< int > m_boundary
boundary conditions
Definition: fopr_CloverGeneral.h:51
Fopr_CloverGeneral::init
void init(const std::string repr)
Definition: fopr_CloverGeneral.cpp:25
Org::Fopr_CloverTerm_General::flop_count
double flop_count()
this returns the number of floating point operations.
Definition: fopr_CloverTerm_General_impl.cpp:269
Org::Fopr_WilsonGeneral::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_WilsonGeneral_impl.cpp:93
Fopr_CloverGeneral::DdagD
void DdagD(Field &, const Field &)
Definition: fopr_CloverGeneral.cpp:178
Fopr_CloverGeneral::DDdag
void DDdag(Field &, const Field &)
Definition: fopr_CloverGeneral.cpp:188
Parameters::fetch_string
int fetch_string(const string &key, string &value) const
Definition: parameters.cpp:378
Field_F
Wilson-type fermion field.
Definition: field_F.h:37
Parameters::fetch_double
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Fopr_CloverGeneral::m_mode
std::string m_mode
mode of multiplication
Definition: fopr_CloverGeneral.h:53
Field
Container of Field-type object.
Definition: field.h:46
Fopr_CloverGeneral::flop_count
double flop_count()
this returns the number of floating point operations.
Definition: fopr_CloverGeneral.cpp:214
ThreadManager::get_thread_id
static int get_thread_id()
returns thread id.
Definition: threadManager.cpp:253
Fopr_CloverGeneral::D
void D(Field &, const Field &)
Definition: fopr_CloverGeneral.cpp:156
Org::Fopr_CloverTerm_General::mult_sigmaF
void mult_sigmaF(Field &, const Field &)
Definition: fopr_CloverTerm_General_impl.cpp:176
Fopr_CloverGeneral::m_vl
Bridge::VerboseLevel m_vl
Definition: fopr_CloverGeneral.h:43
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
Bridge::BridgeIO::get_verbose_level
static std::string get_verbose_level(const VerboseLevel vl)
Definition: bridgeIO.cpp:154