CHROMA
ape_link_smearing.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief APE link smearing
3  */
4 
5 #include "chromabase.h"
6 
9 #include "meas/smear/ape_smear.h"
10 
11 namespace Chroma
12 {
13  // Read parameters
14  void read(XMLReader& xml, const std::string& path, APELinkSmearingEnv::Params& param)
15  {
17  param = tmp;
18  }
19 
20  //! Parameters for running code
21  void write(XMLWriter& xml, const std::string& path, const APELinkSmearingEnv::Params& param)
22  {
23  param.writeXML(xml, path);
24  }
25 
26 
27 
28  //! Hooks to register the class
29  namespace APELinkSmearingEnv
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 = "APE_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 = 1;
69  if (paramtop.count("version") != 0)
70  read(paramtop, "version", version);
71 
72  BlkMax = 100;
73  BlkAccu = 1.0e-5;
74 
75  switch (version)
76  {
77  case 1:
78  break;
79 
80  case 2:
81  read(paramtop, "BlkMax", BlkMax);
82  read(paramtop, "BlkAccu", BlkAccu);
83  break;
84 
85  default :
86  QDPIO::cerr << "Input parameter version " << version << " unsupported." << std::endl;
87  QDP_abort(1);
88  }
89 
90  read(paramtop, "link_smear_num", link_smear_num);
91  read(paramtop, "link_smear_fact", link_smear_fact);
92  read(paramtop, "no_smear_dir", no_smear_dir);
93  }
94 
95  //! Parameters for running code
96  void Params::writeXML(XMLWriter& xml, const std::string& path) const
97  {
98  push(xml, path);
99 
100  int version = 2;
101  write(xml, "version", version);
102  write(xml, "LinkSmearingType", name);
103  write(xml, "link_smear_num", link_smear_num);
104  write(xml, "link_smear_fact", link_smear_fact);
105  write(xml, "no_smear_dir", no_smear_dir);
106  write(xml, "BlkMax", BlkMax);
107  write(xml, "BlkAccu", BlkAccu);
108 
109  pop(xml);
110  }
111 
112 
113  //! Smear the links
114  void
115  LinkSmear::operator()(multi1d<LatticeColorMatrix>& u) const
116  {
117  // Now ape smear
118  multi1d<LatticeColorMatrix> u_ape = u;
119 
120  if (params.link_smear_num > 0)
121  {
122  QDPIO::cout << "APE Smear gauge field" << std::endl;
123 
124  for(int i=0; i < params.link_smear_num; ++i)
125  {
126  multi1d<LatticeColorMatrix> u_tmp(Nd);
127 
128  for(int mu = 0; mu < Nd; ++mu)
129  if ( mu != params.no_smear_dir )
130  APE_Smear(u_ape, u_tmp[mu], mu, 0,
133  else
134  u_tmp[mu] = u_ape[mu];
135 
136  u_ape = u_tmp;
137  }
138  QDPIO::cout << "Gauge field APE-smeared!" << std::endl;
139  }
140 
141  u = u_ape;
142  }
143 
144  }
145 }
Primary include file for CHROMA library code.
void operator()(multi1d< LatticeColorMatrix > &u) const
Smear the links.
Base class for link smearing.
Definition: link_smearing.h:19
static T & Instance()
Definition: singleton.h:432
int mu
Definition: cool.cc:24
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 APE_Smear(const multi1d< LatticeColorMatrix > &u, LatticeColorMatrix &u_smear, int mu, int bl_level, const Real &sm_fact, const Real &BlkAccu, int BlkMax, int j_decay)
Construct APE smeared links from:
Definition: ape_smear.cc:44
Nd
Definition: meslate.cc:74
std::string getName()
Return the name.
bool registerAll()
Register all the factories.
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.
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
Params for APE link smearing.
void writeXML(XMLWriter &in, const std::string &path) const
Parameters for running code.