Tidal tensors
Some weekend thoughts on the tidal tensor (TT) calculations that I may end up not liking in the end...
Context: We worry that the tidal tensor calculation in @dc-pfef1 and @rcrain's globular cluster model is too memory intensive as every particle carries the values, including all the DM particles (x4 in COLIBRE).
My understanding is that the model only needs the tensors for the stars.
This means, that we could potentially store that information in the spart
only.
A lot of (all of?) the gravity calculation is done using local caches for the variables we need as it makes a lot of the operation much more CPU-cache-friendly and as branch-free as possible.
We could hence compute the tidal tensor as is now done in the COLBRE branch, but, crucially, modify the cache write-back function to write these fields back to the spart
and not to the gpart
and only do this if the gpart
we play with is of the stellar kind.
We could then extend the mechanism to potentially carry these fields in any of the part
/spart
/bpart
/DM depending on the needs of a specific run.
If no particle wants at TT calculation then even the core calculation (loops in runner_do_iact_grav.c and multipoles.h) do nothing, as is the case now for the potential.
For the COLIBRE-GC case, we would still pay for the slowdown due to the TT calculation but not pay the memory bill any more. The cache write-back function will likely be slower however, as it will need to act on two separate arrays via pointer hoping.