CHROMA
unprec_hamberwu_linop_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Unpreconditioned Hamber-Wu linear operator
3  */
4 
5 #include "chromabase.h"
7 
8 using namespace QDP::Hints;
9 
10 namespace Chroma
11 {
12 
13  //! Creation routine
14  /*!
15  *
16  * \param u_ gauge field (Read)
17  * \param Mass_ fermion kappa (Read)
18  */
19  void UnprecHamberWuLinOp::create(Handle< FermState<T,P,Q> > fs,
20  const Real& Mass_, const Real& u0_)
21  {
22  Mass = Mass_;
23  u0 = u0_;
24 
25  D.create(fs);
26 
27  const multi1d<LatticeColorMatrix>& u = fs->getLinks();
28 
29  // CoeffWilsr_s = (AnisoP) ? Wilsr_s / xiF_0 : 1;
30 
31  /* Make "dble links", UU */
32  u_dble.resize(u.size());
33  for(int mu=0; mu < u.size(); ++mu)
34  u_dble[mu] = u[mu] * shift(u[mu], FORWARD, mu);
35 
36  fact1 = Nd + Mass;
37  fact2 = -2 /(3*u0);
38  fact4 = 1 / (12*u0*u0);
39  fact3 = 2 * fact4;
40  }
41 
42 
43 
44  // Override inherited one with a few more funkies
45  void UnprecHamberWuLinOp::operator()(LatticeFermion & chi,
46  const LatticeFermion& psi,
47  enum PlusMinus isign) const
48  {
49  START_CODE();
50 
51  LatticeFermion tmp1; moveToFastMemoryHint(tmp1);
52  LatticeFermion tmp2; moveToFastMemoryHint(tmp2);
53  LatticeFermion tmp_s; moveToFastMemoryHint(tmp_s);
54  LatticeFermion tmp_v; moveToFastMemoryHint(tmp_v);
55 
56  D(tmp1, psi, isign);
57 
58  chi = fact1*psi + fact2*tmp1;
59 
60  tmp_s = zero;
61  tmp_v = zero;
62 
63  for (int mu = 0; mu < Nd; mu++)
64  {
65  /* Next-nearest neighbors */
66  tmp2 = shift(psi, FORWARD, mu);
67  tmp1 = u_dble[mu] * shift(tmp2, FORWARD, mu);
68  tmp_s += tmp1;
69  tmp2 = Gamma(1 << mu) * tmp1;
70  tmp_v -= tmp2;
71 
72  tmp2 = shift(adj(u_dble[mu]) * psi, BACKWARD, mu);
73  tmp1 = shift(tmp2, BACKWARD, mu);
74  tmp_s += tmp1;
75  tmp2 = Gamma(1 << mu) * tmp1;
76  tmp_v += tmp2;
77  }
78 
79  chi += fact3 * tmp_s;
80  if (isign == PLUS)
81  chi += fact4 * tmp_v;
82  else
83  chi -= fact4 * tmp_v;
84 
85  getFermBC().modifyF(chi);
86 
87  END_CODE();
88  }
89 
90 
91  //! Return flops performed by the operator()
92  unsigned long UnprecHamberWuLinOp::nFlops() const
93  {
94  unsigned long site_flops = D.nFlops()+2*(2*Nc)*(2*Nc)*Ns*4*Nd;
95  return site_flops*(Layout::sitesOnNode());
96  }
97 
98 
99  //! Derivative of unpreconditioned Hamber-Wu dM/dU
100  /*!
101  * \param chi left std::vector on cb (Read)
102  * \param psi right std::vector on 1-cb (Read)
103  * \param isign D'^dag or D' ( MINUS | PLUS ) resp. (Read)
104  * \param cb Checkerboard of chi std::vector (Read)
105  *
106  * \return Computes \f$\chi^\dag * \dot(D} * \psi\f$
107  */
108  void
109  UnprecHamberWuLinOp::deriv(multi1d<LatticeColorMatrix>& ds_u,
110  const LatticeFermion& chi, const LatticeFermion& psi,
111  enum PlusMinus isign) const
112  {
113  QDP_error_exit("Hamber-Wu deriv not correct yet");
114 
115 
116  START_CODE();
117 
118  // This does both parities
119  D.deriv(ds_u, chi, psi, isign);
120 
121  // Factor in front of the dslash
122  for(int mu = 0; mu < Nd; ++mu)
123  ds_u[mu] *= fact2;
124 
125  // NOTE: missing derivative of 2 link piece
126 
127  getFermBC().zero(ds_u);
128 
129  END_CODE();
130  }
131 
132 } // End Namespace Chroma
Primary include file for CHROMA library code.
#define END_CODE()
Definition: chromabase.h:65
#define START_CODE()
Definition: chromabase.h:64
Support class for fermion actions and linear operators.
Definition: state.h:94
Class for counted reference semantics.
Definition: handle.h:33
Real u0
int mu
Definition: cool.cc:24
Real Mass
Nd
Definition: meslate.cc:74
Double tmp2
Definition: mesq.cc:30
multi1d< Hadron2PtContraction_t > operator()(const multi1d< LatticeColorMatrix > &u)
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
QDP_error_exit("too many BiCG iterations", n_count, rsd_sq, cp, c, re_rvr, im_rvr, re_a, im_a, re_b, im_b)
static multi1d< LatticeColorMatrix > u
@ PLUS
Definition: chromabase.h:45
Double zero
Definition: invbicg.cc:106
chi
Definition: pade_trln_w.cc:24
psi
Definition: pade_trln_w.cc:191
#define FORWARD
Definition: primitives.h:82
#define BACKWARD
Definition: primitives.h:83
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.
Unpreconditioned Hamber-Wu fermion linear operator.