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

Commit

Permalink
Added generic resize methods to all body types
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Aug 2, 2021
1 parent 27af16a commit ff95789
Show file tree
Hide file tree
Showing 10 changed files with 592 additions and 95 deletions.
16 changes: 15 additions & 1 deletion src/modules/rmvs_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ module rmvs_classes
!! 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 :: 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
procedure :: rearrange => rmvs_util_sort_rearrange_tp !! Rearranges the order of array elements of body based on an input index array. Used in sorting methods
procedure :: spill => rmvs_util_spill_tp !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic)
Expand All @@ -92,9 +93,10 @@ 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 :: 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
procedure :: rearrange => rmvs_util_sort_rearrange_pl !! Rearranges the order of array elements of body based on an input index array. Used in sorting methods
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 :: spill => rmvs_util_spill_pl !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic)
end type rmvs_pl

Expand Down Expand Up @@ -170,6 +172,18 @@ module subroutine rmvs_util_fill_tp(self, inserts, lfill_list)
logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps
end subroutine rmvs_util_fill_tp

module subroutine rmvs_util_resize_pl(self, nnew)
implicit none
class(rmvs_pl), intent(inout) :: self !! RMVS massive body object
integer(I4B), intent(in) :: nnew !! New size neded
end subroutine rmvs_util_resize_pl

module subroutine rmvs_util_resize_tp(self, nnew)
implicit none
class(rmvs_tp), intent(inout) :: self !! RMVS test particle object
integer(I4B), intent(in) :: nnew !! New size neded
end subroutine rmvs_util_resize_tp

module subroutine rmvs_util_sort_pl(self, sortby, ascending)
implicit none
class(rmvs_pl), intent(inout) :: self !! RMVS massive body object
Expand Down
59 changes: 53 additions & 6 deletions src/modules/swiftest_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ module swiftest_classes
integer(I4B), dimension(:), allocatable :: id !! External identifier (unique)
integer(I4B), dimension(:), allocatable :: status !! An integrator-specific status indicator
logical, dimension(:), allocatable :: ldiscard !! Body should be discarded
logical, dimension(:), allocatable :: lmask !! Logical mask used to select a subset of bodies when performing certain operations (drift, kick, accel, etc.)
real(DP), dimension(:), allocatable :: mu !! G * (Mcb + [m])
real(DP), dimension(:,:), allocatable :: xh !! Heliocentric position
real(DP), dimension(:,:), allocatable :: vh !! Heliocentric velocity
real(DP), dimension(:,:), allocatable :: xb !! Barycentric position
Expand All @@ -142,8 +144,6 @@ module swiftest_classes
real(DP), dimension(:), allocatable :: capom !! Longitude of ascending node
real(DP), dimension(:), allocatable :: omega !! Argument of pericenter
real(DP), dimension(:), allocatable :: capm !! Mean anomaly
real(DP), dimension(:), allocatable :: mu !! G * (Mcb + [m])
logical, dimension(:), allocatable :: lmask !! Logical mask used to select a subset of bodies when performing certain operations (drift, kick, accel, etc.)
!! Note to developers: If you add components to this class, be sure to update methods and subroutines that traverse the
!! component list, such as setup_body and util_spill
contains
Expand Down Expand Up @@ -209,6 +209,7 @@ module swiftest_classes
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)
procedure :: resize => util_resize_pl !! Checks the current size of a Swiftest body against the requested size and resizes it if it is too small.
procedure :: set_beg_end => util_set_beg_end_pl !! Sets the beginning and ending positions and velocities of planets.
procedure :: set_mu => util_set_mu_pl !! Method used to construct the vectorized form of the central body mass
procedure :: set_rhill => util_set_rhill !! Calculates the Hill's radii for each body
Expand Down Expand Up @@ -239,6 +240,7 @@ module swiftest_classes
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
Expand Down Expand Up @@ -847,14 +849,59 @@ module subroutine util_peri_tp(self, system, param)
class(swiftest_nbody_system), intent(inout) :: system !! Swiftest nbody system object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters
end subroutine util_peri_tp
end interface

interface util_resize
module subroutine util_resize_arr_char_string(arr, nnew)
implicit none
character(len=STRMAX), dimension(:), allocatable, intent(inout) :: arr !! Array to resize
integer(I4B), intent(in) :: nnew !! New size
end subroutine util_resize_arr_char_string

module subroutine util_resize_arr_DP(arr, nnew)
implicit none
real(DP), dimension(:), allocatable, intent(inout) :: arr !! Array to resize
integer(I4B), intent(in) :: nnew !! New size
end subroutine util_resize_arr_DP

module subroutine util_resize_arr_DPvec(arr, nnew)
implicit none
real(DP), dimension(:,:), allocatable, intent(inout) :: arr !! Array to resize
integer(I4B), intent(in) :: nnew !! New size
end subroutine util_resize_arr_DPvec

module subroutine util_resize_arr_I4B(arr, nnew)
implicit none
integer(I4B), dimension(:), allocatable, intent(inout) :: arr !! Array to resize
integer(I4B), intent(in) :: nnew !! New size
end subroutine util_resize_arr_I4B

module subroutine util_resize_arr_logical(arr, nnew)
implicit none
logical, dimension(:), allocatable, intent(inout) :: arr !! Array to resize
integer(I4B), intent(in) :: nnew !! New size
end subroutine util_resize_arr_logical
end interface

module subroutine util_resize_body(self, nrequested, param)
interface
module subroutine util_resize_body(self, nnew)
implicit none
class(swiftest_body), intent(inout) :: self !! Swiftest body object
integer(I4B), intent(in) :: nrequested !! New size neded
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters
class(swiftest_body), intent(inout) :: self !! Swiftest body object
integer(I4B), intent(in) :: nnew !! New size neded
end subroutine util_resize_body

module subroutine util_resize_pl(self, nnew)
implicit none
class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object
integer(I4B), intent(in) :: nnew !! New size neded
end subroutine util_resize_pl

module subroutine util_resize_tp(self, nnew)
implicit none
class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object
integer(I4B), intent(in) :: nnew !! New size neded
end subroutine util_resize_tp

module subroutine util_set_beg_end_pl(self, xbeg, xend, vbeg)
implicit none
class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object
Expand Down
58 changes: 44 additions & 14 deletions src/modules/symba_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ 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 :: fill => symba_util_fill_pl !! "Fills" bodies from one object into another depending on the results of a mask (uses the UNPACK intrinsic)
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
procedure :: rearrange => symba_util_sort_rearrange_pl !! Rearranges the order of array elements of body based on an input index array. Used in sorting methods
procedure :: spill => symba_util_spill_pl !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic)
procedure :: spill => symba_util_spill_pl !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic)
end type symba_pl

!********************************************************************************************************************************
Expand All @@ -111,10 +112,11 @@ 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 :: fill => symba_util_fill_tp !! "Fills" bodies from one object into another depending on the results of a mask (uses the UNPACK intrinsic)
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
procedure :: rearrange => symba_util_sort_rearrange_tp !! Rearranges the order of array elements of body based on an input index array. Used in sorting methods
procedure :: spill => symba_util_spill_tp !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic)
procedure :: spill => symba_util_spill_tp !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic)
end type symba_tp

!********************************************************************************************************************************
Expand Down Expand Up @@ -163,12 +165,12 @@ module symba_classes
class(symba_pl), allocatable :: pl_discards !! Discarded test particle data structure
integer(I4B) :: irec !! System recursion level
contains
procedure :: initialize => symba_setup_initialize_system !! Performs SyMBA-specific initilization steps
procedure :: step => symba_step_system !! Advance the SyMBA nbody system forward in time by one step
procedure :: interp => symba_step_interp_system !! Perform an interpolation step on the SymBA nbody system
procedure :: set_recur_levels => symba_step_set_recur_levels_system !! Sets recursion levels of bodies and encounter lists to the current system level
procedure :: recursive_step => symba_step_recur_system !! Step interacting planets and active test particles ahead in democratic heliocentric coordinates at the current recursion level, if applicable, and descend to the next deeper level if necessary
procedure :: reset => symba_step_reset_system !! Resets pl, tp,and encounter structures at the start of a new step
procedure :: initialize => symba_setup_initialize_system !! Performs SyMBA-specific initilization steps
procedure :: step => symba_step_system !! Advance the SyMBA nbody system forward in time by one step
procedure :: interp => symba_step_interp_system !! Perform an interpolation step on the SymBA nbody system
procedure :: set_recur_levels => symba_step_set_recur_levels_system !! Sets recursion levels of bodies and encounter lists to the current system level
procedure :: recursive_step => symba_step_recur_system !! Step interacting planets and active test particles ahead in democratic heliocentric coordinates at the current recursion level, if applicable, and descend to the next deeper level if necessary
procedure :: reset => symba_step_reset_system !! Resets pl, tp,and encounter structures at the start of a new step
end type symba_nbody_system

interface
Expand Down Expand Up @@ -439,12 +441,12 @@ module subroutine symba_util_fill_arr_char_info(keeps, inserts, lfill_list)
logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps
end subroutine symba_util_fill_arr_char_info

module subroutine symba_util_fill_arr_char_kin(keeps, inserts, lfill_list)
module subroutine symba_util_fill_arr_kin(keeps, inserts, lfill_list)
implicit none
type(symba_kinship), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep
type(symba_kinship), 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_kin
end subroutine symba_util_fill_arr_kin
end interface

interface
Expand All @@ -463,13 +465,41 @@ module subroutine symba_util_fill_tp(self, inserts, lfill_list)
class(swiftest_body), intent(in) :: inserts !! Inserted object
logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps
end subroutine symba_util_fill_tp
end interface

interface util_resize
module subroutine symba_util_resize_arr_info(arr, nnew)
implicit none
type(symba_particle_info), dimension(:), allocatable, intent(inout) :: arr !! Array to resize
integer(I4B), intent(in) :: nnew !! New size
end subroutine symba_util_resize_arr_info

module subroutine symba_util_resize_pltpenc(self, nrequested)
module subroutine symba_util_resize_arr_kin(arr, nnew)
implicit none
type(symba_kinship), dimension(:), allocatable, intent(inout) :: arr !! Array to resize
integer(I4B), intent(in) :: nnew !! New size
end subroutine symba_util_resize_arr_kin
end interface

interface
module subroutine symba_util_resize_pl(self, nnew)
implicit none
class(symba_pl), intent(inout) :: self !! SyMBA massive body object
integer(I4B), intent(in) :: nnew !! New size neded
end subroutine symba_util_resize_pl

module subroutine symba_util_resize_pltpenc(self, nnew)
implicit none
class(symba_pltpenc), intent(inout) :: self !! SyMBA pl-tp encounter list
integer(I4B), intent(in) :: nrequested !! New size of list needed
integer(I4B), intent(in) :: nnew !! New size of list needed
end subroutine symba_util_resize_pltpenc

module subroutine symba_util_resize_tp(self, nnew)
implicit none
class(symba_tp), intent(inout) :: self !! SyMBA massive body object
integer(I4B), intent(in) :: nnew !! New size neded
end subroutine symba_util_resize_tp

module subroutine symba_util_sort_pl(self, sortby, ascending)
implicit none
class(symba_pl), intent(inout) :: self !! SyMBA massive body object
Expand Down
Loading

0 comments on commit ff95789

Please sign in to comment.