Draft: Merge the moving mesh hydro scheme in master

Yolan Uyttenhove requested to merge moving_mesh into master


This adds a moving-mesh hydro scheme to SWIFT. To use it, SWIFT must be compiled with the option --with-hydro=shadowswift and run with --hydro. Most hydro-test work out of the box, but might need tweaking for optimal performance (see caveats).

The scheme uses a drift -> geometry -> flux -> kick2 -> gradient -> timestep -> kick1 structure for it's time-step:

  • Grid construction is carried out as a self task with implicit grid-sync pair tasks ensuring the necessary synchronization with the neighboring cells whose particles are read during construction.
  • Flux exchange is always carried out by ordinary self and pair tasks since it must be done on the construction level in the tree (we need the Voronoi faces). Flux exchange is also manifestly conservative/symmetric and therefore pair tasks must be handled on both MPI nodes if necessary.
  • For the gradient interaction, I have switched to a meshless WLS gradient scheme, meaning that the gradient calculation is a "normal" hydro loop which can be carried out by self, pair, subself and subpair interactions on any desired level, independent of the grid construction. Alternatively, the older WLS gradient computation which uses the Voronoi cells is also available and that method uses the same task structure of the flux interaction loop.
  • The limiter interaction follows the same structure as the gradient loop. Meaning that it will be an ordinary hydro loop when the meshless gradients are used and a neighbour loop explicitely looping over the Voronoi faces else.


  • Running a hydro-test as-is, will introduce scatter in the densities, because each particle has it's own volume determined by it's Voronoi cell. Exact ICs can be computed by using the volumes saved in the first snapshot and the desired densities to compute the appropriate masses for the particles.
  • A vacuum must be explicitly represented by particles of 0 (or extremely low) density (e.g. in the Evrard collapse or Vacuum hydro tests). Exactly zero mass particles cause problems with gravity at the moment (e.g. cannot compute center of mass of cells containing only zero mass particles), but work fine in hydro only simulations.
  • The timestep limiter works in most cases, but might use a wrong timestep for the flux calculation in some rare cases (see also Issue #832).

Current status

This is an overview of what is/isn't working (yet):

  • Hydrodynamics (1D, 2D and 3D)
  • Cosmological time-integration
  • Zel'dovich pancake
  • Gravity
  • (Basic) cooling
  • Star formation/stellar feedback
  • Chemistry (See also issue #834)
  • Non periodic boundary conditions: reflective, vacuum, open and inflow boundary conditions
  • (Fixed) boundary particles
  • MPI support
  • Particle splitting/merging


  • Some functions are missing docstrings
  • Documentation on website
Edited by Yolan Uyttenhove

Merge request reports