CHROMA
gauge_monomial.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Generic gauge action monomial wrapper
4  */
5 
6 #include "chromabase.h"
7 
12 
13 namespace Chroma
14 {
15  namespace GaugeMonomialEnv
16  {
17  namespace
18  {
19  //! Callback function for the factory
21  multi1d<LatticeColorMatrix> >*
22  createMonomial(XMLReader& xml, const std::string& path)
23  {
24  QDPIO::cout << "Create monomial: " << name << std::endl;
25 
26  return new GaugeMonomial(GaugeMonomialParams(xml, path));
27  }
28 
29  //! Local registration flag
30  bool registered = false;
31  }
32 
33  const std::string name("GAUGE_MONOMIAL");
34 
35  //! Register all the factories
36  bool registerAll()
37  {
38  bool success = true;
39  if (! registered)
40  {
41  success &= GaugeActsEnv::registerAll();
42  success &= TheMonomialFactory::Instance().registerObject(name, createMonomial);
43  registered = true;
44  }
45  return success;
46  }
47  } //end namespace GaugeMonomialEnv
48 
49 
50 
51  // Read the parameters
52  GaugeMonomialParams::GaugeMonomialParams(XMLReader& xml_in, const std::string& path)
53  {
54  // Get the top of the parameter XML tree
55  XMLReader paramtop(xml_in, path);
56 
57  try {
58  // Read the inverter Parameters
59  XMLReader xml_tmp(paramtop, "./GaugeAction");
60  std::ostringstream os;
61  xml_tmp.print(os);
62  gauge_act = os.str();
63 
64  }
65  catch(const std::string& s) {
66  QDPIO::cerr << "Caught Exception while reading parameters: " << s <<std::endl;
67  QDP_abort(1);
68  }
69 
70  QDPIO::cout << "GaugeMonomialParams: read \n" << gauge_act << std::endl;
71  }
72 
73  //! Read Parameters
74  void read(XMLReader& xml, const std::string& path,
76  {
77  GaugeMonomialParams tmp(xml, path);
78  params = tmp;
79  }
80 
81  //! Write Parameters
82  void write(XMLWriter& xml, const std::string& path,
84  {
85  // Not implemented
86  QDPIO::cerr << GaugeMonomialEnv::name << ": write not implemented" << std::endl;
87  QDP_abort(1);
88  }
89 
90 
91  // Constructor
93  {
94  std::istringstream is(param_.gauge_act);
95  XMLReader gaugeact_reader(is);
96 
97  // Get the name of the gauge act
98  std::string gaugeact_string;
99  try {
100  read(gaugeact_reader, "/GaugeAction/Name", gaugeact_string);
101  }
102  catch( const std::string& e) {
103  QDPIO::cerr << "Error grepping the gaugeact name: " << e<< std::endl;
104  QDP_abort(1);
105  }
106 
107  // Throw an exception if not found
108  gaugeact = TheGaugeActFactory::Instance().createObject(gaugeact_string,
109  gaugeact_reader,
110  "/GaugeAction");
111  }
112 
113 } //end namespace Chroma
114 
115 
Primary include file for CHROMA library code.
Wrapper class for gauge monomials.
Handle< GaugeAction< P, Q > > gaugeact
An abstract monomial class, for inexact algorithms.
Definition: abs_monomial.h:43
static T & Instance()
Definition: singleton.h:432
Generic gauge action monomial wrapper.
Fermion action factories.
All gauge actions.
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
Monomial factories.
static bool registered
Local registration flag.
Monomial< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > * createMonomial(XMLReader &xml, const std::string &path)
Callback function for the factory.
bool registerAll()
Register all the factories.
const std::string name
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
multi1d< LatticeFermion > s(Ncb)
::std::string string
Definition: gtest.h:1979