CHROMA
szin_gauge_init.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Read a SZIN config
3  */
4 
7 
9 #include "io/readszin.h"
10 
11 namespace Chroma
12 {
13 
14  // Read parameters
15  void read(XMLReader& xml, const std::string& path, SZINGaugeInitEnv::Params& param)
16  {
17  SZINGaugeInitEnv::Params tmp(xml, path);
18  param = tmp;
19  }
20 
21  //! Parameters for running code
22  void write(XMLWriter& xml, const std::string& path, const SZINGaugeInitEnv::Params& param)
23  {
24  param.writeXML(xml, path);
25  }
26 
27 
28  //! Hooks to register the class
29  namespace SZINGaugeInitEnv
30  {
31  //! Callback function
32  GaugeInit* createSource(XMLReader& xml_in,
33  const std::string& path)
34  {
35  return new GaugeIniter(Params(xml_in, path));
36  }
37 
38  //! Name to be used
39  const std::string name = "SZIN";
40 
41  //! Local registration flag
42  static bool registered = false;
43 
44  //! Register all the factories
45  bool registerAll()
46  {
47  bool success = true;
48  if (! registered)
49  {
50  success &= Chroma::TheGaugeInitFactory::Instance().registerObject(name, createSource);
51  registered = true;
52  }
53  return success;
54  }
55 
56 
57  // Parameters for running code
58  Params::Params(XMLReader& xml, const std::string& path)
59  {
60  XMLReader paramtop(xml, path);
61 
62  read(paramtop, "cfg_file", cfg_file);
63  }
64 
65 
66  //! Parameters for running code
67  void Params::writeXML(XMLWriter& xml, const std::string& path) const
68  {
69  push(xml, path);
70 
71  int version = 1;
72  write(xml, "cfg_type", SZINGaugeInitEnv::name);
73  write(xml, "cfg_file", cfg_file);
74 
75  pop(xml);
76  }
77 
78 
79  // Initialize the gauge field
80  void
81  GaugeIniter::operator()(XMLReader& gauge_file_xml,
82  XMLReader& gauge_xml,
83  multi1d<LatticeColorMatrix>& u) const
84  {
85  u.resize(Nd);
86  readSzin(gauge_xml, u, params.cfg_file);
87  }
88  }
89 }
Base class for gauge initialization.
Definition: gauge_init.h:19
void operator()(XMLReader &gauge_file_xml, XMLReader &gauge_xml, multi1d< LatticeColorMatrix > &u) const
Initialize the gauge field.
static T & Instance()
Definition: singleton.h:432
All gauge field initializers.
Factory for producing gauge initializer objects.
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 readSzin(SzinGauge_t &header, multi1d< LatticeColorMatrix > &u, const std::string &cfg_file)
Read a SZIN configuration file.
Definition: readszin.cc:31
Nd
Definition: meslate.cc:74
const std::string name
Name to be used.
GaugeInit * createSource(XMLReader &xml_in, const std::string &path)
Callback function.
static bool registered
Local registration flag.
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")
pop(xml_out)
::std::string string
Definition: gtest.h:1979
Read in a configuration written by SZIN up to configuration version 7.
Params for initializing config.
void writeXML(XMLWriter &in, const std::string &path) const
Parameters for running code.
Read a SZIN config.