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

Commit

Permalink
Added more detail to the fraggle output. I discovered a need to take …
Browse files Browse the repository at this point in the history
…a snapshot of some of the planet variables in the colliders object.
  • Loading branch information
daminton committed Dec 9, 2022
1 parent 0a808bf commit b3f8c06
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 30 deletions.
62 changes: 32 additions & 30 deletions src/fraggle/fraggle_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -158,39 +158,41 @@ module subroutine fraggle_io_write_frame(self, nc, param)
class(encounter_io_parameters), intent(inout) :: nc !! Parameters used to identify a particular encounter io NetCDF dataset
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
! Internals
integer(I4B) :: i, eslot, idslot, old_mode, npl
integer(I4B) :: i, j, eslot, idslot, old_mode, npl
character(len=NAMELEN) :: charstring

eslot = param%ioutput
associate(pl => self%pl, colliders => self%colliders, fragments => self%fragments)

call check( nf90_set_fill(nc%id, nf90_nofill, old_mode), "fraggle_io_write_frame nf90_set_fill" )

call check( nf90_put_var(nc%id, nc%time_varid, self%t, start=[eslot]), "fraggle_io_write_frame nf90_put_var time_varid" )
call check( nf90_put_var(nc%id, nc%loop_varid, int(self%iloop,kind=I4B), start=[eslot]), "fraggle_io_write_frame nf90_put_var pl loop_varid" )

! npl = pl%nbody
! do i = 1, npl
! idslot = pl%id(i)
! call check( nf90_put_var(nc%id, nc%id_varid, pl%id(i), start=[idslot]), "fraggle_io_write_frame nf90_put_var pl id_varid" )
! call check( nf90_put_var(nc%id, nc%rh_varid, pl%rh(:,i), start=[1,idslot,eslot], count=[NDIM,1,1]), "fraggle_io_write_frame nf90_put_var pl rh_varid" )
! call check( nf90_put_var(nc%id, nc%vh_varid, pl%vh(:,i), start=[1,idslot,eslot], count=[NDIM,1,1]), "fraggle_io_write_frame nf90_put_var pl vh_varid" )
! call check( nf90_put_var(nc%id, nc%Gmass_varid, pl%Gmass(i), start=[idslot, eslot]), "fraggle_io_write_frame nf90_put_var pl Gmass_varid" )

! if (param%lclose) call check( nf90_put_var(nc%id, nc%radius_varid, pl%radius(i), start=[idslot, eslot]), "fraggle_io_write_frame nf90_put_var pl radius_varid" )

! if (param%lrotation) then
! call check( nf90_put_var(nc%id, nc%Ip_varid, pl%Ip(:,i), start=[1, idslot, eslot], count=[NDIM,1,1]), "fraggle_io_write_frame nf90_put_var pl Ip_varid" )
! call check( nf90_put_var(nc%id, nc%rot_varid, pl%rot(:,i), start=[1,idslot, eslot], count=[NDIM,1,1]), "fraggle_io_write_frame nf90_put_var pl rotx_varid" )
! end if

! charstring = trim(adjustl(pl%info(i)%name))
! call check( nf90_put_var(nc%id, nc%name_varid, charstring, start=[1, idslot], count=[NAMELEN, 1]), "fraggle_io_write_frame nf90_put_var pl name_varid" )
! charstring = trim(adjustl(pl%info(i)%particle_type))
! call check( nf90_put_var(nc%id, nc%ptype_varid, charstring, start=[1, idslot], count=[NAMELEN, 1]), "fraggle_io_write_frame nf90_put_var pl particle_type_varid" )
! end do

call check( nf90_set_fill(nc%id, old_mode, old_mode) )
associate(pl => self%colliders%pl, colliders => self%colliders, fragments => self%fragments)
select type(nc)
class is (fraggle_io_parameters)
call check( nf90_set_fill(nc%id, nf90_nofill, old_mode), "fraggle_io_write_frame nf90_set_fill" )

call check( nf90_put_var(nc%id, nc%time_varid, self%t, start=[eslot]), "fraggle_io_write_frame nf90_put_var time_varid" )
call check( nf90_put_var(nc%id, nc%loop_varid, int(self%iloop,kind=I4B), start=[eslot]), "fraggle_io_write_frame nf90_put_var pl loop_varid" )
call check( nf90_put_var(nc%id, nc%regime_varid, REGIME_NAMES(fragments%regime) , start=[eslot]), "fraggle_io_write_frame nf90_put_var pl loop_varid" )

! Stage 1: The Colliders
npl = size(colliders%idx)
do j = 1, npl
i = colliders%idx(j)
idslot = pl%id(i)
call check( nf90_put_var(nc%id, nc%id_varid, pl%id(i), start=[ idslot ]), "fraggle_io_write_frame nf90_put_var pl id_varid" )
charstring = trim(adjustl(pl%info(i)%name))
call check( nf90_put_var(nc%id, nc%name_varid, charstring, start=[1, idslot], count=[NAMELEN, 1]), "fraggle_io_write_frame nf90_put_var pl name_varid" )
charstring = trim(adjustl(pl%info(i)%particle_type))
call check( nf90_put_var(nc%id, nc%ptype_varid, charstring, start=[1, idslot], count=[NAMELEN, 1]), "fraggle_io_write_frame nf90_put_var pl particle_type_varid" )
end do

call check( nf90_put_var(nc%id, nc%rh_varid, pl%rh(:,i), start=[1, idslot, 1, eslot], count=[NDIM,1,1,1]), "fraggle_io_write_frame nf90_put_var pl rh_varid" )
call check( nf90_put_var(nc%id, nc%vh_varid, pl%vh(:,i), start=[1, idslot, 1, eslot], count=[NDIM,1,1,1]), "fraggle_io_write_frame nf90_put_var pl vh_varid" )
call check( nf90_put_var(nc%id, nc%Gmass_varid, pl%Gmass(i), start=[ idslot, 1, eslot]), "fraggle_io_write_frame nf90_put_var pl Gmass_varid" )
call check( nf90_put_var(nc%id, nc%radius_varid, pl%radius(i), start=[ idslot, 1, eslot]), "fraggle_io_write_frame nf90_put_var pl radius_varid" )
call check( nf90_put_var(nc%id, nc%Ip_varid, pl%Ip(:,i), start=[1, idslot, 1, eslot], count=[NDIM,1,1,1]), "fraggle_io_write_frame nf90_put_var pl Ip_varid" )
call check( nf90_put_var(nc%id, nc%rot_varid, pl%rot(:,i), start=[1, idslot, 1, eslot], count=[NDIM,1,1,1]), "fraggle_io_write_frame nf90_put_var pl rotx_varid" )


call check( nf90_set_fill(nc%id, old_mode, old_mode) )
end select
end associate

return
Expand Down
1 change: 1 addition & 0 deletions src/modules/fraggle_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module fraggle_classes
real(DP), dimension(NDIM,2) :: Ip !! Two-body equivalent principal axes moments of inertia the collider bodies prior to collision
real(DP), dimension(2) :: mass !! Two-body equivalent mass of the collider bodies prior to the collision
real(DP), dimension(2) :: radius !! Two-body equivalent radii of the collider bodies prior to the collision
class(swiftest_pl), allocatable :: pl !! A snapshot of the planets involved in the collision
contains
procedure :: regime => fraggle_regime_colliders !! Determine which fragmentation regime the set of colliders will be
final :: fraggle_util_final_colliders !! Finalizer will deallocate all allocatables
Expand Down
1 change: 1 addition & 0 deletions src/modules/swiftest_globals.f90
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ module swiftest_globals
integer(I4B), parameter :: COLLRESOLVE_REGIME_SUPERCATASTROPHIC = 3
integer(I4B), parameter :: COLLRESOLVE_REGIME_GRAZE_AND_MERGE = 4
integer(I4B), parameter :: COLLRESOLVE_REGIME_HIT_AND_RUN = 5
character(len=*),dimension(5), parameter :: REGIME_NAMES = ["Merge", "Disruption", "Supercatastrophic", "Graze and Merge", "Hit and Run"]

!> String labels for body/particle addition/subtraction in discard file
character(*), parameter :: ADD = '+1'
Expand Down

0 comments on commit b3f8c06

Please sign in to comment.