Refactor type arguments to compute cell_index
This commit is contained in:
parent
d957a90573
commit
cd4a00ebed
2 changed files with 6 additions and 3 deletions
|
@ -55,8 +55,10 @@ struct CellList {
|
|||
// TODO; Maybe update this to use Morton Encodings in the future to improve
|
||||
// locality of particle indices. Unclear how much of a benefit this will add,
|
||||
// but would be cool to do
|
||||
__host__ __device__ int get_cell_index(int x, int y, int z) const {
|
||||
return z * grid_size.x * grid_size.y + y * grid_size.x + x;
|
||||
__host__ __device__ int
|
||||
get_cell_index_from_cell_coords(int3 cell_coords) const {
|
||||
return cell_coords.z * grid_size.x * grid_size.y +
|
||||
cell_coords.y * grid_size.x + cell_coords.x;
|
||||
}
|
||||
|
||||
std::pair<int3, float3> calc_grid_and_cell_size(Box &box,
|
||||
|
|
|
@ -27,5 +27,6 @@ TEST(CellListTest, GetCellIndex) {
|
|||
int expected_index = z * cell_list.grid_size.x * cell_list.grid_size.y +
|
||||
y * cell_list.grid_size.x + x;
|
||||
|
||||
EXPECT_EQ(cell_list.get_cell_index(x, y, z), expected_index);
|
||||
EXPECT_EQ(cell_list.get_cell_index_from_cell_coords({x, y, z}),
|
||||
expected_index);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue