[FLASH-USERS] Sink particles question. Get particle info from sink tag.

Joshua Wall joshua.e.wall at gmail.com
Thu Apr 2 09:17:18 EDT 2015


Juan,

    It sounds like you want to get information from a particle knowing the
tag. For that you can use the QSort subroutines after a call to
pt_sinkGatherGlobal() to sort by particles by tag, then call the particles
using the index array returned by QSort. If you want to then change any
information you can do this, then loop over the sinks up to localnp on each
processor because the particles_global() array on each processor lists the
local particles in the first localnp positions in the array.

    You can also use this sequence of steps to make the calls by tags. I've
written a small set of functions as getters and setters for position,
velocity and mass for sinks in FLASH. As an example to get particle
positions by tag number I wrote the following:

###############################################################################################################

FUNCTION get_particle_position_array(tags, x, y, z, nparts)
  implicit none
  integer :: nparts, MyPe
  double precision, dimension(nparts) :: x, y, z, tags
  integer :: get_particle_position_array, i, j, p
  integer, dimension(:), allocatable :: QSindex, id_sorted

call Driver_getMype(GLOBAL_COMM, MyPe)
call pt_sinkGatherGlobal()

! I only need one proc to do this.

if (MyPe .eq. 0) then

  ! Sort by particle tag. Note that output positions will also be
  ! ordered by tag number then.

  allocate(QSindex(localnpf))
  allocate(id_sorted(localnpf))

  do p = 1, localnpf
     id_sorted(p) = int(particles_global(TAG_PART_PROP,p))
  end do

  call NewQsort_IN(id_sorted, QSindex)

  ! Are we checking every particle in the simulation?

  if (nparts .eq. localnpf) then ! Yes, then lets do them all at once.

    do i=1, localnpf

      x(i) = particles_global(POSX_PART_PROP, QSindex(i))
      y(i) = particles_global(POSY_PART_PROP, QSindex(i))
      z(i) = particles_global(POSZ_PART_PROP, QSindex(i))

    end do

  else

  ! If not doing them all, have to do it by tag number.

      do i=1, localnpf

        do j=1, nparts

          if (id_sorted(QSindex(i)) .eq. tags(j)) then ! Check for matching
tag.

            x(j) = particles_global(POSX_PART_PROP, QSindex(i))
            y(j) = particles_global(POSY_PART_PROP, QSindex(i))
            z(j) = particles_global(POSZ_PART_PROP, QSindex(i))

          end if

        end do

    end do

  end if

  deallocate(QSindex)
  deallocate(id_sorted)

end if

get_particle_position_array=0
END FUNCTION

##############################################################################################################

For the example that inspired my functions also take a look at the
Particles_sinkAccelGasOnSinks() subroutine which uses this type of sorting
to write information to the sink particle arrays in parallel.

Hope that helps!

Josh


On Thu, Apr 2, 2015 at 12:02 AM Juan Camilo Ibañez Mejia <
jcibanezmejia at gmail.com> wrote:

> Hi all,
>
> is there a simple way to get the information in a sink particle knowing
> the particle tag ?
> Like using the particles_global array ? something like :
>
>         > blockID = particles_global( BLK_PART_PROP, SinkTag )
>
> The problem here is that the second input is the particle position in the
> global array,
> not the particle tag so of course this doesn’t work.
>
> I need this because at some point one processor, hosting a sink particle,
> informs the
> sink tag to all other processors. Then each processor needs to look for
> the position,
> velocity, mass and blockID of the sink.
>
> Thanks,
>
> Juan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://flash.rochester.edu/pipermail/flash-users/attachments/20150402/72f37e11/attachment.htm>


More information about the flash-users mailing list