CHROMA
poly_cheb_fermact_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Chebyshev polynomial fermion action
3  */
4 
5 #include "chromabase.h"
9 
12 
15 
16 namespace Chroma
17 {
18  //! Hooks to register the class with the fermact factory
19  namespace PolyChebFermActEnv
20  {
21  //! Callback function
22  WilsonTypeFermAct<LatticeFermion,
23  multi1d<LatticeColorMatrix>,
24  multi1d<LatticeColorMatrix> >* createFermAct4D(XMLReader& xml_in,
25  const std::string& path)
26  {
27  return new PolyChebFermAct(CreateFermStateEnv::reader(xml_in, path),
28  PolyChebFermActParams(xml_in, path));
29  }
30 
31  //! Callback function
32  /*! Differs in return type */
33  FermionAction<LatticeFermion,
34  multi1d<LatticeColorMatrix>,
35  multi1d<LatticeColorMatrix> >* createFermAct(XMLReader& xml_in,
36  const std::string& path)
37  {
38  return createFermAct4D(xml_in, path);
39  }
40 
41  //! Name to be used
42  const std::string name = "POLYNOMIAL_CHEBYSHEV";
43 
44  //! Local registration flag
45  static bool registered = false;
46 
47  //! Register all the factories
48  bool registerAll()
49  {
50  bool success = true;
51  if (! registered)
52  {
54  success &= Chroma::TheFermionActionFactory::Instance().registerObject(name, createFermAct);
56  registered = true;
57  }
58  return success;
59  }
60  }
61 
62 
63  //! Read parameters
65  {
66  XMLReader paramtop(xml, path);
67 
68  // Read the chebyshev params
69  {
70  XMLReader chebtop(paramtop, "PolyParams");
71  read(chebtop, "degree", polyParams.degree);
72  read(chebtop, "UpperBound", polyParams.UpperBound);
73  read(chebtop, "LowerBound", polyParams.LowerBound);
74  read(chebtop, "order", polyParams.order);
75  }
76 
77  // Read the underlying fermion action
78  try
79  {
80  if(paramtop.count("AuxFermAct") == 1 )
81  {
82  XMLReader xml_tmp(paramtop, "AuxFermAct");
83  std::ostringstream os;
84  xml_tmp.print(os);
85  AuxFermAct = os.str();
86  }
87  else
88  {
89  throw std::string("No auxilliary action");
90  }
91  }
92  catch(const std::string& e) {
93  QDPIO::cerr << PolyChebFermActEnv::name << ": Caught Exception reading params: " << e << std::endl;
94  QDP_abort(1);
95  }
96 
97  }
98 
99  //! Read parameters
100  void read(XMLReader& xml, const std::string& path, PolyChebFermActParams& param)
101  {
102  PolyChebFermActParams tmp(xml, path);
103  param = tmp;
104  }
105 
106 
107  //! General FermBC
109  const PolyChebFermActParams& param_) :
110  cfs(cfs_), param(param_)
111  {
112  QDPIO::cout << "Constructing PolyChebFermAct from params" << std::endl;
113  std::istringstream xml_s(param.AuxFermAct);
114  XMLReader fermacttop(xml_s);
115  const std::string fermact_path = "/AuxFermAct";
116 
117  try
118  {
119  std::string auxfermact;
120  read(fermacttop, fermact_path + "/FermAct", auxfermact);
121  QDPIO::cout << "AuxFermAct: " << auxfermact << std::endl;
122 
123  // Generic Wilson-Type stuff
125  S_f(TheWilsonTypeFermActFactory::Instance().createObject(auxfermact,
126  fermacttop,
127  fermact_path));
128 
129  fermact = S_f;
130  }
131  catch (const std::string& e)
132  {
133  // General breakage Scenario
134  QDPIO::cerr << "Error reading data: " << e << std::endl;
135  throw;
136  }
137 
138  }
139 
140  //! Produce a linear operator for this action
141  PolyLinearOperator<LatticeFermion,
142  multi1d<LatticeColorMatrix>,
143  multi1d<LatticeColorMatrix> >*
145  {
147  MdagM(fermact->lMdagM(state));
148 
149  return new lpoly<T,P,Q>(MdagM,
153  // param.polyParams.order); // comment this out to use
154  // bit reversal ordering
155  }
156 
157  //! Produce a linear operator for this action
158  DiffLinearOperator<LatticeFermion,
159  multi1d<LatticeColorMatrix>,
160  multi1d<LatticeColorMatrix> >*
162  {
165 
166  return new PolyPrec<T,P,Q>(M, Pol);
167  }
168 
169 
170  //! Return a linear operator solver for this action to solve M*psi=chi
173  const GroupXML_t& invParam) const
174  {
175  std::istringstream xml(invParam.xml);
176  XMLReader paramtop(xml);
177 
178  // Return solver for [Q*P(Q^2)*Q]^{-1} X = phi
179  return ThePolyPrecFermSystemSolverFactory::Instance().createObject(invParam.id,
180  paramtop,
181  invParam.path,
183  }
184 
185 }
Primary include file for CHROMA library code.
Create a fermion connection state.
Definition: create_state.h:69
Differentiable Linear Operator.
Definition: linearop.h:98
Support class for fermion actions and linear operators.
Definition: state.h:94
Base class for quadratic matter actions (e.g., fermions)
Definition: fermact.h:53
Class for counted reference semantics.
Definition: handle.h:33
Chebyshev Polynomial fermion action.
Handle< WilsonTypeFermAct< T, P, Q > > fermact
PolyChebFermActParams param
PolyLinearOperator< T, P, Q > * polyLinOp(Handle< FermState< T, P, Q > > state) const
Produce a linear operator M^dag.M for this action.
DiffLinearOperator< T, P, Q > * polyPrecLinOp(Handle< FermState< T, P, Q > > state) const
Produce a linear operator for this action.
PolyPrecSystemSolver< T > * invPolyPrec(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return a linear operator solver for this action to solve M*psi=chi.
Polynomial linear operator including derivatives.
Definition: polylinop.h:23
Polynomial preconditioner.
Definition: polprec_op.h:25
static T & Instance()
Definition: singleton.h:432
Wilson-like fermion actions.
Definition: fermact.orig.h:344
Polynomial operator.
Definition: polynomial_op.h:27
All ferm create-state method.
Fermion action factories.
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
Handle< CreateFermState< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > reader(XMLReader &xml_in, const std::string &path)
Helper function for the CreateFermState readers.
const std::string name
Name to be used.
static bool registered
Local registration flag.
WilsonTypeFermAct< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > * createFermAct4D(XMLReader &xml_in, const std::string &path)
Callback function.
bool registerAll()
Register all the factories.
FermionAction< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > * createFermAct(XMLReader &xml_in, const std::string &path)
Callback function.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
const WilsonTypeFermAct< multi1d< LatticeFermion > > & S_f
Definition: pbg5p_w.cc:27
::std::string string
Definition: gtest.h:1979
Maybe usefull for polynomial preconditioning. It contructs an operator that is , where ,...
Chebyshev polynomial fermion action.
Polynomial filter for 4D Dirac operators. It creates an approximation to 1/Q^2 in the range with wh...
Hold group xml and type id.
Params for Chebyshev polynomial preconditioner.
struct Chroma::PolyChebFermActParams::PolyParams polyParams
SystemSolver disambiguator.
Handle< LinearOperator< T > > MdagM
Register linop system solvers that solve PolyPrec*psi=chi.
Factory for solving PolyPrec*psi=chi where PolyPrec is hermitian and pos. def.