CHROMA
partwall_source_const.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Partial wall source construction
3  */
4 
5 #include "chromabase.h"
6 
10 #include "util/ferm/transf.h"
11 
12 
13 namespace Chroma
14 {
15 
16  // Read parameters
17  void read(XMLReader& xml, const std::string& path, PartialWallQuarkSourceConstEnv::Params& param)
18  {
20  param = tmp;
21  }
22 
23  // Writer
24  void write(XMLWriter& xml, const std::string& path, const PartialWallQuarkSourceConstEnv::Params& param)
25  {
26  param.writeXML(xml, path);
27  }
28 
29 
30  // Read parameters
31  void read(XMLReader& xml, const std::string& path, FixedDir_t& param)
32  {
33  XMLReader paramtop(xml, path);
34 
35  read(paramtop, "dir", param.dir);
36  read(paramtop, "coord", param.coord);
37  }
38 
39  // Writer
40  void write(XMLWriter& xml, const std::string& path, const FixedDir_t& param)
41  {
42  write(xml, "dir", param.dir);
43  write(xml, "coord", param.coord);
44  }
45 
46 
47  //! Hooks to register the class
48  namespace PartialWallQuarkSourceConstEnv
49  {
50  namespace
51  {
52  //! Callback function
53  QuarkSourceConstruction<LatticePropagator>* createProp(XMLReader& xml_in,
54  const std::string& path)
55  {
56  return new SourceConst<LatticePropagator>(Params(xml_in, path));
57  }
58 
59  //! Local registration flag
60  bool registered = false;
61 
62  //! Name to be used
63  const std::string name("PARTIAL_WALL_SOURCE");
64  }
65 
66  //! Return the name
67  std::string getName() {return name;}
68 
69  //! Register all the factories
70  bool registerAll()
71  {
72  bool success = true;
73  if (! registered)
74  {
75  success &= Chroma::ThePropSourceConstructionFactory::Instance().registerObject(name, createProp);
76  registered = true;
77  }
78  return success;
79  }
80 
81 
82  //! Initialize
84  {
85 // j_decay = -1;
86 // t_source = -1;
87  }
88 
89 
90  //! Read parameters
91  Params::Params(XMLReader& xml, const std::string& path)
92  {
93  XMLReader paramtop(xml, path);
94 
95  int version;
96  read(paramtop, "version", version);
97 
98  switch (version)
99  {
100  case 1:
101  break;
102 
103  default:
104  QDPIO::cerr << __func__ << ": parameter version " << version
105  << " unsupported." << std::endl;
106  QDP_abort(1);
107  }
108 
109  read(paramtop, "FixedDirs", fixed_dirs);
110 // read(paramtop, "j_decay", j_decay);
111 // read(paramtop, "t_source", t_source);
112  }
113 
114 
115  // Writer
116  void Params::writeXML(XMLWriter& xml, const std::string& path) const
117  {
118  push(xml, path);
119 
120  int version = 1;
121  write(xml, "version", version);
122 
123  write(xml, "FixedDirs", fixed_dirs);
124 // write(xml, "j_decay", j_decay);
125 // write(xml, "t_source", t_source);
126  pop(xml);
127  }
128 
129 
130  //! Construct the source
131  template<>
132  LatticePropagator
133  SourceConst<LatticePropagator>::operator()(const multi1d<LatticeColorMatrix>& u) const
134  {
135  QDPIO::cout << "Partial Wall source" << std::endl;
136 
137  // Create a mask of which sites are included
138  LatticeBoolean mask = true;
139  for(int i=0; i < params.fixed_dirs.size(); ++i)
140  {
141  int dir = params.fixed_dirs[i].dir;
142  int coord = params.fixed_dirs[i].coord;
143 
144  if (dir < 0 || dir >= Nd)
145  {
146  QDPIO::cerr << name << ": invalid direction, dir=" << dir << std::endl;
147  QDP_abort(1);
148  }
149 
150  if (coord < 0 || coord >= QDP::Layout::lattSize()[dir])
151  {
152  QDPIO::cerr << name << ": invalid coordinate, coord=" << coord << std::endl;
153  QDP_abort(1);
154  }
155 
156  mask &= where(Layout::latticeCoordinate(dir) == coord, Boolean(true), Boolean(false));
157  }
158 
159 
160  // Create the quark source
161  LatticePropagator quark_source = zero;
162 
163  for(int color_source = 0; color_source < Nc; ++color_source)
164  {
165  for(int spin_source = 0; spin_source < Ns; ++spin_source)
166  {
167  // Write ONE to all field
168  Real one = 1;
169  Complex sitecomp = cmplx(one,0);
170  ColorVector sitecolor = zero;
171  Fermion sitefield = zero;
172 
173  pokeSpin(sitefield,
174  pokeColor(sitecolor,sitecomp,color_source),
175  spin_source);
176 
177  // Narrow the context to the desired slice.
178  LatticeFermion tmp;
179  tmp = sitefield;
180 
181  // Partial Wall fill a fermion source. Insert it into the propagator source
182  LatticeFermion chi = where(mask, tmp, LatticeFermion(zero));
183 
184  FermToProp(chi, quark_source, color_source, spin_source);
185  }
186  }
187 
188  return quark_source;
189  }
190 
191  }
192 
193 }
Primary include file for CHROMA library code.
T operator()(const multi1d< LatticeColorMatrix > &u) const
Construct the source.
Base class for quark source construction.
static T & Instance()
Definition: singleton.h:432
void FermToProp(const LatticeFermionF &a, LatticePropagatorF &b, int color_index, int spin_index)
Insert a LatticeFermion into a LatticePropagator.
Definition: transf.cc:98
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.
Params params
multi1d< int > coord(Nd)
Nd
Definition: meslate.cc:74
static bool registered
Local registration flag.
const std::string name
Name to be used.
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
Double one
Definition: invbicg.cc:105
push(xml_out,"Condensates")
int i
Definition: pbg5p_w.cc:55
multi1d< LatticeFermion > chi(Ncb)
pop(xml_out)
Double zero
Definition: invbicg.cc:106
::std::string string
Definition: gtest.h:1979
Partial wall source construction.
Factory for producing quark prop sources.
Structure holding directions.
void writeXML(XMLWriter &in, const std::string &path) const
Wall source construction.