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

Commit

Permalink
Moved encounter type up to swiftest_classes so that the fragmentation…
Browse files Browse the repository at this point in the history
… code can be written independently of SyMBA
  • Loading branch information
daminton committed Aug 3, 2021
1 parent aa3e810 commit 947c4d4
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 22 deletions.
18 changes: 17 additions & 1 deletion src/modules/swiftest_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ module swiftest_classes
logical :: lintegrate = .false. !! Flag indicating that this object should be integrated in the current step
contains
!! The minimal methods that all systems must have
procedure :: dump => io_dump_swiftest
procedure :: dump => io_dump_swiftest
procedure(abstract_initialize), deferred :: initialize
procedure(abstract_read_frame), deferred :: read_frame
procedure(abstract_write_frame), deferred :: write_frame
Expand Down Expand Up @@ -286,6 +286,16 @@ module swiftest_classes
procedure :: set_msys => util_set_msys !! Sets the value of msys from the masses of system bodies.
end type swiftest_nbody_system

type :: swiftest_encounter
integer(I4B) :: nenc !! Total number of encounters
logical, dimension(:), allocatable :: lvdotr !! relative vdotr flag
integer(I4B), dimension(:), allocatable :: status !! status of the interaction
integer(I4B), dimension(:), allocatable :: index1 !! position of the first body in the encounter
integer(I4B), dimension(:), allocatable :: index2 !! position of the second body in the encounter
contains
procedure :: copy => util_copy_encounter
end type swiftest_encounter

abstract interface
subroutine abstract_discard_body(self, system, param)
import swiftest_body, swiftest_nbody_system, swiftest_parameters
Expand Down Expand Up @@ -824,6 +834,12 @@ module subroutine util_coord_h2b_tp(self, cb)
class(swiftest_cb), intent(in) :: cb !! Swiftest central body object
end subroutine util_coord_h2b_tp

module subroutine util_copy_encounter(self, source)
implicit none
class(swiftest_encounter), intent(inout) :: self !! Encounter list
class(swiftest_encounter), intent(in) :: source !! Source object to copy into
end subroutine util_copy_encounter

module subroutine util_exit(code)
implicit none
integer(I4B), intent(in) :: code !! Failure exit code
Expand Down
19 changes: 8 additions & 11 deletions src/modules/symba_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module symba_classes
!! Definition of classes and methods specific to the Democratic SyMBAcentric Method
!! Adapted from David E. Kaufmann's Swifter routine: helio.f90
use swiftest_globals
use swiftest_classes, only : swiftest_parameters, swiftest_base
use swiftest_classes, only : swiftest_parameters, swiftest_base, swiftest_encounter
use helio_classes, only : helio_cb, helio_pl, helio_tp, helio_nbody_system
use rmvs_classes, only : rmvs_chk_ind
implicit none
Expand Down Expand Up @@ -125,13 +125,8 @@ module symba_classes
! symba_pltpenc class definitions and method interfaces
!*******************************************************************************************************************************
!> SyMBA class for tracking pl-tp close encounters in a step
type :: symba_pltpenc
integer(I4B) :: nenc !! Total number of encounters
logical, dimension(:), allocatable :: lvdotr !! relative vdotr flag
integer(I4B), dimension(:), allocatable :: status !! status of the interaction
type, extends(swiftest_encounter) :: symba_pltpenc
integer(I4B), dimension(:), allocatable :: level !! encounter recursion level
integer(I4B), dimension(:), allocatable :: index1 !! position of the planet in encounter
integer(I4B), dimension(:), allocatable :: index2 !! position of the test particle in encounter
contains
procedure :: collision_check => symba_collision_check_pltpenc !! Checks if a test particle is going to collide with a massive body
procedure :: encounter_check => symba_encounter_check_pltpenc !! Checks if massive bodies are going through close encounters with each other
Expand Down Expand Up @@ -465,15 +460,17 @@ module subroutine symba_util_append_tp(self, source, lsource_mask)
end subroutine symba_util_append_tp

module subroutine symba_util_copy_pltpenc(self, source)
use swiftest_classes, only : swiftest_encounter
implicit none
class(symba_pltpenc), intent(inout) :: self !! SyMBA pl-tp encounter list
class(symba_pltpenc), intent(in) :: source !! Source object to copy into
class(symba_pltpenc), intent(inout) :: self !! SyMBA pl-tp encounter list
class(swiftest_encounter), intent(in) :: source !! Source object to copy into
end subroutine symba_util_copy_pltpenc

module subroutine symba_util_copy_plplenc(self, source)
use swiftest_classes, only : swifest_encounter
implicit none
class(symba_plplenc), intent(inout) :: self !! SyMBA pl-pl encounter list
class(symba_pltpenc), intent(in) :: source !! Source object to copy into
class(symba_plplenc), intent(inout) :: self !! SyMBA pl-pl encounter list
class(swiftest_encounter), intent(in) :: source !! Source object to copy into
end subroutine symba_util_copy_plplenc
end interface

Expand Down
19 changes: 9 additions & 10 deletions src/symba/symba_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,15 @@ module subroutine symba_util_copy_pltpenc(self, source)
!! Copies elements from the source encounter list into self.
implicit none
! Arguments
class(symba_pltpenc), intent(inout) :: self !! SyMBA pl-tp encounter list
class(symba_pltpenc), intent(in) :: source !! Source object to copy into
class(symba_pltpenc), intent(inout) :: self !! SyMBA pl-tp encounter list
class(swiftest_encounter), intent(in) :: source !! Source object to copy into

call util_copy_encounter(self, source)
associate(n => source%nenc)
self%nenc = n
self%lvdotr(1:n) = source%lvdotr(1:n)
self%status(1:n) = source%status(1:n)
self%level(1:n) = source%level(1:n)
self%index1(1:n) = source%index1(1:n)
self%index2(1:n) = source%index2(1:n)
select type(source)
class is (symba_pltpenc)
self%level(1:n) = source%level(1:n)
end select
end associate

return
Expand All @@ -170,8 +169,8 @@ module subroutine symba_util_copy_plplenc(self, source)
!! Copies elements from the source encounter list into self.
implicit none
! Arguments
class(symba_plplenc), intent(inout) :: self !! SyMBA pl-pl encounter list
class(symba_pltpenc), intent(in) :: source !! Source object to copy into
class(symba_plplenc), intent(inout) :: self !! SyMBA pl-pl encounter list
class(swiftest_encounter), intent(in) :: source !! Source object to copy into

call symba_util_copy_pltpenc(self, source)
associate(n => source%nenc)
Expand Down
25 changes: 25 additions & 0 deletions src/util/util_copy.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
submodule(swiftest_classes) s_util_copy
use swiftest
contains

module subroutine util_copy_encounter(self, source)
!! author: David A. Minton
!!
!! Copies elements from the source encounter list into self.
implicit none
! Arguments
class(swiftest_encounter), intent(inout) :: self !! Encounter list
class(swiftest_encounter), intent(in) :: source !! Source object to copy into

associate(n => source%nenc)
self%nenc = n
self%lvdotr(1:n) = source%lvdotr(1:n)
self%status(1:n) = source%status(1:n)
self%index1(1:n) = source%index1(1:n)
self%index2(1:n) = source%index2(1:n)
end associate

return
end subroutine util_copy_encounter

end submodule s_util_copy

0 comments on commit 947c4d4

Please sign in to comment.