CHROMA
sf_gauge_init.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Initialize a Schroedinger BC config
3  */
4 
5 #include "handle.h"
9 
13 
14 namespace Chroma
15 {
16 
17  // Read parameters
18  void read(XMLReader& xml, const std::string& path, SFGaugeInitEnv::Params& param)
19  {
20  SFGaugeInitEnv::Params tmp(xml, path);
21  param = tmp;
22  }
23 
24  //! Parameters for running code
25  void write(XMLWriter& xml, const std::string& path, const SFGaugeInitEnv::Params& param)
26  {
27  param.writeXML(xml, path);
28  }
29 
30 
31  //! Hooks to register the class
32  namespace SFGaugeInitEnv
33  {
34  //! Callback function
35  GaugeInit* createCfg(XMLReader& xml_in,
36  const std::string& path)
37  {
38  return new GaugeIniter(Params(xml_in, path));
39  }
40 
41  //! Name to be used
42  const std::string name = "CLASSICAL_SF";
43 
44  //! Local registration flag
45  static bool registered = false;
46 
47  //! Register all the factories
48  bool registerAll()
49  {
50  bool success = true;
51  if (! registered)
52  {
54  success &= Chroma::TheGaugeInitFactory::Instance().registerObject(name, createCfg);
55  registered = true;
56  }
57  return success;
58  }
59 
60 
61  // Parameters for running code
62  Params::Params(XMLReader& xml, const std::string& path)
63  {
64  XMLReader paramtop(xml, path);
65 
66  cgs = readXMLGroup(paramtop, "GaugeState", "Name");
67  }
68 
69 
70  //! Parameters for running code
71  void Params::writeXML(XMLWriter& xml, const std::string& path) const
72  {
73  push(xml, path);
74 
75  int version = 1;
76  write(xml, "cfg_type", SFGaugeInitEnv::name);
77  xml << cgs.xml;
78 
79  pop(xml);
80  }
81 
82 
83  // Initialize the gauge field
84  void
85  GaugeIniter::operator()(XMLReader& gauge_file_xml,
86  XMLReader& gauge_xml,
87  multi1d<LatticeColorMatrix>& u) const
88  {
89  QDPIO::cout << "Starting up a classical Schroedinger functional config" << std::endl;
90 
91  try
92  {
93  //
94  // Create the GaugeState object
95  //
96  std::istringstream xml_s(params.cgs.xml);
97  XMLReader top(xml_s);
98  QDPIO::cout << "GaugeState type = " << params.cgs.id << std::endl;
99 
100  Handle< CreateGaugeState< multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> > >
102  top,
103  params.cgs.path));
104 
105  // Need to downcast to the appropriate BC
106  const SchrGaugeBC& gaugebc = dynamic_cast<const SchrGaugeBC&>(cgs->getBC());
107 
108  // Set the fields to the appropriate background field
109  u = gaugebc.SFBndFld();
110 
111  // Munge the fields with the state
112  Handle<GaugeState< multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> > >
113  state((*cgs)(u));
114 
115  // Pull the u fields back out from the state since they might have been
116  // munged with gaugeBC's
117  u = state->getLinks();
118  }
119  catch( std::bad_cast )
120  {
121  QDPIO::cerr << name << ": caught dynamic cast error" << std::endl;
122  QDP_abort(1);
123  }
124  catch(const std::string& e)
125  {
126  QDPIO::cerr << name << ": Caught Exception in creating GaugeState: " << e << std::endl;
127  QDP_abort(1);
128  }
129 
130  XMLBufferWriter file_xml, record_xml;
131  push(file_xml, "gauge");
132  write(file_xml, "id", int(0));
133  pop(file_xml);
134  params.writeXML(record_xml, "SF_classical");
135 
136  gauge_file_xml.open(file_xml);
137  gauge_xml.open(record_xml);
138  }
139  }
140 }
Base class for gauge initialization.
Definition: gauge_init.h:19
Class for counted reference semantics.
Definition: handle.h:33
void operator()(XMLReader &gauge_file_xml, XMLReader &gauge_xml, multi1d< LatticeColorMatrix > &u) const
Initialize the gauge field.
Abstract class for all gauge action boundary conditions with Schroedinger BC.
virtual const multi1d< LatticeColorMatrix > & SFBndFld() const =0
Fixed gauge links on only the lSFmask() sites.
static T & Instance()
Definition: singleton.h:432
All gauge create-state method.
Gauge create state factory.
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.
GroupXML_t readXMLGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
Class for counted reference semantics.
bool registerAll()
Register all the factories.
static bool registered
Local registration flag.
const std::string name
Name to be used.
GaugeInit * createCfg(XMLReader &xml_in, const std::string &path)
Callback function.
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)
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
::std::string string
Definition: gtest.h:1979
Schroedinger Gauge boundary conditions.
Initialize a Schroedinger BC config.
Params for initializing config.
Definition: sf_gauge_init.h:25
void writeXML(XMLWriter &in, const std::string &path) const
Parameters for running code.