modifying the particle list on multiple processors

From: Mark Baumann <>
Date: Tue, 8 Mar 2011 10:43:47 -0600 (CST)


Like others I am implementing sink particles in Gadget. Thanks to
previous discussions on this list I believe I have sink particles working
on a single process. Here is my approach:

All "STAR" particles are considered sink particles
All "GAS" particles are absorbed by sink particles when they come within a
predefined distance of a STAR particle.

I've added a method called sink_particle() that is called from the main
loop before domain_Decomposition(). The sink_particle()
method does the following:

loop through all particles (i in the range 0..NumPart) on the local
processor and find the STAR particles

for each STAR particle found:
         loop through all Gas particles (i in the range 0..N_gas) on the
                 local processor
         if Gas particle i is within predefined distance of STAR particle,
                 flag it by setting its particle type to -1 and increment
                 the variable "numcoll"

if numcoll > 0:
         create a new particle array with size MaxPart
         create a new SPH array with size MaxPartSph
         copy all particles of type -1 into the new particle array and the
                 new SPH array
         delete the old particle array and the old SPH array
         update particle counts as follows:
                 NumPart -= numcoll
                 N_gas -= numcoll
                 All.TotNumPart -= numcoll
                 All.TotN_gas -= numcoll
         force a new domain decomposition by setting

Then, in the routine gravity_tree(), before anything else is done I update
the value of NumForceUpdate in the way Volker Springel suggested.

First, this seems to work but does anyone see any potential problems?

And second, how would I make this work on multiple processors?

In particular, I am still unclear on how particles are managed across
multiple processors, so here are a few thoughts:

When I delete a particle on the local processor, do I need to update
particle arrays on other processors, or is it sufficient to simply
decrement the All.TotNumPart and All.TotNgas counts by the appropriate

Would I need to check for "collisions" between a STAR particle on the
local processor and GAS particles on other processors, or is it impossible
for such a thing to happen? And conversely, do I need to check for
collisions between a GAS particle on the local processor and STAR
particles on the other processors?

Thank you for your insights!


Received on 2011-03-08 18:05:04

This archive was generated by hypermail 2.3.0 : 2023-01-10 10:01:31 CET