Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
smear_APE.cpp
Go to the documentation of this file.
1 
14 #include "smear_APE.h"
15 
16 #ifdef USE_FACTORY_AUTOREGISTER
17 namespace {
18  bool init = Smear_APE::register_factory();
19 }
20 #endif
21 
22 const std::string Smear_APE::class_name = "Smear_APE";
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 
34  int err = 0;
35  err += params.fetch_double("rho_uniform", rho1);
36 
37  if (err) {
38  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
39  exit(EXIT_FAILURE);
40  }
41 
42  set_parameters(rho1);
43 }
44 
45 
46 //====================================================================
47 void Smear_APE::set_parameters(const double rho1)
48 {
49  //- print input parameters
50  vout.general(m_vl, "%s:\n", class_name.c_str());
51  vout.general(m_vl, " rho = %8.4f\n", rho1);
52 
53  //- range check
54  // NB. rho == 0 is allowed.
55 
56  //- store values
57  // m_rho.resize(m_Ndim * m_Ndim); // already resized in init.
58  for (int mu = 0; mu < m_Ndim; ++mu) {
59  for (int nu = 0; nu < m_Ndim; ++nu) {
60  m_rho[mu + nu * m_Ndim] = rho1;
61  }
62  }
63 }
64 
65 
66 //====================================================================
67 void Smear_APE::set_parameters(const std::vector<double>& rho)
68 {
69  //- print input parameters
70  vout.general(m_vl, "%s:\n", class_name.c_str());
71  for (int mu = 0; mu < m_Ndim; ++mu) {
72  vout.general(m_vl, " rho[%d] = %8.4f\n", mu, rho[mu]);
73  }
74 
75  // range check
76  // NB. rho == 0 is allowed.
77  assert(rho.size() == m_Ndim * m_Ndim);
78 
79  //- store values
80  // m_rho.resize(m_Ndim * m_Ndim); // already resized in init.
81  for (int mu = 0; mu < m_Ndim; ++mu) {
82  for (int nu = 0; nu < m_Ndim; ++nu) {
83  m_rho[mu + nu * m_Ndim] = rho[mu + nu * m_Ndim];
84  }
85  }
86 }
87 
88 
89 //====================================================================
90 void Smear_APE::smear(Field_G& Usmear, const Field_G& U)
91 {
92  const int Nvol = CommonParameters::Nvol();
93 
94  assert(U.nvol() == Nvol);
95  assert(U.nex() == m_Ndim);
96  assert(Usmear.nvol() == Nvol);
97  assert(Usmear.nex() == m_Ndim);
98 
99  Usmear.set(0.0);
100 
101  for (int mu = 0; mu < m_Ndim; ++mu) {
102  Field_G c_tmp;
103  c_tmp.set(0.0);
104 
105  Field_G u_tmp;
106  u_tmp.setpart_ex(0, U, mu);
107 
108  Field_G u_tmp2;
109 
110  for (int nu = 0; nu < m_Ndim; ++nu) {
111  if (nu != mu) {
112  Staple_lex staple;
113 
114  double rho = m_rho[mu + m_Ndim * nu];
115  staple.upper(u_tmp2, U, mu, nu);
116  c_tmp.addpart_ex(0, u_tmp2, 0, rho);
117 
118  staple.lower(u_tmp2, U, mu, nu);
119  c_tmp.addpart_ex(0, u_tmp2, 0, rho);
120  }
121  }
122 
123  double rho0 = m_rho[mu + m_Ndim * mu];
124  m_proj->project(u_tmp2, rho0, c_tmp, u_tmp);
125  Usmear.setpart_ex(mu, u_tmp2, 0);
126  }
127 }
128 
129 
130 //====================================================================
131 //============================================================END=====
BridgeIO vout
Definition: bridgeIO.cpp:503
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
void general(const char *format,...)
Definition: bridgeIO.cpp:197
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
int nvol() const
Definition: field.h:127
Class for parameters.
Definition: parameters.h:46
void lower(Field_G &, const Field_G &, const int mu, const int nu)
constructs lower staple in mu-nu plane.
Definition: staple_lex.cpp:177
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:204
void set_parameters(const Parameters &params)
Setting parameters with Parameters object.
Definition: smear_APE.cpp:25
void smear(Field_G &Usmear, const Field_G &U)
Smearing of a given gauge field.
Definition: smear_APE.cpp:90
Projection * m_proj
projector to group element.
Definition: smear_APE.h:51
virtual void project(Field_G &v, const double alpha, const Field_G &C, const Field_G &U)=0
projection V = P[alpha, C, U]
Staple construction.
Definition: staple_lex.h:39
SU(N) gauge field.
Definition: field_G.h:38
static const std::string class_name
Definition: smear_APE.h:46
int nex() const
Definition: field.h:128
void upper(Field_G &, const Field_G &, const int mu, const int nu)
constructs upper staple in mu-nu plane.
Definition: staple_lex.cpp:151
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
std::valarray< double > m_rho
smearing parameter
Definition: smear_APE.h:50
int m_Ndim
spacetime dimension
Definition: smear_APE.h:49
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
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131