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

Commit

Permalink
Fixed naming scheme for mergers. Merged bodies get the string _MERGEX…
Browse files Browse the repository at this point in the history
…XXXXXX, (where XXXXXXX is the new id) appended to the end of the original name. The string is replaced if it already exists.
  • Loading branch information
daminton committed Jan 9, 2023
1 parent 9bed146 commit 2a409ed
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/collision/collision_resolve.f90
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,12 @@ module subroutine collision_resolve_mergeaddsub(nbody_system, param, t, status)
real(DP), intent(in) :: t !! Time of collision
integer(I4B), intent(in) :: status !! Status flag to assign to adds
! Internals
integer(I4B) :: i, ibiggest, ismallest, iother, nimpactors, nfrag
integer(I4B) :: i, ibiggest, ismallest, iother, nimpactors, nfrag, nameidx
logical, dimension(:), allocatable :: lmask
class(swiftest_pl), allocatable :: plnew, plsub
character(*), parameter :: FRAGFMT = '("Newbody",I0.7)'
character(*), parameter :: MERGEFMT = '(A,"_MERGE",I0.7)'
integer(I4B), parameter :: merge_text_length = 12
character(len=NAMELEN) :: newname, origin_type
real(DP) :: volume

Expand Down Expand Up @@ -408,10 +410,18 @@ module subroutine collision_resolve_mergeaddsub(nbody_system, param, t, status)
discard_body_id=iother)
end do
case(MERGED)
call plnew%info(1)%copy(pl%info(ibiggest))
write(origin_type,*) "Merger"
call plnew%info(1)%copy(pl%info(ibiggest))
param%maxid = param%maxid + 1
plnew%id(1) = param%maxid

! Appends an index number to the end of the original name to make it unique, but still identifiable as the original.
! If there is already an index number appended, replace it
nameidx = index(plnew%info(1)%name, "_MERGE") - 1
if (nameidx < 0) nameidx = min(len(trim(adjustl(plnew%info(1)%name))), NAMELEN - merge_text_length)
write(newname,MERGEFMT) trim(adjustl(plnew%info(1)%name(1:nameidx))),plnew%id(1)
plnew%status(1) = NEW_PARTICLE
call plnew%info(1)%set_value(origin_type=origin_type, origin_time=t,&
call plnew%info(1)%set_value(origin_type=origin_type, origin_time=t, name=newname, &
origin_rh=plnew%rh(:,1), origin_vh=plnew%vh(:,1), &
collision_id=param%maxid_collision)
do i = 1, nimpactors
Expand Down

0 comments on commit 2a409ed

Please sign in to comment.