Bridge++  Ver. 2.0.2
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  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 
35  int err = 0;
36  err += params.fetch_double("rho_uniform", rho1);
37 
38  if (err) {
39  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
40  exit(EXIT_FAILURE);
41  }
42 
43  set_parameters(rho1);
44 }
45 
46 
47 //====================================================================
49 {
50  std::vector<double> rho(m_rho.size());
51  // std::copy(rho.begin(), m_rho.begin(), m_rho.end());
52  for (size_t i = 0; i < m_rho.size(); ++i) {
53  rho[i] = m_rho[i];
54  }
55  params.set_double_vector("rho", rho);
56 
57  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
58 }
59 
60 
61 //====================================================================
62 void Smear_APE::set_parameters(const double rho1)
63 {
64  //- print input parameters
65  vout.general(m_vl, "%s:\n", class_name.c_str());
66  vout.general(m_vl, " rho = %8.4f\n", rho1);
67 
68  //- range check
69  // NB. rho == 0 is allowed.
70 
71  //- store values
72  // m_rho.resize(m_Ndim * m_Ndim); // already resized in init.
73  for (int mu = 0; mu < m_Ndim; ++mu) {
74  for (int nu = 0; nu < m_Ndim; ++nu) {
75  m_rho[mu + nu * m_Ndim] = rho1;
76  }
77  }
78 }
79 
80 
81 //====================================================================
82 void Smear_APE::set_parameters(const std::vector<double>& rho)
83 {
84  //- print input parameters
85  vout.general(m_vl, "%s:\n", class_name.c_str());
86  for (int mu = 0; mu < m_Ndim; ++mu) {
87  vout.general(m_vl, " rho[%d] = %8.4f\n", mu, rho[mu]);
88  }
89 
90  // range check
91  // NB. rho == 0 is allowed.
92  assert(rho.size() == m_Ndim * m_Ndim);
93 
94  //- store values
95  // m_rho.resize(m_Ndim * m_Ndim); // already resized in init.
96  for (int mu = 0; mu < m_Ndim; ++mu) {
97  for (int nu = 0; nu < m_Ndim; ++nu) {
98  m_rho[mu + nu * m_Ndim] = rho[mu + nu * m_Ndim];
99  }
100  }
101 }
102 
103 
104 //====================================================================
105 void Smear_APE::smear(Field_G& Usmear, const Field_G& U)
106 {
107  const int Nvol = CommonParameters::Nvol();
108 
109  assert(U.nvol() == Nvol);
110  assert(U.nex() == m_Ndim);
111  assert(Usmear.nvol() == Nvol);
112  assert(Usmear.nex() == m_Ndim);
113 
114  Usmear.set(0.0);
115 
116  for (int mu = 0; mu < m_Ndim; ++mu) {
117  Field_G c_tmp;
118  c_tmp.set(0.0);
119 
120  Field_G u_tmp;
121  u_tmp.setpart_ex(0, U, mu);
122 
123  Field_G u_tmp2;
124 
125  for (int nu = 0; nu < m_Ndim; ++nu) {
126  if (nu != mu) {
127  Staple_lex staple;
128 
129  double rho = m_rho[mu + m_Ndim * nu];
130  staple.upper(u_tmp2, U, mu, nu);
131  c_tmp.addpart_ex(0, u_tmp2, 0, rho);
132 
133  staple.lower(u_tmp2, U, mu, nu);
134  c_tmp.addpart_ex(0, u_tmp2, 0, rho);
135  }
136  }
137 
138  double rho0 = m_rho[mu + m_Ndim * mu];
139  m_proj->project(u_tmp2, rho0, c_tmp, u_tmp);
140  Usmear.setpart_ex(mu, u_tmp2, 0);
141  }
142 }
143 
144 
145 //====================================================================
146 //============================================================END=====
Field::setpart_ex
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:201
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
Smear_APE::m_vl
Bridge::VerboseLevel m_vl
Definition: smear_APE.h:49
Smear_APE::m_Ndim
int m_Ndim
spacetime dimension
Definition: smear_APE.h: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
Smear_APE::set_parameters
void set_parameters(const Parameters &params)
Setting parameters with Parameters object.
Definition: smear_APE.cpp:25
Smear_APE::smear
void smear(Field_G &Usmear, const Field_G &U)
Smearing of a given gauge field.
Definition: smear_APE.cpp:105
Smear_APE::class_name
static const std::string class_name
Definition: smear_APE.h:46
Field::nex
int nex() const
Definition: field.h:128
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Staple_lex::lower
void lower(Field_G &, const Field_G &, const int mu, const int nu)
constructs lower staple in mu-nu plane.
Definition: staple_lex.cpp:286
Parameters::set_double_vector
void set_double_vector(const string &key, const vector< double > &value)
Definition: parameters.cpp:42
Field::addpart_ex
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:208
Field::nvol
int nvol() const
Definition: field.h:127
Smear_APE::m_rho
std::valarray< double > m_rho
smearing parameter
Definition: smear_APE.h:52
Smear_APE::m_proj
Projection * m_proj
projector to group element.
Definition: smear_APE.h:53
Staple_lex::upper
void upper(Field_G &, const Field_G &, const int mu, const int nu)
constructs upper staple in mu-nu plane.
Definition: staple_lex.cpp:263
Staple_lex
Staple construction.
Definition: staple_lex.h:39
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
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
smear_APE.h
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Field_G
SU(N) gauge field.
Definition: field_G.h:38
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Smear_APE::get_parameters
void get_parameters(Parameters &params) const
Getting parameters by Parameters object.
Definition: smear_APE.cpp:48
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]