CHROMA
eoprec_fermact_qprop_array.cc
Go to the documentation of this file.
1 // $Log: eoprec_fermact_qprop_array.cc,v $
2 // Revision 3.1 2006-10-19 16:01:33 edwards
3 // Split apart the fermact.h file into lots of separate bits to make it
4 // easier to manage. Split up the linearop.h file more as well. Split
5 // up and rearranged the tprec_linop.h files for the anticipated
6 // new time-preconditioning. Added some new functionality here.
7 // For neatness sake, moved and renamed
8 // all the "prec_*" files (which are specific to 4d even-odd preconditioning)
9 // to "eoprec_*" filenames.
10 //
11 // Revision 3.3 2006/07/03 15:26:09 edwards
12 // Changed FermionAction API to produce system solver classes. No longer have
13 // a fixed InvertParam set. Removed old inverter enum and support. Have default
14 // creation for inverters to solve M*psi=chi, MdagM*psi=chi, and multi-shift
15 // support. Some older files still have explicit calls to CG solver.
16 //
17 // Revision 3.2 2006/06/11 06:30:32 edwards
18 // Change in interface. The quarkProp routines now all take a "numRetries"
19 // variable for the number of times to call the qprop routine. The propagator
20 // regression tests have all been up to version 10 to read this new variable.
21 // The SystemSolver routines now all return a SystemSolverResults_t struct
22 // instead of an int of "n_count" . A residual of the unpreconditioned
23 // system of equations for the qprop and qpropT is computed.
24 //
25 // Revision 3.1 2006/04/11 03:02:59 edwards
26 // Removed debugging.
27 //
28 // Revision 3.0 2006/04/03 04:58:53 edwards
29 // Major overhaul of fermion and gauge action interface. Basically,
30 // all fermacts and gaugeacts now carry out <T,P,Q> template parameters. These are
31 // the fermion type, the "P" - conjugate momenta, and "Q" - generalized coordinates
32 // in the sense of Hamilton's equations. The fermbc's have been rationalized to never
33 // be over multi1d<T>. The "createState" within the FermionAction is now fixed meaning
34 // the "u" fields are now from the coordinate type. There are now "ConnectState" that
35 // derive into FermState<T,P,Q> and GaugeState<P,Q>.
36 //
37 // Revision 2.1 2005/10/06 18:09:23 flemingg
38 // Fixed a malfeature exposed by GCC 4.0.
39 //
40 // Revision 2.0 2005/09/25 21:04:30 edwards
41 // Moved to version 2.0
42 //
43 // Revision 1.16 2005/05/18 15:41:56 bjoo
44 // Speeded up CFZ Op
45 //
46 // Revision 1.15 2005/03/02 16:27:15 bjoo
47 // Removed chi.resize() stuff from LinopArrays
48 //
49 // Revision 1.14 2005/02/21 19:28:59 edwards
50 // Changed initHeader's to be instead the appropriate default constructor
51 // for the ChiralParam, AnisoParam and QQQ structs. Removed all
52 // calls to initHeader. Changed quarkProp routines to instead take
53 // the appropriate SystemSolver instead of fermact. Added AnisoParam
54 // support for DWF and SSE DWF.
55 //
56 // Revision 1.13 2005/01/07 05:00:10 edwards
57 // Fixed up dwf_fermact to use specialized qpropT. Now, have exposed
58 // a typedef version of DWFQpropT and the optimized version is defined
59 // to this if --enable-dwf-cg is on.
60 //
61 // Revision 1.12 2005/01/02 05:21:10 edwards
62 // Rearranged top-level fermion actions and linear operators.
63 // The deriv is pushed up much higher. This has the effect that
64 // now the "P" type (conjugate momentum type) is carried around
65 // in DiffFermAct4D<T,P> and below carry this "P" template param.
66 // All fermacts now have at least default deriv support (possibly
67 // Not Implemented error). Made qprop and qpropT now go through
68 // factory functions.
69 //
70 // Revision 1.11 2004/12/29 22:13:41 edwards
71 // Rearranged the top-level FermionAction structure. Moved up
72 // 5d-style actions to be a FermAct5D and there is a FermAct4D.
73 // Consolidated quarkprop routines and fermact factories.
74 //
75 // Revision 1.10 2004/12/12 21:22:17 edwards
76 // Major overhaul of fermact and linearop class structure. Merged ApproxLinOp
77 // into LinOp. Removed dsdu stuff - now in linops. Introduced levels of
78 // fermacts (base or not) that have derivs. All low level fermacts/linops
79 // have an additional template param for type of conjugate momenta in
80 // derivative. Made all fermacts and linops within chroma namespace.
81 //
82 // Revision 1.9 2004/11/17 16:52:24 edwards
83 // Improved some comments
84 //
85 // Revision 1.8 2004/10/08 13:20:15 bjoo
86 // IBM Fixes
87 //
88 // Revision 1.7 2004/09/08 02:48:26 edwards
89 // Big switch-over of fermact IO. New fermact startup mechanism -
90 // now using Singleton Factory object. Moved quarkprop4 to be
91 // a virtual func with top level FermionAction. Disconnected
92 // zolo4d and 5d fermacts temporarily. Removing usage of old
93 // fermact and subsequently md,gaugeact IO mechanisms.
94 //
95 // Revision 1.6.2.1 2004/09/02 16:00:07 bjoo
96 // Trolled beneath the fermact mountains and changed the invocations
97 // of the inverters to conform to the new inverter interface (invParam -- vs RsdCG, MaxCG and friends) - also in the qprop_files too.
98 //
99 // I HAVE REMOVED ZOLOTAREV4D and ZOLOTAREV5D from the build as these
100 // will need extensive reworking to keep those params inside them
101 // (simply too many). I will get them to conform later. Use the
102 // production branch if you need access to those
103 //
104 // I have added the various LOKI based files (Alexandrescu) to the
105 // Makefile.am so that things install correctly.
106 //
107 // I made the propagator code go through the factory invokation to
108 // do a propagator calculation with prec wilson fermions.
109 //
110 // Interestingly the linkage_hack appeared to be optimised away in its
111 // old form. I turned it into a function that returns the "foo" within,
112 // so it cannot be compiled away. Interestingly, it still doesn't actually
113 // need to be CALLED.
114 //
115 // Main achievements:
116 // Library compiles
117 // Propagator runs with suitable fermacts (I should check DWF etc)
118 //
119 // Revision 1.6 2004/07/28 02:38:02 edwards
120 // Changed {START,END}_CODE("foo") to {START,END}_CODE().
121 //
122 // Revision 1.5 2004/02/05 20:01:47 kostas
123 // Fixed the chi_tmp bug to all inverters
124 //
125 /*! \file
126  * \brief Propagator solver for a generic even-odd preconditioned fermion operator
127  *
128  * Solve for the propagator of a even-odd non-preconditioned fermion operator
129  */
130 
131 #include "chromabase.h"
134 
135 namespace Chroma
136 {
137  //! Propagator of a generic even-odd preconditioned fermion linear operator
138  /*!
139  * \param psi quark propagator ( Modify )
140  * \param chi source ( Read )
141  * \return number of CG iterations
142  */
143  template <>
145  PrecFermAct5DQprop<LatticeFermion,
146  multi1d<LatticeColorMatrix>,
147  multi1d<LatticeColorMatrix> >::operator()(multi1d<LatticeFermion>& psi,
148  const multi1d<LatticeFermion>& chi) const
149  {
150  START_CODE();
151 
152  const int N5 = size();
153 
154  if (psi.size() != size() && chi.size() != size())
155  QDP_error_exit("PrecFA5DQprop: sizes wrong");
156 
157  /* Step (i) */
158  /* chi_tmp_o = chi_o - D_oe * A_ee^-1 * chi_e */
159  multi1d<LatticeFermion> chi_tmp(N5);
160  {
161  multi1d<LatticeFermion> tmp1(N5);
162  multi1d<LatticeFermion> tmp2(N5);
163 
164  A->evenEvenInvLinOp(tmp1, chi, PLUS);
165  A->oddEvenLinOp(tmp2, tmp1, PLUS);
166  for(int n=0; n < N5; ++n)
167  chi_tmp[n][rb[1]] = chi[n] - tmp2[n];
168  }
169 
170  // Call inverter
171  // psi = M^(-1) psi
172  SystemSolverResults_t res = (*invA)(psi, chi_tmp);
173 
174  /* Step (ii) */
175  /* psi_e = A_ee^-1 * [chi_e - D_eo * psi_o] */
176 
177  {
178  multi1d<LatticeFermion> tmp1(N5);
179  multi1d<LatticeFermion> tmp2(N5);
180 
181  A->evenOddLinOp(tmp1, psi, PLUS);
182 
183  for(int n=0; n < N5; ++n)
184  tmp2[n][rb[0]] = chi[n] - tmp1[n];
185 
186 
187  A->evenEvenInvLinOp(psi, tmp2, PLUS);
188 
189  }
190 
191  // Compute residual
192  {
193  multi1d<LatticeFermion> r(N5);
194  A->unprecLinOp(r, psi, PLUS);
195  r -= chi;
196  res.resid = sqrt(norm2(r));
197  }
198 
199  END_CODE();
200 
201  return res;
202  }
203 
204 
205  typedef LatticeFermion LF;
206  typedef multi1d<LatticeColorMatrix> LCM;
207 
208  //! Propagator of a generic even-odd preconditioned fermion linear operator
209  template<>
212  const GroupXML_t& invParam) const
213  {
216  Handle< LinOpSystemSolverArray<LF> >((*this).invLinOp(state,invParam)));
217  }
218 
219 
220 } // namespace Chroma
Primary include file for CHROMA library code.
Even-odd preconditioned linear operator including derivatives for arrays.
Definition: eoprec_linop.h:312
virtual SystemSolverArray< T > * qpropT(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return quark prop solver, solution of unpreconditioned system.
Support class for fermion actions and linear operators.
Definition: state.h:94
Class for counted reference semantics.
Definition: handle.h:33
SystemSolver disambiguator.
Propagator of a generic even-odd preconditioned 5D fermion linear operator.
Linear system solvers of arrays.
Definition: syssolver.h:62
Propagator solver for a generic even-odd preconditioned fermion operator.
Conjugate-Gradient algorithm for a generic Linear Operator.
unsigned n
Definition: ldumul_w.cc:36
Double tmp2
Definition: mesq.cc:30
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
QDP_error_exit("too many BiCG iterations", n_count, rsd_sq, cp, c, re_rvr, im_rvr, re_a, im_a, re_b, im_b)
@ PLUS
Definition: chromabase.h:45
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
LatticeStaggeredFermion LF
Definition: asqtad_qprop.cc:19
multi1d< LatticeColorMatrix > LCM
Definition: asqtad_qprop.cc:20
START_CODE()
A(A, psi, r, Ncb, PLUS)
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
Hold group xml and type id.
Holds return info from SystemSolver call.
Definition: syssolver.h:17