Bridge++  Ver. 2.0.2
smear_APE_SF.cpp
Go to the documentation of this file.
1 
14 #include "smear_APE_SF.h"
15 
16 #ifdef USE_FACTORY_AUTOREGISTER
17 namespace {
18  bool init = Smear_APE_SF::register_factory();
19 }
20 #endif
21 
22 const std::string Smear_APE_SF::class_name = "Smear_APE_SF";
23 
24 //====================================================================
26 {
27  std::string vlevel;
28  if (!params.fetch_string("verbose_level", vlevel)) {
29  m_vl = vout.set_verbose_level(vlevel);
30  }
31 
32  //- fetch and check input parameters
33  double rho1;
34  std::vector<double> phi, phipr;
35 
36  int err = 0;
37  err += params.fetch_double("rho_uniform", rho1);
38  err += params.fetch_double_vector("phi", phi);
39  err += params.fetch_double_vector("phipr", phipr);
40 
41  if (err) {
42  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
43  exit(EXIT_FAILURE);
44  }
45 
46  set_parameters(rho1, phi, phipr);
47 }
48 
49 
50 //====================================================================
52 {
53  std::vector<double> rho(m_rho.size());
54  for (size_t i = 0; i < m_rho.size(); ++i) {
55  rho[i] = m_rho[i];
56  }
57  params.set_double_vector("rho", rho);
58  params.set_double_vector("phi", m_phi);
59  params.set_double_vector("phipr", m_phipr);
60 
61  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
62 }
63 
64 
65 //====================================================================
66 void Smear_APE_SF::set_parameters(const double rho1,
67  const std::vector<double>& phi,
68  const std::vector<double>& phipr)
69 {
70  //- print input parameters
71  vout.general(m_vl, "%s:\n", class_name.c_str());
72  vout.general(m_vl, " rho = %8.4f\n", rho1);
73 
74  vout.general(m_vl, " phi1 = %12.6f\n", phi[0]);
75  vout.general(m_vl, " phi2 = %12.6f\n", phi[1]);
76  vout.general(m_vl, " phi3 = %12.6f\n", phi[2]);
77  vout.general(m_vl, " phipr1= %12.6f\n", phipr[0]);
78  vout.general(m_vl, " phipr2= %12.6f\n", phipr[1]);
79  vout.general(m_vl, " phipr3= %12.6f\n", phipr[2]);
80 
81  //- range check
82  // NB. rho == 0 is allowed.
83  // NB. phi,phipr == 0 is allowed.
84 
85  //- store values
86  // m_rho.resize(m_Ndim * m_Ndim); // already resized in init.
87  for (int mu = 0; mu < m_Ndim; ++mu) {
88  for (int nu = 0; nu < m_Ndim; ++nu) {
89  m_rho[mu + nu * m_Ndim] = rho1;
90  }
91  }
92 
93  m_phi.resize(3);
94  m_phipr.resize(3);
95  for (int i = 0; i < 3; ++i) {
96  m_phi[i] = phi[i];
97  m_phipr[i] = phipr[i];
98  }
101 }
102 
103 
104 //====================================================================
105 void Smear_APE_SF::set_parameters(const std::vector<double>& rho,
106  const std::vector<double>& phi,
107  const std::vector<double>& phipr)
108 {
109  //- print input parameters
110  vout.general(m_vl, "%s:\n", class_name.c_str());
111  for (int mu = 0; mu < m_Ndim; ++mu) {
112  vout.general(m_vl, " rho[%d] = %8.4f\n", mu, rho[mu]);
113  }
114 
115  vout.general(m_vl, " phi1 = %12.6f\n", phi[0]);
116  vout.general(m_vl, " phi2 = %12.6f\n", phi[1]);
117  vout.general(m_vl, " phi3 = %12.6f\n", phi[2]);
118  vout.general(m_vl, " phipr1= %12.6f\n", phipr[0]);
119  vout.general(m_vl, " phipr2= %12.6f\n", phipr[1]);
120  vout.general(m_vl, " phipr3= %12.6f\n", phipr[2]);
121 
122  //- range check
123  // NB. rho == 0 is allowed.
124  // NB. phi,phipr == 0 is allowed.
125  assert(rho.size() == m_Ndim * m_Ndim);
126 
127  // store values
128  // m_rho.resize(m_Ndim * m_Ndim); // already resized in init.
129  for (int mu = 0; mu < m_Ndim; ++mu) {
130  for (int nu = 0; nu < m_Ndim; ++nu) {
131  m_rho[mu + nu * m_Ndim] = rho[mu + nu * m_Ndim];
132  }
133  }
134 
135  m_phi.resize(3);
136  m_phipr.resize(3);
137  for (int i = 0; i < 3; ++i) {
138  m_phi[i] = phi[i];
139  m_phipr[i] = phipr[i];
140  }
141 
144 }
145 
146 
147 //====================================================================
148 void Smear_APE_SF::smear(Field_G& Usmear, const Field_G& U)
149 {
150  const int Nvol = CommonParameters::Nvol();
151 
152  assert(U.nvol() == Nvol);
153  assert(U.nex() == m_Ndim);
154  assert(Usmear.nvol() == Nvol);
155  assert(Usmear.nex() == m_Ndim);
156 
157  Staple_SF staple;
158  staple.set_parameters(m_phi, m_phipr);
159 
160  Usmear.set(0.0);
161 
162  for (int mu = 0; mu < m_Ndim; ++mu) {
163  Field_G c_tmp;
164  c_tmp.set(0.0);
165 
166  Field_G u_tmp;
167  copy(u_tmp, 0, U, mu);
168 
169  Field_G u_tmp2;
170 
171  for (int nu = 0; nu < m_Ndim; ++nu) {
172  if (nu != mu) {
173  double rho = m_rho[mu + m_Ndim * nu];
174  staple.upper(u_tmp2, U, mu, nu);
175  axpy(c_tmp, 0, rho, u_tmp2, 0);
176 
177  staple.lower(u_tmp2, U, mu, nu);
178  axpy(c_tmp, 0, rho, u_tmp2, 0);
179  }
180  }
181 
182  double rho0 = m_rho[mu + m_Ndim * mu];
183  m_proj->project(u_tmp2, rho0, c_tmp, u_tmp);
184 
185  if (mu != 3) Field_SF::set_boundary_wk(u_tmp2, m_wk);
186  copy(Usmear, mu, u_tmp2, 0);
187  }
188 }
189 
190 
191 //============================================================END=====
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
Staple_SF::set_parameters
void set_parameters(const Parameters &params)
Definition: staple_SF.cpp:35
Smear_APE_SF::get_parameters
void get_parameters(Parameters &params) const
Definition: smear_APE_SF.cpp:51
Field::set
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
Parameters
Class for parameters.
Definition: parameters.h:46
Field::nex
int nex() const
Definition: field.h:128
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Field_SF::set_boundary_wk
void set_boundary_wk(Field_G &u, const Mat_SU_N &wk)
Definition: field_SF.cpp:32
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
Staple_SF
Staple construction.
Definition: staple_SF.h:36
Parameters::set_double_vector
void set_double_vector(const string &key, const vector< double > &value)
Definition: parameters.cpp:42
Staple_SF::upper
void upper(Field_G &, const Field_G &, const int, const int)
Definition: staple_SF.cpp:877
copy
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:212
Smear_APE_SF::m_phipr
std::vector< double > m_phipr
SF boundary condition at t=Nt.
Definition: smear_APE_SF.h:49
Smear_APE_SF::m_Ndim
int m_Ndim
Definition: smear_APE_SF.h:44
Smear_APE_SF::m_phi
std::vector< double > m_phi
SF boundary condition at t=0.
Definition: smear_APE_SF.h:48
Smear_APE_SF::m_rho
std::valarray< double > m_rho
Definition: smear_APE_SF.h:45
Field::nvol
int nvol() const
Definition: field.h:127
Field_SF::set_boundary_matrix
void set_boundary_matrix(Mat_SU_N &wk, const std::vector< double > &phi)
Definition: field_SF.cpp:216
Smear_APE_SF::m_vl
Bridge::VerboseLevel m_vl
Definition: smear_APE_SF.h:42
Staple_SF::lower
void lower(Field_G &, const Field_G &, const int, const int)
Definition: staple_SF.cpp:912
Smear_APE_SF::m_wkpr
Mat_SU_N m_wkpr
SF boundary condition at t=Nt.
Definition: smear_APE_SF.h:52
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
Smear_APE_SF::m_wk
Mat_SU_N m_wk
SF boundary condition at t=0.
Definition: smear_APE_SF.h:51
Parameters::fetch_string
int fetch_string(const string &key, string &value) const
Definition: parameters.cpp:378
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
Smear_APE_SF::class_name
static const std::string class_name
Definition: smear_APE_SF.h:39
Smear_APE_SF::set_parameters
void set_parameters(const Parameters &params)
Definition: smear_APE_SF.cpp:25
Field_G
SU(N) gauge field.
Definition: field_G.h:38
Parameters::fetch_double_vector
int fetch_double_vector(const string &key, vector< double > &value) const
Definition: parameters.cpp:410
smear_APE_SF.h
Smear_APE_SF::m_proj
Projection * m_proj
Definition: smear_APE_SF.h:46
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Smear_APE_SF::smear
void smear(Field_G &Usmear, const Field_G &U)
Definition: smear_APE_SF.cpp:148
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
Projection::project
virtual void project(Field_G &v, const double alpha, const Field_G &C, const Field_G &U)=0
projection V = P[alpha, C, U]