diff --git a/src/runner_black_holes.c b/src/runner_black_holes.c index 354b01e2e00fc0985a25bc958c0ec13af929f5b4..32301896f737f9cc3ce4600c58bfd8f506f7757f 100644 --- a/src/runner_black_holes.c +++ b/src/runner_black_holes.c @@ -306,9 +306,10 @@ void runner_do_bh_swallow(struct runner *r, struct cell *c, int timer) { } } else { - /* Loop over all the gas particles in the cell + /* Loop over all the BH particles in the cell * Note that the cell (and hence the bparts) may be local or foreign. */ const size_t nr_cell_bparts = c->black_holes.count; + for (size_t k = 0; k < nr_cell_bparts; k++) { /* Get a handle on the part. */ @@ -317,7 +318,7 @@ void runner_do_bh_swallow(struct runner *r, struct cell *c, int timer) { /* Ignore inhibited particles (they have already been removed!) */ if (bpart_is_inhibited(cell_bp, e)) continue; - /* Get the ID of the black holes that will swallow this part */ + /* Get the ID of the black holes that will swallow this bpart */ const long long swallow_id = black_holes_get_bpart_swallow_id(&cell_bp->merger_data); @@ -350,7 +351,21 @@ void runner_do_bh_swallow(struct runner *r, struct cell *c, int timer) { */ lock_lock(&s->lock); - /* Swallow the gas particle (i.e. update the BH properties) */ + /* If bpart is inhibited, it cannot do any swallowing */ + if (bpart_is_inhibited(bp, e)) { + message("BH %lld inhibited -- DOES NOT swallow BH %lld", bp->id, + cell_bp->id); + + /* Pretend it was found */ + found = 1; + + if (lock_unlock(&s->lock) != 0) + error("Failed to unlock the space."); + break; + } + + /* Swallow the BH particle (i.e. update the swallowing BH + * properties with the properties of cell_bp) */ black_holes_swallow_bpart(bp, cell_bp, e->cosmology, e->time, with_cosmology, props); @@ -360,12 +375,12 @@ void runner_do_bh_swallow(struct runner *r, struct cell *c, int timer) { message("BH %lld swallowing BH particle %lld", bp->id, cell_bp->id); - /* If the gas particle is local, remove it */ + /* If the BH particle is local, remove it */ if (c->nodeID == e->nodeID) { message("BH %lld removing BH particle %lld", bp->id, cell_bp->id); - /* Finally, remove the gas particle from the system + /* Finally, remove the BH particle from the system * Recall that the gpart associated with it is also removed * at the same time. */ cell_remove_bpart(e, c, cell_bp); @@ -414,6 +429,7 @@ void runner_do_bh_swallow(struct runner *r, struct cell *c, int timer) { error("BH particle %lld could not find BH %lld to be swallowed", cell_bp->id, swallow_id); } + } /* Part was flagged for swallowing */ } /* Loop over the parts */ } /* Cell is not split */