CHROMA
wall_sink_smearing.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Wall sink smearing
3  */
4 
5 #include "chromabase.h"
6 #include "handle.h"
7 
10 #include "util/ft/sftmom.h"
11 
12 namespace Chroma
13 {
14  // Read parameters
15  void read(XMLReader& xml, const std::string& path, WallQuarkSinkSmearingEnv::Params& param)
16  {
18  param = tmp;
19  }
20 
21  // Writer
22  void write(XMLWriter& xml, const std::string& path, const WallQuarkSinkSmearingEnv::Params& param)
23  {
24  param.writeXML(xml, path);
25  }
26 
27 
28  //! Hooks to register the class
29  namespace WallQuarkSinkSmearingEnv
30  {
31  namespace
32  {
33  //! Callback function
34  QuarkSourceSink<LatticePropagator>* createProp(XMLReader& xml_in,
35  const std::string& path,
36  const multi1d<LatticeColorMatrix>& u)
37  {
38  return new SinkSmear<LatticePropagator>(Params(xml_in, path), u);
39  }
40 
41  //! Callback function
42  QuarkSourceSink<LatticeStaggeredPropagator>* createStagProp(XMLReader& xml_in,
43  const std::string& path,
44  const multi1d<LatticeColorMatrix>& u)
45  {
46  return new SinkSmear<LatticeStaggeredPropagator>(Params(xml_in, path), u);
47  }
48 
49  //! Callback function
51  const std::string& path,
52  const multi1d<LatticeColorMatrix>& u)
53  {
54  return new SinkSmear<LatticeFermion>(Params(xml_in, path), u);
55  }
56 
57  //! Name to be used
58  const std::string name("WALL_SINK");
59 
60  //! Local registration flag
61  bool registered = false;
62  }
63 
64  //! Return the name
65  std::string getName() {return name;}
66 
67  //! Register all the factories
68  bool registerAll()
69  {
70  bool success = true;
71  if (! registered)
72  {
73  success &= Chroma::ThePropSinkSmearingFactory::Instance().registerObject(name, createProp);
74  success &= Chroma::TheStagPropSinkSmearingFactory::Instance().registerObject(name, createStagProp);
75  success &= Chroma::TheFermSinkSmearingFactory::Instance().registerObject(name, createFerm);
76  registered = true;
77  }
78  return success;
79  }
80 
81 
82  //! Initialize
84  {
85  }
86 
87 
88  //! Read parameters
89  Params::Params(XMLReader& xml, const std::string& path)
90  {
91  XMLReader paramtop(xml, path);
92 
93  int version;
94  read(paramtop, "version", version);
95 
96  switch (version)
97  {
98  case 1:
99  break;
100 
101  default:
102  QDPIO::cerr << __func__ << ": parameter version " << version
103  << " unsupported." << std::endl;
104  QDP_abort(1);
105  }
106 
107  read(paramtop, "j_decay", j_decay);
108 
109  // Sanity check
110  if (j_decay < 0 || j_decay >= Nd)
111  {
112  QDPIO::cerr << name << ": invalid params.j_decay=" << j_decay << std::endl;
113  QDP_abort(1);
114  }
115  }
116 
117 
118  // Writer
119  void Params::writeXML(XMLWriter& xml, const std::string& path) const
120  {
121  int version = 1;
122  push(xml, path);
123  write(xml, "version", version);
124  write(xml, "SinkType", WallQuarkSinkSmearingEnv::getName());
125  write(xml, "j_decay", j_decay);
126  pop(xml);
127  }
128 
129 
130  //! Construct the sink smearing
131  template<>
132  void
133  SinkSmear<LatticePropagator>::operator()(LatticePropagator& quark_sink) const
134  {
135  QDPIO::cout << "Wall sink" << std::endl;
136 
137  // Project onto zero mom. at each time slice, the put back into
138  // original field
139  SftMom phases(0, true, params.j_decay);
140  multi1d<DPropagator> slice_prop(sumMulti(quark_sink, phases.getSet()));
141 
142  for(int t=0; t < phases.numSubsets(); ++t)
143  quark_sink[phases.getSet()[t]] = slice_prop[t];
144 
145  return;
146  }
147 
148 
149 
150  //! Construct the sink smearing
151  template<>
152  void
153  SinkSmear<LatticeStaggeredPropagator>::operator()(LatticeStaggeredPropagator& quark_sink) const
154  {
155  QDPIO::cout << "Wall sink" << std::endl;
156 
157  // Project onto zero mom. at each time slice, the put back into
158  // original field
159  SftMom phases(0, true, params.j_decay);
160  multi1d<DStaggeredPropagator> slice_prop(sumMulti(quark_sink, phases.getSet()));
161 
162  for(int t=0; t < phases.numSubsets(); ++t)
163  quark_sink[phases.getSet()[t]] = slice_prop[t];
164 
165  return;
166  }
167 
168 
169 
170  //! Construct the sink smearing
171  template<>
172  void
173  SinkSmear<LatticeFermion>::operator()(LatticeFermion& quark_sink) const
174  {
175  QDPIO::cout << "Wall sink" << std::endl;
176 
177  // Project onto zero mom. at each time slice, the put back into
178  // original field
179  SftMom phases(0, true, params.j_decay);
180  multi1d<DFermion> slice_prop(sumMulti(quark_sink, phases.getSet()));
181 
182  for(int t=0; t < phases.numSubsets(); ++t)
183  quark_sink[phases.getSet()[t]] = slice_prop[t];
184 
185  return;
186  }
187  }
188 
189 }
Primary include file for CHROMA library code.
Base class for quark source and sink smearing.
Fourier transform phase factor support.
Definition: sftmom.h:35
int numSubsets() const
Number of subsets - length in decay direction.
Definition: sftmom.h:63
const Set & getSet() const
The set to be used in sumMulti.
Definition: sftmom.h:57
static T & Instance()
Definition: singleton.h:432
void operator()(T &obj) const
Smear the sink.
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.
Class for counted reference semantics.
Params params
int t
Definition: meslate.cc:37
Nd
Definition: meslate.cc:74
static bool registered
Local registration flag.
const std::string name
Name to be used.
CreateFermState< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > * createFerm(XMLReader &xml, const std::string &path)
bool registerAll()
Register all the factories.
std::string getName()
Return the name.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
pop(xml_out)
::std::string string
Definition: gtest.h:1979
Fourier transform phase factor support.
Factory for producing quark prop sinks.
void writeXML(XMLWriter &in, const std::string &path) const
Wall sink smearing.