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

Commit

Permalink
Browse files Browse the repository at this point in the history
Added append methods to all body types
  • Loading branch information
daminton committed Aug 2, 2021
1 parent cedfc4c commit f4bce42
Show file tree
Hide file tree
Showing 9 changed files with 514 additions and 104 deletions.
18 changes: 18 additions & 0 deletions src/modules/rmvs_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ module rmvs_classes
procedure :: accel => rmvs_kick_getacch_tp !! Calculates either the standard or modified version of the acceleration depending if the
!! if the test particle is undergoing a close encounter or not
procedure :: setup => rmvs_setup_tp !! Constructor method - Allocates space for number of particles
procedure :: append => rmvs_util_append_tp !! Appends elements from one structure to another
procedure :: fill => rmvs_util_fill_tp !! "Fills" bodies from one object into another depending on the results of a mask (uses the UNPACK intrinsic)
procedure :: resize => rmvs_util_resize_tp !! Checks the current size of a Swiftest body against the requested size and resizes it if it is too small.
procedure :: sort => rmvs_util_sort_tp !! Sorts body arrays by a sortable componen
Expand All @@ -93,6 +94,7 @@ module rmvs_classes
logical :: lplanetocentric = .false. !! Flag that indicates that the object is a planetocentric set of masive bodies used for close encounter calculations
contains
procedure :: setup => rmvs_setup_pl !! Constructor method - Allocates space for number of particles
procedure :: append => rmvs_util_append_pl !! Appends elements from one structure to another
procedure :: fill => rmvs_util_fill_pl !! "Fills" bodies from one object into another depending on the results of a mask (uses the UNPACK intrinsic)
procedure :: resize => rmvs_util_resize_pl !! Checks the current size of a Swiftest body against the requested size and resizes it if it is too small.
procedure :: sort => rmvs_util_sort_pl !! Sorts body arrays by a sortable componen
Expand Down Expand Up @@ -156,6 +158,22 @@ module subroutine rmvs_setup_tp(self, n, param)
class(swiftest_parameters), intent(in) :: param !! Current run configuration parametere
end subroutine rmvs_setup_tp

module subroutine rmvs_util_append_pl(self, source, lsource_mask)
use swiftest_classes, only : swiftest_body
implicit none
class(rmvs_pl), intent(inout) :: self !! RMVS massive body object
class(swiftest_body), intent(in) :: source !! Source object to append
logical, dimension(:), optional, intent(in) :: lsource_mask !! Logical mask indicating which elements to append to
end subroutine rmvs_util_append_pl

module subroutine rmvs_util_append_tp(self, source, lsource_mask)
use swiftest_classes, only : swiftest_body
implicit none
class(rmvs_tp), intent(inout) :: self !! RMVS test particle object
class(swiftest_body), intent(in) :: source !! Source object to append
logical, dimension(:), optional, intent(in) :: lsource_mask !! Logical mask indicating which elements to append to
end subroutine rmvs_util_append_tp

module subroutine rmvs_util_fill_pl(self, inserts, lfill_list)
use swiftest_classes, only : swiftest_body
implicit none
Expand Down
52 changes: 34 additions & 18 deletions src/modules/swiftest_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ module swiftest_classes
procedure :: accel_obl => obl_acc_pl !! Compute the barycentric accelerations of bodies due to the oblateness of the central body
procedure :: setup => setup_pl !! A base constructor that sets the number of bodies and allocates and initializes all arrays
procedure :: accel_tides => tides_kick_getacch_pl !! Compute the accelerations of bodies due to tidal interactions with the central body
procedure :: append => util_append_pl !! Appends elements from one structure to another
procedure :: h2b => util_coord_h2b_pl !! Convert massive bodies from heliocentric to barycentric coordinates (position and velocity)
procedure :: b2h => util_coord_b2h_pl !! Convert massive bodies from barycentric to heliocentric coordinates (position and velocity)
procedure :: fill => util_fill_pl !! "Fills" bodies from one object into another depending on the results of a mask (uses the UNPACK intrinsic)
Expand All @@ -231,19 +232,20 @@ module swiftest_classes
contains
! Test particle-specific concrete methods
! These are concrete because they are the same implemenation for all integrators
procedure :: discard => discard_tp !! Check to see if test particles should be discarded based on their positions relative to the massive bodies
procedure :: accel_int => kick_getacch_int_tp !! Compute direct cross (third) term heliocentric accelerations of test particles by massive bodies
procedure :: accel_obl => obl_acc_tp !! Compute the barycentric accelerations of bodies due to the oblateness of the central body
procedure :: setup => setup_tp !! A base constructor that sets the number of bodies and
procedure :: h2b => util_coord_h2b_tp !! Convert test particles from heliocentric to barycentric coordinates (position and velocity)
procedure :: b2h => util_coord_b2h_tp !! Convert test particles from barycentric to heliocentric coordinates (position and velocity)
procedure :: fill => util_fill_tp !! "Fills" bodies from one object into another depending on the results of a mask (uses the UNPACK intrinsic)
procedure :: get_peri => util_peri_tp !! Determine system pericenter passages for test particles
procedure :: resize => util_resize_tp !! Checks the current size of a Swiftest body against the requested size and resizes it if it is too small.
procedure :: set_mu => util_set_mu_tp !! Method used to construct the vectorized form of the central body mass
procedure :: sort => util_sort_tp !! Sorts body arrays by a sortable component
procedure :: rearrange => util_sort_rearrange_tp !! Rearranges the order of array elements of body based on an input index array. Used in sorting methods
procedure :: spill => util_spill_tp !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic)
procedure :: discard => discard_tp !! Check to see if test particles should be discarded based on their positions relative to the massive bodies
procedure :: accel_int => kick_getacch_int_tp !! Compute direct cross (third) term heliocentric accelerations of test particles by massive bodies
procedure :: accel_obl => obl_acc_tp !! Compute the barycentric accelerations of bodies due to the oblateness of the central body
procedure :: setup => setup_tp !! A base constructor that sets the number of bodies and
procedure :: append => util_append_tp !! Appends elements from one structure to another
procedure :: h2b => util_coord_h2b_tp !! Convert test particles from heliocentric to barycentric coordinates (position and velocity)
procedure :: b2h => util_coord_b2h_tp !! Convert test particles from barycentric to heliocentric coordinates (position and velocity)
procedure :: fill => util_fill_tp !! "Fills" bodies from one object into another depending on the results of a mask (uses the UNPACK intrinsic)
procedure :: get_peri => util_peri_tp !! Determine system pericenter passages for test particles
procedure :: resize => util_resize_tp !! Checks the current size of a Swiftest body against the requested size and resizes it if it is too small.
procedure :: set_mu => util_set_mu_tp !! Method used to construct the vectorized form of the central body mass
procedure :: sort => util_sort_tp !! Sorts body arrays by a sortable component
procedure :: rearrange => util_sort_rearrange_tp !! Rearranges the order of array elements of body based on an input index array. Used in sorting methods
procedure :: spill => util_spill_tp !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic)
end type swiftest_tp

!********************************************************************************************************************************
Expand Down Expand Up @@ -742,35 +744,35 @@ end subroutine user_kick_getacch_body
module subroutine util_append_arr_char_string(arr, source, lsource_mask)
implicit none
character(len=STRMAX), dimension(:), allocatable, intent(inout) :: arr !! Destination array
character(len=STRMAX), dimension(:), allocatable, intent(inout) :: source !! Array to append
character(len=STRMAX), dimension(:), allocatable, intent(in) :: source !! Array to append
logical, dimension(:), optional, intent(in) :: lsource_mask !! Logical mask indicating which elements to append to
end subroutine util_append_arr_char_string

module subroutine util_append_arr_DP(arr, source, lsource_mask)
implicit none
real(DP), dimension(:), allocatable, intent(inout) :: arr !! Destination array
real(DP), dimension(:), allocatable, intent(inout) :: source !! Array to append
real(DP), dimension(:), allocatable, intent(in) :: source !! Array to append
logical, dimension(:), optional, intent(in) :: lsource_mask !! Logical mask indicating which elements to append to
end subroutine util_append_arr_DP

module subroutine util_append_arr_DPvec(arr, source, lsource_mask)
implicit none
real(DP), dimension(:,:), allocatable, intent(inout) :: arr !! Destination array
real(DP), dimension(:,:), allocatable, intent(inout) :: source !! Array to append
real(DP), dimension(:,:), allocatable, intent(in) :: source !! Array to append
logical, dimension(:), optional, intent(in) :: lsource_mask !! Logical mask indicating which elements to append to
end subroutine util_append_arr_DPvec

module subroutine util_append_arr_I4B(arr, source, lsource_mask)
implicit none
integer(I4B), dimension(:), allocatable, intent(inout) :: arr !! Destination array
integer(I4B), dimension(:), allocatable, intent(inout) :: source !! Array to append
integer(I4B), dimension(:), allocatable, intent(in) :: source !! Array to append
logical, dimension(:), optional, intent(in) :: lsource_mask !! Logical mask indicating which elements to append to
end subroutine util_append_arr_I4B

module subroutine util_append_arr_logical(arr, source, lsource_mask)
implicit none
logical, dimension(:), allocatable, intent(inout) :: arr !! Destination array
logical, dimension(:), allocatable, intent(inout) :: source !! Array to append
logical, dimension(:), allocatable, intent(in) :: source !! Array to append
logical, dimension(:), optional, intent(in) :: lsource_mask !! Logical mask indicating which elements to append to
end subroutine util_append_arr_logical
end interface
Expand All @@ -783,6 +785,20 @@ module subroutine util_append_body(self, source, lsource_mask)
logical, dimension(:), optional, intent(in) :: lsource_mask !! Logical mask indicating which elements to append to
end subroutine util_append_body

module subroutine util_append_pl(self, source, lsource_mask)
implicit none
class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object
class(swiftest_body), intent(in) :: source !! Source object to append
logical, dimension(:), optional, intent(in) :: lsource_mask !! Logical mask indicating which elements to append to
end subroutine util_append_pl

module subroutine util_append_tp(self, source, lsource_mask)
implicit none
class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object
class(swiftest_body), intent(in) :: source !! Source object to append
logical, dimension(:), optional, intent(in) :: lsource_mask !! Logical mask indicating which elements to append to
end subroutine util_append_tp

module subroutine util_coord_b2h_pl(self, cb)
implicit none
class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object
Expand Down
40 changes: 38 additions & 2 deletions src/modules/symba_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ module symba_classes
procedure :: encounter_check => symba_encounter_check_pl !! Checks if massive bodies are going through close encounters with each other
procedure :: accel => symba_kick_getacch_pl !! Compute heliocentric accelerations of massive bodies
procedure :: setup => symba_setup_pl !! Constructor method - Allocates space for number of particle
procedure :: append => symba_util_append_pl !! Appends elements from one structure to another
procedure :: fill => symba_util_fill_pl !! "Fills" bodies from one object into another depending on the results of a mask (uses the UNPACK intrinsic)
procedure :: resize => symba_util_resize_pl !! Checks the current size of a Swiftest body against the requested size and resizes it if it is too small.
procedure :: sort => symba_util_sort_pl !! Sorts body arrays by a sortable componen
Expand All @@ -112,6 +113,7 @@ module symba_classes
procedure :: encounter_check => symba_encounter_check_tp !! Checks if any test particles are undergoing a close encounter with a massive body
procedure :: accel => symba_kick_getacch_tp !! Compute heliocentric accelerations of test particles
procedure :: setup => symba_setup_tp !! Constructor method - Allocates space for number of particle
procedure :: append => symba_util_append_tp !! Appends elements from one structure to another
procedure :: fill => symba_util_fill_tp !! "Fills" bodies from one object into another depending on the results of a mask (uses the UNPACK intrinsic)
procedure :: resize => symba_util_resize_tp !! Checks the current size of a Swiftest body against the requested size and resizes it if it is too small.
procedure :: sort => symba_util_sort_tp !! Sorts body arrays by a sortable componen
Expand Down Expand Up @@ -419,6 +421,40 @@ module subroutine symba_step_reset_system(self)
implicit none
class(symba_nbody_system), intent(inout) :: self !! SyMBA nbody system object
end subroutine symba_step_reset_system
end interface

interface util_append
module subroutine symba_util_append_arr_info(arr, source, lsource_mask)
implicit none
type(symba_particle_info), dimension(:), allocatable, intent(inout) :: arr !! Destination array
type(symba_particle_info), dimension(:), allocatable, intent(in) :: source !! Array to append
logical, dimension(:), optional, intent(in) :: lsource_mask !! Logical mask indicating which elements to append to
end subroutine symba_util_append_arr_info

module subroutine symba_util_append_arr_kin(arr, source, lsource_mask)
implicit none
type(symba_kinship), dimension(:), allocatable, intent(inout) :: arr !! Destination array
type(symba_kinship), dimension(:), allocatable, intent(in) :: source !! Array to append
logical, dimension(:), optional, intent(in) :: lsource_mask !! Logical mask indicating which elements to append to
end subroutine symba_util_append_arr_kin
end interface

interface
module subroutine symba_util_append_pl(self, source, lsource_mask)
use swiftest_classes, only : swiftest_body
implicit none
class(symba_pl), intent(inout) :: self !! SyMBA massive body object
class(swiftest_body), intent(in) :: source !! Source object to append
logical, dimension(:), optional, intent(in) :: lsource_mask !! Logical mask indicating which elements to append to
end subroutine symba_util_append_pl

module subroutine symba_util_append_tp(self, source, lsource_mask)
use swiftest_classes, only : swiftest_body
implicit none
class(symba_tp), intent(inout) :: self !! SyMBA test particle object
class(swiftest_body), intent(in) :: source !! Source object to append
logical, dimension(:), optional, intent(in) :: lsource_mask !! Logical mask indicating which elements to append to
end subroutine symba_util_append_tp

module subroutine symba_util_copy_pltpenc(self, source)
implicit none
Expand All @@ -434,12 +470,12 @@ end subroutine symba_util_copy_plplenc
end interface

interface util_fill
module subroutine symba_util_fill_arr_char_info(keeps, inserts, lfill_list)
module subroutine symba_util_fill_arr_info(keeps, inserts, lfill_list)
implicit none
type(symba_particle_info), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep
type(symba_particle_info), dimension(:), allocatable, intent(in) :: inserts !! Array of values to insert into keep
logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps
end subroutine symba_util_fill_arr_char_info
end subroutine symba_util_fill_arr_info

module subroutine symba_util_fill_arr_kin(keeps, inserts, lfill_list)
implicit none
Expand Down
Loading

0 comments on commit f4bce42

Please sign in to comment.