CellGPU  0.8.0
GPU-accelerated simulations of cells
Public Member Functions | Public Attributes | List of all members
HilbertSorter Struct Reference

Spatially sort points in 2D according to a 1D Hilbert curve. More...

#include <HilbertSort.h>

Public Member Functions

HOSTDEVICE HilbertSorter (gpubox Box)
 The only constructor requires a box.
 
HOSTDEVICE void setOrder (int m)
 Set the order of the desired HC.
 
HOSTDEVICE int int_power (int i, int j)
 A hand-written function to take integer powers of integers.
 
HOSTDEVICE void HilbertRotate (int n, int &x, int &y, int rx, int ry)
 Rotate/flip quadrants appropriately.
 
HOSTDEVICE int getIdx (Dscalar2 point)
 

Public Attributes

gpubox box
 A box to put the particles in the unit square for easy sorting.
 
int M
 The integer order of the Hilbert curve to use.
 

Detailed Description

Spatially sort points in 2D according to a 1D Hilbert curve.

This structure can help sort scalar2's according to their position along a hilbert curve of order M... This sorting can improve data locality (i.e. particles that are close to each other in physical space reside close to each other in memory). This is a small boost for CPU-based code, but can be very important for the efficiency of GPU-based execution.

Member Function Documentation

◆ getIdx()

HOSTDEVICE int HilbertSorter::getIdx ( Dscalar2  point)
inline

Convert a real(x,y) pair to a nearby integer pair, and then gets the 1D Hilbert coordinate of that point. The number of cells is 2^M (M is the index of the HC))

Referenced by Simple2DCell::spatiallySortCells(), and Simple2DCell::spatiallySortVertices().


The documentation for this struct was generated from the following file: