Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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  const string str_vlevel = params.get_string("verbose_level");
28 
29  m_vl = vout.set_verbose_level(str_vlevel);
30 
31  //- fetch and check input parameters
32  double rho1;
33  std::vector<double> phi, phipr;
34 
35  int err = 0;
36  err += params.fetch_double("rho_uniform", rho1);
37  err += params.fetch_double_vector("phi", phi);
38  err += params.fetch_double_vector("phipr", phipr);
39 
40  if (err) {
41  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
42  exit(EXIT_FAILURE);
43  }
44 
45  set_parameters(rho1, &phi[0], &phipr[0]);
46 }
47 
48 
49 //====================================================================
50 void Smear_APE_SF::set_parameters(const double rho1,
51  double *phi, double *phipr)
52 {
53  //- print input parameters
54  vout.general(m_vl, "%s:\n", class_name.c_str());
55  vout.general(m_vl, " rho = %8.4f\n", rho1);
56 
57  vout.general(m_vl, " phi1 = %12.6f\n", phi[0]);
58  vout.general(m_vl, " phi2 = %12.6f\n", phi[1]);
59  vout.general(m_vl, " phi3 = %12.6f\n", phi[2]);
60  vout.general(m_vl, " phipr1= %12.6f\n", phipr[0]);
61  vout.general(m_vl, " phipr2= %12.6f\n", phipr[1]);
62  vout.general(m_vl, " phipr3= %12.6f\n", phipr[2]);
63 
64  //- range check
65  // NB. rho == 0 is allowed.
66  // NB. phi,phipr == 0 is allowed.
67 
68  //- store values
69  // m_rho.resize(m_Ndim * m_Ndim); // already resized in init.
70  for (int mu = 0; mu < m_Ndim; ++mu) {
71  for (int nu = 0; nu < m_Ndim; ++nu) {
72  m_rho[mu + nu * m_Ndim] = rho1;
73  }
74  }
75 
76  for (int i = 0; i < 3; ++i) {
77  m_phi[i] = phi[i];
78  m_phipr[i] = phipr[i];
79  }
80 }
81 
82 
83 //====================================================================
84 void Smear_APE_SF::set_parameters(const std::vector<double>& rho, double *phi, double *phipr)
85 {
86  //- print input parameters
87  vout.general(m_vl, "%s:\n", class_name.c_str());
88  for (int mu = 0; mu < m_Ndim; ++mu) {
89  vout.general(m_vl, " rho[%d] = %8.4f\n", mu, rho[mu]);
90  }
91 
92  vout.general(m_vl, " phi1 = %12.6f\n", phi[0]);
93  vout.general(m_vl, " phi2 = %12.6f\n", phi[1]);
94  vout.general(m_vl, " phi3 = %12.6f\n", phi[2]);
95  vout.general(m_vl, " phipr1= %12.6f\n", phipr[0]);
96  vout.general(m_vl, " phipr2= %12.6f\n", phipr[1]);
97  vout.general(m_vl, " phipr3= %12.6f\n", phipr[2]);
98 
99  //- range check
100  // NB. rho == 0 is allowed.
101  // NB. phi,phipr == 0 is allowed.
102  assert(rho.size() == m_Ndim * m_Ndim);
103 
104  // store values
105  // m_rho.resize(m_Ndim * m_Ndim); // already resized in init.
106  for (int mu = 0; mu < m_Ndim; ++mu) {
107  for (int nu = 0; nu < m_Ndim; ++nu) {
108  m_rho[mu + nu * m_Ndim] = rho[mu + nu * m_Ndim];
109  }
110  }
111 
112  for (int i = 0; i < 3; ++i) {
113  m_phi[i] = phi[i];
114  m_phipr[i] = phipr[i];
115  }
116 }
117 
118 
119 //====================================================================
120 void Smear_APE_SF::smear(Field_G& Usmear, const Field_G& U)
121 {
122  const int Nvol = CommonParameters::Nvol();
123 
124  assert(U.nvol() == Nvol);
125  assert(U.nex() == m_Ndim);
126  assert(Usmear.nvol() == Nvol);
127  assert(Usmear.nex() == m_Ndim);
128 
129  Usmear.set(0.0);
130 
131  for (int mu = 0; mu < m_Ndim; ++mu) {
132  Field_G c_tmp;
133  c_tmp.set(0.0);
134 
135  Field_G u_tmp;
136  u_tmp.setpart_ex(0, U, mu);
137 
138  Field_G_SF u_tmp2;
139 
140  for (int nu = 0; nu < m_Ndim; ++nu) {
141  if (nu != mu) {
142  Staple_SF staple;
143  staple.set_parameters(m_phi, m_phipr);
144 
145  double rho = m_rho[mu + m_Ndim * nu];
146  staple.upper(u_tmp2, U, mu, nu);
147  c_tmp.addpart_ex(0, u_tmp2, 0, rho);
148 
149  staple.lower(u_tmp2, U, mu, nu);
150  c_tmp.addpart_ex(0, u_tmp2, 0, rho);
151  }
152  }
153 
154  double rho0 = m_rho[mu + m_Ndim * mu];
155  // vout.general(m_vl,"mu=%d\n",mu);
156  m_proj->project(u_tmp2, rho0, c_tmp, u_tmp);
157 
158  Field_G_SF set_wk(m_phi, m_phipr);
159  if (mu != 3) set_wk.set_boundary_wk(u_tmp2);
160  Usmear.setpart_ex(mu, u_tmp2, 0);
161 
162  /* For a debugging
163  for(int site = 0; site < Nvol; ++site){
164  vout.general(m_vl,"site smeared=%d\n",site);
165  for(int ll=0; ll<9; ++ll){
166  vout.general(m_vl,"(%lf %lf)\n",u_tmp2.cmp_r(ll,site,0),u_tmp2.cmp_i(ll,site,0));
167  }
168  }
169  */
170  }
171 }
172 
173 
174 //====================================================================
175 //============================================================END=====
SU(N) gauge field class in which a few functions are added for the SF.
Definition: field_G_SF.h:33
BridgeIO vout
Definition: bridgeIO.cpp:503
int fetch_double_vector(const string &key, vector< double > &value) const
Definition: parameters.cpp:410
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
Projection * m_proj
Definition: smear_APE_SF.h:44
void general(const char *format,...)
Definition: bridgeIO.cpp:197
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
Staple construction.
Definition: staple_SF.h:36
int nvol() const
Definition: field.h:127
Class for parameters.
Definition: parameters.h:46
double m_phi[3]
SF boundary condition at t=0.
Definition: smear_APE_SF.h:47
static const std::string class_name
Definition: smear_APE_SF.h:39
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:204
void set_parameters(const Parameters &params)
Definition: staple_SF.cpp:35
void upper(Field_G_SF &, const Field_G &, const int, const int)
Definition: staple_SF.cpp:886
virtual void project(Field_G &v, const double alpha, const Field_G &C, const Field_G &U)=0
projection V = P[alpha, C, U]
SU(N) gauge field.
Definition: field_G.h:38
void set_boundary_wk(const Mat_SU_N &U)
Set the boundary spatial link at t=0 for SF bc.
Definition: field_G_SF.cpp:27
int nex() const
Definition: field.h:128
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
void set_parameters(const Parameters &params)
double m_phipr[3]
SF boundary condition at t=Nt.
Definition: smear_APE_SF.h:49
std::valarray< double > m_rho
Definition: smear_APE_SF.h:43
void lower(Field_G_SF &, const Field_G &, const int, const int)
Definition: staple_SF.cpp:921
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:197
string get_string(const string &key) const
Definition: parameters.cpp:221
Bridge::VerboseLevel m_vl
Definition: smear.h:37
void smear(Field_G &Usmear, const Field_G &U)
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131