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

Commit

Permalink
Rearranged how the non-plpl discards work to use the same pattern as …
Browse files Browse the repository at this point in the history
…the plpl discards
  • Loading branch information
daminton committed Aug 31, 2021
1 parent 565ed44 commit f563225
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/symba/symba_discard.f90
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,32 @@ subroutine symba_discard_nonplpl(pl, system, param)
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters
! Internals
logical, dimension(pl%nbody) :: ldiscard
integer(I4B) :: i, nstart, nend, nsub
class(symba_pl), allocatable :: plsub

! First check for collisions with the central body
associate(npl => pl%nbody, cb => system%cb)
if (npl == 0) return
ldiscard(1:npl) = pl%ldiscard(1:npl) ! Don't include any bodies that were previously flagged for discard in here
if ((param%rmin >= 0.0_DP) .or. (param%rmax >= 0.0_DP) .or. (param%rmaxu >= 0.0_DP)) then
call symba_discard_cb_pl(pl, system, param)
end if
if (param%qmin >= 0.0_DP .and. npl > 0) call symba_discard_peri_pl(pl, system, param)
if (any(.not.ldiscard(1:npl) .and. pl%ldiscard(1:npl))) then
ldiscard(1:npl) = .not.ldiscard(1:npl) .and. pl%ldiscard(1:npl)
call system%pl_discards%append(pl, ldiscard)
end if
select type(pl_discards => system%pl_discards)
class is (symba_merger)
if ((param%rmin >= 0.0_DP) .or. (param%rmax >= 0.0_DP) .or. (param%rmaxu >= 0.0_DP)) then
call symba_discard_cb_pl(pl, system, param)
end if
if (param%qmin >= 0.0_DP) call symba_discard_peri_pl(pl, system, param)
if (any(pl%ldiscard(1:npl))) then
ldiscard(1:npl) = pl%ldiscard(1:npl)

allocate(plsub, mold=pl)
call pl%spill(plsub, ldiscard, ldestructive=.false.)
nsub = plsub%nbody
nstart = pl_discards%nbody + 1
nend = pl_discards%nbody + nsub
call pl_discards%append(plsub, lsource_mask=[(.true., i = 1, nsub)])

! Record how many bodies were subtracted in this event
pl_discards%ncomp(nstart:nend) = nsub
end if
end select
end associate

return
Expand Down

0 comments on commit f563225

Please sign in to comment.