CHROMA
inline_qactden.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Inline action density and really naive topological charge
3  */
4 
7 #include "meas/glue/qactden.h"
9 
12 
13 
14 namespace Chroma
15 {
16 
17  namespace InlineQActDenEnv
18  {
19  namespace
20  {
21  AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
22  const std::string& path)
23  {
24  Params p(xml_in, path);
25  return new InlineMeas(p);
26  }
27 
28  //! Local registration flag
29  bool registered = false;
30 
31  const std::string name = "QACTDEN";
32  }
33 
34  //! Register all the factories
35  bool registerAll()
36  {
37  bool success = true;
38  if (! registered)
39  {
41  success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
42  registered = true;
43  }
44  return success;
45  }
46 
47 
48 
49  //! Parameter input
50  void read(XMLReader& xml, const std::string& path, Params::Param_t& param)
51  {
52  XMLReader paramtop(xml, path);
53 
54  int version;
55  read(paramtop, "version", version);
56 
57  switch (version)
58  {
59  case 1:
60  if (paramtop.count("GaugeState") != 0)
61  param.cgs = readXMLGroup(paramtop, "GaugeState", "Name");
62  else
64  break;
65 
66  default:
67  QDPIO::cerr << "Params::Param_t: " << version
68  << " unsupported." << std::endl;
69  QDP_abort(1);
70  }
71  }
72 
73  //! Parameter output
74  void write(XMLWriter& xml, const std::string& path, const Params::Param_t& param)
75  {
76  push(xml, path);
77 
78  int version = 1;
79  write(xml, "version", version);
80  xml << param.cgs.xml;
81 
82  pop(xml);
83  }
84 
85 
86  //! Parameter input
87  void read(XMLReader& xml, const std::string& path, Params::NamedObject_t& input)
88  {
89  XMLReader inputtop(xml, path);
90 
91  read(inputtop, "gauge_id", input.gauge_id);
92  }
93 
94  //! Parameter output
95  void write(XMLWriter& xml, const std::string& path, const Params::NamedObject_t& input)
96  {
97  push(xml, path);
98 
99  write(xml, "gauge_id", input.gauge_id);
100 
101  pop(xml);
102  }
103 
104 
105  // Params
107  {
108  frequency = 0;
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  catch(const std::string& e)
130  {
131  QDPIO::cerr << "Caught Exception reading XML: " << e << std::endl;
132  QDP_abort(1);
133  }
134  }
135 
136  void
137  InlineMeas::operator()(unsigned long update_no,
138  XMLWriter& xml_out)
139  {
140  START_CODE();
141 
142  // Grab the object
143  multi1d<LatticeColorMatrix> u =
144  TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
145 
146  push(xml_out, "QActDen");
147  write(xml_out, "update_no", update_no);
148 
149  LatticeReal lract;
150  LatticeReal lrqtop;
151  qactden(lract, lrqtop, u);
152 
153  write(xml_out, "actionDensity", lract);
154  write(xml_out, "naiveTopCharge", lrqtop);
155 
156  pop(xml_out);
157 
158  END_CODE();
159  }
160 
161  }
162 
163 }
Inline measurement factory.
void operator()(unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
static T & Instance()
Definition: singleton.h:432
All gauge create-state method.
Gauge create state factory.
void qactden(LatticeReal &lract, LatticeReal &lrqtop, const multi1d< LatticeColorMatrix > &u)
Measure the lattice density of the lattice energy and the naive topological charge.
Definition: qactden.cc:20
GroupXML_t readXMLGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
Inline action density and really naive topological charge.
LatticeReal lract
Definition: meslate.cc:44
LatticeReal lrqtop
Definition: meslate.cc:45
Named object function std::map.
static bool registered
Local registration flag.
const std::string name
Name to be used.
bool registerAll()
Register all the factories.
GroupXML_t nullXMLGroup()
Returns a simple createstate group.
void write(XMLWriter &xml, const std::string &path, const Params::Param_t &param)
Parameter output.
bool registerAll()
Register all the factories.
void read(XMLReader &xml, const std::string &path, Params::Param_t &param)
Parameter input.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
push(xml_out,"Condensates")
pop(xml_out)
START_CODE()
::std::string string
Definition: gtest.h:1979
Measure the lattice density of the lattice energy and the naive topological charge.
struct Chroma::InlineQActDenEnv::Params::Param_t param
struct Chroma::InlineQActDenEnv::Params::NamedObject_t named_obj