CHROMA
eo3dprec_s_cprec_t_wilson_linop_w.h
Go to the documentation of this file.
1 #ifndef EO3DPREC_S_CPREC_T_WILSON_LINOP_W_H
2 #define EO3DPREC_S_CPREC_T_WILSON_LINOP_W_H
3 
4 #include "qdp_config.h"
5 
6 #if QDP_ND == 4
7 #if QDP_NC == 3
8 #if QDP_NS == 4
9 
10 #include "linearop.h"
11 #include "central_tprec_linop.h"
12 
15 
16 namespace Chroma
17 {
18  //! Wilson Dirac Operator - Unpreconditioned in Space, Centrally Preconditioned in time
19  /*!
20  * \ingroup linop
21  *
22  * This routine is specific to Wilson fermions!
23  *
24  * ~ ~+
25  */
26 
27  class EO3DPrecSCprecTWilsonLinOp :
28  public EO3DPrecSpaceCentralPrecTimeLinearOperator<LatticeFermion,
29  multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >
30  {
31  public:
32  // Typedefs to save typing
33  typedef LatticeFermion T;
34  typedef multi1d<LatticeColorMatrix> P;
35  typedef multi1d<LatticeColorMatrix> Q;
36  typedef PScalar<PColorMatrix<RComplex<REAL>, 3> > CMat; // Useful type: ColorMat with no Outer<>
37  typedef PSpinVector<PColorVector<RComplex<REAL>, 3>, 2> HVec_site; // Useful type: Half Vec with no Outer<>
38  //! Partial constructor
39  EO3DPrecSCprecTWilsonLinOp() {}
40 
41 
42  //! Full constructor with Anisotropy
43  EO3DPrecSCprecTWilsonLinOp(Handle< FermState<T,P,Q> > fs_,
44  const Real& Mass_,
45  const AnisoParam_t& aniso_)
46  {create(fs_,Mass_,aniso_);}
47 
48  //! Destructor is automatic
49  ~EO3DPrecSCprecTWilsonLinOp() {}
50 
51  //! Return the fermion BC object for this linear operator
52  const FermBC<T,P,Q>& getFermBC() const {return fs->getBC();}
53 
54 
55  //! Creation routine with Anisotropy
56  void create(Handle< FermState<T,P,Q> > fs_,
57  const Real& Mass_,
58  const AnisoParam_t& aniso_);
59 
60 
61  //! The time direction
62 
63  int tDir() const {
64  // Always 3 for now?
65  return 3;
66  }
67 
68  //! Apply inv (C_L)^{-1}
69  void invCLeftLinOp(T& chi, const T& psi, enum PlusMinus isign, int cb3d) const;
70 
71  //! Apply inv (C_R)^{-1}
72  void invCRightLinOp(T& chi, const T& psi, enum PlusMinus isign, int cb3d) const;
73 
74  //! Apply C_L
75  void cLeftLinOp(T& chi, const T& psi, enum PlusMinus isign, int cb3d) const;
76 
77  //! Apply C_R
78  void cRightLinOp(T& chi, const T& psi, enum PlusMinus isign, int cb3d) const;
79 
80  inline
81  void evenEvenLinOp(T& chi, const T& psi, enum PlusMinus isign) const {
82  chi[rb3[0]] = psi;
83  }
84 
85  inline
86  void evenEvenInvLinOp(T& chi, const T& psi, enum PlusMinus isign) const {
87  chi[rb3[0]] = psi;
88  }
89 
90  inline
91  void oddOddLinOp(T& chi, const T& psi, enum PlusMinus isign) const {
92  chi[rb3[1]] = psi;
93  }
94 
95  inline
96  void evenOddLinOp(T& chi, const T& psi, enum PlusMinus isign) const {
97  T tmp1, tmp2;
98 
99  switch(isign) {
100  case PLUS:
101  {
102 
103  cRightLinOp(tmp1, psi, isign, 1);
104  spaceLinOp(tmp2, tmp1, isign, 0);
105  cLeftLinOp(chi, tmp2, isign, 0);
106  }
107  break;
108  case MINUS:
109  {
110  cLeftLinOp(tmp1, psi, isign, 1);
111  spaceLinOp(tmp2, tmp1, isign, 0);
112  cRightLinOp(chi, tmp2, isign, 0);
113  }
114  break;
115  };
116  }
117 
118 
119  inline
120  void oddEvenLinOp(T& chi, const T& psi, enum PlusMinus isign) const {
121  T tmp1, tmp2;
122 
123  switch(isign) {
124  case PLUS:
125  {
126 
127  cRightLinOp(tmp1, psi, isign, 0);
128  spaceLinOp(tmp2, tmp1, isign, 1);
129  cLeftLinOp(chi, tmp2, isign, 1);
130  }
131  break;
132  case MINUS:
133  {
134  cLeftLinOp(tmp1, psi, isign, 0);
135  spaceLinOp(tmp2, tmp1, isign, 1);
136  cRightLinOp(chi, tmp2, isign, 1);
137  }
138  break;
139  };
140  }
141 
142 
143  // Override: Get rid of the inv calls
144 
145  //! Apply the operator onto a source std::vector
146  virtual void operator() (T& chi, const T& psi, enum PlusMinus isign) const
147  {
148  T tmp1, tmp2; moveToFastMemoryHint(tmp1); moveToFastMemoryHint(tmp2);
149 
150  switch (isign)
151  {
152  case PLUS:
153  // \chi = ( M_oo - M_oe M^{-1}_ee M_eo ) \psi
154 
155  // chi = M_oo \psi
156  oddOddLinOp(chi, psi, PLUS);
157 
158  // tmp2 = M_oe M^{-1}_ee M_eo \psi
159  evenOddLinOp(tmp1, psi, PLUS);
160  oddEvenLinOp(tmp2, tmp1, PLUS);
161 
162  chi[rb3[1]] -= tmp2;
163  break;
164 
165  case MINUS:
166  // \chi = ( M_oo - M_oe M^{-1}_ee M_eo )^\dagger \psi
167  // = M^\dagger_oo \psi - M^\dagger_{oe} ( M^{-1}_ee )^\dagger M^\dagger{eo}
168  //
169  // NB: Daggering acts on checkerboarding to achieve the result above.
170 
171  oddOddLinOp(chi, psi, MINUS);
172 
173  // tmp2 = M_oe M^{-1}_ee M_eo \psi
174  evenOddLinOp(tmp1, psi, MINUS);
175  oddEvenLinOp(tmp2, tmp1, MINUS);
176 
177  chi[rb3[1]] -= tmp2;
178  break;
179 
180  default:
181  QDPIO::cerr << "unknown sign" << std::endl;
182  QDP_abort(1);
183  }
184 
185  getFermBC().modifyF(chi, QDP::rb3[1]);
186  }
187 
188 
189  //! Apply the d/dt of the preconditioned linop
190  void deriv(P& ds_u, const T& X, const T& Y, enum PlusMinus isign) const {
191 
192  QDPIO::cerr << "Not Yet Implemented" << std::endl;
193  QDP_abort(1);
194 
195  }
196 
197  //! Get log det ( T^\dag T )
198  Double logDetTDagT(void) const {
199  QDPIO::cerr << "Not Yet Implemented" << std::endl;
200  QDP_abort(1);
201  return (double)0;
202  }
203 
204 
205  //! Get the force due to the det T^\dag T bit
206  void derivLogDetTDagT(P& ds_u, enum PlusMinus isign) const {
207  QDPIO::cerr << "Not Yet Implemented" << std::endl;
208  QDP_abort(1);
209  }
210 
211 
212  unsigned long nFlops() const
213  {
214  // QDPIO::cout << "Flopcount Not Yet Implemented " << std::endl;
215  return 0;
216  }
217 
218  private:
219 
220  //! Apply the the space block onto a source std::vector
221  // cb3d is the 3d (rb3) checkerboard of the target
222  void spaceLinOp(T& chi, const T& psi, enum PlusMinus isign, int cb3d) const {
223  Real mhalf=Real(-0.5);
224  Dw3D.apply(chi, psi, isign, cb3d);
225  chi[ rb3[cb3d] ] *= mhalf;
226  getFermBC().modifyF(chi, rb3[cb3d]);
227  }
228 
229  int getTMax() const {
230  return Layout::lattSize()[Nd-1];
231  }
232 
233  private:
234 
235  AnisoParam_t aniso;
236  Real fact; // tmp holding Nd+Mass
237  Real invfact;
238  Real Mass;
239  Handle< FermState<T,P,Q> > fs;
240  multi1d<LatticeColorMatrix> u;
241 
242  multi3d< int > tsite; // Tsite array - 3d even sites
243 
244  multi3d< CMat > P_mat; // 3d even sites
245  multi3d< CMat > P_mat_dag;
246 
247  multi2d< CMat > Q_mat_inv; // Just one matrix for each spatial site ( 1+P[t=0] )^{-1}
248  multi2d< CMat > Q_mat_dag_inv; // Just one matrix for each spatial site ( 1+P_dag[t=Nt-1])^{-1}
249 
250  WilsonDslash3D Dw3D;
251  };
252 
253 } // End Namespace Chroma
254 
255 
256 #endif
257 #endif
258 #endif
259 
260 #endif
Time-preconditioned Linear Operators.
Support for time preconditioning.
Include possibly optimized Wilson dslash.
Linear Operators.
Nd
Definition: meslate.cc:74
Double tmp2
Definition: mesq.cc:30
multi1d< LatticeColorMatrix > P
multi1d< Hadron2PtContraction_t > operator()(const multi1d< LatticeColorMatrix > &u)
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static int tDir()
Definition: coulgauge.cc:14
static multi1d< LatticeColorMatrix > u
LinOpSysSolverMGProtoClover::Q Q
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > & Mass
Definition: pbg5p_w.cc:29
LinOpSysSolverMGProtoClover::T T
@ MINUS
Definition: chromabase.h:45
@ PLUS
Definition: chromabase.h:45
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
FloatingPoint< double > Double
Definition: gtest.h:7351
LatticeFermion T
Definition: t_clover.cc:11
multi1d< LatticeColorMatrix > P
Definition: t_clover.cc:13
multi1d< LatticeColorMatrix > deriv(const EvenOddPrecLinearOperator< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &AP, const LatticeFermion &chi, const LatticeFermion &psi, enum PlusMinus isign)
Apply the operator onto a source std::vector.