/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: ./lib/lattice/PaddedCell.h Copyright (C) 2019 Author: Peter Boyle pboyle@bnl.gov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ #pragma once NAMESPACE_BEGIN(Grid); class PaddedCell { public: GridCartesian * unpadded_grid; int dims; int depth; std::vector grids; ~PaddedCell() { DeleteGrids(); } PaddedCell(int _depth,GridCartesian *_grid) { unpadded_grid = _grid; depth=_depth; dims=_grid->Nd(); AllocateGrids(); Coordinate local =unpadded_grid->LocalDimensions(); Coordinate procs =unpadded_grid->ProcessorGrid(); for(int d=0;d 1 ) assert(local[d]>=depth); } } void DeleteGrids(void) { for(int d=0;dLocalDimensions(); Coordinate simd =unpadded_grid->_simd_layout; Coordinate processors=unpadded_grid->_processors; Coordinate plocal =unpadded_grid->LocalDimensions(); Coordinate global(dims); // expand up one dim at a time for(int d=0;d inline Lattice Extract(Lattice &in) { Lattice out(unpadded_grid); Coordinate local =unpadded_grid->LocalDimensions(); Coordinate fll(dims,depth); // depends on the MPI spread Coordinate tll(dims,0); // depends on the MPI spread localCopyRegion(in,out,fll,tll,local); return out; } template inline Lattice Exchange(Lattice &in) { 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) { GridBase *old_grid = in.Grid(); GridCartesian *new_grid = grids[dim];//These are new grids Lattice padded(new_grid); Lattice shifted(old_grid); Coordinate local =old_grid->LocalDimensions(); Coordinate plocal =new_grid->LocalDimensions(); if(dim==0) conformable(old_grid,unpadded_grid); else conformable(old_grid,grids[dim-1]); // std::cout << " dim "<