CHROMA
eo3dprec_s_cprec_t_clover_linop_w.h
Go to the documentation of this file.
1 #ifndef EO3DPREC_S_CPREC_T_CLOVER_LINOP_W_H
2 #define EO3DPREC_S_CPREC_T_CLOVER_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"
16 namespace Chroma
17 {
18 
19 
20  //! Clover Dirac Operator - Unpreconditioned in Space, Centrally Preconditioned in time
21  /*!
22  * \ingroup linop
23  *
24  * This routine is specific to Clover fermions!
25  *
26  * ~ ~+
27  */
28  class EELinOp : public LinearOperator<LatticeFermion> {
29  public:
30  ~EELinOp() {}
31  EELinOp(const EO3DPrecSpaceCentralPrecTimeLinearOperator<LatticeFermion,
32  multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >& EO_,
33  enum PlusMinus isign) : EOLinOp(EO_), my_isign(isign) {}
34 
35  virtual void operator() (LatticeFermion& chi, const LatticeFermion& psi, enum PlusMinus isign) const {
36  switch( my_isign ) {
37  case PLUS:
38  EOLinOp.evenEvenLinOp(chi, psi, isign);
39  break;
40  case MINUS:
41  {
42  enum PlusMinus opp_sign = (isign == PLUS ? MINUS : PLUS);
43  EOLinOp.evenEvenLinOp(chi, psi, opp_sign);
44  }
45  break;
46  default:
47  break;
48  };
49  }
50  //! Return the subset on which the operator acts
51  virtual const Subset& subset() const {
52  return rb3[0];
53  }
54 
55 
56  private:
57  const EO3DPrecSpaceCentralPrecTimeLinearOperator<LatticeFermion,
58  multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >& EOLinOp;
59 
60  enum PlusMinus my_isign;
61  };
62 
63  class EO3DPrecSCprecTCloverLinOp :
64  public EO3DPrecSpaceCentralPrecTimeLinearOperator<LatticeFermion,
65  multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >
66  {
67  public:
68  // Typedefs to save typing
69  typedef LatticeFermion T;
70  typedef multi1d<LatticeColorMatrix> P;
71  typedef multi1d<LatticeColorMatrix> Q;
72  typedef PScalar<PColorMatrix<RComplex<REAL>, 3> > CMat; // Useful type: ColorMat with no Outer<>
73  typedef PSpinVector<PColorVector<RComplex<REAL>, 3>, 2> HVec_site; // Useful type: Half Vec with no Outer<>
74  //! Partial constructor
75  EO3DPrecSCprecTCloverLinOp() {}
76 
77 
78  //! Full constructor with Anisotropy
79  EO3DPrecSCprecTCloverLinOp(Handle< FermState<T,P,Q> > fs_,
80  const CloverFermActParams& param_)
81  {create(fs_,param_);}
82 
83  //! Destructor is automatic
84  ~EO3DPrecSCprecTCloverLinOp() {}
85 
86  //! Return the fermion BC object for this linear operator
87  const FermBC<T,P,Q>& getFermBC() const {return fs->getBC();}
88 
89 
90  //! Creation routine with Anisotropy
91  void create(Handle< FermState<T,P,Q> > fs_,
92  const CloverFermActParams& param_);
93 
94 
95  //! The time direction
96 
97  int tDir() const {
98  // Always 3 for now?
99  return 3;
100  }
101 
102  int getTMax() const {
103  return Layout::lattSize()[tDir()];
104  }
105 
106  //! Apply inv (C_L)^{-1}
107  void invCLeftLinOp(T& chi, const T& psi, enum PlusMinus isign, int cb3d) const;
108 
109  //! Apply inv (C_R)^{-1}
110  void invCRightLinOp(T& chi, const T& psi, enum PlusMinus isign, int cb3d) const;
111 
112  //! Apply C_L
113  void cLeftLinOp(T& chi, const T& psi, enum PlusMinus isign, int cb3d) const;
114 
115  //! Apply C_R
116  void cRightLinOp(T& chi, const T& psi, enum PlusMinus isign, int cb3d) const;
117 
118  inline
119  void diagLinOp(T& chi, const T& psi, enum PlusMinus isign, int cb3) const {
120  // This is now 1 + C_L (A-fact) C_R on even even
121  T tmp1 = zero;
122  T tmp2 = zero;
123 
124  switch(isign) {
125  case PLUS:
126  {
127  cRightLinOp(tmp1, psi, PLUS, cb3);
128 
129  const int* tab = rb3[cb3].siteTable().slice();
130  for(int j=0; j < rb3[cb3].siteTable().size(); j++) {
131  int site=tab[j];
132  APlusFact.applySite(tmp2, tmp1, PLUS, site);
133  }
134  tmp2[rb3[cb3]] -= fact * tmp1;
135 
136  cLeftLinOp(tmp1, tmp2, PLUS, cb3);
137 
138  chi[rb3[cb3]] = psi + tmp1;
139  }
140  break;
141  case MINUS:
142  {
143  cLeftLinOp(tmp1, psi, MINUS, cb3);
144  const int* tab = rb3[cb3].siteTable().slice();
145  for(int j=0; j < rb3[cb3].siteTable().size(); j++) {
146  int site=tab[j];
147  APlusFact.applySite(tmp2, tmp1, MINUS, site);
148  }
149 
150  tmp2[rb3[cb3]] -= fact * tmp1;
151  cRightLinOp(tmp1, tmp2, MINUS, cb3);
152  chi[rb3[cb3]] = psi + tmp1;
153  }
154  break;
155  default:
156  QDPIO::cout << "error: Unknown ISIGN" << std::endl;
157  QDP_abort(1);
158  break;
159  }
160  }
161 
162 
163 
164  inline
165  void evenEvenLinOp(T& chi, const T& psi, enum PlusMinus isign) const {
166  diagLinOp(chi,psi, isign, 0);
167  }
168 
169  inline
170  void evenEvenInvLinOp(T& chi, const T& psi, enum PlusMinus isign) const {
171  // Do with a CG?
172  EELinOp eeLin(*this, isign);
173  enum PlusMinus opp_sign = (isign == PLUS ? MINUS : PLUS );
174 
175  T tmp1;
176  chi[rb3[0]]=zero;
177  evenEvenLinOp(tmp1, psi, opp_sign);
178  Real RsdCG=Real(1.0e-8);
179  int MaxCG=200;
180  InvCG2( eeLin, tmp1, chi, RsdCG, MaxCG);
181 
182  }
183 
184  inline
185  void oddOddLinOp(T& chi, const T& psi, enum PlusMinus isign) const {
186  diagLinOp(chi,psi, isign, 1);
187  }
188 
189  inline
190  void evenOddLinOp(T& chi, const T& psi, enum PlusMinus isign) const {
191  T tmp1, tmp2;
192 
193  switch(isign) {
194  case PLUS:
195  {
196 
197  cRightLinOp(tmp1, psi, isign, 1);
198  spaceLinOp(tmp2, tmp1, isign, 0);
199  cLeftLinOp(chi, tmp2, isign, 0);
200  }
201  break;
202  case MINUS:
203  {
204  cLeftLinOp(tmp1, psi, isign, 1);
205  spaceLinOp(tmp2, tmp1, isign, 0);
206  cRightLinOp(chi, tmp2, isign, 0);
207  }
208  break;
209  };
210  }
211 
212 
213  inline
214  void oddEvenLinOp(T& chi, const T& psi, enum PlusMinus isign) const {
215  T tmp1, tmp2;
216 
217  switch(isign) {
218  case PLUS:
219  {
220 
221  cRightLinOp(tmp1, psi, isign, 0);
222  spaceLinOp(tmp2, tmp1, isign, 1);
223  cLeftLinOp(chi, tmp2, isign, 1);
224  }
225  break;
226  case MINUS:
227  {
228  cLeftLinOp(tmp1, psi, isign, 0);
229  spaceLinOp(tmp2, tmp1, isign, 1);
230  cRightLinOp(chi, tmp2, isign, 1);
231  }
232  break;
233  };
234  }
235 
236  unsigned long nFlops() const
237  {
238  // QDPIO::cout << "Flopcount Not Yet Implemented " << std::endl;
239  return 0;
240  }
241 
242 
243  //! Apply the d/dt of the preconditioned linop
244  void deriv(P& ds_u, const T& X, const T& Y, enum PlusMinus isign) const {
245 
246  QDPIO::cerr << "Not Yet Implemented" << std::endl;
247  QDP_abort(1);
248 
249  }
250 
251  //! Get log det ( T^\dag T )
252  Double logDetTDagT(void) const {
253  QDPIO::cerr << "Not Yet Implemented" << std::endl;
254  QDP_abort(1);
255  return (double)0;
256  }
257 
258 
259 
260  //! Get the force due to the det T^\dag T bit
261  void derivLogDetTDagT(P& ds_u, enum PlusMinus isign) const {
262  QDPIO::cerr << "Not Yet Implemented" << std::endl;
263  QDP_abort(1);
264  }
265 
266 
267  private:
268 
269  //! Apply the the space block onto a source std::vector
270  // cb3d is the 3d (rb3) checkerboard of the target
271  void spaceLinOp(T& chi, const T& psi, enum PlusMinus isign, int cb3d) const {
272  Real mhalf=Real(-0.5);
273  Dw3D.apply(chi, psi, isign, cb3d);
274  chi[rb3[cb3d]] *= mhalf;
275  }
276 
277 
278  private:
279 
280  AnisoParam_t aniso;
281  Real fact; // tmp holding Nd+Mass
282  Real invfact;
283  Real Mass;
284  Handle< FermState<T,P,Q> > fs;
285  multi1d<LatticeColorMatrix> u;
286 
287  multi3d< int > tsite; // Tsite array - 3d even sites
288 
289  multi3d< CMat > P_mat; // 3d even sites
290  multi3d< CMat > P_mat_dag;
291 
292  multi2d< CMat > Q_mat_inv; // Just one matrix for each spatial site ( 1+P[t=0] )^{-1}
293  multi2d< CMat > Q_mat_dag_inv; // Just one matrix for each spatial site ( 1+P_dag[t=Nt-1])^{-1}
294 
295  CloverTerm APlusFact;
296  CloverFermActParams param;
297 
298  WilsonDslash3D Dw3D;
299 
300  };
301 
302 } // End Namespace Chroma
303 
304 #endif
305 #endif
306 #endif
307 
308 #endif
Time-preconditioned Linear Operators.
Support for time preconditioning.
Parameters for Clover fermion action.
Include possibly optimized Clover terms.
Include possibly optimized Wilson dslash.
SystemSolverResults_t InvCG2(const LinearOperator< LatticeFermionF > &M, const LatticeFermionF &chi, LatticeFermionF &psi, const Real &RsdCG, int MaxCG)
Conjugate-Gradient (CGNE) algorithm for a generic Linear Operator.
Definition: invcg2.cc:240
Conjugate-Gradient algorithm for a generic Linear Operator.
unsigned j
Definition: ldumul_w.cc:35
Linear Operators.
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
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > enum InvType invType const multi1d< Real > & RsdCG
Definition: pbg5p_w.cc:30
static multi1d< LatticeColorMatrix > u
LinOpSysSolverMGProtoClover::Q Q
QDPCloverTerm CloverTerm
Definition: clover_term_w.h:92
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > & Mass
Definition: pbg5p_w.cc:29
LinOpSysSolverMGProtoClover::T T
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > enum InvType invType const multi1d< Real > int MaxCG
Definition: pbg5p_w.cc:32
@ MINUS
Definition: chromabase.h:45
@ PLUS
Definition: chromabase.h:45
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
Double zero
Definition: invbicg.cc:106
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.