CellGPU  0.8.0
GPU-accelerated simulations of cells
Public Member Functions | Public Attributes | Protected Attributes | List of all members
cellListGPU Class Reference

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ cellListGPU() [1/2]

cellListGPU::cellListGPU ( vector< Dscalar > &  points)

construct with a given set of points

Parameters
pointsthe positions of points to populate the cell list with

References Box, Nmax, and setParticles().

◆ cellListGPU() [2/2]

cellListGPU::cellListGPU ( Dscalar  a,
vector< Dscalar > &  points,
gpubox bx 
)

constructor with points, a box, and a size for the underlying grid

Parameters
athe approximate side length of the cells
pointsthe positions of points to populate the cell list with
bxthe period box for the system

Member Function Documentation

◆ setParticles() [1/2]

void cellListGPU::setParticles ( const vector< Dscalar > &  points)

Set the object's points to a given vector.

Parameters
pointsset 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().

◆ setParticles() [2/2]

void cellListGPU::setParticles ( const vector< Dscalar2 > &  points)

Set the object's points to a given vector of Dscalar2s.

Parameters
pointsset 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().

◆ setBox()

void cellListGPU::setBox ( gpubox bx)

Set the objects box object.

Parameters
bxthe box defining the periodic unit cell

◆ setNp()

void cellListGPU::setNp ( int  nn)

Set the number of particles to put in the buckets.

Parameters
nnthe number of particles to sort

References Np.

Referenced by voronoiModelBase::resizeAndReset(), and setBox().

◆ setGridSize()

void cellListGPU::setGridSize ( Dscalar  a)

call setGridSize if the particles and box already set, as this doubles as a general initialization of data structures

Parameters
athe 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().

◆ positionToCellIndex()

int cellListGPU::positionToCellIndex ( Dscalar  x,
Dscalar  y 
)

If the grid is already initialized, given a spatial position return the cell index.

Parameters
xthe x coordinate of the position
ythe y coordinate of the position returns the cell index that (x,y) would be contained in for the current cell list

◆ getCellNeighbors()

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

Parameters
cellIndexthe base cell index to find the neighbors of
widththe distance (in cells) to search
cellNeighborsa vector of all cell indices that are neighbors of cellIndex

References cell_indexer, xsize, and ysize.

◆ getCellShellNeighbors()

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

Parameters
cellIndexthe base cell index to find the neighbors of
widththe distance (in cells) to search
cellNeighborsa 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.

◆ resetCellSizesCPU()

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().

◆ resetCellSizes()

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().

◆ compute() [1/2]

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().

◆ computeGPU() [1/2]

void cellListGPU::computeGPU ( )

◆ computeGPU() [2/2]

void cellListGPU::computeGPU ( GPUArray< Dscalar2 > &  points)

compute the cell list of the gpuarry passed to it. GPU function

Parameters
pointsthe 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.

◆ compute() [2/2]

void cellListGPU::compute ( GPUArray< Dscalar2 > &  points)

compute the cell list of the gpuarry passed to it. GPU function

Parameters
pointsthe 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.


The documentation for this class was generated from the following files: