CHROMA
inline_plaquette.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Inline plaquette
3  */
4 
8 #include "meas/glue/mesplq.h"
10 
12 
15 
16 namespace Chroma
17 {
18  //! Plaquette input
19  void read(XMLReader& xml, const std::string& path, InlinePlaquetteEnv::Params::Param_t& param)
20  {
21  XMLReader paramtop(xml, path);
22 
23  int version;
24  read(paramtop, "version", version);
26 
27  switch (version)
28  {
29  case 2:
30  if (paramtop.count("GaugeState") != 0)
31  param.cgs = readXMLGroup(paramtop, "GaugeState", "Name");
32  break;
33 
34  default:
35  QDPIO::cerr << "InlinePlaquetteEnv::Params::Param_t: " << version
36  << " unsupported." << std::endl;
37  QDP_abort(1);
38  }
39  }
40 
41  //! Plaquette output
42  void write(XMLWriter& xml, const std::string& path, const InlinePlaquetteEnv::Params::Param_t& param)
43  {
44  push(xml, path);
45 
46  int version = 2;
47  write(xml, "version", version);
48  xml << param.cgs.xml;
49 
50  pop(xml);
51  }
52 
53 
54  //! Plaquette input
55  void read(XMLReader& xml, const std::string& path, InlinePlaquetteEnv::Params::NamedObject_t& input)
56  {
57  XMLReader inputtop(xml, path);
58 
59  read(inputtop, "gauge_id", input.gauge_id);
60  }
61 
62  //! Plaquette output
63  void write(XMLWriter& xml, const std::string& path, const InlinePlaquetteEnv::Params::NamedObject_t& input)
64  {
65  push(xml, path);
66 
67  write(xml, "gauge_id", input.gauge_id);
68 
69  pop(xml);
70  }
71 
72 
73  namespace InlinePlaquetteEnv
74  {
75  namespace
76  {
77  AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
78  const std::string& path)
79  {
80  return new InlineMeas(Params(xml_in, path));
81  }
82 
83  //! Local registration flag
84  bool registered = false;
85  }
86 
87  const std::string name = "PLAQUETTE";
88 
89  //! Register all the factories
90  bool registerAll()
91  {
92  bool success = true;
93  if (! registered)
94  {
96  success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
97  registered = true;
98  }
99  return success;
100  }
101 
102 
103  // Params
105  {
106  frequency = 0;
109  xml_file ="";
110  }
111 
112  Params::Params(XMLReader& xml_in, const std::string& path)
113  {
114  try
115  {
116  XMLReader paramtop(xml_in, path);
117 
118  if (paramtop.count("Frequency") == 1)
119  read(paramtop, "Frequency", frequency);
120  else
121  frequency = 1;
122 
123  // Params
124  read(paramtop, "Param", param);
125 
126  // Ids
127  read(paramtop, "NamedObject", named_obj);
128 
129  // Possible alternate XML file pattern
130  if (paramtop.count("xml_file") != 0) {
131  read(paramtop, "xml_file", xml_file);
132  }
133  }
134  catch(const std::string& e)
135  {
136  QDPIO::cerr << "Caught Exception reading XML: " << e << std::endl;
137  QDP_abort(1);
138  }
139  }
140 
141 
142  void
143  InlineMeas::operator()(unsigned long update_no,
144  XMLWriter& xml_out)
145  {
146  if( params.xml_file != "" )
147  {
148  std::string xml_file = makeXMLFileName(params.xml_file, update_no);
149  push( xml_out, "Plaquette");
150  write(xml_out, "update_no", update_no);
151  write(xml_out, "xml_file", xml_file);
152  pop(xml_out);
153 
154  XMLFileWriter xml(xml_file);
155  func(update_no, xml);
156  }
157  else
158  {
159  func(update_no, xml_out);
160  }
161 
162  }
163 
164  void
165  InlineMeas::func(const unsigned long update_no,
166  XMLWriter& xml_out)
167  {
168  START_CODE();
169 
170  // Test and grab a reference to the gauge field
171  multi1d<LatticeColorMatrix> u;
172  XMLBufferWriter gauge_xml;
173 
174  try
175  {
176  u = TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
177  TheNamedObjMap::Instance().get(params.named_obj.gauge_id).getRecordXML(gauge_xml);
178 
179  // Set the construct state and modify the fields
180  {
181  std::istringstream xml_s(params.param.cgs.xml);
182  XMLReader gaugetop(xml_s);
183 
184  Handle<CreateGaugeState< multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> > >
186  gaugetop,
187  params.param.cgs.path));
188 
189  Handle<GaugeState< multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> > >
190  state((*cgs)(u));
191 
192  // Pull the u fields back out from the state since they might have been
193  // munged with gaugeBC's
194  u = state->getLinks();
195  }
196  }
197  catch( std::bad_cast )
198  {
199  QDPIO::cerr << InlinePlaquetteEnv::name << ": caught dynamic cast error"
200  << std::endl;
201  QDP_abort(1);
202  }
203  catch (const std::string& e)
204  {
205  QDPIO::cerr << InlinePlaquetteEnv::name << ": std::map call failed: " << e
206  << std::endl;
207  QDP_abort(1);
208  }
209 
210  push(xml_out, "Plaquette");
211  write(xml_out, "update_no", update_no);
212 
214  multi2d<Double> plane_plaq;
215 
216  MesPlq(u, w_plaq, s_plaq, t_plaq, plane_plaq, link);
217  write(xml_out, "w_plaq", w_plaq);
218  write(xml_out, "s_plaq", s_plaq);
219  write(xml_out, "t_plaq", t_plaq);
220 
221  if (Nd >= 2)
222  {
223  write(xml_out, "plane_01_plaq", plane_plaq[0][1]);
224  }
225 
226  if (Nd >= 3)
227  {
228  write(xml_out, "plane_02_plaq", plane_plaq[0][2]);
229  write(xml_out, "plane_12_plaq", plane_plaq[1][2]);
230  }
231 
232  if (Nd >= 4)
233  {
234  write(xml_out, "plane_03_plaq", plane_plaq[0][3]);
235  write(xml_out, "plane_13_plaq", plane_plaq[1][3]);
236  write(xml_out, "plane_23_plaq", plane_plaq[2][3]);
237  }
238 
239  write(xml_out, "link", link);
240 
241  pop(xml_out); // pop("Plaquette");
242 
243  END_CODE();
244  }
245 
246  } // namespace InlinePlaquetteEnv
247 
248 } // namespace Chroma
Inline measurement factory.
Class for counted reference semantics.
Definition: handle.h:33
void func(const unsigned long update_no, XMLWriter &xml_out)
void operator()(unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
static T & Instance()
Definition: singleton.h:432
Functions to set and get default gauge field.
All gauge create-state method.
Gauge create state factory.
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.
std::string makeXMLFileName(std::string xml_file, unsigned long update_no)
Return a xml file name for inline measurements.
std::string getId()
Get the default gauge field named object id.
GroupXML_t readXMLGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
Inline plaquette.
Make xml file writer.
Nd
Definition: meslate.cc:74
Named object function std::map.
static bool registered
Local registration flag.
bool registerAll()
Register all the factories.
GroupXML_t nullXMLGroup()
Returns a simple createstate group.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
push(xml_out,"Condensates")
pop(xml_out)
void MesPlq(const multi1d< LatticeColorMatrixF3 > &u, multi2d< Double > &plane_plaq, Double &link)
Definition: mesplq.cc:83
START_CODE()
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
FloatingPoint< double > Double
Definition: gtest.h:7351
::std::string string
Definition: gtest.h:1979
Double link
Definition: pade_trln_w.cc:146
Double t_plaq
Definition: pade_trln_w.cc:145
Double w_plaq
Definition: pade_trln_w.cc:143
Double s_plaq
Definition: pade_trln_w.cc:144
struct Chroma::InlinePlaquetteEnv::Params::Param_t param
struct Chroma::InlinePlaquetteEnv::Params::NamedObject_t named_obj