Skip to content
Snippets Groups Projects
Commit c465fd84 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Improve the logic in the BH sub-task recursion to make sure we also recurse if...

Improve the logic in the BH sub-task recursion to make sure we also recurse if there is no gas in the cell as we need the recursion for the BH-BH merger detection.
parent 160e3ac9
Branches
Tags
No related merge requests found
...@@ -391,10 +391,8 @@ void DOPAIR1_BH_NAIVE(struct runner *r, struct cell *restrict ci, ...@@ -391,10 +391,8 @@ void DOPAIR1_BH_NAIVE(struct runner *r, struct cell *restrict ci,
const int do_cj_bh = 1; const int do_cj_bh = 1;
#endif #endif
if (do_ci_bh && ci->black_holes.count != 0 && cj->hydro.count != 0) if (do_ci_bh) DO_NONSYM_PAIR1_BH_NAIVE(r, ci, cj);
DO_NONSYM_PAIR1_BH_NAIVE(r, ci, cj); if (do_cj_bh) DO_NONSYM_PAIR1_BH_NAIVE(r, cj, ci);
if (do_cj_bh && cj->black_holes.count != 0 && ci->hydro.count != 0)
DO_NONSYM_PAIR1_BH_NAIVE(r, cj, ci);
TIMER_TOC(TIMER_DOPAIR_BH); TIMER_TOC(TIMER_DOPAIR_BH);
} }
...@@ -789,11 +787,24 @@ void DOSUB_PAIR1_BH(struct runner *r, struct cell *ci, struct cell *cj, ...@@ -789,11 +787,24 @@ void DOSUB_PAIR1_BH(struct runner *r, struct cell *ci, struct cell *cj,
struct space *s = r->e->s; struct space *s = r->e->s;
const struct engine *e = r->e; const struct engine *e = r->e;
/* Should we even bother? */ /* Should we even bother?
* In the swallow case we care about BH-BH and BH-gas
* interactions.
* In all other cases only BH-gas so we can abort if there is
* is no gas in the cell */
#if (FUNCTION_TASK_LOOP == TASK_LOOP_SWALLOW)
const int should_do_ci =
ci->black_holes.count != 0 && cell_is_active_black_holes(ci, e);
const int should_do_cj =
cj->black_holes.count != 0 && cell_is_active_black_holes(cj, e);
#else
const int should_do_ci = ci->black_holes.count != 0 && cj->hydro.count != 0 && const int should_do_ci = ci->black_holes.count != 0 && cj->hydro.count != 0 &&
cell_is_active_black_holes(ci, e); cell_is_active_black_holes(ci, e);
const int should_do_cj = cj->black_holes.count != 0 && ci->hydro.count != 0 && const int should_do_cj = cj->black_holes.count != 0 && ci->hydro.count != 0 &&
cell_is_active_black_holes(cj, e); cell_is_active_black_holes(cj, e);
#endif
if (!should_do_ci && !should_do_cj) return; if (!should_do_ci && !should_do_cj) return;
/* Get the type of pair and flip ci/cj if needed. */ /* Get the type of pair and flip ci/cj if needed. */
...@@ -819,17 +830,18 @@ void DOSUB_PAIR1_BH(struct runner *r, struct cell *ci, struct cell *cj, ...@@ -819,17 +830,18 @@ void DOSUB_PAIR1_BH(struct runner *r, struct cell *ci, struct cell *cj,
const int do_ci_bh = ci->nodeID == e->nodeID; const int do_ci_bh = ci->nodeID == e->nodeID;
const int do_cj_bh = cj->nodeID == e->nodeID; const int do_cj_bh = cj->nodeID == e->nodeID;
#elif (FUNCTION_TASK_LOOP == TASK_LOOP_FEEDBACK) #elif (FUNCTION_TASK_LOOP == TASK_LOOP_FEEDBACK)
/* here we are updating the hydro -> switch ci, cj */ /* Here we are updating the hydro -> switch ci, cj */
const int do_ci_bh = cj->nodeID == e->nodeID; const int do_ci_bh = cj->nodeID == e->nodeID;
const int do_cj_bh = ci->nodeID == e->nodeID; const int do_cj_bh = ci->nodeID == e->nodeID;
#else #else
/* Here we perform the task on both sides */
const int do_ci_bh = 1; const int do_ci_bh = 1;
const int do_cj_bh = 1; const int do_cj_bh = 1;
#endif #endif
const int do_ci = ci->black_holes.count != 0 && cj->hydro.count != 0 && const int do_ci = ci->black_holes.count != 0 &&
cell_is_active_black_holes(ci, e) && do_ci_bh; cell_is_active_black_holes(ci, e) && do_ci_bh;
const int do_cj = cj->black_holes.count != 0 && ci->hydro.count != 0 && const int do_cj = cj->black_holes.count != 0 &&
cell_is_active_black_holes(cj, e) && do_cj_bh; cell_is_active_black_holes(cj, e) && do_cj_bh;
if (do_ci) { if (do_ci) {
...@@ -838,14 +850,14 @@ void DOSUB_PAIR1_BH(struct runner *r, struct cell *ci, struct cell *cj, ...@@ -838,14 +850,14 @@ void DOSUB_PAIR1_BH(struct runner *r, struct cell *ci, struct cell *cj,
if (!cell_are_bpart_drifted(ci, e)) if (!cell_are_bpart_drifted(ci, e))
error("Interacting undrifted cells (bparts)."); error("Interacting undrifted cells (bparts).");
if (!cell_are_part_drifted(cj, e)) if (cj->hydro.count != 0 && !cell_are_part_drifted(cj, e))
error("Interacting undrifted cells (parts)."); error("Interacting undrifted cells (parts).");
} }
if (do_cj) { if (do_cj) {
/* Make sure both cells are drifted to the current timestep. */ /* Make sure both cells are drifted to the current timestep. */
if (!cell_are_part_drifted(ci, e)) if (ci->hydro.count != 0 && !cell_are_part_drifted(ci, e))
error("Interacting undrifted cells (parts)."); error("Interacting undrifted cells (parts).");
if (!cell_are_bpart_drifted(cj, e)) if (!cell_are_bpart_drifted(cj, e))
...@@ -869,15 +881,27 @@ void DOSUB_SELF1_BH(struct runner *r, struct cell *ci, int gettimer) { ...@@ -869,15 +881,27 @@ void DOSUB_SELF1_BH(struct runner *r, struct cell *ci, int gettimer) {
TIMER_TIC; TIMER_TIC;
const struct engine *e = r->e;
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (ci->nodeID != engine_rank) if (ci->nodeID != engine_rank)
error("This function should not be called on foreign cells"); error("This function should not be called on foreign cells");
#endif #endif
/* Should we even bother? */ /* Should we even bother?
if (ci->hydro.count == 0 || ci->black_holes.count == 0 || * In the swallow case we care about BH-BH and BH-gas
!cell_is_active_black_holes(ci, r->e)) * interactions.
return; * In all other cases only BH-gas so we can abort if there is
* is no gas in the cell */
#if (FUNCTION_TASK_LOOP == TASK_LOOP_SWALLOW)
const int should_do_ci =
ci->black_holes.count != 0 && cell_is_active_black_holes(ci, e);
#else
const int should_do_ci = ci->black_holes.count != 0 && ci->hydro.count != 0 &&
cell_is_active_black_holes(ci, e);
#endif
if (!should_do_ci) return;
/* Recurse? */ /* Recurse? */
if (cell_can_recurse_in_self_black_holes_task(ci)) { if (cell_can_recurse_in_self_black_holes_task(ci)) {
...@@ -895,8 +919,11 @@ void DOSUB_SELF1_BH(struct runner *r, struct cell *ci, int gettimer) { ...@@ -895,8 +919,11 @@ void DOSUB_SELF1_BH(struct runner *r, struct cell *ci, int gettimer) {
/* Otherwise, compute self-interaction. */ /* Otherwise, compute self-interaction. */
else { else {
/* Drift the cell to the current timestep if needed. */ /* Check we did drift to the current time */
if (!cell_are_bpart_drifted(ci, r->e)) error("Interacting undrifted cell."); if (!cell_are_bpart_drifted(ci, e)) error("Interacting undrifted cell.");
if (ci->hydro.count != 0 && !cell_are_part_drifted(ci, e))
error("Interacting undrifted cells (bparts).");
DOSELF1_BRANCH_BH(r, ci); DOSELF1_BRANCH_BH(r, ci);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment