CHROMA
stout_link_smearing.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Stout link smearing
3  */
4 
5 #include "chromabase.h"
6 
10 
11 namespace Chroma
12 {
13 
14  // Read parameters
15  void read(XMLReader& xml, const std::string& path, StoutLinkSmearingEnv::Params& param)
16  {
18  param = tmp;
19  }
20 
21  //! Parameters for running code
22  void write(XMLWriter& xml, const std::string& path, const StoutLinkSmearingEnv::Params& param)
23  {
24  param.writeXML(xml, path);
25  }
26 
27 
28  //! Hooks to register the class
29  namespace StoutLinkSmearingEnv
30  {
31  namespace
32  {
33  //! Callback function
34  LinkSmearing* createSource(XMLReader& xml_in,
35  const std::string& path)
36  {
37  return new LinkSmear(Params(xml_in, path));
38  }
39 
40  //! Local registration flag
41  bool registered = false;
42 
43  //! Name to be used
44  const std::string name = "STOUT_SMEAR";
45  }
46 
47  //! Return the name
48  std::string getName() {return name;}
49 
50  //! Register all the factories
51  bool registerAll()
52  {
53  bool success = true;
54  if (! registered)
55  {
56  success &= Chroma::TheLinkSmearingFactory::Instance().registerObject(name, createSource);
57  registered = true;
58  }
59  return success;
60  }
61 
62 
63  //! Parameters for running code
64  Params::Params(XMLReader& xml, const std::string& path)
65  {
66  XMLReader paramtop(xml, path);
67 
68  int version = 2;
69  if (paramtop.count("version") > 0)
70  read(paramtop, "version", version);
71 
72  switch (version)
73  {
74  case 2:
75  {
76  int no_smear_dir;
77  read(paramtop, "no_smear_dir", no_smear_dir);
78  smear_dirs.resize(Nd);
79  smear_dirs = true;
80  smear_dirs[no_smear_dir] = false;
81  }
82  break;
83 
84  case 3:
85  read(paramtop, "smear_dirs", smear_dirs);
86  break;
87 
88  default:
89  QDPIO::cerr << StoutLinkSmearingEnv::name << ": Input version " << version
90  << " unsupported." << std::endl;
91  QDP_abort(1);
92  }
93 
94  read(paramtop, "link_smear_num", link_smear_num);
95  read(paramtop, "link_smear_fact", link_smear_fact);
96 
97  // For each (mu,nu) set sm_fact_array(mu,nu)=sm_fact
98  // (Isotropy). Since mu != nu ever, we set those
99  // to zero for safety
100  rho.resize(Nd,Nd);
101 
102  for(int mu=0; mu < Nd; mu++)
103  {
104  for(int nu=0; nu < Nd; nu++)
105  {
106  if( mu != nu )
107  {
108  rho[mu][nu] = link_smear_fact;
109  }
110  else
111  {
112  // Set the rho to 0 if mu==nu
113  rho[mu][nu] = 0;
114  }
115  }
116  }
117 
118  // Zero out any directions that are not smeared
119  for(int mu=0; mu < Nd; mu++)
120  {
121  if( ! smear_dirs[mu] )
122  {
123  for(int nu=0; nu < Nd; nu++)
124  {
125  rho[mu][nu] = 0;
126  rho[nu][mu] = 0;
127  }
128  }
129  }
130  }
131 
132 
133  //! Parameters for running code
134  void Params::writeXML(XMLWriter& xml, const std::string& path) const
135  {
136  push(xml, path);
137 
138  int version = 3;
139  write(xml, "version", version);
140  write(xml, "LinkSmearingType", StoutLinkSmearingEnv::name);
141  write(xml, "link_smear_num", link_smear_num);
142  write(xml, "link_smear_fact", link_smear_fact);
143  write(xml, "smear_dirs", smear_dirs);
144 
145  pop(xml);
146  }
147 
148 
149  //! Smear the links
150  void
151  LinkSmear::operator()(multi1d<LatticeColorMatrix>& u) const
152  {
153  // Now stout smear
154  multi1d<LatticeColorMatrix> u_stout = u;
155  multi1d<LatticeColorMatrix> u_tmp(Nd);
156 
157  if (params.link_smear_num > 0)
158  {
159  QDPIO::cout << "Stout Smear gauge field" << std::endl;
160 
161  for(int i=0; i < params.link_smear_num; ++i)
162  {
163  Stouting::smear_links(u_stout, u_tmp,
165  params.rho);
166 
167  u_stout = u_tmp;
168  }
169  QDPIO::cout << "Gauge field Stout-smeared!" << std::endl;
170  }
171 
172  u = u_stout;
173  }
174  }
175 }
Primary include file for CHROMA library code.
Base class for link smearing.
Definition: link_smearing.h:19
static T & Instance()
Definition: singleton.h:432
void operator()(multi1d< LatticeColorMatrix > &u) const
Smear the links.
int mu
Definition: cool.cc:24
int nu
Definition: cool.cc:25
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
void smear_links(const multi1d< LatticeColorMatrix > &current, multi1d< LatticeColorMatrix > &next, const multi1d< bool > &smear_in_this_dirP, const multi2d< Real > &rho)
Do the smearing from level i to level i+1.
Definition: stout_utils.cc:936
Nd
Definition: meslate.cc:74
static bool registered
Local registration flag.
const std::string name
Name to be used.
GaugeInit * createSource(XMLReader &xml_in, const std::string &path)
Callback function.
std::string getName()
Return the name.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
int i
Definition: pbg5p_w.cc:55
pop(xml_out)
::std::string string
Definition: gtest.h:1979
Stout utilities.
Params for Stout link smearing.
void writeXML(XMLWriter &in, const std::string &path) const
Parameters for running code.