CHROMA
wall_source_const.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Wall source construction
3  */
4 
5 #include "chromabase.h"
6 
10 #include "util/ferm/transf.h"
11 
12 namespace Chroma
13 {
14  // Read parameters
15  void read(XMLReader& xml, const std::string& path, WallQuarkSourceConstEnv::Params& param)
16  {
18  param = tmp;
19  }
20 
21  // Writer
22  void write(XMLWriter& xml, const std::string& path, const WallQuarkSourceConstEnv::Params& param)
23  {
24  param.writeXML(xml, path);
25  }
26 
27 
28  //! Hooks to register the class
29  namespace WallQuarkSourceConstEnv
30  {
31  namespace
32  {
33  //! Callback function
34  QuarkSourceConstruction<LatticePropagator>* createProp(XMLReader& xml_in,
35  const std::string& path)
36  {
37  return new SourceConst<LatticePropagator>(Params(xml_in, path));
38  }
39 
40  //! Name to be used
41  const std::string name("WALL_SOURCE");
42 
43  //! Local registration flag
44  bool registered = false;
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::ThePropSourceConstructionFactory::Instance().registerObject(name, createProp);
57  registered = true;
58  }
59  return success;
60  }
61 
62 
63  //! Initialize
65  {
66  j_decay = -1;
67  t_source = -1;
68  }
69 
70 
71  //! Read parameters
72  Params::Params(XMLReader& xml, const std::string& path)
73  {
74  XMLReader paramtop(xml, path);
75 
76  int version;
77  read(paramtop, "version", version);
78 
79  switch (version)
80  {
81  case 1:
82  break;
83 
84  default:
85  QDPIO::cerr << __func__ << ": parameter version " << version
86  << " unsupported." << std::endl;
87  QDP_abort(1);
88  }
89 
90  read(paramtop, "j_decay", j_decay);
91  read(paramtop, "t_source", t_source);
92  }
93 
94 
95  // Writer
96  void Params::writeXML(XMLWriter& xml, const std::string& path) const
97  {
98  push(xml, path);
99 
100  int version = 1;
101  write(xml, "version", version);
102  write(xml, "SourceType", WallQuarkSourceConstEnv::name);
103  write(xml, "j_decay", j_decay);
104  write(xml, "t_source", t_source);
105  pop(xml);
106  }
107 
108 
109  //! Construct the source
110  template<>
111  LatticePropagator
112  SourceConst<LatticePropagator>::operator()(const multi1d<LatticeColorMatrix>& u) const
113  {
114  QDPIO::cout << "Wall source" << std::endl;
115 
116  // Create the quark source
117  LatticePropagator quark_source;
118 
119  for(int color_source = 0; color_source < Nc; ++color_source)
120  {
121  for(int spin_source = 0; spin_source < Ns; ++spin_source)
122  {
123  // Wall fill a fermion source. Insert it into the propagator source
124  LatticeFermion chi;
125  walfil(chi,
127  params.j_decay,
128  color_source, spin_source);
129  FermToProp(chi, quark_source, color_source, spin_source);
130  }
131  }
132 
133  return quark_source;
134  }
135 
136  }
137 
138 }
Primary include file for CHROMA library code.
Base class for quark source construction.
static T & Instance()
Definition: singleton.h:432
T operator()(const multi1d< LatticeColorMatrix > &u) const
Construct the source.
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.
void walfil(LatticeStaggeredFermion &a, int slice, int mu, int color_index, int src_index)
Fill a specific color and spin index with 1.0 on a wall.
Definition: walfil_s.cc:36
Params params
static bool registered
Local registration flag.
const std::string name
Name to be used.
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")
multi1d< LatticeFermion > chi(Ncb)
pop(xml_out)
::std::string string
Definition: gtest.h:1979
Factory for producing quark prop sources.
void writeXML(XMLWriter &in, const std::string &path) const
Wall source construction.
Wall source construction.