Add particle assignment to cells
This commit is contained in:
parent
cd4a00ebed
commit
ca852c8a51
1 changed files with 11 additions and 2 deletions
|
@ -76,12 +76,21 @@ struct CellList {
|
||||||
return std::make_pair(grid_size, cell_size);
|
return std::make_pair(grid_size, cell_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get cell coordinates from position
|
__device__ int3 get_cell_coords_from_position(float3 pos) const {
|
||||||
__device__ int3 get_cell_coords(float3 pos) const {
|
|
||||||
return make_int3((int)((pos.x - box_min.x) / cell_size.x),
|
return make_int3((int)((pos.x - box_min.x) / cell_size.x),
|
||||||
(int)((pos.y - box_min.y) / cell_size.y),
|
(int)((pos.y - box_min.y) / cell_size.y),
|
||||||
(int)((pos.z - box_min.z) / cell_size.z));
|
(int)((pos.z - box_min.z) / cell_size.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__device__ int get_cell_index_from_position(float3 pos) const {
|
||||||
|
return get_cell_index_from_cell_coords(get_cell_coords_from_position(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
__device__ void assign_particles_to_cells(float3 *positions) {
|
||||||
|
for (int i = 0; i < this->n_particles; i++) {
|
||||||
|
particle_cells[i] = get_cell_index_from_position(positions[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue