Open Qmin
0.8.0
GPU-accelerated Q-tensor-based liquid crystal simulations
|
Construct simple cell/bucket structures on the CPU or GPU given a hyper-rectangular domain with PBCs. More...
#include <hyperrectangularCellList.h>
Public Member Functions | |
hyperrectangularCellList () | |
Blank constructor. More... | |
hyperrectangularCellList (scalar a, BoxPtr _box) | |
a box, and a size for the underlying grid More... | |
void | setBox (BoxPtr bx) |
Set the BoxPtr to point to an existing one. More... | |
void | setGridSize (scalar a) |
call setGridSize if the particles and box already set, as this doubles as a general initialization of data structures More... | |
int | getNmax () |
Get an upper bound on the maximum number of particles in a given bucket. More... | |
iVec | getBinsPerSide () |
The number of cells in each direction. More... | |
dVec | getCellSize () |
Returns the length of the square that forms the base grid size. More... | |
int | positionToCellIndex (const dVec &pos) |
Return the index of the cell that contains the given point. More... | |
iVec | indexToiVec (const int cellIndex) |
return the iVec corresponding to a 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 | 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. More... | |
const GPUArray< int > & | getIdxArray () const |
Return the array of cell indices in the different cells. More... | |
void | computeCellList (GPUArray< dVec > &points) |
compute the cell list of the gpuarry passed to it. More... | |
void | computeGPU (GPUArray< dVec > &points) |
compute the cell list of the gpuarry passed to it. GPU function More... | |
void | computeCPU (GPUArray< dVec > &points) |
compute the cell list of the gpuarry passed to it. CPU function More... | |
virtual void | setGPU (bool _useGPU=true) |
Enforce GPU operation. More... | |
GPUArray< int > & | returnAdjacentCells () |
return the list of adjacent cells More... | |
void | computeAdjacentCells (int width=1) |
compute the adjacent cells up to a scale More... | |
Public Attributes | |
IndexDD | cellIndexer |
Indexes the cells in the grid themselves (so the index of the bin corresponding to (iVec) is bin = cellIndexer(iVec) More... | |
Index2D | cellListIndexer |
Indexes elements in the cell list (i.e., the third element of cell index i is cellListIndexer(3,i) More... | |
GPUArray< unsigned int > | elementsPerCell |
An array containing the number of elements in each cell. More... | |
GPUArray< int > | particleIndices |
An array containing the indices of particles in various cells. So, particleIndices[cellListIndexer(nn,bin)] gives the index of the nth particle in the bin "bin" of the cell list. More... | |
GPUArray< dVec > | particlePositions |
An array containing the positions of particles in various cells. Aligned with the particleIndices array, so that derived methods can choose whatever is most convenient,so particlePositions[cellListIndexer(nn,bin)] gives the positionof the nth particle in the bin "bin" of the cell list. More... | |
int | computations |
A reporter index of how hard it was to compute the cell list. More... | |
int | adjacentCellsPerCell |
the number of cells in the adjacency list for each cell More... | |
Index2D | adjacentCellIndexer |
indexes the adjacent cells of each cell More... | |
Protected Attributes | |
GPUArray< int > | assist |
first index is Nmax, second is whether to recompute More... | |
GPUArray< int > | adjacentCells |
an array that stores the list cell adjacent to every cell More... | |
iVec | gridCellsPerSide |
The number of bins in each of the different dimensions. More... | |
dVec | gridCellSizes |
The size of each cell (e.g., each cell is a small hyperrectangle of these dimensions. More... | |
int | totalCells |
int | Nmax |
the maximum number of particles found in any bin More... | |
BoxPtr | Box |
The Box used to compute periodic distances. More... | |
bool | useGPU |
whether the updater does its work on the GPU or not More... | |
bool | adjCellsComputed |
have we already computed the adjacent cell lists? More... | |
Construct simple cell/bucket structures on the CPU or GPU given a hyper-rectangular domain with PBCs.
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 can only handle hyper-rectangular boxes.
|
inline |
a box, and a size for the underlying grid
a | the approximate side length of the cells |
_box | the period box for the system |
References Box, Nmax, setGridSize(), and useGPU.
|
inline |
Set the BoxPtr to point to an existing one.
References Box.
void hyperrectangularCellList::setGridSize | ( | scalar | 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 in each dimension, close to the desired size, that fit in the box. |
References adjCellsComputed, Box, cellIndexer, cellListIndexer, elementsPerCell, gridCellSizes, gridCellsPerSide, Nmax, resetCellSizesCPU(), GPUArray< T >::resize(), totalCells, and iVec::x.
Referenced by hyperrectangularCellList().
|
inline |
Get an upper bound on the maximum number of particles in a given bucket.
References Nmax.
|
inline |
The number of cells in each direction.
References gridCellsPerSide.
|
inline |
Returns the length of the square that forms the base grid size.
References gridCellSizes.
int hyperrectangularCellList::positionToCellIndex | ( | const dVec & | pos | ) |
Return the index of the cell that contains the given point.
pos | the dVec coordinate of the position returns the cell index that (pos) would be contained in for the current cell list |
References cellIndexer, gridCellSizes, gridCellsPerSide, and iVec::x.
|
inline |
return the iVec corresponding to a cell index
References cellIndexer, and IndexDD::inverseIndex().
void hyperrectangularCellList::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 cellIndexer, gridCellsPerSide, idPow(), IndexDD::inverseIndex(), iVecIterate(), modularAddition(), and iVec::x.
void hyperrectangularCellList::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, cellListIndexer, ArrayHandle< T >::data, elementsPerCell, Index2D::getNumElements(), GPUArray< T >::getNumElements(), access_location::host, Nmax, access_mode::overwrite, particleIndices, particlePositions, GPUArray< T >::resize(), and totalCells.
Referenced by computeCPU(), and setGridSize().
void hyperrectangularCellList::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, cellListIndexer, ArrayHandle< T >::data, access_location::device, elementsPerCell, Index2D::getNumElements(), GPUArray< T >::getNumElements(), gpu_set_array(), access_location::host, Nmax, NVTXPOP, NVTXPUSH, access_mode::overwrite, particleIndices, particlePositions, GPUArray< T >::resize(), and totalCells.
Referenced by computeGPU().
|
inline |
Return the array of particles per cell.
References elementsPerCell.
|
inline |
Return the array of cell indices in the different cells.
References particleIndices.
|
inline |
compute the cell list of the gpuarry passed to it.
References adjCellsComputed, computeAdjacentCells(), computeCPU(), computeGPU(), and useGPU.
void hyperrectangularCellList::computeGPU | ( | GPUArray< dVec > & | 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, cellIndexer, cellListIndexer, ArrayHandle< T >::data, access_location::device, elementsPerCell, GPUArray< T >::getNumElements(), gpu_compute_cell_list(), gridCellSizes, gridCellsPerSide, access_location::host, Nmax, NVTXPOP, NVTXPUSH, particleIndices, particlePositions, access_mode::read, access_mode::readwrite, resetCellSizes(), and totalCells.
Referenced by computeCellList().
void hyperrectangularCellList::computeCPU | ( | GPUArray< dVec > & | points | ) |
compute the cell list of the gpuarry passed to it. CPU function
points | the set of points to assign to cells |
References cellIndexer, cellListIndexer, computations, ArrayHandle< T >::data, elementsPerCell, GPUArray< T >::getNumElements(), gridCellSizes, access_location::host, Nmax, particleIndices, particlePositions, access_mode::read, access_mode::readwrite, resetCellSizesCPU(), totalCells, and iVec::x.
Referenced by computeCellList().
|
inlinevirtual |
Enforce GPU operation.
References useGPU.
|
inline |
return the list of adjacent cells
References adjacentCells.
void hyperrectangularCellList::computeAdjacentCells | ( | int | width = 1 | ) |
compute the adjacent cells up to a scale
width*gridsize should be a cutoff scale in the problem... this will evaluate all cells that might containt a neighbor within gridsize*width; not all cells in a hypercube of sidelength width
References adjacentCellIndexer, adjacentCells, adjacentCellsPerCell, adjCellsComputed, cellIndexer, ArrayHandle< T >::data, GPUArray< T >::getNumElements(), gridCellSizes, gridCellsPerSide, IndexDD::inverseIndex(), iVecIterate(), modularAddition(), GPUArray< T >::resize(), scalar, totalCells, and iVec::x.
Referenced by computeCellList().
IndexDD hyperrectangularCellList::cellIndexer |
Indexes the cells in the grid themselves (so the index of the bin corresponding to (iVec) is bin = cellIndexer(iVec)
Referenced by computeAdjacentCells(), computeCPU(), computeGPU(), getCellNeighbors(), indexToiVec(), positionToCellIndex(), and setGridSize().
Index2D hyperrectangularCellList::cellListIndexer |
Indexes elements in the cell list (i.e., the third element of cell index i is cellListIndexer(3,i)
Referenced by computeCPU(), computeGPU(), resetCellSizes(), resetCellSizesCPU(), and setGridSize().
GPUArray<unsigned int> hyperrectangularCellList::elementsPerCell |
An array containing the number of elements in each cell.
Referenced by computeCPU(), computeGPU(), getCellSizeArray(), resetCellSizes(), resetCellSizesCPU(), and setGridSize().
GPUArray<int> hyperrectangularCellList::particleIndices |
An array containing the indices of particles in various cells. So, particleIndices[cellListIndexer(nn,bin)] gives the index of the nth particle in the bin "bin" of the cell list.
Referenced by computeCPU(), computeGPU(), getIdxArray(), resetCellSizes(), and resetCellSizesCPU().
GPUArray<dVec> hyperrectangularCellList::particlePositions |
An array containing the positions of particles in various cells. Aligned with the particleIndices array, so that derived methods can choose whatever is most convenient,so particlePositions[cellListIndexer(nn,bin)] gives the positionof the nth particle in the bin "bin" of the cell list.
Referenced by computeCPU(), computeGPU(), resetCellSizes(), and resetCellSizesCPU().
int hyperrectangularCellList::computations |
A reporter index of how hard it was to compute the cell list.
Referenced by computeCPU().
int hyperrectangularCellList::adjacentCellsPerCell |
the number of cells in the adjacency list for each cell
Referenced by computeAdjacentCells().
Index2D hyperrectangularCellList::adjacentCellIndexer |
indexes the adjacent cells of each cell
Referenced by computeAdjacentCells().
|
protected |
first index is Nmax, second is whether to recompute
Referenced by computeGPU(), resetCellSizes(), and resetCellSizesCPU().
|
protected |
an array that stores the list cell adjacent to every cell
Referenced by computeAdjacentCells(), and returnAdjacentCells().
|
protected |
The number of bins in each of the different dimensions.
Referenced by computeAdjacentCells(), computeGPU(), getBinsPerSide(), getCellNeighbors(), positionToCellIndex(), and setGridSize().
|
protected |
The size of each cell (e.g., each cell is a small hyperrectangle of these dimensions.
Referenced by computeAdjacentCells(), computeCPU(), computeGPU(), getCellSize(), positionToCellIndex(), and setGridSize().
|
protected |
Referenced by computeAdjacentCells(), computeCPU(), computeGPU(), resetCellSizes(), resetCellSizesCPU(), and setGridSize().
|
protected |
the maximum number of particles found in any bin
Referenced by computeCPU(), computeGPU(), getNmax(), hyperrectangularCellList(), resetCellSizes(), resetCellSizesCPU(), and setGridSize().
|
protected |
The Box used to compute periodic distances.
Referenced by computeGPU(), hyperrectangularCellList(), setBox(), and setGridSize().
|
protected |
whether the updater does its work on the GPU or not
Referenced by computeCellList(), hyperrectangularCellList(), and setGPU().
|
protected |
have we already computed the adjacent cell lists?
Referenced by computeAdjacentCells(), computeCellList(), and setGridSize().