Open Qmin  0.8.0
GPU-accelerated Q-tensor-based liquid crystal simulations
Public Member Functions | Public Attributes | Protected Attributes | List of all members
hyperrectangularCellList Class Reference

Construct simple cell/bucket structures on the CPU or GPU given a hyper-rectangular domain with PBCs. More...

#include <hyperrectangularCellList.h>

Collaboration diagram for hyperrectangularCellList:
Collaboration graph
[legend]

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

Detailed Description

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.

Constructor & Destructor Documentation

◆ hyperrectangularCellList() [1/2]

hyperrectangularCellList::hyperrectangularCellList ( )
inline

Blank constructor.

References Box, and Nmax.

◆ hyperrectangularCellList() [2/2]

hyperrectangularCellList::hyperrectangularCellList ( scalar  a,
BoxPtr  _box 
)

a box, and a size for the underlying grid

Parameters
athe approximate side length of the cells
_boxthe period box for the system

References Box, Nmax, setGridSize(), and useGPU.

Member Function Documentation

◆ setBox()

void hyperrectangularCellList::setBox ( BoxPtr  bx)
inline

Set the BoxPtr to point to an existing one.

References Box.

◆ setGridSize()

void hyperrectangularCellList::setGridSize ( scalar  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 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().

◆ getNmax()

int hyperrectangularCellList::getNmax ( )
inline

Get an upper bound on the maximum number of particles in a given bucket.

References Nmax.

◆ getBinsPerSide()

iVec hyperrectangularCellList::getBinsPerSide ( )
inline

The number of cells in each direction.

References gridCellsPerSide.

◆ getCellSize()

dVec hyperrectangularCellList::getCellSize ( )
inline

Returns the length of the square that forms the base grid size.

References gridCellSizes.

◆ positionToCellIndex()

int hyperrectangularCellList::positionToCellIndex ( const dVec &  pos)

Return the index of the cell that contains the given point.

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

◆ indexToiVec()

iVec hyperrectangularCellList::indexToiVec ( const int  cellIndex)
inline

return the iVec corresponding to a cell index

References cellIndexer, and IndexDD::inverseIndex().

◆ getCellNeighbors()

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

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 cellIndexer, gridCellsPerSide, idPow(), IndexDD::inverseIndex(), iVecIterate(), modularAddition(), and iVec::x.

◆ resetCellSizesCPU()

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

◆ resetCellSizes()

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

◆ getCellSizeArray()

const GPUArray<unsigned int>& hyperrectangularCellList::getCellSizeArray ( ) const
inline

Return the array of particles per cell.

References elementsPerCell.

◆ getIdxArray()

const GPUArray<int>& hyperrectangularCellList::getIdxArray ( ) const
inline

Return the array of cell indices in the different cells.

References particleIndices.

◆ computeCellList()

void hyperrectangularCellList::computeCellList ( GPUArray< dVec > &  points)
inline

compute the cell list of the gpuarry passed to it.

References adjCellsComputed, computeAdjacentCells(), computeCPU(), computeGPU(), and useGPU.

◆ computeGPU()

void hyperrectangularCellList::computeGPU ( GPUArray< dVec > &  points)

◆ computeCPU()

void hyperrectangularCellList::computeCPU ( GPUArray< dVec > &  points)

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

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

◆ setGPU()

virtual void hyperrectangularCellList::setGPU ( bool  _useGPU = true)
inlinevirtual

Enforce GPU operation.

References useGPU.

◆ returnAdjacentCells()

GPUArray<int>& hyperrectangularCellList::returnAdjacentCells ( )
inline

return the list of adjacent cells

References adjacentCells.

◆ computeAdjacentCells()

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

Member Data Documentation

◆ cellIndexer

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

◆ cellListIndexer

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

◆ elementsPerCell

GPUArray<unsigned int> hyperrectangularCellList::elementsPerCell

An array containing the number of elements in each cell.

Referenced by computeCPU(), computeGPU(), getCellSizeArray(), resetCellSizes(), resetCellSizesCPU(), and setGridSize().

◆ particleIndices

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

◆ particlePositions

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

◆ computations

int hyperrectangularCellList::computations

A reporter index of how hard it was to compute the cell list.

Referenced by computeCPU().

◆ adjacentCellsPerCell

int hyperrectangularCellList::adjacentCellsPerCell

the number of cells in the adjacency list for each cell

Referenced by computeAdjacentCells().

◆ adjacentCellIndexer

Index2D hyperrectangularCellList::adjacentCellIndexer

indexes the adjacent cells of each cell

Referenced by computeAdjacentCells().

◆ assist

GPUArray<int> hyperrectangularCellList::assist
protected

first index is Nmax, second is whether to recompute

Referenced by computeGPU(), resetCellSizes(), and resetCellSizesCPU().

◆ adjacentCells

GPUArray<int> hyperrectangularCellList::adjacentCells
protected

an array that stores the list cell adjacent to every cell

Referenced by computeAdjacentCells(), and returnAdjacentCells().

◆ gridCellsPerSide

iVec hyperrectangularCellList::gridCellsPerSide
protected

The number of bins in each of the different dimensions.

Referenced by computeAdjacentCells(), computeGPU(), getBinsPerSide(), getCellNeighbors(), positionToCellIndex(), and setGridSize().

◆ gridCellSizes

dVec hyperrectangularCellList::gridCellSizes
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().

◆ totalCells

int hyperrectangularCellList::totalCells
protected

◆ Nmax

int hyperrectangularCellList::Nmax
protected

the maximum number of particles found in any bin

Referenced by computeCPU(), computeGPU(), getNmax(), hyperrectangularCellList(), resetCellSizes(), resetCellSizesCPU(), and setGridSize().

◆ Box

BoxPtr hyperrectangularCellList::Box
protected

The Box used to compute periodic distances.

Referenced by computeGPU(), hyperrectangularCellList(), setBox(), and setGridSize().

◆ useGPU

bool hyperrectangularCellList::useGPU
protected

whether the updater does its work on the GPU or not

Referenced by computeCellList(), hyperrectangularCellList(), and setGPU().

◆ adjCellsComputed

bool hyperrectangularCellList::adjCellsComputed
protected

have we already computed the adjacent cell lists?

Referenced by computeAdjacentCells(), computeCellList(), and setGridSize().


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