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++; } } } } } }
std::vector<unsigned> LinkCells::findMyCell( const Vector& pos ) const { Vector fpos=mypbc.realToScaled( pos ); std::vector<unsigned> celn(3); for(unsigned j=0;j<3;++j){ celn[j] = std::floor( ( Tools::pbc(fpos[j]) + 0.5 ) * ncells[j] ); plumed_assert( celn[j]>=0 && celn[j]<ncells[j] ); // Check that atom is in box } return celn; }
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] ); }