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

Commit

Permalink
Did some OOF magic to get the fraggle encounters saved and output sel…
Browse files Browse the repository at this point in the history
…ected
  • Loading branch information
daminton committed Dec 9, 2022
1 parent 2ea96cd commit 9ae43a7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/encounter/encounter_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ module subroutine encounter_io_dump(self, param)
! Internals
integer(I4B) :: i


do i = 1, self%nframes
if (allocated(self%frame(i)%item)) then
select type(snapshot => self%frame(i)%item)
class is (encounter_snapshot)
param%ioutput = self%tslot(i)
call snapshot%write_frame(self%nc,param)
select type(snapshot) ! Be sure to call the base class method to get the regular encounter data sved
class is (fraggle_encounter_snapshot)
call snapshot%encounter_snapshot%write_frame(self%nc,param)
end select

end select
else
exit
Expand Down
5 changes: 3 additions & 2 deletions src/modules/fraggle_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ module fraggle_classes
end type fraggle_storage

type, extends(encounter_snapshot) :: fraggle_encounter_snapshot
class(fraggle_colliders), allocatable :: colliders !! Colliders object at this snapshot
class(fraggle_fragments), allocatable :: fragments !! Fragments object at this snapshot
logical :: lcollision !! Indicates that this snapshot contains at least one collision
class(fraggle_colliders), allocatable :: colliders !! Colliders object at this snapshot
class(fraggle_fragments), allocatable :: fragments !! Fragments object at this snapshot
contains
procedure :: write_frame => fraggle_io_encounter_write_frame !! Writes a frame of encounter data to file
final :: fraggle_util_final_snapshot
Expand Down
2 changes: 2 additions & 0 deletions src/symba/symba_step.f90
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ module subroutine symba_step_reset_system(self, param)
call pl%set_renc(0)
call system%plplenc_list%setup(nenc_old) ! This resizes the pl-pl encounter list to be the same size as it was the last step, to decrease the number of potential resize operations that have to be one inside the step
system%plplenc_list%nenc = 0 ! Sets the true number of encounters back to 0 after resizing
system%plplenc_list%lcollision = .false.
end if

nenc_old = system%pltpenc_list%nenc
Expand All @@ -308,6 +309,7 @@ module subroutine symba_step_reset_system(self, param)
tp%ldiscard(1:ntp) = .false.
call system%pltpenc_list%setup(nenc_old)! This resizes the pl-tp encounter list to be the same size as it was the last step, to decrease the number of potential resize operations that have to be one inside the step
system%pltpenc_list%nenc = 0 ! Sets the true number of encounters back to 0 after resizing
system%pltpenc_list%lcollision = .false.
end if

call system%pl_adds%setup(0, param)
Expand Down
12 changes: 9 additions & 3 deletions src/symba/symba_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1296,11 +1296,16 @@ module subroutine symba_util_take_encounter_snapshot(self, param, t)
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters
real(DP), intent(in) :: t !! current time
! Arguments
type(fraggle_encounter_snapshot) :: snapshot
class(encounter_snapshot), allocatable :: snapshot
integer(I4B) :: i, npl_snap, ntp_snap

associate(npl => self%pl%nbody, ntp => self%tp%nbody)

if (self%plplenc_list%lcollision) then
allocate(fraggle_encounter_snapshot :: snapshot)
else
allocate(encounter_snapshot :: snapshot)
end if
snapshot%t = t
snapshot%iloop = param%iloop

Expand Down Expand Up @@ -1380,10 +1385,11 @@ module subroutine symba_util_take_encounter_snapshot(self, param, t)
end select
end select

if (self%plplenc_list%lcollision) then
select type(snapshot)
class is (fraggle_encounter_snapshot)
allocate(snapshot%colliders, source=self%colliders)
allocate(snapshot%fragments, source=self%fragments)
end if
end select

! Save the snapshot
call symba_util_save_storage(self,snapshot,t)
Expand Down

0 comments on commit 9ae43a7

Please sign in to comment.