CHROMA
lcm_toplevel_integrator.cc
Go to the documentation of this file.
1 #include "chromabase.h"
6 
7 namespace Chroma {
8 
9  //! A reader for an element of the copy list
10  void read(XMLReader& xml, const std::string& path, IDPair& p)
11  {
12  try {
13  XMLReader paramtop(xml, path);
14  read(paramtop, "./copyFrom", p.source);
15  read(paramtop, "./copyTo", p.dest);
16  }
17  catch( const std::string& e) {
18  QDPIO::cout << "Caught exception reading XML: " << e << std::endl;
19  QDP_abort(1);
20  }
21  }
22 
23  //! A Writer for an element of the copy list
24  void write(XMLWriter& xml, const std::string& path, const IDPair& p)
25  {
26  push(xml, path);
27  write(xml, "copyFrom", p.source);
28  write(xml, "copyTo", p.dest);
29  pop(xml);
30  }
31 
33  try {
34  XMLReader paramtop(xml, path);
35  read(paramtop, "tau0", tau0); // Read Traj Length
36  copy_list.resize(0); // Initialize 0 length list
37  if( paramtop.count("./copyList") > 0 ) {
38  read(paramtop, "./copyList", copy_list); // Read Copy List
39  }
40 
41  //Read the integrator XML
42  XMLReader integrator_xml_reader(paramtop, "./Integrator");
43  std::ostringstream os;
44  integrator_xml_reader.print(os);
45  integrator_xml = os.str();
46 
47  // Look for anisotropic integration.
48  // (Optional)
49  if( paramtop.count("anisoP") == 1 ) {
50  read(paramtop, "anisoP", anisoP);
51  read(paramtop, "t_dir", t_dir);
52  if( t_dir < 0 || t_dir >= Nd ) {
53  QDPIO::cout << "Value of t_dir must be 0 <= t_dir < Nd. t_dir is " << t_dir << std::endl;
54  QDP_abort(1);
55  }
56  read(paramtop, "xi_mom", xi_mom);
57  }
58  else {
59  // If there is no data then set defaults for isotropy
60  anisoP = false;
61  t_dir = 3;
62  xi_mom = 1;
63  }
64 
65  }
66  catch(const std::string& e) {
67  QDPIO::cout << "Caught Exception Reading XML: " << e << std::endl;
68  QDP_abort(1);
69  }
70 
71 
72  }
73 
74  //! Read the Integrator Params
75  void read(XMLReader& xml, const std::string& path, LCMToplevelIntegratorParams& p)
76  {
78  p = tmp;
79  }
80 
81  //! Write the Integrator Params
82  void write(XMLWriter& xml, const std::string& path, const LCMToplevelIntegratorParams& p)
83  {
84  push(xml, path);
85  write(xml, "tau0", p.tau0);
86  write(xml, "copyList", p.copy_list);
87  std::istringstream int_is(p.integrator_xml);
88  XMLReader int_reader(int_is);
89  xml << int_reader;
90  if( p.anisoP ) {
91  write(xml, "anisoP", p.anisoP);
92  write(xml, "t_dir", p.t_dir);
93  write(xml, "xi_mom", p.xi_mom);
94  }
95  pop(xml);
96  }
97 
98 
101  params(p) {
102 
103  std::istringstream is( p.integrator_xml );
104  XMLReader integrator_reader( is );
105  std::string root="/Integrator";
106  std::string integrator_name;
107  try {
108  read(integrator_reader, "/Integrator/Name", integrator_name);
109  }
110  catch( const std::string& e) {
111  QDPIO::cout << "Caught Exception while processing XML: " << e << std::endl;
112  QDP_abort(1);
113  }
114 
116  multi1d<LatticeColorMatrix> > > h(
117  TheMDComponentIntegratorFactory::Instance().createObject(integrator_name, integrator_reader, root));
118 
119  top_integrator = h;
120 
121  // Deal with Anisotropic integration
122  if ( p.anisoP ) {
123  Real factor = Real(1) / p.xi_mom;
124  // Set the step size
125  LCMMDIntegratorSteps::theAnisoStepSizeArray::Instance().setAnisoStepSize(p.t_dir, factor);
126 
127  }
128  }
129 
132  multi1d<LatticeColorMatrix> > > MHandle;
133 
134  QDPIO::cout << "Working through Copy List of length " << params.copy_list.size() << std::endl;
135  // Loop through all the items in the copy list
136  for(int i=0; i < params.copy_list.size(); i++) {
137  std::string source_id = params.copy_list[i].source;
138  std::string dest_id = params.copy_list[i].dest;
139  MHandle src_mon =
140  TheNamedObjMap::Instance().getData<MHandle>(source_id);
141 
142  MHandle dest_mon =
143  TheNamedObjMap::Instance().getData<MHandle>(dest_id);
144 
145  QDPIO::cout << "Copying monomial: " << source_id << " to " << dest_id<< std::endl;
146  dest_mon->setInternalFields( *src_mon );
147  }
148  }
149 
150 
151 }
Primary include file for CHROMA library code.
Class for counted reference semantics.
Definition: handle.h:33
LCMToplevelIntegratorParams params
void copyFields(void) const
Copy fields between the monomials of a copy list.
Handle< AbsComponentIntegrator< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > top_integrator
LCMToplevelIntegrator(const LCMToplevelIntegratorParams &p)
Construct from parameters.
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.
Params params
Integrator factories.
Nd
Definition: meslate.cc:74
Named object function std::map.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
int i
Definition: pbg5p_w.cc:55
pop(xml_out)
::std::string string
Definition: gtest.h:1979
A Struct for holding pairs of IDs in the copy list.
A Structure to hold the top level parameters.
LCMToplevelIntegratorParams(XMLReader &xml, const std::string &path)
Construct from XML.