CHROMA
cern_gauge_init.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Read a CERN config
3  */
4 
7 
9 #include "qdp_iogauge.h"
10 
11 #include "io/cern_io.h"
12 
13 namespace Chroma
14 {
15 
16  // Read parameters
17  void read(XMLReader& xml, const std::string& path, CERNGaugeInitEnv::Params& param)
18  {
19  CERNGaugeInitEnv::Params tmp(xml, path);
20  param = tmp;
21  }
22 
23  //! Parameters for running code
24  void write(XMLWriter& xml, const std::string& path, const CERNGaugeInitEnv::Params& param)
25  {
26  param.writeXML(xml, path);
27  }
28 
29 
30  //! Hooks to register the class
31  namespace CERNGaugeInitEnv
32  {
33  //! Callback function
34  GaugeInit* createSource(XMLReader& xml_in,
35  const std::string& path)
36  {
37  return new GaugeIniter(Params(xml_in, path));
38  }
39 
40  //! Name to be used
41  const std::string name = "CERN";
42 
43  //! Local registration flag
44  static bool registered = false;
45 
46  //! Register all the factories
47  bool registerAll()
48  {
49  bool success = true;
50  if (! registered)
51  {
52  success &= Chroma::TheGaugeInitFactory::Instance().registerObject(name, createSource);
53  registered = true;
54  }
55  return success;
56  }
57 
58 
59  // Parameters for running code
60  Params::Params(XMLReader& xml, const std::string& path)
61  {
62  XMLReader paramtop(xml, path);
63 
64  read(paramtop, "cfg_file", cfg_file);
65  }
66 
67 
68  //! Parameters for running code
69  void Params::writeXML(XMLWriter& xml, const std::string& path) const
70  {
71  push(xml, path);
72 
73  int version = 1;
74  write(xml, "cfg_type", CERNGaugeInitEnv::name);
75  write(xml, "cfg_file", cfg_file);
76 
77  pop(xml);
78  }
79 
80 
81  // Initialize the gauge field
82  void
83  GaugeIniter::operator()(XMLReader& gauge_file_xml,
84  XMLReader& gauge_xml,
85  multi1d<LatticeColorMatrix>& u) const
86  {
87  u.resize(Nd);
89 
90  XMLBufferWriter file_xml, record_xml;
91  push(file_xml, "gauge");
92  write(file_xml, "info", "A_CERN_Gauge_Field");
93  pop(file_xml);
94 
95  push(record_xml, "record");
96  write(record_xml, "info", "Spooled_from_CERN_Format_File");
97  pop(record_xml);
98 
99  gauge_file_xml.open(file_xml);
100  gauge_xml.open(record_xml);
101 
102  }
103  }
104 }
Read a CERN config.
CPPACS gauge format routines.
void operator()(XMLReader &gauge_file_xml, XMLReader &gauge_xml, multi1d< LatticeColorMatrix > &u) const
Initialize the gauge field.
Base class for gauge initialization.
Definition: gauge_init.h:19
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.
Nd
Definition: meslate.cc:74
GaugeInit * createSource(XMLReader &xml_in, const std::string &path)
Callback function.
static bool registered
Local registration flag.
bool registerAll()
Register all the factories.
const std::string name
Name to be used.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
void readCERN(multi1d< LatticeColorMatrix > &, const std::string &)
Definition: readcern.cc:223
pop(xml_out)
::std::string string
Definition: gtest.h:1979
Params for initializing config.
void writeXML(XMLWriter &in, const std::string &path) const
Parameters for running code.