void LinkCells::retrieveNeighboringAtoms( const Vector& pos, unsigned& natomsper, std::vector<unsigned>& atoms ) const { plumed_assert( natomsper==1 || natomsper==2 ); // This is really a bug. If you are trying to reuse this ask GAT for help std::vector<unsigned> celn( findMyCell( pos ) ); for(int nx=LINKC_MIN(ncells[0]);nx<LINKC_MAX(ncells[0]);++nx){ int xval = celn[0] + nx; xval=LINKC_PBC(xval,ncells[0])*nstride[0]; for(int ny=LINKC_MIN(ncells[1]);ny<LINKC_MAX(ncells[1]);++ny){ int yval = celn[1] + ny; yval=LINKC_PBC(yval,ncells[1])*nstride[1]; for(int nz=LINKC_MIN(ncells[2]);nz<LINKC_MAX(ncells[2]);++nz){ int zval = celn[2] + nz; zval=LINKC_PBC(zval,ncells[2])*nstride[2]; unsigned mybox=xval+yval+zval; for(unsigned k=0;k<lcell_tots[mybox];++k){ unsigned myatom = lcell_lists[lcell_starts[mybox]+k]; if( myatom!=atoms[0] ){ // Ideally would provide an option to not do this atoms[natomsper]=myatom; natomsper++; } } } } } }
unsigned LinkCells::findCell( const Vector& pos ) const { std::vector<unsigned> celn( findMyCell(pos ) ); return celn[0]*nstride[0] + celn[1]*nstride[1] + celn[2]*nstride[2]; }
unsigned LinkCells::findCell( const Vector& pos ) const { std::array<unsigned,3> celn( findMyCell(pos ) ); return convertIndicesToIndex( celn[0], celn[1], celn[2] ); }
void LinkCells::retrieveNeighboringAtoms( const Vector& pos, std::vector<unsigned>& cell_list, unsigned& natomsper, std::vector<unsigned>& atoms ) const { if( cell_list.size()!=getNumberOfCells() ) cell_list.resize( getNumberOfCells() ); unsigned ncellt=0; addRequiredCells( findMyCell( pos ), ncellt, cell_list ); retrieveAtomsInCells( ncellt, cell_list, natomsper, atoms ); }