CHROMA
central_tprec_fermact_qprop_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Propagator solver for a generic even-odd preconditioned fermion operator
3  *
4  * Solve for the propagator of a even-odd non-preconditioned fermion operator
5  */
6 
7 #include "qdp_config.h"
8 #if QDP_NS == 4
9 #if QDP_ND == 4
10 #if QDP_NC == 3
11 
12 
16 
17 namespace Chroma
18 {
19  //! Propagator for unpreconditioned space centrally preconditioned time FermAct
20  /*! \ingroup qprop
21  *
22  */
23  template<typename T, typename P, typename Q, template <typename, typename, typename> class L>
24  class CentralPrecTimeFermActQprop : public SystemSolver<T>
25  {
26  public:
27  //! Constructor
28  /*!
29  * \param A_ Linear operator ( Read )
30  * \param invParam_ inverter parameters ( Read )
31  */
32  CentralPrecTimeFermActQprop(Handle< L<T,P,Q> > A_,
33  Handle< LinOpSystemSolver<T> > invA_) : A(A_), invA(invA_)
34  {}
35 
36  //! Destructor is automatic
37  ~CentralPrecTimeFermActQprop() {}
38 
39  //! Return the subset on which the operator acts
40  const Subset& subset() const {return all;}
41 
42  //! Solver the linear system
43  /*!
44  * \param psi quark propagator ( Modify )
45  * \param chi source ( Read )
46  * \return number of CG iterations
47  */
48  SystemSolverResults_t operator() (T& psi, const T& chi) const
49  {
50  START_CODE();
51 
52  // We need to solve C_L^{1}( 1 + C_L D_s C_R )C_R^{-1} \psi = \chi
53  //
54  // We do this by solving ( 1 + C_L D_s C_R ) \psi' = \chi'
55  // with \chi' = C_L \chi
56  //
57  // and then at the end C_R^{-1] \psi = \psi' => \psi = C_R \psi'
58  //
59  // First compute \chi'
60  T chi_prime=zero;
61  QDPIO::cout << "Preparing LinOp" << std::endl;
62  A->cLeftLinOp(chi_prime, chi, PLUS);
63 
64 
65  psi=zero;
66  T psi_prime = zero;
67 
68  // Call inverter
69  QDPIO::cout << "Solving" << std::endl;
70  SystemSolverResults_t res = (*invA)(psi_prime, chi_prime);
71 
72 
73  QDPIO::cout <<"Reconstructing" << std::endl;
74  // Reconstruct psi = C_R psi_prime
75  A->cRightLinOp(psi, psi_prime, PLUS);
76 
77  // Compute residual
78  {
79  T r=zero;
80  A->unprecLinOp(r, psi, PLUS);
81  r -= chi;
82  res.resid = sqrt(norm2(r));
83  }
84 
85  END_CODE();
86 
87  return res;
88  }
89 
90  private:
91  // Hide default constructor
92  CentralPrecTimeFermActQprop() {}
93 
94  Handle< L<T,P,Q> > A;
95  Handle< LinOpSystemSolver<T> > invA;
96  };
97 
98  template<typename T, typename P, typename Q, template <typename, typename, typename> class L>
99  class Central2PrecTimeFermActQprop : public SystemSolver<T>
100  {
101  public:
102  //! Constructor
103  /*!
104  * \param A_ Linear operator ( Read )
105  * \param invParam_ inverter parameters ( Read )
106  */
107  Central2PrecTimeFermActQprop(Handle< L<T,P,Q> > A_,
108  Handle< LinOpSystemSolver<T> > invA_) : A(A_), invA(invA_)
109  {}
110 
111  //! Destructor is automatic
112  ~Central2PrecTimeFermActQprop() {}
113 
114  //! Return the subset on which the operator acts
115  const Subset& subset() const {return all;}
116 
117  //! Solver the linear system
118  /*!
119  * \param psi quark propagator ( Modify )
120  * \param chi source ( Read )
121  * \return number of CG iterations
122  */
123  SystemSolverResults_t operator() (T& psi, const T& chi) const
124  {
125  START_CODE();
126 
127  // We need to solve C_L^{1}( 1 + C_L D_s C_R )C_R^{-1} \psi = \chi
128  //
129  // We do this by solving ( 1 + C_L D_s C_R ) \psi' = \chi'
130  // with \chi' = C_L \chi
131  //
132  // and then at the end C_R^{-1] \psi = \psi' => \psi = C_R \psi'
133  //
134  // First compute \chi'
135  T chi_prime=zero;
136  QDPIO::cout << "Preparing LinOp" << std::endl;
137  A->leftLinOp(chi_prime, chi, PLUS);
138 
139 
140  psi=zero;
141  T psi_prime = zero;
142 
143  // Call inverter
144  QDPIO::cout << "Solving" << std::endl;
145  SystemSolverResults_t res = (*invA)(psi_prime, chi_prime);
146 
147 
148  QDPIO::cout <<"Reconstructing" << std::endl;
149  // Reconstruct psi = C_R psi_prime
150  A->rightLinOp(psi, psi_prime, PLUS);
151 
152  // Compute residual
153  {
154  T r=zero;
155  A->unprecLinOp(r, psi, PLUS);
156  r -= chi;
157  res.resid = sqrt(norm2(r));
158  }
159 
160  END_CODE();
161 
162  return res;
163  }
164 
165  private:
166  // Hide default constructor
167  Central2PrecTimeFermActQprop() {}
168 
169  Handle< L<T,P,Q> > A;
170  Handle< LinOpSystemSolver<T> > invA;
171  };
172 
173 
174  typedef LatticeFermion LF;
175  typedef multi1d<LatticeColorMatrix> LCM;
176 
177 
178  template<>
179  SystemSolver<LF>*
181  const GroupXML_t& invParam) const
182  {
183  return new CentralPrecTimeFermActQprop<LF,LCM,LCM,UnprecSpaceCentralPrecTimeLinearOperator>(Handle< UnprecSpaceCentralPrecTimeLinearOperator<LF,LCM,LCM> >((*this).linOp(state)),
184  Handle< LinOpSystemSolver<LF> >((*this).invLinOp(state,invParam)));
185  }
186 
187  template<>
188  SystemSolver<LF>*
190  const GroupXML_t& invParam) const
191  {
192  return new CentralPrecTimeFermActQprop<LF,LCM,LCM,ILUPrecSpaceCentralPrecTimeLinearOperator>(Handle< ILUPrecSpaceCentralPrecTimeLinearOperator<LF,LCM,LCM> >((*this).linOp(state)),
193  Handle< LinOpSystemSolver<LF> >((*this).invLinOp(state,invParam)));
194  }
195 
196 
197  template<>
198  SystemSolver<LF>*
200  const GroupXML_t& invParam) const
201  {
202  return new Central2PrecTimeFermActQprop<LF,LCM,LCM,ILU2PrecSpaceCentralPrecTimeLinearOperator>(Handle< ILU2PrecSpaceCentralPrecTimeLinearOperator<LF,LCM,LCM> >((*this).linOp(state)),
203  Handle< LinOpSystemSolver<LF> >((*this).invLinOp(state,invParam)));
204  }
205 
206 
207  //! Propagator for unpreconditioned space centrally preconditioned time FermAct
208  /*! \ingroup qprop
209  *
210  */
211  template<typename T, typename P, typename Q, template <typename, typename, typename> class L>
212  class EO3DPrecCentralPrecTimeFermActQprop : public SystemSolver<T>
213  {
214  public:
215  //! Constructor
216  /*!
217  * \param A_ Linear operator ( Read )
218  * \param invParam_ inverter parameters ( Read )
219  */
220  EO3DPrecCentralPrecTimeFermActQprop(Handle< L<T,P,Q> > A_,
221  Handle< LinOpSystemSolver<T> > invA_) : A(A_), invA(invA_)
222  {}
223 
224  //! Destructor is automatic
225  ~EO3DPrecCentralPrecTimeFermActQprop() {}
226 
227  //! Return the subset on which the operator acts
228  const Subset& subset() const {return all;}
229 
230  //! Solver the linear system
231  /*!
232  * \param psi quark propagator ( Modify )
233  * \param chi source ( Read )
234  * \return number of CG iterations
235  */
236  SystemSolverResults_t operator() (T& psi, const T& chi) const
237  {
238  START_CODE();
239 
240  // We need to solve C_L^{1}( 1 + C_L D_s C_R )C_R^{-1} \psi = \chi
241  //
242  // We do this by solving ( 1 + C_L D_s C_R ) \psi' = \chi'
243  // with \chi' = C_L \chi
244  //
245  // and then at the end C_R^{-1] \psi = \psi' => \psi = C_R \psi'
246  //
247  // First compute \chi'
248  T chi_prime;
249  A->cLeftLinOp(chi_prime, chi, PLUS,0);
250  A->cLeftLinOp(chi_prime, chi, PLUS,1);
251 
252  // Now I want chi'' = ( 1 0 ) ( chi'_e )
253  // ( -M_oe M_ee^{-1} 1 ) ( chi'_o )
254  T tmp1, tmp2;
255  A->evenEvenInvLinOp(tmp1, chi_prime, PLUS);
256  A->oddEvenLinOp(tmp2, tmp1, PLUS);
257  chi_prime[rb3[1]] -= tmp2;
258 
259 
260  T psi_prime = zero;
261  // Call inverter
262  QDPIO::cout << "Solving" << std::endl;
263  SystemSolverResults_t res = (*invA)(psi_prime, chi_prime);
264  A->evenEvenInvLinOp(psi_prime, chi_prime, PLUS);
265 
266  QDPIO::cout <<"Reconstructing" << std::endl;
267 
268  // ( 1 - M_ee^{-1} M_eo )
269  // ( 0 1 )
270  A->evenOddLinOp(tmp1, psi_prime, PLUS);
271  A->evenEvenInvLinOp(tmp2, tmp1, PLUS);
272  psi_prime[rb3[0]] -= tmp2;
273 
274  // Reconstruct psi = C_R psi_prime
275  A->cRightLinOp(psi, psi_prime, PLUS,0);
276  A->cRightLinOp(psi, psi_prime, PLUS,1);
277 
278  // Compute residual
279  {
280  T r;
281  A->unprecLinOp(r, psi, PLUS);
282  r -= chi;
283  res.resid = sqrt(norm2(r));
284  }
285 
286  END_CODE();
287 
288  return res;
289  }
290 
291  private:
292  // Hide default constructor
293  EO3DPrecCentralPrecTimeFermActQprop() {}
294 
295  Handle< L<T,P,Q> > A;
296  Handle< LinOpSystemSolver<T> > invA;
297  };
298 
299  template<>
300  SystemSolver<LF>*
302  const GroupXML_t& invParam) const
303  {
304  return new EO3DPrecCentralPrecTimeFermActQprop<LF,LCM,LCM,EO3DPrecSpaceCentralPrecTimeLinearOperator>(Handle< EO3DPrecSpaceCentralPrecTimeLinearOperator<LF,LCM,LCM> >((*this).linOp(state)),
305  Handle< LinOpSystemSolver<LF> >((*this).invLinOp(state,invParam)));
306  }
307 
308 
309 } // namespace Chroma
310 
311 
312 #endif
313 #endif
314 #endif
315 
virtual SystemSolver< T > * qprop(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return quark prop solver, solution of unpreconditioned system.
virtual SystemSolver< T > * qprop(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return quark prop solver, solution of unpreconditioned system.
virtual SystemSolver< T > * qprop(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return quark prop solver, solution of unpreconditioned system.
virtual SystemSolver< T > * qprop(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Return quark prop solver, solution of unpreconditioned system.
ILUPreconditioned spatial Preconditioned Temporal Wilson like fermion action.
ILUPreconditioned spatial Preconditioned Temporal Wilson like fermion action.
Double tmp2
Definition: mesq.cc:30
multi1d< Hadron2PtContraction_t > operator()(const multi1d< LatticeColorMatrix > &u)
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
@ 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
Double zero
Definition: invbicg.cc:106
LatticeFermion T
Definition: t_clover.cc:11
Unpreconditioned spatial Preconditioned Temporal Wilson like fermion action.