From 060e10cf181456db5466d7e03cff27d5e98afd59 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Wed, 6 Mar 2019 14:17:34 +0000 Subject: [PATCH 1/3] Use the density getter for the gas in the default feedback task. --- src/stars/Default/stars_iact.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stars/Default/stars_iact.h b/src/stars/Default/stars_iact.h index cbf3065f1..0a9fa7f79 100644 --- a/src/stars/Default/stars_iact.h +++ b/src/stars/Default/stars_iact.h @@ -81,7 +81,7 @@ runner_iact_nonsym_stars_feedback(float r2, const float *dx, float hi, float hj, struct part *restrict pj, float a, float H) { const float mj = hydro_get_mass(pj); - const float rhoj = pj->rho; + const float rhoj = hydro_get_comoving_density(pj); const float r = sqrtf(r2); const float ri = 1.f / r; -- GitLab From 0e1a000f27e73d6348ea8a6d694c4c9f49fe1add Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Wed, 6 Mar 2019 16:03:50 +0000 Subject: [PATCH 2/3] Only set a common super-cell pointer if we are running with the policy corresponding the to the hydro/grav pointer we are looing for. --- src/cell.c | 23 +++++++++++++++-------- src/cell.h | 1 - 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/cell.c b/src/cell.c index af4edc6a9..9fd32ed8c 100644 --- a/src/cell.c +++ b/src/cell.c @@ -3596,11 +3596,15 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) { * * @param c The top-level #cell to play with. * @param super Pointer to the deepest cell with tasks in this part of the tree. + * @param with_hydro Are we running with hydrodynamics on? + * @param with_grav Are we running with gravity on? */ -void cell_set_super(struct cell *c, struct cell *super) { +void cell_set_super(struct cell *c, struct cell *super, const int with_hydro, + const int with_grav) { /* Are we in a cell which is either the hydro or gravity super? */ - if (super == NULL && (c->hydro.super != NULL || c->grav.super != NULL)) + if (super == NULL && ((with_hydro && c->hydro.super != NULL) || + (with_grav && c->grav.super != NULL))) super = c; /* Set the super-cell */ @@ -3609,7 +3613,8 @@ void cell_set_super(struct cell *c, struct cell *super) { /* Recurse */ if (c->split) for (int k = 0; k < 8; k++) - if (c->progeny[k] != NULL) cell_set_super(c->progeny[k], super); + if (c->progeny[k] != NULL) + cell_set_super(c->progeny[k], super, with_hydro, with_grav); } /** @@ -3668,6 +3673,10 @@ void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data) { const struct engine *e = (const struct engine *)extra_data; + const int with_hydro = (e->policy & engine_policy_hydro); + const int with_grav = (e->policy & engine_policy_self_gravity) || + (e->policy & engine_policy_external_gravity); + for (int ind = 0; ind < num_elements; ind++) { struct cell *c = &((struct cell *)map_data)[ind]; @@ -3677,15 +3686,13 @@ void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data) { #endif /* Super-pointer for hydro */ - if (e->policy & engine_policy_hydro) cell_set_super_hydro(c, NULL); + if (with_hydro) cell_set_super_hydro(c, NULL); /* Super-pointer for gravity */ - if ((e->policy & engine_policy_self_gravity) || - (e->policy & engine_policy_external_gravity)) - cell_set_super_gravity(c, NULL); + if (with_grav) cell_set_super_gravity(c, NULL); /* Super-pointer for common operations */ - cell_set_super(c, NULL); + cell_set_super(c, NULL, with_hydro, with_grav); } } diff --git a/src/cell.h b/src/cell.h index b13889abd..baae12e4a 100644 --- a/src/cell.h +++ b/src/cell.h @@ -747,7 +747,6 @@ void cell_reset_task_counters(struct cell *c); int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s); int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s); int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s); -void cell_set_super(struct cell *c, struct cell *super); void cell_drift_part(struct cell *c, const struct engine *e, int force); void cell_drift_gpart(struct cell *c, const struct engine *e, int force); void cell_drift_spart(struct cell *c, const struct engine *e, int force); -- GitLab From d16f58cb3e2d16addc0e266fca52b76f8fe05848 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Thu, 7 Mar 2019 18:20:01 +0100 Subject: [PATCH 3/3] Correct the condition to escape the creation of hydro tasks in the absence of feedabck in the make_hydroloop() function. --- src/engine_maketasks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine_maketasks.c b/src/engine_maketasks.c index 6340cb17e..d1858f87f 100644 --- a/src/engine_maketasks.c +++ b/src/engine_maketasks.c @@ -2066,7 +2066,7 @@ void engine_make_hydroloop_tasks_mapper(void *map_data, int num_elements, struct cell *ci = &cells[cid]; /* Skip cells without hydro or star particles */ - if ((ci->hydro.count == 0) && (with_feedback && ci->stars.count == 0)) + if ((ci->hydro.count == 0) && (!with_feedback || ci->stars.count == 0)) continue; /* If the cell is local build a self-interaction */ @@ -2096,7 +2096,7 @@ void engine_make_hydroloop_tasks_mapper(void *map_data, int num_elements, /* Is that neighbour local and does it have gas or star particles ? */ if ((cid >= cjd) || ((cj->hydro.count == 0) && - (with_feedback && cj->stars.count == 0)) || + (!with_feedback || cj->stars.count == 0)) || (ci->nodeID != nodeID && cj->nodeID != nodeID)) continue; -- GitLab