This PR adds two new lines to the restart parameter file that lists the kind and label of particle types in the simulation. These values are read but not stored upon restart because they are calculated on the fly. This change is motivated primarily to make particle data access easier in yt. Example:
I am not married to doing it this way (introducing the new global array GlobalActiveParticlesTypeCount), but this seemed the most straightforward.
I should have added that this is different from AppendActiveParticleType is that PresentParticleTypes lists what types are actually is being written to disk, while the former lists what is * eligible* for creation.
Changes in response to Matt's very useful comments.
After thinking about this for a couple days, I agreed with Nathan's earlier comments that calling ActiveParticleFindAll would be unnecessarily expensive. Therefore I have vastly modified how I'm doing things. Instead of a global active particle type count array, I've added ActiveParticleTypeCount attached to each grid, and modified the grid hierarchy text file accordingly. Right now this array is only updated whenever CommunicationSyncNumberOfParticles is called (so that makes an effective global type count possible if needed), which is sufficient for the current purpose of writing the information to disk. It would not be terribly difficult to add hooks to particle creation/destruction/movement so that the array stays synched more often. Here's what the particle lines in a new grid entry look like:
This is great! Thanks for thinking through this Stephen.
I think this will work in general but it's not clear that CommunicationSyncNumberOfParticles will necessarily be called in serial or statically refined runs. I'll do some quick tests to check and will update later.