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

Commit

Permalink
Consolidated setup and util submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Dec 23, 2022
1 parent d54cb62 commit 5e4bff8
Show file tree
Hide file tree
Showing 26 changed files with 1,274 additions and 1,403 deletions.
18 changes: 5 additions & 13 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,51 +44,43 @@ SET(FAST_MATH_FILES
${SRC}/collision/collision_io.f90
${SRC}/collision/collision_regime.f90
${SRC}/collision/collision_resolve.f90
${SRC}/collision/collision_setup.f90
${SRC}/collision/collision_util.f90
${SRC}/encounter/encounter_check.f90
${SRC}/encounter/encounter_io.f90
${SRC}/encounter/encounter_setup.f90
${SRC}/encounter/encounter_util.f90
${SRC}/fraggle/fraggle_generate.f90
${SRC}/fraggle/fraggle_set.f90
${SRC}/fraggle/fraggle_setup.f90
${SRC}/fraggle/fraggle_util.f90
${SRC}/helio/helio_drift.f90
${SRC}/helio/helio_gr.f90
${SRC}/helio/helio_setup.f90
${SRC}/helio/helio_step.f90
${SRC}/helio/helio_util.f90
${SRC}/netcdf_io/netcdf_io_implementations.f90
${SRC}/operator/operator_cross.f90
${SRC}/operator/operator_mag.f90
${SRC}/operator/operator_unit.f90
${SRC}/rmvs/rmvs_discard.f90
${SRC}/rmvs/rmvs_encounter_check.f90
${SRC}/rmvs/rmvs_setup.f90
${SRC}/rmvs/rmvs_step.f90
${SRC}/rmvs/rmvs_util.f90
${SRC}/swiftest/swiftest_discard.f90
${SRC}/swiftest/swiftest_io.f90
${SRC}/swiftest/swiftest_obl.f90
${SRC}/swiftest/swiftest_util.f90
${SRC}/swiftest/swiftest_drift.f90
${SRC}/swiftest/swiftest_orbel.f90
${SRC}/swiftest/swiftest_gr.f90
${SRC}/swiftest/swiftest_io.f90
${SRC}/swiftest/swiftest_kick.f90
${SRC}/swiftest/swiftest_setup.f90
${SRC}/swiftest/swiftest_obl.f90
${SRC}/swiftest/swiftest_orbel.f90
${SRC}/swiftest/swiftest_util.f90
${SRC}/symba/symba_discard.f90
${SRC}/symba/symba_drift.f90
${SRC}/symba/symba_encounter_check.f90
${SRC}/symba/symba_gr.f90
${SRC}/symba/symba_io.f90
${SRC}/symba/symba_setup.f90
${SRC}/symba/symba_step.f90
${SRC}/symba/symba_util.f90
${SRC}/walltime/walltime_implementations.f90
${SRC}/whm/whm_coord.f90
${SRC}/whm/whm_drift.f90
${SRC}/whm/whm_gr.f90
${SRC}/whm/whm_setup.f90
${SRC}/whm/whm_step.f90
${SRC}/whm/whm_util.f90
${SRC}/swiftest/swiftest_driver.f90
Expand Down
20 changes: 10 additions & 10 deletions src/collision/collision_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ module collision
real(DP), dimension(2) :: pe !! Before/after potential energy
real(DP), dimension(2) :: Etot !! Before/after total nbody_system energy
contains
procedure :: setup => collision_setup_system !! Initializer for the encounter collision system and the before/after snapshots
procedure :: setup_impactors => collision_setup_impactors_system !! Initializer for the impactors for the encounter collision system. Deallocates old impactors before creating new ones
procedure :: setup_fragments => collision_setup_fragments_system !! Initializer for the fragments of the collision system.
procedure :: setup => collision_util_setup_system !! Initializer for the encounter collision system and the before/after snapshots
procedure :: setup_impactors => collision_util_setup_impactors_system !! Initializer for the impactors for the encounter collision system. Deallocates old impactors before creating new ones
procedure :: setup_fragments => collision_util_setup_fragments_system !! Initializer for the fragments of the collision system.
procedure :: add_fragments => collision_util_add_fragments_to_system !! Add fragments to nbody_system
procedure :: construct_temporary_system => collision_util_construct_temporary_system !! Constructs temporary n-body nbody_system in order to compute pre- and post-impact energy and momentum
procedure :: get_energy_and_momentum => collision_util_get_energy_momentum !! Calculates total nbody_system energy in either the pre-collision outcome state (lbefore = .true.) or the post-collision outcome state (lbefore = .false.)
Expand Down Expand Up @@ -352,22 +352,22 @@ module subroutine collision_util_set_coordinate_system(self)
class(collision_merge), intent(inout) :: self !! Collisional nbody_system
end subroutine collision_util_set_coordinate_system

module subroutine collision_setup_system(self, nbody_system)
module subroutine collision_util_setup_system(self, nbody_system)
implicit none
class(collision_merge), intent(inout) :: self !! Encounter collision system object
class(base_nbody_system), intent(in) :: nbody_system !! Current nbody system. Used as a mold for the before/after snapshots
end subroutine collision_setup_system
end subroutine collision_util_setup_system

module subroutine collision_setup_impactors_system(self)
module subroutine collision_util_setup_impactors_system(self)
implicit none
class(collision_merge), intent(inout) :: self !! Encounter collision system object
end subroutine collision_setup_impactors_system
end subroutine collision_util_setup_impactors_system

module subroutine collision_setup_fragments_system(self, nfrag)
module subroutine collision_util_setup_fragments_system(self, nfrag)
implicit none
class(collision_merge), intent(inout) :: self !! Encounter collision system object
integer(I4B), intent(in) :: nfrag !! Number of fragments to create
end subroutine collision_setup_fragments_system
end subroutine collision_util_setup_fragments_system

module subroutine collision_util_add_fragments_to_system(self, nbody_system, param)
implicit none
Expand Down Expand Up @@ -438,7 +438,6 @@ end subroutine collision_util_snapshot

contains


subroutine collision_final_fragments(self)
!! author: David A. Minton
!!
Expand Down Expand Up @@ -466,6 +465,7 @@ subroutine collision_final_impactors(self)
return
end subroutine collision_final_impactors


subroutine collision_final_netcdf_parameters(self)
!! author: David A. Minton
!!
Expand Down
68 changes: 0 additions & 68 deletions src/collision/collision_setup.f90

This file was deleted.

55 changes: 54 additions & 1 deletion src/collision/collision_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ module subroutine collision_util_construct_temporary_system(self, nbody_system,
if (allocated(tmpparam)) deallocate(tmpparam)
if (allocated(tmpsys)) deallocate(tmpsys)
allocate(tmpparam, source=param)
call swiftest_setup_construct_system(tmpsys_local, tmpparam_local)
call swiftest_util_setup_construct_system(tmpsys_local, tmpparam_local)

! No test particles necessary for energy/momentum calcs
call tmpsys_local%tp%setup(0, tmpparam_local)
Expand Down Expand Up @@ -571,6 +571,59 @@ module subroutine collision_util_set_mass_dist(self, param)
end subroutine collision_util_set_mass_dist


module subroutine collision_util_setup_system(self, nbody_system)
!! author: David A. Minton
!!
!! Initializer for the encounter collision system. Sets up impactors and the before/after snapshots,
!! but not fragments. Those are setup later when the number of fragments is known.
implicit none
! Arguments
class(collision_merge), intent(inout) :: self !! Encounter collision system object
class(base_nbody_system), intent(in) :: nbody_system !! Current nbody system. Used as a mold for the before/after snapshots

call self%setup_impactors()
if (allocated(self%before)) deallocate(self%before)
if (allocated(self%after)) deallocate(self%after)

allocate(self%before, mold=nbody_system)
allocate(self%after, mold=nbody_system)

return
end subroutine collision_util_setup_system


module subroutine collision_util_setup_impactors_system(self)
!! author: David A. Minton
!!
!! Initializer for the impactors for the encounter collision system. Deallocates old impactors before creating new ones
implicit none
! Arguments
class(collision_merge), intent(inout) :: self !! Encounter collision system object

if (allocated(self%impactors)) deallocate(self%impactors)
allocate(collision_impactors :: self%impactors)

return
end subroutine collision_util_setup_impactors_system


module subroutine collision_util_setup_fragments_system(self, nfrag)
!! author: David A. Minton
!!
!! Initializer for the fragments of the collision system.
implicit none
! Arguments
class(collision_merge), intent(inout) :: self !! Encounter collision system object
integer(I4B), intent(in) :: nfrag !! Number of fragments to create

if (allocated(self%fragments)) deallocate(self%fragments)
allocate(collision_fragments(nfrag) :: self%fragments)
self%fragments%nbody = nfrag

return
end subroutine collision_util_setup_fragments_system


subroutine collision_util_save_snapshot(collision_history, snapshot)
!! author: David A. Minton
!!
Expand Down
12 changes: 6 additions & 6 deletions src/encounter/encounter_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module encounter
real(DP), dimension(:,:), allocatable :: v2 !! the velocity of body 2 in the encounter
integer(I4B), dimension(:), allocatable :: level !! Recursion level (used in SyMBA)
contains
procedure :: setup => encounter_setup_list !! A constructor that sets the number of encounters and allocates and initializes all arrays
procedure :: setup => encounter_util_setup_list !! A constructor that sets the number of encounters and allocates and initializes all arrays
procedure :: append => encounter_util_append_list !! Appends elements from one structure to another
procedure :: copy => encounter_util_copy_list !! Copies elements from the source encounter list into self.
procedure :: dealloc => encounter_util_dealloc_list !! Deallocates all allocatables
Expand Down Expand Up @@ -98,7 +98,7 @@ module encounter
type encounter_bounding_box
type(encounter_bounding_box_1D), dimension(SWEEPDIM) :: aabb
contains
procedure :: setup => encounter_setup_aabb !! Setup a new axis-aligned bounding box structure
procedure :: setup => encounter_util_setup_aabb !! Setup a new axis-aligned bounding box structure
procedure :: sweep_single => encounter_check_sweep_aabb_single_list !! Sweeps the sorted bounding box extents and returns the encounter candidates
procedure :: sweep_double => encounter_check_sweep_aabb_double_list !! Sweeps the sorted bounding box extents and returns the encounter candidates
generic :: sweep => sweep_single, sweep_double
Expand Down Expand Up @@ -236,18 +236,18 @@ module subroutine encounter_io_netcdf_write_frame_snapshot(self, history, param)
class(base_parameters), intent(inout) :: param !! Current run configuration parameters
end subroutine encounter_io_netcdf_write_frame_snapshot

module subroutine encounter_setup_aabb(self, n, n_last)
module subroutine encounter_util_setup_aabb(self, n, n_last)
implicit none
class(encounter_bounding_box), intent(inout) :: self !! Swiftest encounter structure
integer(I4B), intent(in) :: n !! Number of objects with bounding box extents
integer(I4B), intent(in) :: n_last !! Number of objects with bounding box extents the previous time this was called
end subroutine encounter_setup_aabb
end subroutine encounter_util_setup_aabb

module subroutine encounter_setup_list(self, n)
module subroutine encounter_util_setup_list(self, n)
implicit none
class(encounter_list), intent(inout) :: self !! Swiftest encounter structure
integer(I8B), intent(in) :: n !! Number of encounters to allocate space for
end subroutine encounter_setup_list
end subroutine encounter_util_setup_list

module subroutine encounter_util_append_list(self, source, lsource_mask)
implicit none
Expand Down
Loading

0 comments on commit 5e4bff8

Please sign in to comment.