Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/adjust_data.f90
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ subroutine adjust_data_codeunits
use labels, only:ih,ix,ivx,get_sink_type,ipmass,idustfrac,irho,labeltype,label
use settings_data, only:ncolumns,ndimV,ndim,ntypes,iverbose,UseFakeDustParticles,UseFastRender,icoords
use particle_data, only:dat,npartoftype,iamtype
use filenames, only:ifileopen,nstepsinfile
use filenames, only:ifileopen,nstepsinfile,have_origin,have_sinkpos,xyz_origin,isinkid
use geometry, only:labelcoord
use part_utils, only:locate_first_two_of_type,locate_nth_particle_of_type,get_binary,got_particles_of_type
real :: hmin,dphi,domega,period
Expand Down Expand Up @@ -140,14 +140,14 @@ subroutine adjust_data_codeunits
!--can specify either just "true" for sink #1, or specify a number for a particular sink
centreonsink = lenvironment('SPLASH_CENTRE_ON_SINK') .or. lenvironment('SPLASH_CENTER_ON_SINK')
isink = max(ienvironment('SPLASH_CENTRE_ON_SINK'),ienvironment('SPLASH_CENTER_ON_SINK'))
if (have_sinkpos) isink = isinkid(ifileopen)
if (isink > 0 .or. centreonsink .and. all(ix(1:ndim) > 0)) then
if (isink==0) isink = 1
itype = get_sink_type(ntypes)
if (itype > 0) then
if (all(npartoftype(itype,:) < isink)) then
print "(a,i10,a)",' ERROR: --sink = ',isink,' but not enough sink particles'
else
if (iverbose >= 1) print*
if (isink < 10) then
print "(a,i1,a)",' :: CENTREING ON SINK ',isink,' from --sink flag'
else
Expand All @@ -163,6 +163,17 @@ subroutine adjust_data_codeunits
' corresponding to sink particles'
endif
endif

!
!--environment variable to recentre each file on a given origin
! This will not produce the intended results if any other shifting has occurred
if (have_origin) then
if (iverbose >= 1) print "(a,3(1x,es10.3))",' :: manual origin =',xyz_origin(1:3,ndim)
do j=1,nstepsinfile(ifileopen)
call shift_positions(dat(:,:,j),ntot,ndim,xyz_origin(1:3,ifileopen))
enddo
endif

!
!--center on a particular particle
!
Expand Down
42 changes: 39 additions & 3 deletions src/globaldata.f90
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ end module particle_data
module filenames
implicit none
integer, parameter :: maxfile = 10001
integer :: nfiles,nsteps,ifileopen,iposopen
integer :: nfiles,nsteps,ifileopen,iposopen,i,io
real :: xyz_origin(3,maxfile)
character(len=120), dimension(maxfile) :: rootname
character(len=100) :: fileprefix
character(len=120) :: defaultsfile,limitsfile,unitsfile,coloursfile
integer, dimension(maxfile) :: nstepsinfile
character(len=120) :: defaultsfile,limitsfile,unitsfile,coloursfile,originfile,sinkposfile
integer, dimension(maxfile) :: nstepsinfile,isinkid
logical :: have_origin,have_sinkpos
character(len=*), parameter :: tagline = &
'SPLASH: A visualisation tool for SPH data (c)2004-2022 Daniel Price and contributors'

Expand All @@ -113,6 +115,7 @@ module filenames

subroutine set_filenames(prefix)
character(len=*), intent(in) :: prefix
logical :: fexists

fileprefix = trim(adjustl(prefix))
if (fileprefix(len_trim(fileprefix):len_trim(fileprefix))=='.') then
Expand All @@ -122,6 +125,39 @@ subroutine set_filenames(prefix)
limitsfile = trim(adjustl(fileprefix))//'.limits'
unitsfile = trim(adjustl(fileprefix))//'.units'
coloursfile = trim(adjustl(fileprefix))//'.colours'
originfile = trim(adjustl(fileprefix))//'.origin'
sinkposfile = trim(adjustl(fileprefix))//'.sinkpos'

inquire(file=originfile,exist=fexists)
xyz_origin = 0.
have_origin = .false.
if (fexists) then
print*, 'Reading in ',trim(originfile)
print*, 'WARNING: this will not provided the desired result if other shifting applied'
print*, 'WARNING: This method has not yet been fully tested'
have_origin = .true.
open(unit=1701,file=originfile)
io = 0
i = 1
do while (io==0)
read(1701,*,iostat=io) xyz_origin(:,i)
i = i + 1
enddo
endif
inquire(file=sinkposfile,exist=fexists)
isinkid = 0
have_sinkpos = .false.
if (fexists) then
print*, 'Reading in ',trim(sinkposfile)
have_sinkpos = .true.
open(unit=1701,file=sinkposfile)
io = 0
i = 1
do while (io==0)
read(1701,*,iostat=io) isinkid(i)
i = i + 1
enddo
endif

return
end subroutine set_filenames
Expand Down
8 changes: 4 additions & 4 deletions src/shapes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,10 @@ subroutine add_shape(istart,iend,nshape)
shape(ishape)%ylen = shape(ishape)%xlen
poslabel = ' centre'
case(ishape_rectangle) ! rectangle
call prompt('enter x position of left edge (in '//trim(labelunits(iunits))//')',shape(ishape)%xpos,0.)
call prompt('enter x position of right edge (in '//trim(labelunits(iunits))//')',shape(ishape)%xlen,0.)
call prompt('enter y position of bottom edge (in '//trim(labelunits(iunits))//')',shape(ishape)%ypos,0.)
call prompt('enter y position of top edge (in '//trim(labelunits(iunits))//')',shape(ishape)%ylen,0.)
call prompt('enter x position of left edge (in '//trim(labelunits(iunits))//')',shape(ishape)%xpos)
call prompt('enter x position of right edge (in '//trim(labelunits(iunits))//')',shape(ishape)%xlen)
call prompt('enter y position of bottom edge (in '//trim(labelunits(iunits))//')',shape(ishape)%ypos)
call prompt('enter y position of top edge (in '//trim(labelunits(iunits))//')',shape(ishape)%ylen)
poslabel = ''
case(ishape_arrow) ! arrow
call prompt('enter starting x position (in '//trim(labelunits(iunits))//') ',shape(ishape)%xpos)
Expand Down