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

Commit

Permalink
Rearranged objects to put id into the swiftest_body type out of the base
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Mar 24, 2023
1 parent c4b42c2 commit 346ff32
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 28 deletions.
23 changes: 0 additions & 23 deletions src/base/base_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,6 @@ end subroutine abstract_util_dealloc_object
end interface


type, abstract, extends(base_object) :: base_multibody
integer(I4B) :: nbody = 0 !! Number of bodies
integer(I4B), dimension(:), allocatable :: id !! Identifier
contains
procedure :: dealloc => base_util_dealloc_multibody
end type base_multibody


!> Class definition for the kinship relationships used in bookkeeping multiple collisions bodies in a single time step.
type, abstract :: base_kinship
end type base_kinship
Expand All @@ -240,21 +232,6 @@ subroutine base_util_copy_store(self, source)
end subroutine base_util_copy_store


subroutine base_util_dealloc_multibody(self)
!! author: David A. Minton
!!
!! Finalize the multibody body object - deallocates all allocatables
implicit none
! Argument
class(base_multibody), intent(inout) :: self

self%nbody = 0
if (allocated(self%id)) deallocate(self%id)

return
end subroutine base_util_dealloc_multibody


subroutine base_util_dealloc_param(self)
!! author: David A. Minton
!!
Expand Down
4 changes: 3 additions & 1 deletion src/collision/collision_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ module collision


!> Class definition for the variables that describe a collection of fragments in barycentric coordinates
type, extends(base_multibody) :: collision_fragments
type, extends(base_object) :: collision_fragments
integer(I4B) :: nbody = 0 !! Number of bodies
real(DP) :: mtot !! Total mass of fragments
integer(I4B), dimension(:), allocatable :: id !! Identifier
class(base_particle_info), dimension(:), allocatable :: info !! Particle metadata information
integer(I4B), dimension(:), allocatable :: status !! An integrator-specific status indicator
real(DP), dimension(:,:), allocatable :: rh !! Heliocentric position
Expand Down
2 changes: 2 additions & 0 deletions src/collision/collision_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ module subroutine collision_util_dealloc_fragments(self)
! Arguments
class(collision_fragments), intent(inout) :: self

self%nbody = 0
if (allocated(self%id)) deallocate(self%id)
if (allocated(self%info)) deallocate(self%info)
if (allocated(self%status)) deallocate(self%status)
if (allocated(self%rh)) deallocate(self%rh)
Expand Down
4 changes: 3 additions & 1 deletion src/swiftest/swiftest_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ module swiftest


!> An abstract class for a generic collection of Swiftest bodies
type, abstract, extends(base_multibody) :: swiftest_body
type, abstract, extends(base_object) :: swiftest_body
!! Superclass that defines the generic elements of a Swiftest particle
logical :: lfirst = .true. !! Run the current step as a first
integer(I4B) :: nbody = 0 !! Number of bodies
integer(I4B), dimension(:), allocatable :: id !! Identifier
type(swiftest_particle_info), dimension(:), allocatable :: info !! Particle metadata information
logical, dimension(:), allocatable :: lmask !! Logical mask used to select a subset of bodies when performing certain operations (drift, kick, accel, etc.)
integer(I4B), dimension(:), allocatable :: status !! An integrator-specific status indicator
Expand Down
5 changes: 2 additions & 3 deletions src/swiftest/swiftest_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,8 @@ module subroutine swiftest_util_dealloc_body(self)
class(swiftest_body), intent(inout) :: self

self%lfirst = .true.

self%nbody = 0
if (allocated(self%id)) deallocate(self%id)
if (allocated(self%info)) deallocate(self%info)
if (allocated(self%status)) deallocate(self%status)
if (allocated(self%lmask)) deallocate(self%lmask)
Expand All @@ -754,8 +755,6 @@ module subroutine swiftest_util_dealloc_body(self)
if (allocated(self%omega)) deallocate(self%omega)
if (allocated(self%capm)) deallocate(self%capm)

call base_util_dealloc_multibody(self)

return
end subroutine swiftest_util_dealloc_body

Expand Down

0 comments on commit 346ff32

Please sign in to comment.