Grid 0.7.0
StaggeredVec5dImpl.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 StaggeredVec5dImpl : public PeriodicGaugeImpl<GaugeImplTypes<S, Representation::Dimension > > {
35
36public:
37
38 static const int Dimension = Representation::Dimension;
39 static const bool isFundamental = Representation::isFundamental;
40 static const bool LsVectorised=true;
41 typedef RealD Coeff_t ;
43
44 //Necessary?
45 constexpr bool is_fundamental() const{return Dimension == Nc ? 1 : 0;}
46
47
49
50 template <typename vtype> using iImplSpinor = iScalar<iScalar<iVector<vtype, Dimension> > >;
51 template <typename vtype> using iImplHalfSpinor = iScalar<iScalar<iVector<vtype, Dimension> > >;
53 template <typename vtype> using iImplGaugeField = iVector<iScalar<iMatrix<vtype, Dimension> >, Nd>;
54 template <typename vtype> using iImplGaugeLink = iScalar<iScalar<iMatrix<vtype, Dimension> > >;
55 template <typename vtype> using iImplPropagator = iScalar<iScalar<iMatrix<vtype, Dimension> > >;
56
57 // Make the doubled gauge field a *scalar*
62
65
68
69
71
76
78
80
81 template <class ref>
82 static accelerator_inline void loadLinkElement(Simd &reg, ref &memory)
83 {
84 vsplat(reg, memory);
85 }
86
89 const SiteHalfSpinor &chi,
90 int mu)
91 {
92 SiteGaugeLink UU;
93 for (int i = 0; i < Dimension; i++) {
94 for (int j = 0; j < Dimension; j++) {
95 vsplat(UU()()(i, j), U(mu)()(i, j));
96 }
97 }
98 mult(&phi(), &UU(), &chi());
99 }
102 const SiteHalfSpinor &chi,
103 int mu)
104 {
105 SiteGaugeLink UU;
106 for (int i = 0; i < Dimension; i++) {
107 for (int j = 0; j < Dimension; j++) {
108 vsplat(UU()()(i, j), U(mu)()(i, j));
109 }
110 }
111 mac(&phi(), &UU(), &chi());
112 }
113
114 inline void InsertGaugeField(DoubledGaugeField &U_ds,const GaugeLinkField &U,int mu)
115 {
116 assert(0);
117 }
118 inline void DoubleStore(GridBase *GaugeGrid,
119 DoubledGaugeField &UUUds, // for Naik term
121 const GaugeField &Uthin,
122 const GaugeField &Ufat)
123 {
124
125 GridBase * InputGrid = Uthin.Grid();
126 conformable(InputGrid,Ufat.Grid());
127
128 GaugeLinkField U(InputGrid);
129 GaugeLinkField UU(InputGrid);
130 GaugeLinkField UUU(InputGrid);
131 GaugeLinkField Udag(InputGrid);
132 GaugeLinkField UUUdag(InputGrid);
133
134 for (int mu = 0; mu < Nd; mu++) {
135
136 // Staggered Phase.
137 Lattice<iScalar<vInteger> > coor(InputGrid);
138 Lattice<iScalar<vInteger> > x(InputGrid); LatticeCoordinate(x,0);
139 Lattice<iScalar<vInteger> > y(InputGrid); LatticeCoordinate(y,1);
140 Lattice<iScalar<vInteger> > z(InputGrid); LatticeCoordinate(z,2);
141 Lattice<iScalar<vInteger> > t(InputGrid); LatticeCoordinate(t,3);
142
143 Lattice<iScalar<vInteger> > lin_z(InputGrid); lin_z=x+y;
144 Lattice<iScalar<vInteger> > lin_t(InputGrid); lin_t=x+y+z;
145
146 ComplexField phases(InputGrid); phases=1.0;
147
148 if ( mu == 1 ) phases = where( mod(x ,2)==(Integer)0, phases,-phases);
149 if ( mu == 2 ) phases = where( mod(lin_z,2)==(Integer)0, phases,-phases);
150 if ( mu == 3 ) phases = where( mod(lin_t,2)==(Integer)0, phases,-phases);
151
152 // 1 hop based on fat links
153 U = PeekIndex<LorentzIndex>(Ufat, mu);
154 Udag = adj( Cshift(U, mu, -1));
155
156 U = U *phases;
157 Udag = Udag *phases;
158
159 InsertGaugeField(Uds,U,mu);
160 InsertGaugeField(Uds,Udag,mu+4);
161
162 // 3 hop based on thin links. Crazy huh ?
163 U = PeekIndex<LorentzIndex>(Uthin, mu);
164 UU = Gimpl::CovShiftForward(U,mu,U);
165 UUU= Gimpl::CovShiftForward(U,mu,UU);
166
167 UUUdag = adj( Cshift(UUU, mu, -3));
168
169 UUU = UUU *phases;
170 UUUdag = UUUdag *phases;
171
172 InsertGaugeField(UUUds,UUU,mu);
173 InsertGaugeField(UUUds,UUUdag,mu+4);
174
175 }
176 }
177
178 inline void InsertForce4D(GaugeField &mat, FermionField &Btilde, FermionField &A,int mu){
179 assert(0);
180 }
181
182 inline void InsertForce5D(GaugeField &mat, FermionField &Btilde, FermionField &Atilde,int mu){
183 assert (0);
184 }
185};
189
#define accelerator_inline
auto Cshift(const Expression &expr, int dim, int shift) -> decltype(closure(expr))
Definition Cshift.h:55
accelerator_inline void vsplat(Grid_simd2< S, V > &ret, ABtype a, ABtype b)
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 PeekIndex(const Lattice< vobj > &lhs, int i) -> Lattice< decltype(peekIndex< Index >(vobj(), i))>
Lattice< vobj > adj(const Lattice< vobj > &lhs)
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
StaggeredVec5dImpl< vComplexF, FundamentalRepresentation > StaggeredVec5dImplF
StaggeredVec5dImpl< vComplexD, FundamentalRepresentation > StaggeredVec5dImplD
StaggeredVec5dImpl< vComplex, FundamentalRepresentation > StaggeredVec5dImplR
static INTERNAL_PRECISION U
Definition Zolotarev.cc:230
const CartesianStencilView< SiteSpinor, SiteSpinor, ImplParams > View_type
Definition Stencil.h:206
static Lattice< covariant > CovShiftForward(const GaugeLinkField &Link, int mu, const Lattice< covariant > &field)
iScalar< iScalar< iMatrix< vtype, Dimension > > > iImplGaugeLink
Lattice< SitePropagator > PropagatorField
iVector< iScalar< iMatrix< vtype, Dimension > >, Nds > iImplDoubledGaugeField
Lattice< SiteDoubledGaugeField > DoubledGaugeField
iVector< iScalar< iMatrix< vtype, Dimension > >, Nd > iImplGaugeField
static accelerator_inline void loadLinkElement(Simd &reg, ref &memory)
void InsertGaugeField(DoubledGaugeField &U_ds, const GaugeLinkField &U, int mu)
iImplGaugeField< typename Simd::scalar_type > SiteScalarGaugeField
void InsertForce4D(GaugeField &mat, FermionField &Btilde, FermionField &A, int mu)
StaggeredImplParams ImplParams
CartesianStencil< SiteSpinor, SiteSpinor, ImplParams > StencilImpl
StaggeredVec5dImpl(const ImplParams &p=ImplParams())
iImplPropagator< Simd > SitePropagator
static accelerator_inline void multLinkAdd(SiteHalfSpinor &phi, const SiteDoubledGaugeField &U, const SiteHalfSpinor &chi, int mu)
StencilImpl::View_type StencilView
Lattice< SiteSpinor > FermionField
INHERIT_GIMPL_TYPES(Gimpl)
iScalar< iScalar< iVector< vtype, Dimension > > > iImplHalfSpinor
void DoubleStore(GridBase *GaugeGrid, DoubledGaugeField &UUUds, DoubledGaugeField &Uds, const GaugeField &Uthin, const GaugeField &Ufat)
iImplSpinor< Simd > SiteSpinor
static accelerator_inline void multLink(SiteHalfSpinor &phi, const SiteDoubledGaugeField &U, const SiteHalfSpinor &chi, int mu)
constexpr bool is_fundamental() const
iScalar< iScalar< iMatrix< vtype, Dimension > > > iImplPropagator
void InsertForce5D(GaugeField &mat, FermionField &Btilde, FermionField &Atilde, int mu)
PeriodicGaugeImpl< GaugeImplTypes< S, Dimension > > Gimpl
iImplDoubledGaugeField< typename Simd::scalar_type > SiteDoubledGaugeField
iScalar< iScalar< iVector< vtype, Dimension > > > iImplSpinor
iImplGaugeLink< typename Simd::scalar_type > SiteScalarGaugeLink
iImplHalfSpinor< Simd > SiteHalfSpinor
SimpleCompressor< SiteSpinor > Compressor