CHROMA
ilu2prec_s_cprec_t_wilsonlike_linop_w.h
Go to the documentation of this file.
1 #ifndef ILU2PREC_S_CPREC_T_WILSONLIKE_LINOP_W_H
2 #define ILU2PREC_S_CPREC_T_WILSONLIKE_LINOP_W_H
3 
4 #include "qdp_config.h"
5 #if QDP_NS == 4
6 #if QDP_ND == 4
7 #if QDP_NC == 3
8 
9 #include "linearop.h"
10 #include "central_tprec_linop.h"
11 
14 
15 namespace Chroma
16 {
17  //! Wilson Dirac Operator - Unpreconditioned in Space, Centrally Preconditioned in time
18  /*!
19  * \ingroup linop
20  *
21  * This routine is specific to Wilson fermions!
22  *
23  * ~ ~+
24  */
25 
26  class ILU2PrecSCprecTWilsonLikeLinOp :
27  public ILU2PrecSpaceCentralPrecTimeLinearOperator<LatticeFermion,
28  multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >
29  {
30  public:
31  // Typedefs to save typing
32  typedef LatticeFermion T;
33  typedef multi1d<LatticeColorMatrix> P;
34  typedef multi1d<LatticeColorMatrix> Q;
35  typedef PScalar<PColorMatrix<RComplex<REAL>, 3> > CMat; // Useful type: ColorMat with no Outer<>
36  typedef PSpinVector<PColorVector<RComplex<REAL>, 3>, 2> HVec_site; // Useful type: Half Vec with no Outer<>
37 
38  //! Destructor is automatic
39  virtual ~ILU2PrecSCprecTWilsonLikeLinOp() {}
40 
41 
42  protected:
43 
44 
45 
46  // Blanks to fill out...
47  virtual const multi3d< int >& getTsiteArray(void) const = 0;
48  virtual const multi3d< CMat >& getPMatrixArray(void) const = 0;
49  virtual const multi3d< CMat >& getPMatrixDaggerArray(void) const = 0;
50  virtual const multi2d< CMat >& getQMatrixInvArray(void) const = 0;
51  virtual const multi2d< CMat >& getQMatrixDaggerInvArray(void) const = 0;
52  virtual const Real& getFactor() const = 0;
53  virtual const Real& getInvFactor() const = 0;
54  virtual const multi1d< LatticeColorMatrix>& getLinks(void) const = 0;
55  virtual int getTMax(void) const = 0;
56  public:
57 
58  //! Return the fermion BC object for this linear operator
59  const FermBC<T,P,Q>& getFermBC() const = 0;
60 
61  //! The time direction
62  int tDir() const {
63  return 3;
64  }
65 
66 
67  // A = 0 so A-1 = -1 => (A-1) psi = -psi and also for the dagger.
68 
69 
70  //! Flopcounter
71  virtual unsigned long nFlops() const
72  {
73  // QDPIO::cout << "Flopcount Not Yet Implemented " << std::endl;
74  return 0;
75  }
76 
77  protected:
78 
79  // C_L^{-1} P+ + P_ T
80  virtual
81  void invCLeftLinOp(T& chi, const T& psi, enum PlusMinus isign, int cb3d) const
82  {
83  LatticeHalfFermion tmp_minus;
84  LatticeHalfFermion tmp_plus;
85  LatticeHalfFermion tmp_T;
86 
87  // This is just a way of doing P+ psi - decompose and reconstruct.
88  // It may be more straightforward to just write a projector ... -- later
89  tmp_plus[ rb3[ cb3d ] ] = spinProjectDir3Plus(psi);
90  chi[ rb3[ cb3d ] ] = spinReconstructDir3Plus(tmp_plus);
91 
92  // Here I project - apply TOp to only the halfector - then reco nstruct
93  tmp_minus[ rb3[ cb3d ] ] = spinProjectDir3Minus(psi);
94 
95 
96  // Use shared routine to apply T or T^\dagger.
97  // Pass in u, and tsite for the subset
98  CentralTPrecNoSpinUtils::TOp(tmp_T,
99  tmp_minus,
100  getLinks(),
101  getTsiteArray()[cb3d],
102  getFactor(),
103  isign,
104  schroedingerTP());
105 
106  chi[rb3[ cb3d ]] += spinReconstructDir3Minus(tmp_T);
107  chi[rb3[ cb3d ]] *= Real(0.5);
108  // getFermBC().modifyF(chi);
109 
110 
111  }
112 
113 
114  // C^{-1}_R = P- + P+ T^\dagger
115  virtual
116  void invCRightLinOp(T& chi, const T& psi, enum PlusMinus isign, int cb3d) const
117  {
118  enum PlusMinus other_sign = (isign == PLUS ? MINUS : PLUS) ;
119  LatticeHalfFermion tmp_minus;
120  LatticeHalfFermion tmp_plus;
121  LatticeHalfFermion tmp_T;
122 
123  // This does the P- modulo a factor of 1/2
124  // Rather than spooling through 2 half vectors I could just do a
125  // ProjectDir3Minus rather than going through half vectirs
126  tmp_minus[rb3[cb3d]] = spinProjectDir3Minus(psi);
127  chi[rb3[cb3d]] = spinReconstructDir3Minus(tmp_minus);
128 
129  // This does the P+ T^\dagger modulo a factor of 1/2
130  tmp_plus[rb3[cb3d]] = spinProjectDir3Plus(psi);
131 
132 
133  // Use shared routine to apply T or T^\dagger.
134  // Pass in u, and tsite for the subset
135  CentralTPrecNoSpinUtils::TOp(tmp_T,
136  tmp_plus,
137  getLinks(),
138  getTsiteArray()[cb3d],
139  getFactor(),
140  other_sign,
141  schroedingerTP());
142 
143  chi[rb3[cb3d]] += spinReconstructDir3Plus(tmp_T);
144 
145  chi[rb3[cb3d]] *= Real(0.5); //The overall factor of 1/2
146 
147  // getFermBC().modifyF(chi);
148 
149 
150  }
151 
152 
153  // C_L = P+ + P_ T^{-1}
154  virtual
155  void cLeftLinOp(T& chi, const T& psi, enum PlusMinus isign, int cb3d) const
156  {
157  LatticeHalfFermion tmp_minus;
158  LatticeHalfFermion tmp_plus;
159  LatticeHalfFermion tmp_T;
160 
161  tmp_plus[rb3[cb3d]] = spinProjectDir3Plus(psi);
162  chi[rb3[cb3d]] = spinReconstructDir3Plus(tmp_plus);
163 
164  tmp_minus[rb3[cb3d]] = spinProjectDir3Minus(psi);
165 
166  // Use shared routine to apply (T)^{-1} or (T^\dagger)^{-1}.
167  // Pass in u, and tsite, P, P^\dag, Q and Q^\dag for the subset.
168  CentralTPrecNoSpinUtils::invTOp( tmp_T,
169  tmp_minus,
170  getLinks(),
171  getTsiteArray()[cb3d],
172  getPMatrixArray()[cb3d],
173  getPMatrixDaggerArray()[cb3d],
174  getQMatrixInvArray()[cb3d],
175  getQMatrixDaggerInvArray()[cb3d],
176  getInvFactor(),
177  isign,
178  getTMax(),
179  schroedingerTP());
180 
181 
182  chi[rb3[cb3d]] += spinReconstructDir3Minus(tmp_T);
183  chi[rb3[cb3d]] *= Real(0.5);
184  // getFermBC().modifyF(chi);
185 
186 
187  }
188 
189 
190  // C_R = P- + P+ T^{-\dagger}
191  virtual
192  void cRightLinOp(T& chi, const T& psi, enum PlusMinus isign, int cb3d) const
193  {
194  enum PlusMinus other_sign = isign == PLUS ? MINUS : PLUS ;
195  LatticeHalfFermion tmp_minus;
196  LatticeHalfFermion tmp_plus;
197  LatticeHalfFermion tmp_T;
198 
199  tmp_minus[rb3[cb3d]] = spinProjectDir3Minus(psi);
200  chi[rb3[cb3d]] = spinReconstructDir3Minus(tmp_minus);
201 
202  tmp_plus[rb3[cb3d]] = spinProjectDir3Plus(psi);
203 
204  // Use shared routine to apply (T)^{-1} or (T^\dagger)^{-1}.
205  // Pass in u, and tsite, P, P^\dag, Q and Q^\dag for the subset.
206  CentralTPrecNoSpinUtils::invTOp( tmp_T,
207  tmp_plus,
208  getLinks(),
209  getTsiteArray()[cb3d],
210  getPMatrixArray()[cb3d],
211  getPMatrixDaggerArray()[cb3d],
212  getQMatrixInvArray()[cb3d],
213  getQMatrixDaggerInvArray()[cb3d],
214  getInvFactor(),
215  other_sign,
216  getTMax(),
217  schroedingerTP());
218 
219 
220  chi[rb3[cb3d]] += spinReconstructDir3Plus(tmp_T);
221  chi[rb3[cb3d]] *= Real(0.5);
222  // getFermBC().modifyF(chi);
223 
224 
225  }
226 
227  virtual void DBar(T& chi, const T& psi, enum PlusMinus isign, int cb3) const
228  {
229  T tmp1, tmp2;
230  if (isign == PLUS) {
231  cRightLinOp(tmp1, psi, PLUS, (1-cb3));
232  Dslash3D(tmp2, tmp1, PLUS, cb3);
233  cLeftLinOp(chi, tmp2, PLUS, cb3);
234  }
235  else {
236  cLeftLinOp(tmp1, psi, MINUS, 1-cb3);
237  Dslash3D(tmp2, tmp1, MINUS, cb3);
238  cRightLinOp(chi, tmp2, MINUS, cb3);
239  }
240  }
241 
242 
243  virtual void ABar(T& chi, const T& psi, enum PlusMinus isign, int cb3) const
244  {
245  T tmp1, tmp2;
246  if( isign == PLUS ) {
247  cRightLinOp(tmp1, psi, PLUS, cb3);
248  AH(tmp2, tmp1, PLUS, cb3);
249  cLeftLinOp(chi, tmp2, PLUS, cb3);
250  }
251  else {
252  cLeftLinOp(tmp1, psi, MINUS, cb3);
253  AH(tmp2, tmp1, MINUS, cb3);
254  cRightLinOp(chi, tmp2, MINUS, cb3);
255  }
256  }
257 
258  virtual void Dslash3D(T& chi, const T& psi, enum PlusMinus isign, int cb) const = 0;
259  virtual void AH(T& chi, const T& psi, enum PlusMinus isign, int cb) const = 0;
260 
261  };
262 
263 
264 } // End Namespace Chroma
265 
266 #endif
267 
268 #endif
269 #endif
270 #endif
Time-preconditioned Linear Operators.
Support for time preconditioning.
Include possibly optimized Wilson dslash.
Linear Operators.
Double tmp2
Definition: mesq.cc:30
multi1d< LatticeColorMatrix > P
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static int tDir()
Definition: coulgauge.cc:14
LinOpSysSolverMGProtoClover::Q Q
LinOpSysSolverMGProtoClover::T T
@ MINUS
Definition: chromabase.h:45
@ PLUS
Definition: chromabase.h:45
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
int cb
Definition: invbicg.cc:120
LatticeFermion T
Definition: t_clover.cc:11