CHROMA
t_invert4_precwilson.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 #include <sstream>
4 #include <iomanip>
5 #include <string>
6 
7 #include <cstdio>
8 
9 #include <stdlib.h>
10 #include <sys/time.h>
11 #include <math.h>
12 
13 #include "chroma.h"
14 
16 
18 #include "actions/ferm/invert/quda_solvers/syssolver_linop_clover_quda_0.3.h"
21 #include <string>
22 using namespace Chroma;
23 
24 struct AppParams {
25  multi1d<int> nrow;
29 };
30 
31 
32 
33 void checkInverter(const AppParams& p, multi1d<LatticeColorMatrix>& u)
34 {
35 
36  typedef LatticeFermion T;
37  typedef multi1d<LatticeColorMatrix> Q;
38  typedef multi1d<LatticeColorMatrix> P;
39 
40  std::istringstream is(p.fermact.xml);
41  XMLReader fermact_xml(is);
42  Handle< WilsonTypeFermAct<T,P,Q> > S_f ( TheWilsonTypeFermActFactory::Instance().createObject(p.fermact.id, fermact_xml, p.fermact.path) );
43  //S_f(
44  // new EvenOddPrecCloverFermAct(CreateFermStateEnv::reader(fermact_xml, p.fermact.path), CloverFermActParams(fermact_xml, p.fermact.path)));
45 
46 
47  Handle< FermState<T,P,Q> > connect_state( S_f->createState(u) );
48 
49  Handle< LinearOperator<LatticeFermion> > D_op( S_f->linOp(connect_state) );
50 
51  std::istringstream is2(p.quda_solver.xml);
52  XMLReader quda_xml(is2);
53  Handle< LinOpSystemSolver<LatticeFermion> > Solver( TheLinOpFermSystemSolverFactory::Instance().createObject(p.quda_solver.id, quda_xml, p.quda_solver.path, connect_state, D_op));
54 
55  //Handle< LinOpSystemSolver<LatticeFermion> > QUDASolver( new LinOpSysSolverQUDAClover(D_op, connect_state, SysSolverQUDACloverParams(quda_xml, p.quda_solver.path)));
56 
57 T chi, psi;
58 
59 // Get Initial Vector
60  chi=zero;
61  gaussian(chi,rb[1]);
62  psi=zero;
63  (*Solver)(psi,chi);
64 
65  T r = chi;
66 T tmp;
67 (*D_op)(tmp, psi, PLUS);
68 r[rb[1]] -= tmp;
69 
70 
71 QDPIO::cout << "||r||= " << sqrt(norm2(r, rb[1])) << std::endl;
72 QDPIO::cout << "||r||/||b||= " << sqrt(norm2(r, rb[1]))/sqrt(norm2(chi,rb[1])) << std::endl;
73 
74 
75 
76 }
77 
78 
79 void read(XMLReader& r, const std::string path, AppParams& p)
80 {
81  read(r, "nrow", p.nrow);
82  read(r, "Cfg", p.inputCfg);
83  p.fermact = readXMLGroup(r, "FermionAction", "FermAct");
84  p.quda_solver = readXMLGroup(r, "InvertParam", "invType");
85 }
86 
87 bool linkageHack(void)
88 {
89  bool foo = true;
90 
91  // Inline Measurements
94 
95  return foo;
96 }
97 
98 int main(int argc, char **argv)
99 {
100  // Put the machine into a known state
101  Chroma::initialize(&argc, &argv);
102  QDPIO::cout << "Linkage = " << linkageHack() << std::endl;
103 
104 
106 
107  XMLReader xml_in;
108  try
109  {
110  xml_in.open(Chroma::getXMLInputFileName());
111  read(xml_in, "/Param", params);
112  }
113  catch(const std::string& e)
114  {
115  QDPIO::cerr << "Caught Exception reading XML: " << e << std::endl;
116  QDP_abort(1);
117  }
118  Layout::setLattSize(params.nrow);
119  Layout::create();
120 
121  multi1d<LatticeColorMatrix> u(Nd);
122  XMLReader gauge_file_xml, gauge_xml;
123  gaugeStartup(gauge_file_xml, gauge_xml, u, params.inputCfg);
124  unitarityCheck(u);
125 
126  // Setup the lattice
127 
128  XMLFileWriter& xml_out = Chroma::getXMLOutputInstance();
129  push(xml_out,"t_invert");
130  push(xml_out,"params");
131  write(xml_out, "nrow", params.nrow);
132  pop(xml_out); // Params
133 
134  // Measure the plaquette on the gauge
135  MesPlq(xml_out, "Observables", u);
136  xml_out.flush();
137 
139 
140  pop(xml_out);
141  xml_out.close();
142 
144 
145  exit(0);
146 }
Primary include file for CHROMA in application codes.
Class for counted reference semantics.
Definition: handle.h:33
static T & Instance()
Definition: singleton.h:432
All ferm create-state method.
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 unitarityCheck(const multi1d< LatticeColorMatrixF3 > &u)
Check the unitarity of color matrix in SU(N)
Definition: unit_check.cc:20
void gaugeStartup(XMLReader &gauge_file_xml, XMLReader &gauge_xml, multi1d< LatticeColorMatrix > &u, Cfg_t &cfg)
Initialize the gauge fields.
GroupXML_t readXMLGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
Params params
Nd
Definition: meslate.cc:74
bool registerAll()
Register all the factories.
bool registerAll()
Register all the factories.
multi1d< LatticeColorMatrix > P
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
gaussian(aux)
static multi1d< LatticeColorMatrix > u
LinOpSysSolverMGProtoClover::Q Q
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
LinOpSysSolverMGProtoClover::T T
void initialize(int *argc, char ***argv)
Chroma initialisation routine.
Definition: chroma_init.cc:114
@ PLUS
Definition: chromabase.h:45
void finalize(void)
Chroma finalization routine.
Definition: chroma_init.cc:308
multi1d< LatticeFermion > chi(Ncb)
bool linkageHack(void)
Definition: const_hmc.cc:660
std::string getXMLInputFileName()
Get input file name.
Definition: chroma_init.cc:88
LatticeFermion psi
Definition: mespbg5p_w.cc:35
pop(xml_out)
void MesPlq(const multi1d< LatticeColorMatrixF3 > &u, multi2d< Double > &plane_plaq, Double &link)
Definition: mesplq.cc:83
XMLFileWriter & getXMLOutputInstance()
Get xml output instance.
Definition: chroma_init.cc:359
const WilsonTypeFermAct< multi1d< LatticeFermion > > & S_f
Definition: pbg5p_w.cc:27
Double zero
Definition: invbicg.cc:106
::std::string string
Definition: gtest.h:1979
GroupXML_t fermact
multi1d< int > nrow
GroupXML_t quda_solver
Gauge configuration structure.
Definition: cfgtype_io.h:16
Hold group xml and type id.
Solve a M*psi=chi linear system by CG2.
Factory for solving M*psi=chi where M is not hermitian or pos. def.
std::string fermact_xml
void checkInverter(const AppParams &p, multi1d< LatticeColorMatrix > &u)
int main(int argc, char **argv)