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