CHROMA
lwldslash_w.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Wilson Dslash linear operator
4  */
5 
6 #ifndef __lwldslash_h__
7 #define __lwldslash_h__
8 
9 #include "state.h"
10 #include "io/aniso_io.h"
12 
13 
14 namespace Chroma
15 {
16  //! General Wilson-Dirac dslash
17  /*!
18  * \ingroup linop
19  *
20  * DSLASH
21  *
22  * This routine is specific to Wilson fermions!
23  *
24  * Description:
25  *
26  * This routine applies the operator D' to Psi, putting the result in Chi.
27  *
28  * Nd-1
29  * ---
30  * \
31  * chi(x) := > U (x) (1 - isign gamma ) psi(x+mu)
32  * / mu mu
33  * ---
34  * mu=0
35  *
36  * Nd-1
37  * ---
38  * \ +
39  * + > U (x-mu) (1 + isign gamma ) psi(x-mu)
40  * / mu mu
41  * ---
42  * mu=0
43  *
44  */
45 
46  template<typename T, typename P, typename Q>
47  class QDPWilsonDslashT : public WilsonDslashBase<T, P, Q>
48  {
49  public:
50 
51  //! Empty constructor. Must use create later
53 
54  //! Full constructor
56 
57  //! Full constructor with anisotropy
59  const AnisoParam_t& aniso_);
60 
61  //! Full constructor with general coefficients
63  const multi1d<Real>& coeffs_);
64 
65  //! Creation routine
67 
68  //! Creation routine with anisotropy
70  const AnisoParam_t& aniso_);
71 
72  //! Full constructor with general coefficients
74  const multi1d<Real>& coeffs_);
75 
76  //! No real need for cleanup here
78 
79  /**
80  * Apply a dslash
81  *
82  * \param chi result (Write)
83  * \param psi source (Read)
84  * \param isign D'^dag or D' ( MINUS | PLUS ) resp. (Read)
85  * \param cb Checkerboard of OUTPUT std::vector (Read)
86  *
87  * \return The output of applying dslash on psi
88  */
89  void apply (T& chi, const T& psi, enum PlusMinus isign, int cb) const;
90 
91  //! Return the fermion BC object for this linear operator
92  const FermBC<T,P,Q>& getFermBC() const {return *fbc;}
93 
94  protected:
95  //! Get the anisotropy parameters
96  const multi1d<Real>& getCoeffs() const {return coeffs;}
97 
98  private:
99  multi1d<Real> coeffs; /*!< Nd array of coefficients of terms in the action */
101  Q u;
102  };
103 
104  //! General Wilson-Dirac dslash
105  /*! \ingroup linop
106  * DSLASH
107  *
108  * This routine is specific to Wilson fermions!
109  *
110  * Description:
111  *
112  * This routine applies the operator D' to Psi, putting the result in Chi.
113  *
114  * Nd-1
115  * ---
116  * \
117  * chi(x) := > U (x) (1 - isign gamma ) psi(x+mu)
118  * / mu mu
119  * ---
120  * mu=0
121  *
122  * Nd-1
123  * ---
124  * \ +
125  * + > U (x-mu) (1 + isign gamma ) psi(x-mu)
126  * / mu mu
127  * ---
128  * mu=0
129  *
130  */
131 
132  //! Empty constructor
133  template<typename T, typename P, typename Q>
135 
136  //! Full constructor
137  template<typename T, typename P, typename Q>
139  {
140  create(state);
141  }
142 
143  //! Full constructor with anisotropy
144  template<typename T, typename P, typename Q>
146  const AnisoParam_t& aniso_)
147  {
148  create(state, aniso_);
149  }
150 
151  //! Full constructor with general coefficients
152  template<typename T, typename P, typename Q>
154  const multi1d<Real>& coeffs_)
155  {
156  create(state, coeffs_);
157  }
158 
159  //! Creation routine
160  template<typename T, typename P, typename Q>
162  {
163  multi1d<Real> cf(Nd);
164  cf = 1.0;
165  create(state, cf);
166  }
167 
168  //! Creation routine with anisotropy
169  template<typename T, typename P, typename Q>
171  const AnisoParam_t& anisoParam)
172  {
173  START_CODE();
174 
175  create(state, makeFermCoeffs(anisoParam));
176 
177  END_CODE();
178  }
179 
180  //! Full constructor with general coefficients
181  template<typename T, typename P, typename Q>
183  const multi1d<Real>& coeffs_)
184  {
185  //QDPIO::cout << "Setting up QDP Wilson Dslash\n";
186 
187  // Save a copy of the aniso params original fields and with aniso folded in
188  coeffs = coeffs_;
189 
190  // Save a copy of the fermbc
191  fbc = state->getFermBC();
192 
193  // Sanity check
194  if (fbc.operator->() == 0)
195  {
196  QDPIO::cerr << "QDPWilsonDslash: error: fbc is null" << std::endl;
197  QDP_abort(1);
198  }
199 
200  u.resize(Nd);
201 
202  // Fold in anisotropy
203  for(int mu=0; mu < u.size(); ++mu) {
204  u[mu] = (state->getLinks())[mu];
205  }
206 
207  // Rescale the u fields by the anisotropy
208  for(int mu=0; mu < u.size(); ++mu)
209  {
210  u[mu] *= coeffs[mu];
211  }
212  }
213 
214 
215  //! General Wilson-Dirac dslash
216  /*! \ingroup linop
217  * Wilson dslash
218  *
219  * Arguments:
220  *
221  * \param chi Result (Write)
222  * \param psi Pseudofermion field (Read)
223  * \param isign D'^dag or D' ( MINUS | PLUS ) resp. (Read)
224  * \param cb Checkerboard of OUTPUT std::vector (Read)
225  */
226  template<typename T, typename P, typename Q>
227  void
229  enum PlusMinus isign, int cb) const
230  {
231  START_CODE();
232 #if (QDP_NC == 2) || (QDP_NC == 3)
233  /* F
234  * a2 (x) := U (x) (1 - isign gamma ) psi(x)
235  * mu mu mu
236  */
237  /* B +
238  * a2 (x) := U (x-mu) (1 + isign gamma ) psi(x-mu)
239  * mu mu mu
240  */
241  // Recontruct the bottom two spinor components from the top two
242  /* F B
243  * chi(x) := sum_mu a2 (x) + a2 (x)
244  * mu mu
245  */
246 
247  /* Why are these lines split? An array syntax would help, but the problem is deeper.
248  * The expression templates require NO variable args (like int's) to a function
249  * and all args must be known at compile time. Hence, the function names carry
250  * (as functions usually do) the meaning (and implicit args) to a function.
251  */
252  switch (isign)
253  {
254  case PLUS:
255  chi[rb[cb]] = spinReconstructDir0Minus(u[0] * shift(spinProjectDir0Minus(psi), FORWARD, 0))
256  + spinReconstructDir0Plus(shift(adj(u[0]) * spinProjectDir0Plus(psi), BACKWARD, 0))
257 #if QDP_ND >= 2
258  + spinReconstructDir1Minus(u[1] * shift(spinProjectDir1Minus(psi), FORWARD, 1))
259  + spinReconstructDir1Plus(shift(adj(u[1]) * spinProjectDir1Plus(psi), BACKWARD, 1))
260 #endif
261 #if QDP_ND >= 3
262  + spinReconstructDir2Minus(u[2] * shift(spinProjectDir2Minus(psi), FORWARD, 2))
263  + spinReconstructDir2Plus(shift(adj(u[2]) * spinProjectDir2Plus(psi), BACKWARD, 2))
264 #endif
265 #if QDP_ND >= 4
266  + spinReconstructDir3Minus(u[3] * shift(spinProjectDir3Minus(psi), FORWARD, 3))
267  + spinReconstructDir3Plus(shift(adj(u[3]) * spinProjectDir3Plus(psi), BACKWARD, 3))
268 #endif
269 #if QDP_ND >= 5
270 #error "Unsupported number of dimensions"
271 #endif
272  ;
273  break;
274 
275  case MINUS:
276  chi[rb[cb]] = spinReconstructDir0Plus(u[0] * shift(spinProjectDir0Plus(psi), FORWARD, 0))
277  + spinReconstructDir0Minus(shift(adj(u[0]) * spinProjectDir0Minus(psi), BACKWARD, 0))
278 #if QDP_ND >= 2
279  + spinReconstructDir1Plus(u[1] * shift(spinProjectDir1Plus(psi), FORWARD, 1))
280  + spinReconstructDir1Minus(shift(adj(u[1]) * spinProjectDir1Minus(psi), BACKWARD, 1))
281 #endif
282 #if QDP_ND >= 3
283  + spinReconstructDir2Plus(u[2] * shift(spinProjectDir2Plus(psi), FORWARD, 2))
284  + spinReconstructDir2Minus(shift(adj(u[2]) * spinProjectDir2Minus(psi), BACKWARD, 2))
285 #endif
286 #if QDP_ND >= 4
287  + spinReconstructDir3Plus(u[3] * shift(spinProjectDir3Plus(psi), FORWARD, 3))
288  + spinReconstructDir3Minus(shift(adj(u[3]) * spinProjectDir3Minus(psi), BACKWARD, 3))
289 #endif
290 #if QDP_ND >= 5
291 #error "Unsupported number of dimensions"
292 #endif
293  ;
294  break;
295  }
296 
297  QDPWilsonDslashT<T,P,Q>::getFermBC().modifyF(chi, QDP::rb[cb]);
298 #else
299  QDPIO::cerr<<"lwldslash_w: not implemented for NC!=3\n";
300  QDP_abort(13) ;
301 #endif
302  END_CODE();
303  }
304 
305  typedef QDPWilsonDslashT<LatticeFermion,
306  multi1d<LatticeColorMatrix>,
307  multi1d<LatticeColorMatrix> > QDPWilsonDslash;
308 
309 
310  typedef QDPWilsonDslashT<LatticeFermionF,
311  multi1d<LatticeColorMatrixF>,
312  multi1d<LatticeColorMatrixF> > QDPWilsonDslashF;
313 
314  typedef QDPWilsonDslashT<LatticeFermionD,
315  multi1d<LatticeColorMatrixD>,
316  multi1d<LatticeColorMatrixD> > QDPWilsonDslashD;
317 
318 } // End Namespace Chroma
319 
320 
321 #endif
Anisotropy parameters.
Base class for all fermion action boundary conditions.
Definition: fermbc.h:20
Support class for fermion actions and linear operators.
Definition: state.h:94
Class for counted reference semantics.
Definition: handle.h:33
General Wilson-Dirac dslash.
Definition: lwldslash_w.h:48
multi1d< Real > coeffs
Definition: lwldslash_w.h:99
~QDPWilsonDslashT()
No real need for cleanup here.
Definition: lwldslash_w.h:77
void create(Handle< FermState< T, P, Q > > state)
Creation routine.
Definition: lwldslash_w.h:161
const FermBC< T, P, Q > & getFermBC() const
Return the fermion BC object for this linear operator.
Definition: lwldslash_w.h:92
const multi1d< Real > & getCoeffs() const
Get the anisotropy parameters.
Definition: lwldslash_w.h:96
Handle< FermBC< T, P, Q > > fbc
Definition: lwldslash_w.h:100
General Wilson-Dirac dslash.
int mu
Definition: cool.cc:24
QDPWilsonDslashT()
Empty constructor. Must use create later.
Definition: lwldslash_w.h:134
void apply(T &chi, const T &psi, enum PlusMinus isign, int cb) const
General Wilson-Dirac dslash.
Definition: lwldslash_w.h:228
Wilson Dslash linear operator.
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
QDPWilsonDslashT< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > QDPWilsonDslash
Definition: lwldslash_w.h:307
static multi1d< LatticeColorMatrix > u
LinOpSysSolverMGProtoClover::Q Q
QDPWilsonDslashT< LatticeFermionD, multi1d< LatticeColorMatrixD >, multi1d< LatticeColorMatrixD > > QDPWilsonDslashD
Definition: lwldslash_w.h:316
LinOpSysSolverMGProtoClover::T T
@ MINUS
Definition: chromabase.h:45
@ PLUS
Definition: chromabase.h:45
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
QDPWilsonDslashT< LatticeFermionF, multi1d< LatticeColorMatrixF >, multi1d< LatticeColorMatrixF > > QDPWilsonDslashF
Definition: lwldslash_w.h:312
START_CODE()
int cb
Definition: invbicg.cc:120
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
multi1d< Real > makeFermCoeffs(const AnisoParam_t &aniso)
Make fermion coefficients.
Definition: aniso_io.cc:63
#define FORWARD
Definition: primitives.h:82
#define BACKWARD
Definition: primitives.h:83
Support class for fermion actions and linear operators.
Parameters for anisotropy.
Definition: aniso_io.h:24