CellGPU
0.8.0
GPU-accelerated simulations of cells
|
Construct simple cell/bucket structures on the GPU, using kernels in cellListGPU Kernels. More...
#include <cellListGPU.h>
Public Member Functions | |
cellListGPU () | |
Blank constructor. | |
cellListGPU (vector< Dscalar > &points) | |
construct with a given set of points More... | |
cellListGPU (Dscalar a, vector< Dscalar > &points, gpubox &bx) | |
constructor with points, a box, and a size for the underlying grid More... | |
void | setParticles (const vector< Dscalar > &points) |
Set the object's points to a given vector. More... | |
void | setParticles (const vector< Dscalar2 > &points) |
Set the object's points to a given vector of Dscalar2s. More... | |
void | setBox (gpubox &bx) |
Set the objects box object. More... | |
void | setBox (BoxPtr bx) |
Set the BoxPtr to point to an existing one. | |
void | setNp (int nn) |
Set the number of particles to put in the buckets. More... | |
void | setGridSize (Dscalar a) |
call setGridSize if the particles and box already set, as this doubles as a general initialization of data structures More... | |
int | getNmax () |
Get am upper bound on the maximum number of particles in a given bucket. | |
int | getXsize () |
The number of cells in the x-direction. | |
int | getYsize () |
The number of cells in the y-direction. | |
Dscalar | getBoxsize () |
Returns the length of the square that forms the base grid size. | |
int | positionToCellIndex (Dscalar x, Dscalar y) |
If the grid is already initialized, given a spatial position return the cell index. More... | |
void | getCellNeighbors (int cellIndex, int width, vector< int > &cellNeighbors) |
given a target cell and a width, get all cell indices that sit in the surrounding square More... | |
void | getCellShellNeighbors (int cellIndex, int width, vector< int > &cellNeighbors) |
given a target cell and a width, get all cell indices that sit on the requested shell More... | |
void | resetCellSizesCPU () |
Initialization and helper without using the GPU. More... | |
void | resetCellSizes () |
Initialization and helper. More... | |
const GPUArray< unsigned int > & | getCellSizeArray () const |
Return the array of particles per cell. | |
const GPUArray< int > & | getIdxArray () const |
Return the array of cell indices in the different cells. | |
void | compute () |
Compute the cell list on the CPU, given the current particle positions in the GPUArray of particles. More... | |
void | computeGPU () |
Compute the cell list for the class' GPUArray of particles on the GPU. More... | |
void | computeGPU (GPUArray< Dscalar2 > &points) |
compute the cell list of the gpuarry passed to it. GPU function More... | |
void | compute (GPUArray< Dscalar2 > &points) |
compute the cell list of the gpuarry passed to it. GPU function More... | |
void | repP (int i) |
A debugging function to report where a point is. | |
Public Attributes | |
Index2D | cell_indexer |
Indexes the cells in the grid themselves (so the bin corresponding to the (j,i) position of the grid is bin=cell_indexer(i,j)) | |
Index2D | cell_list_indexer |
Indexes elements in the cell list. | |
GPUArray< Dscalar2 > | particles |
The particles that some methods act on. | |
GPUArray< unsigned int > | cell_sizes |
An array containing the number of elements in each cell. | |
GPUArray< int > | idxs |
An array containing the indices of particles in various cells. So, idx[cell_list_indexer(nn,bin)] gives the index of the nth particle in the bin "bin" of the cell list. | |
Protected Attributes | |
GPUArray< int > | assist |
first index is Nmax, second is whether to recompute | |
int | Np |
The number of particles to put in cells. | |
Dscalar | boxsize |
The linear size of each grid cell. | |
int | xsize |
The number of bins in the x-direction. | |
int | ysize |
the number of bins in the y-direction | |
int | totalCells |
xsize*ysize | |
int | Nmax |
the maximum number of particles found in any bin | |
BoxPtr | Box |
The Box used to compute periodic distances. | |
Construct simple cell/bucket structures on the GPU, using kernels in cellListGPU Kernels.
A class that can sort points into a grid of buckets. This enables local searches for particle neighbors, etc. Note that at the moment this class (and some of the classes above it) can only handle square boxes. This is not a fundamental limitation, though.
cellListGPU::cellListGPU | ( | vector< Dscalar > & | points | ) |
construct with a given set of points
points | the positions of points to populate the cell list with |
References Box, Nmax, and setParticles().
cellListGPU::cellListGPU | ( | Dscalar | a, |
vector< Dscalar > & | points, | ||
gpubox & | bx | ||
) |
constructor with points, a box, and a size for the underlying grid
a | the approximate side length of the cells |
points | the positions of points to populate the cell list with |
bx | the period box for the system |
void cellListGPU::setParticles | ( | const vector< Dscalar > & | points | ) |
Set the object's points to a given vector.
points | set the list of points cellListGPU knows about to this vector |
References ArrayHandle< T >::data, access_location::host, Np, access_mode::overwrite, particles, and GPUArray< T >::resize().
Referenced by cellListGPU(), and voronoiModelBase::updateCellList().
void cellListGPU::setParticles | ( | const vector< Dscalar2 > & | points | ) |
Set the object's points to a given vector of Dscalar2s.
points | set the list of points cellListGPU knows about to this vector of Dscalar2's |
References ArrayHandle< T >::data, access_location::host, Np, access_mode::overwrite, particles, and GPUArray< T >::resize().
void cellListGPU::setBox | ( | gpubox & | bx | ) |
Set the objects box object.
bx | the box defining the periodic unit cell |
void cellListGPU::setNp | ( | int | nn | ) |
Set the number of particles to put in the buckets.
nn | the number of particles to sort |
References Np.
Referenced by voronoiModelBase::resizeAndReset(), and setBox().
void cellListGPU::setGridSize | ( | Dscalar | a | ) |
call setGridSize if the particles and box already set, as this doubles as a general initialization of data structures
a | the approximate side length of all of the cells. This routine currently picks an even integer of cells, close to the desired size, that fit in the box. |
Referenced by setBox().
int cellListGPU::positionToCellIndex | ( | Dscalar | x, |
Dscalar | y | ||
) |
If the grid is already initialized, given a spatial position return the cell index.
x | the x coordinate of the position |
y | the y coordinate of the position returns the cell index that (x,y) would be contained in for the current cell list |
void cellListGPU::getCellNeighbors | ( | int | cellIndex, |
int | width, | ||
vector< int > & | cellNeighbors | ||
) |
given a target cell and a width, get all cell indices that sit in the surrounding square
cellIndex | the base cell index to find the neighbors of |
width | the distance (in cells) to search |
cellNeighbors | a vector of all cell indices that are neighbors of cellIndex |
References cell_indexer, xsize, and ysize.
void cellListGPU::getCellShellNeighbors | ( | int | cellIndex, |
int | width, | ||
vector< int > & | cellNeighbors | ||
) |
given a target cell and a width, get all cell indices that sit on the requested shell
cellIndex | the base cell index to find the neighbors of |
width | the distance (in cells) to search |
cellNeighbors | a vector of all cell indices that are neighbors of cellIndex This method returns a square outline of neighbors (the neighbor shell) rather than all neighbors within a set distance |
References cell_indexer, xsize, and ysize.
void cellListGPU::resetCellSizesCPU | ( | ) |
Initialization and helper without using the GPU.
Sets all cell sizes to zero, all cell indices to zero, and resets the "assist" utility structure, all on the CPU (so that no expensive copies are needed)
References assist, cell_list_indexer, cell_sizes, ArrayHandle< T >::data, Index2D::getNumElements(), GPUArray< T >::getNumElements(), access_location::host, idxs, Nmax, access_mode::overwrite, GPUArray< T >::resize(), totalCells, xsize, and ysize.
Referenced by compute().
void cellListGPU::resetCellSizes | ( | ) |
Initialization and helper.
Sets all cell sizes to zero, all cell indices to zero, and resets the "assist" utility structure, all on the GPU so that arrays don't need to be copied back to the host
References assist, cell_list_indexer, cell_sizes, ArrayHandle< T >::data, access_location::device, Index2D::getNumElements(), GPUArray< T >::getNumElements(), gpu_zero_array(), access_location::host, idxs, Nmax, access_mode::overwrite, GPUArray< T >::resize(), totalCells, xsize, and ysize.
Referenced by computeGPU().
void cellListGPU::compute | ( | ) |
Compute the cell list on the CPU, given the current particle positions in the GPUArray of particles.
This puts the points the cellList currently knows about into cells
References boxsize, cell_indexer, cell_list_indexer, cell_sizes, ArrayHandle< T >::data, access_location::host, idxs, Nmax, Np, particles, access_mode::read, access_mode::readwrite, resetCellSizesCPU(), and totalCells.
Referenced by getIdxArray(), and voronoiModelBase::updateCellList().
void cellListGPU::computeGPU | ( | ) |
Compute the cell list for the class' GPUArray of particles on the GPU.
Assign known points to cells on the GPU
References assist, Box, boxsize, cell_indexer, cell_list_indexer, cell_sizes, ArrayHandle< T >::data, access_location::device, gpu_compute_cell_list(), access_location::host, idxs, Nmax, Np, particles, access_mode::read, access_mode::readwrite, resetCellSizes(), totalCells, xsize, and ysize.
Referenced by getIdxArray(), and voronoiModelBase::updateCellList().
void cellListGPU::computeGPU | ( | GPUArray< Dscalar2 > & | points | ) |
compute the cell list of the gpuarry passed to it. GPU function
points | the set of points to assign to cells...on the GPU |
References assist, Box, boxsize, cell_indexer, cell_list_indexer, cell_sizes, ArrayHandle< T >::data, access_location::device, gpu_compute_cell_list(), access_location::host, idxs, Nmax, Np, access_mode::read, access_mode::readwrite, resetCellSizes(), totalCells, xsize, and ysize.
void cellListGPU::compute | ( | GPUArray< Dscalar2 > & | points | ) |
compute the cell list of the gpuarry passed to it. GPU function
points | the set of points to assign to cells |
References boxsize, cell_indexer, cell_list_indexer, cell_sizes, ArrayHandle< T >::data, access_location::host, idxs, Nmax, Np, access_mode::read, access_mode::readwrite, resetCellSizesCPU(), and totalCells.