diff --git a/src/runner.c b/src/runner.c index 521914bfdecb18f6c5e4e0a55ec2f0e759424797..4c499af2186eec9dbf026b27757ff0d719a94182 100644 --- a/src/runner.c +++ b/src/runner.c @@ -1350,7 +1350,13 @@ void runner_do_end_force(struct runner *r, struct cell *c, int timer) { /* Get a handle on the part. */ struct part *restrict p = &parts[k]; - if (part_is_active(p, e)) hydro_end_force(p); + + if (part_is_active(p, e)) { + + /* First, finish the force loop */ + hydro_end_force(p); + if (p->gpart != NULL) gravity_end_force(p->gpart, const_G); + } } /* Loop over the g-particles in this cell. */ @@ -1358,7 +1364,12 @@ void runner_do_end_force(struct runner *r, struct cell *c, int timer) { /* Get a handle on the gpart. */ struct gpart *restrict gp = &gparts[k]; - if (gpart_is_active(gp, e)) gravity_end_force(gp, const_G); + + if (gp->type == swift_type_dark_matter) { + + if (gpart_is_active(gp, e)) gravity_end_force(gp, const_G); + + } #ifdef SWIFT_DEBUG_CHECKS if (e->policy & engine_policy_self_gravity) { @@ -1377,7 +1388,12 @@ void runner_do_end_force(struct runner *r, struct cell *c, int timer) { /* Get a handle on the spart. */ struct spart *restrict sp = &sparts[k]; - if (spart_is_active(sp, e)) star_end_force(sp); + if (spart_is_active(sp, e)) { + + /* First, finish the force loop */ + star_end_force(sp); + gravity_end_force(sp->gpart, const_G); + } } }