Skip to content

Draft: Upgrade to FOF to treat some types differently

Matthieu Schaller requested to merge fof_attach_gas into master

Some important changes to the FOF algorithm.

We create two kinds of particles: linkable and attachable:

  • The linkable ones behave as before. They build groups with each other.
  • The attachable ones can only be linked to a linkable. (i.e. no attach-to-attach links allowed). They can't be root. They attach to the nearest linkable.

The two categories are specified at runtime in the parameter file.

The use case is to run FOF on the DM only and then attach the gas/stars/BHs to the nearest DM particle they find. With some minor caveats this is what other FOF codes do.

The strategy I used is as follows:

  1. Create masks based on particle types for the two categories
  2. Create an array of "distance to the nearest linkable" initialised to FLT_MAX
  3. Create an array of "original group_index" initialised to the base group index of each particle (i.e. itself)
  4. When finding a pair < l we act differently based on the types
  5. If two linkable --> Do as before
  6. If two attachable --> abort
  7. If one attachable and one linkable, check whether the distance is shorter than the recorded min dist for this particle.
  8. If it is, restore the group index of the attachable to the original, update the min dist array and perform a modified fof_union
  9. The modified fof_union is similar to the basic one but, crucially, does not make the smallest group_index the root. It maintains the linkable (or its own root) as the root irrespective of group_index. This way the attachable is never a root and always "dangling" at the end of a tree and can thus be updated easily if we find an even nearer linkable later.

Still to do:

  • Extend the mechanism to MPI (need a brain wave here...)
  • Write a python script that verifies the process was indeed performed correctly.
Edited by Matthieu Schaller

Merge request reports