updates the current voxel based upon position
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(cart_grid), | intent(in) | :: | grid |
grid |
||
type(vector), | intent(in) | :: | pos |
current photon packet position |
||
integer, | intent(inout) | :: | celli |
position of photon packet in grid |
||
integer, | intent(inout) | :: | cellj |
position of photon packet in grid |
||
integer, | intent(inout) | :: | cellk |
position of photon packet in grid |
subroutine update_voxels(grid, pos, celli, cellj, cellk) !! updates the current voxel based upon position use vector_class use gridmod !> grid type(cart_grid), intent(IN) :: grid !> current photon packet position type(vector), intent(IN) :: pos !> position of photon packet in grid integer, intent(INOUT) :: celli, cellj, cellk !accurate but slow ! celli = find(pos%x, grid%xface) ! cellj = find(pos%y, grid%yface) ! cellk = find(pos%z, grid%zface) !fast but can be inaccurate in some cases... celli = floor(grid%nxg * (pos%x) / (2. * grid%xmax)) + 1 cellj = floor(grid%nyg * (pos%y) / (2. * grid%ymax)) + 1 cellk = floor(grid%nzg * (pos%z) / (2. * grid%zmax)) + 1 if(celli > grid%nxg .or. celli < 1)celli = -1 if(cellj > grid%nyg .or. cellj < 1)cellj = -1 if(cellk > grid%nzg .or. cellk < 1)cellk = -1 end subroutine update_voxels