Output dataset VELOCIraptorGroupIDs is wrong when running Velociraptor on the fly
If Swift is compiled with Velociraptor support and we have Snapshots:invoke_stf=1 in the input file, then the output snapshots contain a dataset which should specify which Velociraptor group each particle belongs to. This dataset appears to be incorrect with the current master versions of Swift and Velociraptor.
For example, using the EAGLE_DMO_low_z 12Mpc box and plotting particles by assigning a random colour to each velociraptor group index:
At least part of the problem is in velociraptor_convert_particles_mapper() where the array of struct swift_vel_part is populated. The index field is incorrect because it gets set to the index of the particle relative to the subset being processed by this invocation of the mapper function. I think the line
swift_parts[i].index = i;
should be something like
const ptrdiff_t index_offset = gparts - s->gparts;
...
swift_parts[i].index = i + index_offset;
This results in far more of the particles getting assigned a group index, but it's still clearly wrong:
For comparison, here's how it looks if I discard the VELOCIraptorGroupIDs dataset from the snapshot and compute group membership from the velociraptor output files: