CHROMA
inline_random_transf_gauge.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Do a random gauge transformation on a gauge field
3  */
4 
7 #include "util/gauge/rgauge.h"
8 #include "meas/glue/mesplq.h"
9 #include "util/info/proginfo.h"
11 
12 namespace Chroma
13 {
14  // Reader for out gauge file
15  void read(XMLReader& xml, const std::string& path, InlineRandomTransfGaugeEnv::Params::NamedObject_t& input)
16  {
17  XMLReader inputtop(xml, path);
18 
19  read(inputtop, "gauge_id", input.gauge_id);
20  read(inputtop, "rgauge_id", input.rgauge_id);
21  read(inputtop, "gauge_rot_id", input.gauge_rot_id);
22  }
23 
24  // Reader for out gauge file
25  void write(XMLWriter& xml, const std::string& path, const InlineRandomTransfGaugeEnv::Params::NamedObject_t& input)
26  {
27  push(xml, path);
28 
29  write(xml, "gauge_id", input.gauge_id);
30  write(xml, "rgauge_id", input.rgauge_id);
31  write(xml, "gauge_rot_id", input.gauge_rot_id);
32 
33  pop(xml);
34  }
35 
36 
37 
38  namespace InlineRandomTransfGaugeEnv
39  {
40  //! Anonymous namespace
41  namespace
42  {
43  AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
44  const std::string& path)
45  {
46  return new InlineMeas(Params(xml_in, path));
47  }
48 
49  //! Local registration flag
50  bool registered = false;
51  }
52 
53  const std::string name = "RANDOM_GAUGE_TRANSF";
54 
55  //! Register all the factories
56  bool registerAll()
57  {
58  bool success = true;
59  if (! registered)
60  {
61  success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
62  registered = true;
63  }
64  return success;
65  }
66 
67 
68  // Param stuff
70  {
71  frequency = 0;
72  }
73 
74  Params::Params(XMLReader& xml_in, const std::string& path)
75  {
76  try
77  {
78  XMLReader paramtop(xml_in, path);
79 
80  if (paramtop.count("Frequency") == 1)
81  read(paramtop, "Frequency", frequency);
82  else
83  frequency = 1;
84 
85  // Read in the gfix outfile
86  read(paramtop, "NamedObject", named_obj);
87  }
88  catch(const std::string& e)
89  {
90  QDPIO::cerr << name << ": Caught Exception reading XML: " << e << std::endl;
91  QDP_abort(1);
92  }
93  }
94 
95 
96  // Write params
97  void
98  Params::writeXML(XMLWriter& xml, const std::string& path)
99  {
100  push(xml, path);
101 
102  write(xml, "NamedObject", named_obj);
103 
104  pop(xml);
105  }
106 
107 
108  void
109  InlineMeas::operator()(unsigned long update_no,
110  XMLWriter& xml_out)
111  {
112  START_CODE();
113 
114  QDP::StopWatch snoop;
115  snoop.reset();
116  snoop.start();
117 
118  XMLBufferWriter gauge_xml;
119  multi1d<LatticeColorMatrix> u =
120  TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
121  TheNamedObjMap::Instance().get(params.named_obj.gauge_id).getRecordXML(gauge_xml);
122 
123  push(xml_out, "RandomTransfGauge");
124  write(xml_out, "update_no", update_no);
125 
126  QDPIO::cout << name << ": coulomb gauge fix" << std::endl;
127 
128  proginfo(xml_out); // Print out basic program info
129 
130  // Write out the input
131  params.writeXML(xml_out, "Input");
132 
133  // Write out the config header
134  write(xml_out, "Config_info", gauge_xml);
135 
136  push(xml_out, "Output_version");
137  write(xml_out, "out_version", 1);
138  pop(xml_out);
139 
140  // Calculate some gauge invariant observables
141  MesPlq(xml_out, "Observables", u);
142 
143  // Now do a random gauge transformation fix
144  multi1d<LatticeColorMatrix> u_rgauge = u;
145  LatticeColorMatrix g; // the gauge rotation matrices
146  rgauge(u_rgauge, g);
147 
148  // Calculate observables again. The link is not gauge invariant.
149  MesPlq(xml_out, "Random_gauge_transf_observables", u_rgauge);
150 
151  // Now store the configuration to a memory object
152  {
153  XMLBufferWriter file_xml, record_xml;
154  push(file_xml, "gauge");
155  write(file_xml, "id", int(0));
156  pop(file_xml);
157  record_xml << gauge_xml;
158 
159  // Store the gauge field
160  TheNamedObjMap::Instance().create< multi1d<LatticeColorMatrix> >(params.named_obj.rgauge_id);
161  TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.rgauge_id) = u_rgauge;
162  TheNamedObjMap::Instance().get(params.named_obj.rgauge_id).setFileXML(file_xml);
163  TheNamedObjMap::Instance().get(params.named_obj.rgauge_id).setRecordXML(record_xml);
164 
165  // Store the gauge rotation fields
166  TheNamedObjMap::Instance().create< LatticeColorMatrix >(params.named_obj.gauge_rot_id);
167  TheNamedObjMap::Instance().getData< LatticeColorMatrix >(params.named_obj.gauge_rot_id) = g;
168  TheNamedObjMap::Instance().get(params.named_obj.gauge_rot_id).setFileXML(file_xml);
169  TheNamedObjMap::Instance().get(params.named_obj.gauge_rot_id).setRecordXML(record_xml);
170  }
171 
172  pop(xml_out);
173 
174  snoop.stop();
175  QDPIO::cout << name << ": total time = "
176  << snoop.getTimeInSeconds()
177  << " secs" << std::endl;
178 
179  QDPIO::cout << name << ": ran successfully" << std::endl;
180 
181  END_CODE();
182  }
183 
184  }
185 
186 }
Inline measurement factory.
Inline random gauge transformation on a gauge field.
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
static T & Instance()
Definition: singleton.h:432
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 rgauge(multi1d< LatticeColorMatrix > &u, LatticeColorMatrix &g)
Do a random gauge transformation on the u fields.
Definition: rgauge.cc:24
void proginfo(XMLWriter &xml)
Print out basic information about this program.
Definition: proginfo.cc:24
Do a random gauge transformation on a gauge field.
Named object function std::map.
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
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()
::std::string string
Definition: gtest.h:1979
Print out basic info about this program.
Do a random gauge transformation on the u fields.
struct Chroma::InlineRandomTransfGaugeEnv::Params::NamedObject_t named_obj
void writeXML(XMLWriter &xml_out, const std::string &path)