From 08584c42b474cc19ea2e783f4108399ee081d953 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Thu, 1 Dec 2022 16:52:47 -0500 Subject: [PATCH] Added encounter storage object using the same pattern as the system storage object. Also got rid of some old pre-NetCDF cruft in encounter_classes --- src/modules/encounter_classes.f90 | 34 +++++++++++++++++++++++-------- src/modules/swiftest_classes.f90 | 7 +++---- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/modules/encounter_classes.f90 b/src/modules/encounter_classes.f90 index 580becc40..b14fd5da0 100644 --- a/src/modules/encounter_classes.f90 +++ b/src/modules/encounter_classes.f90 @@ -41,6 +41,21 @@ module encounter_classes final :: encounter_util_final_list !! Finalize the encounter list - deallocates all allocatables end type encounter_list + type encounter_storage_frame_list + class(swiftest_nbody_system), allocatable :: system + contains + procedure :: store => encounter_util_copy_store_list !! Stores a snapshot of the nbody system so that later it can be retrieved for saving to file. + generic :: assignment(=) => store + end type + + type :: encounter_storage(nframes) + integer(I4B), len :: nframes + !! A class that that is used to store simulation history data between file output + type(encounter_storage_frame_list), dimension(nframes) :: frame + contains + procedure :: dump => encounter_io_dump_storage_list + end type encounter_storage + type encounter_bounding_box_1D integer(I4B) :: n !! Number of bodies with extents integer(I4B), dimension(:), allocatable :: ind !! Sorted minimum/maximum extent indices (value > n indicates an ending index) @@ -173,16 +188,11 @@ module subroutine encounter_check_sweep_aabb_single_list(self, n, x, v, renc, dt logical, dimension(:), allocatable, intent(out) :: lvdotr !! Logical array indicating which pairs are approaching end subroutine encounter_check_sweep_aabb_single_list - module subroutine encounter_io_write_frame(iu, t, id1, id2, Gmass1, Gmass2, radius1, radius2, xh1, xh2, vh1, vh2) + module subroutine encounter_io_dump_storage_list(self, param) implicit none - integer(I4B), intent(in) :: iu !! Open file unit number - real(DP), intent(in) :: t !! Time of encounter - integer(I4B), intent(in) :: id1, id2 !! ids of the two encountering bodies - real(DP), intent(in) :: Gmass1, Gmass2 !! G*mass of the two encountering bodies - real(DP), intent(in) :: radius1, radius2 !! Radii of the two encountering bodies - real(DP), dimension(:), intent(in) :: xh1, xh2 !! Swiftestcentric position vectors of the two encountering bodies - real(DP), dimension(:), intent(in) :: vh1, vh2 !! Swiftestcentric velocity vectors of the two encountering bodies - end subroutine encounter_io_write_frame + class(encounter_storage(*)), intent(inout) :: self !! Encounter storage object + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + end subroutine encounter_io_dump_storage_list module subroutine encounter_setup_aabb(self, n, n_last) implicit none @@ -210,6 +220,12 @@ module subroutine encounter_util_copy_list(self, source) class(encounter_list), intent(in) :: source !! Source object to copy into end subroutine encounter_util_copy_list + module subroutine encounter_util_copy_store_list(self, system) + implicit none + class(encounter_storage_frame_list), intent(inout) :: self !! Encounter storage object + class(encounter_list), intent(in) :: system !! Swiftest encounter list structure + end subroutine encounter_util_copy_store_list + module subroutine encounter_util_dealloc_aabb(self) implicit none class(encounter_bounding_box_1D), intent(inout) :: self !!Bounding box structure along a single dimension diff --git a/src/modules/swiftest_classes.f90 b/src/modules/swiftest_classes.f90 index 07f446946..54881ae19 100644 --- a/src/modules/swiftest_classes.f90 +++ b/src/modules/swiftest_classes.f90 @@ -424,7 +424,7 @@ module swiftest_classes generic :: assignment(=) => store end type - type, extends(swiftest_base) :: swiftest_storage(nframes) + type :: swiftest_storage(nframes) integer(I4B), len :: nframes !! A class that that is used to store simulation history data between file output type(swiftest_storage_frame_system), dimension(nframes) :: frame @@ -625,7 +625,6 @@ module subroutine io_dump_system(self, param) class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters end subroutine io_dump_system - module subroutine io_dump_storage_system(self, param) implicit none class(swiftest_storage(*)), intent(inout) :: self !! Swiftest simulation history storage object @@ -1245,8 +1244,8 @@ end subroutine util_copy_particle_info_arr module subroutine util_copy_store_system(self, system) implicit none - class(swiftest_storage_frame_system), intent(inout) :: self !! Swiftest storage frame object - class(swiftest_nbody_system), intent(in) :: system !! Swiftest n-body system object + class(swiftest_storage_frame_system), intent(inout) :: self !! Swiftest storage frame object + class(swiftest_nbody_system), intent(in) :: system !! Swiftest n-body system object end subroutine util_copy_store_system module subroutine util_dealloc_body(self)