Skip to content
Snippets Groups Projects
Commit 39740c15 authored by Yannick Bahé's avatar Yannick Bahé Committed by Matthieu Schaller
Browse files

Fix bug in multiple BH mergers

parent 26c1d7b4
No related branches found
No related tags found
No related merge requests found
......@@ -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 */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment