diff --git a/src/adjust_data.f90 b/src/adjust_data.f90 index 71ce6512..3075989f 100644 --- a/src/adjust_data.f90 +++ b/src/adjust_data.f90 @@ -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 @@ -140,6 +140,7 @@ 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) @@ -147,7 +148,6 @@ subroutine adjust_data_codeunits 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 @@ -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 ! diff --git a/src/globaldata.f90 b/src/globaldata.f90 index 034b797a..ed21cd5d 100644 --- a/src/globaldata.f90 +++ b/src/globaldata.f90 @@ -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' @@ -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 @@ -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 diff --git a/src/shapes.f90 b/src/shapes.f90 index 640dc1fe..211f9392 100644 --- a/src/shapes.f90 +++ b/src/shapes.f90 @@ -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)