diff --git a/Grid/lattice/PaddedCell.h b/Grid/lattice/PaddedCell.h index 863d361a..2efd2288 100644 --- a/Grid/lattice/PaddedCell.h +++ b/Grid/lattice/PaddedCell.h @@ -28,12 +28,28 @@ Author: Peter Boyle pboyle@bnl.gov NAMESPACE_BEGIN(Grid); +//Allow the user to specify how the C-shift is performed, e.g. to respect the appropriate boundary conditions +template +struct CshiftImplBase{ + virtual Lattice Cshift(const Lattice &in, int dir, int shift) const = 0; + virtual ~CshiftImplBase(){} +}; +template +struct CshiftImplDefault: public CshiftImplBase{ + Lattice Cshift(const Lattice &in, int dir, int shift) const override{ return Grid::Cshift(in,dir,shift); } +}; +template +struct CshiftImplGauge: public CshiftImplBase{ + typename Gimpl::GaugeLinkField Cshift(const typename Gimpl::GaugeLinkField &in, int dir, int shift) const override{ return Gimpl::CshiftLink(in,dir,shift); } +}; + class PaddedCell { public: GridCartesian * unpadded_grid; int dims; int depth; std::vector grids; + ~PaddedCell() { DeleteGrids(); @@ -77,7 +93,7 @@ public: } }; template - inline Lattice Extract(Lattice &in) + inline Lattice Extract(const Lattice &in) { Lattice out(unpadded_grid); @@ -88,19 +104,19 @@ public: return out; } template - inline Lattice Exchange(Lattice &in) + inline Lattice Exchange(const Lattice &in, const CshiftImplBase &cshift = CshiftImplDefault()) { GridBase *old_grid = in.Grid(); int dims = old_grid->Nd(); Lattice tmp = in; for(int d=0;d - inline Lattice Expand(int dim,Lattice &in) + inline Lattice Expand(int dim, const Lattice &in, const CshiftImplBase &cshift = CshiftImplDefault()) { GridBase *old_grid = in.Grid(); GridCartesian *new_grid = grids[dim];//These are new grids @@ -117,12 +133,12 @@ public: InsertSliceLocal(in,padded,x,depth+x,dim); } // High bit - shifted = Cshift(in,dim,depth); + shifted = cshift.Cshift(in,dim,depth); for(int x=0;x &conjDirs) { _conjDirs=conjDirs; } + static inline void setDirections(const std::vector &conjDirs) { _conjDirs=conjDirs; } static inline std::vector getDirections(void) { return _conjDirs; } static inline bool isPeriodicGaugeField(void) { return false; } }; diff --git a/tests/debug/Test_padded_cell_staple.cc b/tests/debug/Test_padded_cell_staple.cc index 5a7f412a..bed00cad 100644 --- a/tests/debug/Test_padded_cell_staple.cc +++ b/tests/debug/Test_padded_cell_staple.cc @@ -106,9 +106,10 @@ public: GaugeMat U_mu = PeekIndex(U, mu); GaugeMat U_nu = PeekIndex(U, nu); - - GaugeMat Ug_mu = Ghost.Exchange(U_mu); - GaugeMat Ug_nu = Ghost.Exchange(U_nu); + + CshiftImplGauge cshift_impl; + GaugeMat Ug_mu = Ghost.Exchange(U_mu, cshift_impl); + GaugeMat Ug_nu = Ghost.Exchange(U_nu, cshift_impl); GridBase *ggrid = Ug_mu.Grid(); GaugeMat gStaple(ggrid); @@ -299,11 +300,11 @@ public: static void RectStaplePadded(GaugeMat &Stap, const GaugeLorentz &U, int mu) { PaddedCell Ghost(2,U.Grid()); - GaugeLorentz Ug = Ghost.Exchange(const_cast(U)); - GridBase *ggrid = Ug.Grid(); - + GridBase *ggrid = Ghost.grids.back(); + + CshiftImplGauge cshift_impl; std::vector Ug_dirs(Nd,ggrid); - for(int i=0;i(Ug, i); + for(int i=0;i(U, i), cshift_impl); GaugeMat gStaple(ggrid); @@ -495,11 +496,14 @@ int main (int argc, char ** argv) SU::HotConfiguration(pRNG,U); - typedef PeriodicGimplD Gimpl; + //typedef PeriodicGimplD Gimpl; + typedef ConjugateGimplD Gimpl; + std::vector conj_dirs(Nd,0); conj_dirs[0]=1; conj_dirs[3]=1; + Gimpl::setDirections(conj_dirs); + typedef typename WilsonLoopsTest::GaugeMat GaugeMat; typedef typename WilsonLoopsTest::GaugeLorentz GaugeLorentz; -#if 0 std::cout << "Checking Staple" << std::endl; for(int mu=0;mu