Skip to content

Particle deregistration

due to recent events I have started to feel a need for proper particle deregistration, i.e. an interface that allows you to do something to a particle (and possibly the entire simulation) whenever (a) particle[s] get(s) deleted.

Originally I thought one should put a callback hook in flushdeletions! but I didn't like the idea of callback hooks outside the evolve loop.

While thinking about which bits of InPartS deserve special focus in my thesis I realized that the obvious solution is to extend the registrar API to add a deregistration call (probably deregister!([registrar], dynamic_state, particles) or similar). This means that we could do things like storing removal events etc. directly from the registrar, analogous to particle creation events

Things I haven't worked out yet (and that I'm not likely to within the next three months):

  • this is not quite symmetric because additions are dealt with individually, particle-by-particle, while deletions are dealt with in bulk when flushing. this could be changed by initializing particles with dummy IDs and only letting the registrar deal with them in flushadditions!, but that makes other things more difficult (passing custom payload on addition)
  • similarly, this structure there is no good way to pass custom payload on removal. One could argue that in our current models this isn't a problem because removal is usually either very local (i.e. related to the particle state or the simulation state in a neighbourhood of the particle, which are both accessible by just passing the dynamic state) or completely random (also accessible from dynamic state). But that argument is stupid — In theory you can infer the parent of another cell if you just save the entire simulation state before it is born but we don't do that for very good reasons
  • maybe this could be resolved by passing small custom payloads through the addition and deletion buffer (e.g. give addparticle! and rmparticle! a metadata field). But this could easily explode into something too general again

I'm always interested in your feedback and comments, especially as some of you have to get used to think more about keeping this steaming hot pile of garbage alive given that my days here are numbered.