From dc2c74195eb71d04f18e9449c4b115a1eb8b8be3 Mon Sep 17 00:00:00 2001 From: Menno Date: Wed, 11 Dec 2024 16:00:43 +0100 Subject: [PATCH] fix indexing bug when creating null collisions grid that do not fit into the domain a int number of times --- src_cuda_rt/Raytracer.cu | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src_cuda_rt/Raytracer.cu b/src_cuda_rt/Raytracer.cu index 2ce5388..a43506c 100644 --- a/src_cuda_rt/Raytracer.cu +++ b/src_cuda_rt/Raytracer.cu @@ -53,18 +53,18 @@ namespace const Float fz = Float(grid_cells.z) / Float(kn_grid.z); const int x0 = grid_x*fx; - const int x1 = floor((grid_x+1)*fx); + const int x1 = min(grid_cells.x-1, int(floor((grid_x+1)*fx))); const int y0 = grid_y*fy; - const int y1 = floor((grid_y+1)*fy); + const int y1 = min(grid_cells.y-1, int(floor((grid_y+1)*fy))); const int z0 = grid_z*fz; - const int z1 = floor((grid_z+1)*fz); + const int z1 = min(grid_cells.z-1, int(floor((grid_z+1)*fz))); const int ijk_grid = grid_x + grid_y*kn_grid.x + grid_z*kn_grid.y*kn_grid.x; Float k_null = k_ext_null_min; - for (int k=z0; k