Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/grid/grid_geometry_cartesian_3d.f90
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,12 @@ subroutine place_in_cell(p)
p%killed = .true.
else
p%in_cell = .true.
! Only adjust the wall position for photons that were successfully
! placed in a cell - for killed photons the cell indices are invalid
! and adjust_wall would index the wall arrays out of bounds.
call adjust_wall(p)
end if

call adjust_wall(p)

end subroutine place_in_cell

logical function escaped_photon(p)
Expand Down
6 changes: 4 additions & 2 deletions src/grid/grid_geometry_cylindrical_3d.f90
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,12 @@ subroutine place_in_cell(p)
p%killed = .true.
else
p%in_cell = .true.
! Only adjust the wall position for photons that were successfully
! placed in a cell - for killed photons the cell indices are invalid
! and adjust_wall would index the wall arrays out of bounds.
call adjust_wall(p)
end if

call adjust_wall(p)

end subroutine place_in_cell

logical function escaped_photon(p)
Expand Down
6 changes: 4 additions & 2 deletions src/grid/grid_geometry_spherical_3d.f90
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,12 @@ subroutine place_in_cell(p)
p%killed = .true.
else
p%in_cell = .true.
! Only adjust the wall position for photons that were successfully
! placed in a cell - for killed photons the cell indices are invalid
! and adjust_wall would index the wall arrays out of bounds.
call adjust_wall(p)
end if

call adjust_wall(p)

end subroutine place_in_cell

logical function escaped_photon(p)
Expand Down
2 changes: 1 addition & 1 deletion src/grid/grid_geometry_voronoi.f90
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ subroutine setup_grid_geometry(group)
! Specifically:
! - sparse_idx(is) + 1 because sparse_idx is an array of C-style indices,
! - sparse_neighs(...) + 1 because the neighbour indices are C-style.
geo%cells(ic)%neighbors(1:n_neighbors) = sparse_neighs(sparse_idx(is) + 1:sparse_idx(is + 1) + 1) + 1
geo%cells(ic)%neighbors(1:n_neighbors) = sparse_neighs(sparse_idx(is) + 1:sparse_idx(is + 1)) + 1
is = is + 1
end do

Expand Down
26 changes: 26 additions & 0 deletions src/grid/grid_propagate_3d.f90
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ subroutine grid_integrate(p,tau_required,tau_achieved)

if(.not.p%in_cell) call error("grid_integrate", "photon has not been placed in a cell")

! A photon emitted exactly on the outer edge of the grid moving outwards
! is placed by adjust_wall in the cell just outside the grid, so it
! escapes immediately without crossing any walls.
if(escaped(p)) return

if(allocated(n_photons)) then
if(last_photon_id(p%icell%ic).ne.p%id) then
n_photons(p%icell%ic) = n_photons(p%icell%ic) + 1
Expand Down Expand Up @@ -259,6 +264,11 @@ subroutine grid_integrate_noenergy(p,tau_required,tau_achieved)

if(.not.p%in_cell) call error("grid_integrate_noenergy", "photon has not been placed in a cell")

! A photon emitted exactly on the outer edge of the grid moving outwards
! is placed by adjust_wall in the cell just outside the grid, so it
! escapes immediately without crossing any walls.
if(escaped(p)) return

if(tau_required==0._dp) return

! Check what the distance to the nearest source is
Expand Down Expand Up @@ -388,6 +398,14 @@ subroutine grid_escape_tau(p_orig,tmax,tau,killed)

if(.not.p%in_cell) call error("grid_escape_tau", "photon has not been placed in a cell")

! A photon emitted exactly on the outer edge of the grid moving outwards
! is placed by adjust_wall in the cell just outside the grid, so it
! escapes immediately without crossing any walls.
if(escaped(p)) then
tau = 0._dp
return
end if

! Check what the distance to the nearest source is

call find_nearest_source(p%r, p%v, t_source, source_id)
Expand Down Expand Up @@ -485,6 +503,14 @@ subroutine grid_escape_column_density(p_orig,tmax,column_density,killed)

if(.not.p%in_cell) call error("grid_escape_column_density", "photon has not been placed in a cell")

! A photon emitted exactly on the outer edge of the grid moving outwards
! is placed by adjust_wall in the cell just outside the grid, so it
! escapes immediately without crossing any walls.
if(escaped(p)) then
column_density = 0._dp
return
end if

! Check what the distance to the nearest source is

call find_nearest_source(p%r, p%v, t_source, source_id)
Expand Down
Loading