From ebcef5e05c349edfe2176d0cb18a8d1a997bfd67 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Fri, 23 Dec 2022 10:24:00 -0500 Subject: [PATCH] Cleaned up a bunch of lingering problems left over from transferring a bunch of symba body variables to swiftest --- src/swiftest/swiftest_module.f90 | 2 +- src/swiftest/swiftest_util.f90 | 46 +++++++++++++++++--------------- src/symba/symba_util.f90 | 46 ++------------------------------ 3 files changed, 28 insertions(+), 66 deletions(-) diff --git a/src/swiftest/swiftest_module.f90 b/src/swiftest/swiftest_module.f90 index d09f88374..82e233bb3 100644 --- a/src/swiftest/swiftest_module.f90 +++ b/src/swiftest/swiftest_module.f90 @@ -322,7 +322,7 @@ module swiftest class(encounter_list), allocatable :: plpl_encounter !! List of massive body-massive body encounters in a single step class(collision_list_plpl), allocatable :: plpl_collision !! List of massive body-massive body collisions in a single step class(collision_list_plpl), allocatable :: pltp_collision !! List of massive body-massive body collisions in a single step - class(collision_merge), allocatable :: collider !! Collision system object + class(collision_merge), allocatable :: collider !! Collision system object class(encounter_storage(nframes=:)), allocatable :: encounter_history !! Stores encounter history for later retrieval and saving to file class(collision_storage(nframes=:)), allocatable :: collision_history !! Stores encounter history for later retrieval and saving to file diff --git a/src/swiftest/swiftest_util.f90 b/src/swiftest/swiftest_util.f90 index 3d6cd2047..32a137c50 100644 --- a/src/swiftest/swiftest_util.f90 +++ b/src/swiftest/swiftest_util.f90 @@ -328,9 +328,7 @@ module subroutine swiftest_util_append_tp(self, source, lsource_mask) select type(source) class is (swiftest_tp) associate(nold => self%nbody, nsrc => source%nbody) - call swiftest_util_append(self%isperi, source%isperi, nold, nsrc, lsource_mask) - call swiftest_util_append(self%peri, source%peri, nold, nsrc, lsource_mask) - call swiftest_util_append(self%atp, source%atp, nold, nsrc, lsource_mask) + call swiftest_util_append(self%nplenc, source%nplenc, nold, nsrc, lsource_mask) call swiftest_util_append_body(self, source, lsource_mask) end associate @@ -806,9 +804,6 @@ module subroutine swiftest_util_dealloc_tp(self) class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object if (allocated(self%nplenc)) deallocate(self%nplenc) - if (allocated(self%isperi)) deallocate(self%isperi) - if (allocated(self%peri)) deallocate(self%peri) - if (allocated(self%atp)) deallocate(self%atp) if (allocated(self%k_pltp)) deallocate(self%k_pltp) call swiftest_util_dealloc_body(self) @@ -1903,6 +1898,7 @@ module subroutine swiftest_util_reset_kinship_pl(self, idx) ! Internals integer(I4B) :: i, j + self%kin(idx(:))%parent = idx(:) self%kin(idx(:))%nchild = 0 do j = 1, size(idx(:)) @@ -2777,6 +2773,9 @@ module subroutine swiftest_util_setup_body(self, n, param) allocate(self%ah(NDIM, n)) allocate(self%ir3h(n)) allocate(self%aobl(NDIM, n)) + allocate(self%isperi(n)) + allocate(self%peri(n)) + allocate(self%atp(n)) if (param%lclose) then allocate(self%lcollision(n)) allocate(self%lencounter(n)) @@ -2813,6 +2812,9 @@ module subroutine swiftest_util_setup_body(self, n, param) self%ah(:,:) = 0.0_DP self%ir3h(:) = 0.0_DP self%aobl(:,:) = 0.0_DP + self%isperi(:) = 1 + self%peri(:) = 0.0_DP + self%atp(:) = 0.0_DP if (param%ltides) then allocate(self%atide(NDIM, n)) @@ -2837,6 +2839,8 @@ module subroutine swiftest_util_setup_pl(self, n, param) class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object integer(I4B), intent(in) :: n !! Number of particles to allocate space for class(swiftest_parameters), intent(in) :: param !! Current run configuration parameter + ! Internals + integer(I4B) :: i !> Call allocation method for parent class !> The parent class here is the abstract swiftest_body class, so we can't use the type-bound procedure @@ -2860,12 +2864,13 @@ module subroutine swiftest_util_setup_pl(self, n, param) allocate(self%ntpenc(n)) allocate(self%radius(n)) allocate(self%density(n)) + allocate(self%kin(n)) self%nplenc(:) = 0 self%ntpenc(:) = 0 self%radius(:) = 0.0_DP self%density(:) = 1.0_DP - + call self%reset_kinship([(i, i=1, n)]) end if if (param%lmtiny_pl) then @@ -2909,14 +2914,9 @@ module subroutine swiftest_util_setup_tp(self, n, param) call swiftest_util_setup_body(self, n, param) if (n == 0) return - allocate(self%isperi(n)) - allocate(self%peri(n)) - allocate(self%atp(n)) allocate(self%nplenc(n)) - self%isperi(:) = 0 - self%peri(:) = 0.0_DP - self%atp(:) = 0.0_DP + self%npltp = 0_I8B self%nplenc(:) = 0 return @@ -2986,7 +2986,11 @@ module subroutine swiftest_util_sort_body(self, sortby, ascending) call swiftest_util_sort(direction * body%capom(1:n), ind) case("mu") call swiftest_util_sort(direction * body%mu(1:n), ind) - case("lfirst", "nbody", "ldiscard", "rh", "vh", "rb", "vb", "ah", "aobl", "atide", "agr") + case("peri") + call swiftest_util_sort(direction * body%peri(1:n), ind) + case("atp") + call swiftest_util_sort(direction * body%atp(1:n), ind) + case("info", "lfirst", "nbody", "ldiscard", "lcollision", "lencounter", "rh", "vh", "rb", "vb", "ah", "aobl", "atide", "agr","isperi") write(*,*) 'Cannot sort by ' // trim(adjustl(sortby)) // '. Component not sortable!' case default write(*,*) 'Cannot sort by ' // trim(adjustl(sortby)) // '. Component not found!' @@ -3625,7 +3629,11 @@ module subroutine swiftest_util_sort_pl(self, sortby, ascending) call swiftest_util_sort(direction * pl%Q(1:npl), ind) case("tlag") call swiftest_util_sort(direction * pl%tlag(1:npl), ind) - case("rbeg", "rend", "vbeg", "Ip", "rot", "k_plpl", "nplpl") + case("nplenc") + call swiftest_util_sort(direction * pl%nplenc(1:npl), ind) + case("ntpenc") + call swiftest_util_sort(direction * pl%ntpenc(1:npl), ind) + case("lmtiny", "nplm", "nplplm", "kin", "rbeg", "rend", "vbeg", "Ip", "rot", "k_plpl", "nplpl") write(*,*) 'Cannot sort by ' // trim(adjustl(sortby)) // '. Component not sortable!' case default ! Look for components in the parent class call swiftest_util_sort_body(pl, sortby, ascending) @@ -3664,12 +3672,8 @@ module subroutine swiftest_util_sort_tp(self, sortby, ascending) associate(tp => self, ntp => self%nbody) select case(sortby) - case("peri") - call swiftest_util_sort(direction * tp%peri(1:ntp), ind) - case("atp") - call swiftest_util_sort(direction * tp%atp(1:ntp), ind) - case("isperi") - write(*,*) 'Cannot sort by ' // trim(adjustl(sortby)) // '. Component not sortable!' + case("nplenc") + call swiftest_util_sort(direction * tp%nplenc(1:ntp), ind) case default ! Look for components in the parent class call swiftest_util_sort_body(tp, sortby, ascending) return diff --git a/src/symba/symba_util.f90 b/src/symba/symba_util.f90 index 87ba8dacf..0a78693b2 100644 --- a/src/symba/symba_util.f90 +++ b/src/symba/symba_util.f90 @@ -79,9 +79,6 @@ module subroutine symba_util_dealloc_pl(self) if (allocated(self%levelg)) deallocate(self%levelg) if (allocated(self%levelm)) deallocate(self%levelm) - if (allocated(self%isperi)) deallocate(self%isperi) - if (allocated(self%peri)) deallocate(self%peri) - if (allocated(self%atp)) deallocate(self%atp) call self%helio_pl%dealloc() @@ -121,18 +118,9 @@ module subroutine symba_util_fill_pl(self, inserts, lfill_list) associate(keeps => self) select type(inserts) class is (symba_pl) - call swiftest_util_fill(keeps%lcollision, inserts%lcollision, lfill_list) - call swiftest_util_fill(keeps%lencounter, inserts%lencounter, lfill_list) - call swiftest_util_fill(keeps%lmtiny, inserts%lmtiny, lfill_list) - call swiftest_util_fill(keeps%nplenc, inserts%nplenc, lfill_list) - call swiftest_util_fill(keeps%ntpenc, inserts%ntpenc, lfill_list) call swiftest_util_fill(keeps%levelg, inserts%levelg, lfill_list) call swiftest_util_fill(keeps%levelm, inserts%levelm, lfill_list) - call swiftest_util_fill(keeps%isperi, inserts%isperi, lfill_list) - call swiftest_util_fill(keeps%peri, inserts%peri, lfill_list) - call swiftest_util_fill(keeps%atp, inserts%atp, lfill_list) - call swiftest_util_fill(keeps%kin, inserts%kin, lfill_list) - + call swiftest_util_fill_pl(keeps, inserts, lfill_list) ! Note: helio_pl does not have its own fill method, so we skip back to the base class class default write(*,*) "Invalid object passed to the fill method. Source must be of class symba_pl or its descendents!" @@ -221,9 +209,6 @@ module subroutine symba_util_resize_pl(self, nnew) call swiftest_util_resize(self%levelg, nnew) call swiftest_util_resize(self%levelm, nnew) - call swiftest_util_resize(self%isperi, nnew) - call swiftest_util_resize(self%peri, nnew) - call swiftest_util_resize(self%atp, nnew) call swiftest_util_resize_pl(self, nnew) @@ -315,18 +300,9 @@ module subroutine symba_util_setup_pl(self, n, param) allocate(self%levelg(n)) allocate(self%levelm(n)) - allocate(self%isperi(n)) - allocate(self%peri(n)) - allocate(self%atp(n)) - allocate(self%kin(n)) - self%levelg(:) = -1 self%levelm(:) = -1 - self%isperi(:) = 0 - self%peri(:) = 0.0_DP - self%atp(:) = 0.0_DP - call self%reset_kinship([(i, i=1, n)]) return end subroutine symba_util_setup_pl @@ -381,20 +357,11 @@ module subroutine symba_util_sort_pl(self, sortby, ascending) associate(pl => self, npl => self%nbody) select case(sortby) - case("nplenc") - call swiftest_util_sort(direction * pl%nplenc(1:npl), ind) - case("ntpenc") - call swiftest_util_sort(direction * pl%ntpenc(1:npl), ind) case("levelg") call swiftest_util_sort(direction * pl%levelg(1:npl), ind) case("levelm") call swiftest_util_sort(direction * pl%levelm(1:npl), ind) - case("peri") - call swiftest_util_sort(direction * pl%peri(1:npl), ind) - case("atp") - call swiftest_util_sort(direction * pl%atp(1:npl), ind) - case("lcollision", "lencounter", "lmtiny", "nplm", "nplplm", "kin", "info") - write(*,*) 'Cannot sort by ' // trim(adjustl(sortby)) // '. Component not sortable!' + case default ! Look for components in the parent class call swiftest_util_sort_pl(pl, sortby, ascending) return @@ -508,17 +475,8 @@ module subroutine symba_util_spill_pl(self, discards, lspill_list, ldestructive) associate(keeps => self) select type(discards) class is (symba_pl) - call swiftest_util_spill(keeps%lcollision, discards%lcollision, lspill_list, ldestructive) - call swiftest_util_spill(keeps%lencounter, discards%lencounter, lspill_list, ldestructive) - call swiftest_util_spill(keeps%lmtiny, discards%lmtiny, lspill_list, ldestructive) - call swiftest_util_spill(keeps%nplenc, discards%nplenc, lspill_list, ldestructive) - call swiftest_util_spill(keeps%ntpenc, discards%ntpenc, lspill_list, ldestructive) call swiftest_util_spill(keeps%levelg, discards%levelg, lspill_list, ldestructive) call swiftest_util_spill(keeps%levelm, discards%levelm, lspill_list, ldestructive) - call swiftest_util_spill(keeps%isperi, discards%isperi, lspill_list, ldestructive) - call swiftest_util_spill(keeps%peri, discards%peri, lspill_list, ldestructive) - call swiftest_util_spill(keeps%atp, discards%atp, lspill_list, ldestructive) - call swiftest_util_spill(keeps%kin, discards%kin, lspill_list, ldestructive) call swiftest_util_spill_pl(keeps, discards, lspill_list, ldestructive) class default