Skip to content

Add star particles on-the-fly

Matthieu Schaller requested to merge add_particles into master

@pdraper @nnrw56 I'll open a proper merge request for this later on but I am stuck with a weird mistake.

The strategy is as follows:

  • In each top-level cell, at rebuild time, allocate more memory in order to have some spares.
  • In a new task, decide whether a given part should become a `spart.
  • If this happens, discard the part (i.e. make it inhibited as already works)
  • Create a new spart and attach it to the gpart-friend of the now-removed part.

The creation of the spart is done by shifting all the spart in that top-level cell ahead of the current leaf-cell by one slot. We also update the counters and pointers.
This is all done in cell_add_spart() and the shift is currently performed by an expensive memmove() but I am hoping to change this to a few swaps of particles in the future.

The issue I am facing is that the current code runs smoothly the EAGLE_6 and EAGLE_12 examples. However, it does segfault when running the EAGLE-25 case after 3 steps when creating a star. The annoying aspect is that it does not segfault when running through the debugger nor does the memory sanitizer report anything.

So I am currently stuck here. Could you see something obvious that I am doing wrong here with my memory transactions?

Edited by Matthieu Schaller

Merge request reports