Grid 0.7.0
StaggeredImpl.h
Go to the documentation of this file.
1/*************************************************************************************
2
3Grid physics library, www.github.com/paboyle/Grid
4
5Source file: ./lib/qcd/action/fermion/FermionOperatorImpl.h
6
7Copyright (C) 2015
8
9Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
10
11This program is free software; you can redistribute it and/or modify
12it under the terms of the GNU General Public License as published by
13the Free Software Foundation; either version 2 of the License, or
14(at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License along
22with this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24
25See the full license in the file "LICENSE" in the top level distribution
26directory
27*************************************************************************************/
28 /* END LEGAL */
29#pragma once
30
32
33template <class S, class Representation = FundamentalRepresentation >
34class StaggeredImpl : public PeriodicGaugeImpl<GaugeImplTypes<S, Representation::Dimension > >
35{
36
37public:
38
39 typedef RealD _Coeff_t ;
40 static const int Dimension = Representation::Dimension;
41 static const bool isFundamental = Representation::isFundamental;
42 static const bool LsVectorised=false;
44
45 //Necessary?
46 constexpr bool is_fundamental() const{return Dimension == Nc ? 1 : 0;}
47
49
51
52 template <typename vtype> using iImplSpinor = iScalar<iScalar<iVector<vtype, Dimension> > >;
53 template <typename vtype> using iImplHalfSpinor = iScalar<iScalar<iVector<vtype, Dimension> > >;
55 template <typename vtype> using iImplPropagator = iScalar<iScalar<iMatrix<vtype, Dimension> > >;
56
61
65
70
72
74
75 template<class _Spinor>
76 static accelerator_inline void multLink(_Spinor &phi,
78 const _Spinor &chi,
79 int mu)
80 {
81 auto UU = coalescedRead(U(mu));
82 mult(&phi(), &UU, &chi());
83 }
84 template<class _Spinor>
85 static accelerator_inline void multLinkAdd(_Spinor &phi,
87 const _Spinor &chi,
88 int mu)
89 {
90 auto UU = coalescedRead(U(mu));
91 mac(&phi(), &UU, &chi());
92 }
93
94 template <class ref>
95 static accelerator_inline void loadLinkElement(Simd &reg, ref &memory)
96 {
97 reg = memory;
98 }
99
101 const GaugeLinkField &U,int mu)
102 {
103 PokeIndex<LorentzIndex>(U_ds, U, mu);
104 }
105 inline void DoubleStore(GridBase *GaugeGrid,
106 DoubledGaugeField &UUUds, // for Naik term
108 const GaugeField &Uthin,
109 const GaugeField &Ufat) {
110 conformable(Uds.Grid(), GaugeGrid);
111 conformable(Uthin.Grid(), GaugeGrid);
112 conformable(Ufat.Grid(), GaugeGrid);
113 GaugeLinkField U(GaugeGrid);
114 GaugeLinkField UU(GaugeGrid);
115 GaugeLinkField UUU(GaugeGrid);
116 GaugeLinkField Udag(GaugeGrid);
117 GaugeLinkField UUUdag(GaugeGrid);
118 for (int mu = 0; mu < Nd; mu++) {
119
120 // Staggered Phase.
121 Lattice<iScalar<vInteger> > coor(GaugeGrid);
122 Lattice<iScalar<vInteger> > x(GaugeGrid); LatticeCoordinate(x,0);
123 Lattice<iScalar<vInteger> > y(GaugeGrid); LatticeCoordinate(y,1);
124 Lattice<iScalar<vInteger> > z(GaugeGrid); LatticeCoordinate(z,2);
125 Lattice<iScalar<vInteger> > t(GaugeGrid); LatticeCoordinate(t,3);
126
127 Lattice<iScalar<vInteger> > lin_z(GaugeGrid); lin_z=x+y;
128 Lattice<iScalar<vInteger> > lin_t(GaugeGrid); lin_t=x+y+z;
129
130 ComplexField phases(GaugeGrid); phases=1.0;
131
132 if ( mu == 1 ) phases = where( mod(x ,2)==(Integer)0, phases,-phases);
133 if ( mu == 2 ) phases = where( mod(lin_z,2)==(Integer)0, phases,-phases);
134 if ( mu == 3 ) phases = where( mod(lin_t,2)==(Integer)0, phases,-phases);
135
136 // 1 hop based on fat links
137 U = PeekIndex<LorentzIndex>(Ufat, mu);
138 Udag = adj( Cshift(U, mu, -1));
139
140 U = U *phases;
141 Udag = Udag *phases;
142
143 InsertGaugeField(Uds,U,mu);
144 InsertGaugeField(Uds,Udag,mu+4);
145 // PokeIndex<LorentzIndex>(Uds, U, mu);
146 // PokeIndex<LorentzIndex>(Uds, Udag, mu + 4);
147
148 // 3 hop based on thin links. Crazy huh ?
149 U = PeekIndex<LorentzIndex>(Uthin, mu);
150 UU = Gimpl::CovShiftForward(U,mu,U);
151 UUU= Gimpl::CovShiftForward(U,mu,UU);
152
153 UUUdag = adj( Cshift(UUU, mu, -3));
154
155 UUU = UUU *phases;
156 UUUdag = UUUdag *phases;
157
158 InsertGaugeField(UUUds,UUU,mu);
159 InsertGaugeField(UUUds,UUUdag,mu+4);
160
161 }
162 }
163
164 inline void InsertForce4D(GaugeField &mat, FermionField &Btilde, FermionField &A,int mu){
165 GaugeLinkField link(mat.Grid());
166 link = TraceIndex<SpinIndex>(outerProduct(Btilde,A));
167 PokeIndex<LorentzIndex>(mat,link,mu);
168 }
169
170 inline void InsertForce5D(GaugeField &mat, FermionField &Btilde, FermionField &Atilde,int mu){
171 assert (0);
172 // Must never hit
173 }
174};
178
#define accelerator_inline
auto Cshift(const Expression &expr, int dim, int shift) -> decltype(closure(expr))
Definition Cshift.h:55
void mac(Lattice< obj1 > &ret, const Lattice< obj2 > &lhs, const Lattice< obj3 > &rhs)
void mult(Lattice< obj1 > &ret, const Lattice< obj2 > &lhs, const Lattice< obj3 > &rhs)
void conformable(const Lattice< obj1 > &lhs, const Lattice< obj2 > &rhs)
void LatticeCoordinate(Lattice< iobj > &l, int mu)
auto outerProduct(const Lattice< ll > &lhs, const Lattice< rr > &rhs) -> Lattice< decltype(outerProduct(ll(), rr()))>
void PokeIndex(Lattice< vobj > &lhs, const Lattice< decltype(peekIndex< Index >(vobj(), 0))> &rhs, int i)
auto PeekIndex(const Lattice< vobj > &lhs, int i) -> Lattice< decltype(peekIndex< Index >(vobj(), i))>
Lattice< vobj > adj(const Lattice< vobj > &lhs)
auto TraceIndex(const Lattice< vobj > &lhs) -> Lattice< decltype(traceIndex< Index >(vobj()))>
Lattice< obj > mod(const Lattice< obj > &rhs_i, Integer y)
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
static constexpr int Nd
Definition QCD.h:52
static constexpr int Nc
Definition QCD.h:50
static constexpr int Nds
Definition QCD.h:54
uint32_t Integer
Definition Simd.h:58
double RealD
Definition Simd.h:61
SimpleCompressorGather< vobj, FaceGatherSimple > SimpleCompressor
StaggeredImpl< vComplexD, FundamentalRepresentation > StaggeredImplD
StaggeredImpl< vComplexF, FundamentalRepresentation > StaggeredImplF
StaggeredImpl< vComplex, FundamentalRepresentation > StaggeredImplR
accelerator_inline vobj coalescedRead(const vobj &__restrict__ vec, int lane=0)
Definition Tensor_SIMT.h:61
static INTERNAL_PRECISION U
Definition Zolotarev.cc:230
const CartesianStencilView< SiteSpinor, SiteSpinor, ImplParams > View_type
Definition Stencil.h:206
GridBase * Grid(void) const
static Lattice< covariant > CovShiftForward(const GaugeLinkField &Link, int mu, const Lattice< covariant > &field)
Lattice< SiteDoubledGaugeField > DoubledGaugeField
constexpr bool is_fundamental() const
SimpleCompressor< SiteSpinor > Compressor
static accelerator_inline void multLinkAdd(_Spinor &phi, const SiteDoubledGaugeField &U, const _Spinor &chi, int mu)
StencilImpl::View_type StencilView
iImplHalfSpinor< Simd > SiteHalfSpinor
Lattice< SiteSpinor > FermionField
void InsertGaugeField(DoubledGaugeField &U_ds, const GaugeLinkField &U, int mu)
iScalar< iScalar< iMatrix< vtype, Dimension > > > iImplPropagator
Lattice< SitePropagator > PropagatorField
iVector< iScalar< iMatrix< vtype, Dimension > >, Nds > iImplDoubledGaugeField
static accelerator_inline void loadLinkElement(Simd &reg, ref &memory)
iImplDoubledGaugeField< Simd > SiteDoubledGaugeField
_Coeff_t Coeff_t
iImplSpinor< Simd > SiteSpinor
iImplPropagator< Simd > SitePropagator
iScalar< iScalar< iVector< vtype, Dimension > > > iImplHalfSpinor
void InsertForce5D(GaugeField &mat, FermionField &Btilde, FermionField &Atilde, int mu)
CartesianStencil< SiteSpinor, SiteSpinor, ImplParams > StencilImpl
PeriodicGaugeImpl< GaugeImplTypes< S, Dimension > > Gimpl
StaggeredImplParams ImplParams
void InsertForce4D(GaugeField &mat, FermionField &Btilde, FermionField &A, int mu)
StaggeredImpl(const ImplParams &p=ImplParams())
void DoubleStore(GridBase *GaugeGrid, DoubledGaugeField &UUUds, DoubledGaugeField &Uds, const GaugeField &Uthin, const GaugeField &Ufat)
static accelerator_inline void multLink(_Spinor &phi, const SiteDoubledGaugeField &U, const _Spinor &chi, int mu)
INHERIT_GIMPL_TYPES(Gimpl)
iScalar< iScalar< iVector< vtype, Dimension > > > iImplSpinor