Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
streamlined sweep step
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Oct 23, 2021
1 parent 13aa255 commit 4032d6b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
25 changes: 5 additions & 20 deletions src/encounter/encounter_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -989,22 +989,14 @@ module subroutine encounter_check_sweep_aabb_double_list(self, n1, n2, nenc, ind
call timer%stop()
write(*,*) "sweep double: ",timer%count_stop_step - timer%count_start_step

call timer%reset()
call timer%start()
call encounter_check_collapse_ragged_list(lenc, ntot, nenc, index1, index2)
call timer%stop()
write(*,*) "collapse rag: ",timer%count_stop_step - timer%count_start_step

call timer%reset()
call timer%start()
! Reorder the pairs and sort the first index in order to remove any duplicates
do concurrent(k = 1:nenc, index2(k) < index1(k))
i = index2(k)
index2(k) = index1(k)
index1(k) = i
end do
call timer%stop()
write(*,*) "reorder arr : ",timer%count_stop_step - timer%count_start_step

return
end subroutine encounter_check_sweep_aabb_double_list
Expand Down Expand Up @@ -1146,7 +1138,6 @@ subroutine encounter_check_sweep_aabb_one_double_list(i, n1, n2, ntot, ext_ind,
logical, dimension(:), intent(out) :: lencounteri !! Encounter list for the ith body
! Internals
integer(I4B) :: j, jbox, dim, jlo, jhi
logical, dimension(2:SWEEPDIM) :: lenc
integer(I4B), dimension(:), allocatable :: box

lencounteri(:) = .false.
Expand All @@ -1157,14 +1148,12 @@ subroutine encounter_check_sweep_aabb_one_double_list(i, n1, n2, ntot, ext_ind,
where(box(:) > ntot)
box(:) = box(:) - ntot
endwhere
do concurrent(jbox = jlo:jhi) ! Sweep forward until the end of the interval

do concurrent (jbox = jlo:jhi)
j = box(jbox)
if (((i <= n1) .and. (j <= n1)) .or. ((i > n1) .and. (j > n1))) cycle ! only pairs from the two different lists allowed
! Check the y-dimension
do dim = 2, SWEEPDIM
lenc(dim) = (iend(dim,j) > ibegi(dim)) .and. (ibeg(dim,j) < iendi(dim))
end do
lencounteri(j) = all(lenc(:))
! Check the other dimensions
lencounteri(j) = all((iend(2:SWEEPDIM,j) > ibegi(2:SWEEPDIM)) .and. (ibeg(2:SWEEPDIM,j) < iendi(2:SWEEPDIM)))
end do

return
Expand All @@ -1184,7 +1173,6 @@ pure subroutine encounter_check_sweep_aabb_one_single_list(n, ext_ind, ibegi, ie
logical, dimension(:), intent(out) :: lencounteri !! Encounter list for the ith body
! Internals
integer(I4B) :: j, jbox, dim, jlo, jhi
logical, dimension(2:SWEEPDIM) :: lenc
integer(I4B), dimension(:), allocatable :: box

lencounteri(:) = .false.
Expand All @@ -1202,10 +1190,7 @@ pure subroutine encounter_check_sweep_aabb_one_single_list(n, ext_ind, ibegi, ie
do concurrent(jbox = jlo:jhi) ! Sweep forward until the end of the interval
j = box(jbox)
! Check the other dimensions
do dim = 2, SWEEPDIM
lenc(dim) = (iend(dim,j) > ibegi(dim)) .and. (ibeg(dim,j) < iendi(dim))
end do
lencounteri(j) = all(lenc(:))
lencounteri(j) = all((iend(2:SWEEPDIM,j) > ibegi(2:SWEEPDIM)) .and. (ibeg(2:SWEEPDIM,j) < iendi(2:SWEEPDIM)))
end do

return
Expand Down
2 changes: 1 addition & 1 deletion src/modules/encounter_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module encounter_classes
implicit none
public

integer(I4B), parameter :: SWEEPDIM = 2
integer(I4B), parameter :: SWEEPDIM = 3

type :: encounter_list
integer(I4B) :: nenc = 0 !! Total number of encounters
Expand Down

0 comments on commit 4032d6b

Please sign in to comment.