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

Commit

Permalink
Added encounter storage object using the same pattern as the system s…
Browse files Browse the repository at this point in the history
…torage object. Also got rid of some old pre-NetCDF cruft in encounter_classes
  • Loading branch information
daminton committed Dec 1, 2022
1 parent 5d243fd commit 08584c4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
34 changes: 25 additions & 9 deletions src/modules/encounter_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/modules/swiftest_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 08584c4

Please sign in to comment.