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

Commit

Permalink
Made new collision_history storage object
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Dec 10, 2022
1 parent dc894e6 commit 7972bcc
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/encounter/encounter_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ module subroutine encounter_io_dump(self, param)

select type(snapshot => self%frame(i)%item)
class is (fraggle_collision_snapshot)
call snapshot%write_frame(self%ncc,param)
call snapshot%encounter_snapshot%write_frame(self%nce,param)
call snapshot%write_frame(self%nc,param)
call snapshot%encounter_snapshot%write_frame(self%nc,param)
class is (encounter_snapshot)
call snapshot%write_frame(self%nce,param)
call snapshot%write_frame(self%nc,param)
end select
else
exit
Expand Down
3 changes: 1 addition & 2 deletions src/modules/encounter_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ module encounter_classes

!> A class that that is used to store simulation history data between file output
type, extends(swiftest_storage) :: encounter_storage
class(encounter_io_parameters), allocatable :: nce !! NetCDF parameter object containing the details about the encounter file attached to this storage object
class(encounter_io_parameters), allocatable :: ncc !! NetCDF parameter object containing the details about the collision file attached to this storage object
class(encounter_io_parameters), allocatable :: nc !! NetCDF parameter object containing the details about the file attached to this storage object
contains
procedure :: dump => encounter_io_dump !! Dumps contents of encounter history to file
final :: encounter_util_final_storage
Expand Down
1 change: 1 addition & 0 deletions src/modules/symba_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ module symba_classes
class(fraggle_colliders), allocatable :: colliders !! Fraggle colliders object
class(fraggle_fragments), allocatable :: fragments !! Fraggle fragmentation system object
type(encounter_storage(nframes=:)), allocatable :: encounter_history !! Stores encounter history for later retrieval and saving to file
type(encounter_storage(nframes=:)), allocatable :: collision_history !! Stores encounter history for later retrieval and saving to file
contains
procedure :: write_discard => symba_io_write_discard !! Write out information about discarded and merged planets and test particles in SyMBA
procedure :: initialize => symba_setup_initialize_system !! Performs SyMBA-specific initilization steps
Expand Down
17 changes: 11 additions & 6 deletions src/setup/setup.f90
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,21 @@ module subroutine setup_construct_system(system, param)
if (param%lencounter_save) then
allocate(encounter_storage :: system%encounter_history)
associate (encounter_history => system%encounter_history)
allocate(encounter_io_parameters :: encounter_history%nce)
allocate(encounter_io_parameters :: encounter_history%nc)
call encounter_history%reset()
select type(nce => encounter_history%nce)
select type(nc => encounter_history%nc)
class is (encounter_io_parameters)
nce%file_number = param%iloop / param%dump_cadence
nc%file_number = param%iloop / param%dump_cadence
end select
allocate(fraggle_io_parameters :: encounter_history%ncc)
select type(ncc => encounter_history%ncc)
end associate

allocate(encounter_storage :: system%collision_history)
associate (collision_history => system%collision_history)
allocate(fraggle_io_parameters :: collision_history%nc)
call collision_history%reset()
select type(nc => collision_history%nc)
class is (fraggle_io_parameters)
ncc%file_number = param%iloop / param%dump_cadence
nc%file_number = param%iloop / param%dump_cadence
end select
end associate
end if
Expand Down
16 changes: 10 additions & 6 deletions src/symba/symba_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,25 @@ module subroutine symba_io_dump_encounter(self, param)

if (self%encounter_history%iframe == 0) return ! No enounters in this interval

associate(encounter_history => self%encounter_history, nce => self%encounter_history%nce, ncc => self%encounter_history%ncc, iframe => self%encounter_history%iframe)
associate(encounter_history => self%encounter_history, nce => self%encounter_history%nc, eframe => self%encounter_history%iframe,&
collision_history => self%collision_history, ncc => self%collision_history%nc, cframe => self%collision_history%iframe)

! Create and save the output files for this encounter and fragmentation
nce%file_number = nce%file_number + 1
ncc%file_number = ncc%file_number + 1
nce%time_dimsize = maxval(encounter_history%tslot(:))
ncc%time_dimsize = maxval(encounter_history%tslot(:))
write(nce%file_name, '("encounter_",I0.6,".nc")') nce%file_number
write(ncc%file_name, '("collision_",I0.6,".nc")') ncc%file_number
call nce%initialize(param)
call ncc%initialize(param)
call encounter_history%dump(param)
call nce%close()
call ncc%close()
call encounter_history%reset()

ncc%file_number = ncc%file_number + 1
write(ncc%file_name, '("collision_",I0.6,".nc")') ncc%file_number
ncc%time_dimsize = maxval(collision_history%tslot(:))
call ncc%initialize(param)
call collision_history%dump(param)
call ncc%close()
call collision_history%reset()
end associate

return
Expand Down
3 changes: 1 addition & 2 deletions src/symba/symba_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,7 @@ subroutine symba_util_save_storage(system, snapshot, t)
tmp%tslot(1:nold) = system%encounter_history%tslot(1:nold)
tmp%tslot(nold+1:nbig) = 0
tmp%iframe = system%encounter_history%iframe
call move_alloc(system%encounter_history%nce, tmp%nce)
call move_alloc(system%encounter_history%ncc, tmp%ncc)
call move_alloc(system%encounter_history%nc, tmp%nc)

do i = 1, nold
if (allocated(system%encounter_history%frame(i)%item)) call move_alloc(system%encounter_history%frame(i)%item, tmp%frame(i)%item)
Expand Down

0 comments on commit 7972bcc

Please sign in to comment.