From 92662f45971b89bbce4dcb79a20ed6f685800e3f Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Tue, 2 Apr 2019 17:45:36 +0200 Subject: [PATCH] Move the star-formation task to the top-level and not the super-level to avoid dependency problems. --- .../isolated_galaxy.yml | 2 +- src/cell.c | 2 +- src/cell.h | 3 ++ src/engine_maketasks.c | 29 ++++++++++++------- src/engine_marktasks.c | 2 +- src/runner.c | 8 +++++ src/space.c | 1 + src/task.c | 2 ++ src/task.h | 2 ++ tools/task_plots/analyse_tasks.py | 2 ++ tools/task_plots/plot_tasks.py | 2 ++ 11 files changed, 41 insertions(+), 14 deletions(-) diff --git a/examples/IsolatedGalaxy/IsolatedGalaxy_starformation/isolated_galaxy.yml b/examples/IsolatedGalaxy/IsolatedGalaxy_starformation/isolated_galaxy.yml index 7dac0a8a6c..341cae8a3f 100644 --- a/examples/IsolatedGalaxy/IsolatedGalaxy_starformation/isolated_galaxy.yml +++ b/examples/IsolatedGalaxy/IsolatedGalaxy_starformation/isolated_galaxy.yml @@ -35,7 +35,7 @@ Statistics: # Parameters related to the initial conditions InitialConditions: - file_name: fid.hdf5 # The file to read + file_name: lowres8.hdf5 # The file to read periodic: 0 # Are we running with periodic ICs? stars_smoothing_length: 0.5 diff --git a/src/cell.c b/src/cell.c index a6308faff6..fa6c972e7a 100644 --- a/src/cell.c +++ b/src/cell.c @@ -3223,7 +3223,7 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { if (c->logger != NULL) scheduler_activate(s, c->logger); if (c->hydro.star_formation != NULL) { - scheduler_activate(s, c->hydro.star_formation); + scheduler_activate(s, c->top->hydro.star_formation); cell_activate_drift_spart(c, s); } } diff --git a/src/cell.h b/src/cell.h index 4db2feeb0a..b0912d33f2 100644 --- a/src/cell.h +++ b/src/cell.h @@ -239,6 +239,9 @@ struct cell { /*! Parent cell. */ struct cell *parent; + /*! Pointer to the top-level cell in a hierarchy */ + struct cell *top; + /*! Super cell, i.e. the highest-level parent cell with *any* task */ struct cell *super; diff --git a/src/engine_maketasks.c b/src/engine_maketasks.c index 669b6353f2..a8dd38f5ff 100644 --- a/src/engine_maketasks.c +++ b/src/engine_maketasks.c @@ -608,6 +608,16 @@ void engine_make_hierarchical_tasks_common(struct engine *e, struct cell *c) { struct scheduler *s = &e->sched; const int with_limiter = (e->policy & engine_policy_limiter); + const int with_star_formation = (e->policy & engine_policy_star_formation); + + /* Are we at the top-level? */ + if (c->top == c && c->nodeID == e->nodeID) { + + if (with_star_formation && c->hydro.count > 0) { + c->hydro.star_formation = scheduler_addtask( + s, task_type_star_formation, task_subtype_none, 0, 0, c, NULL); + } + } /* Are we in a super-cell ? */ if (c->super == c) { @@ -634,6 +644,12 @@ void engine_make_hierarchical_tasks_common(struct engine *e, struct cell *c) { scheduler_addunlock(s, c->kick2, c->timestep); scheduler_addunlock(s, c->timestep, c->kick1); + /* Subgrid tasks: star formation */ + if (with_star_formation && c->hydro.count > 0) { + scheduler_addunlock(s, c->kick2, c->top->hydro.star_formation); + scheduler_addunlock(s, c->top->hydro.star_formation, c->timestep); + } + /* Time-step limiting */ if (with_limiter) { c->timestep_limiter = scheduler_addtask( @@ -868,16 +884,6 @@ void engine_make_hierarchical_tasks_hydro(struct engine *e, struct cell *c) { scheduler_addunlock(s, c->hydro.end_force, c->super->kick2); } - /* Subgrid tasks: star formation */ - if (with_star_formation) { - - c->hydro.star_formation = scheduler_addtask( - s, task_type_star_formation, task_subtype_none, 0, 0, c, NULL); - - scheduler_addunlock(s, c->super->kick2, c->hydro.star_formation); - scheduler_addunlock(s, c->hydro.star_formation, c->super->timestep); - } - /* Subgrid tasks: feedback */ if (with_feedback) { @@ -896,7 +902,8 @@ void engine_make_hierarchical_tasks_hydro(struct engine *e, struct cell *c) { scheduler_addunlock(s, c->stars.stars_out, c->super->timestep); if (with_star_formation) { - scheduler_addunlock(s, c->hydro.star_formation, c->stars.stars_in); + scheduler_addunlock(s, c->top->hydro.star_formation, + c->stars.stars_in); } } } diff --git a/src/engine_marktasks.c b/src/engine_marktasks.c index 277c956031..d2bd1719e2 100644 --- a/src/engine_marktasks.c +++ b/src/engine_marktasks.c @@ -665,7 +665,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, else if (t_type == task_type_star_formation) { if (cell_is_active_hydro(t->ci, e)) { scheduler_activate(s, t); - cell_activate_drift_spart(t->ci, s); + // cell_activate_drift_spart(t->ci, s); } } } diff --git a/src/runner.c b/src/runner.c index 299e274e87..1a07da1069 100644 --- a/src/runner.c +++ b/src/runner.c @@ -589,7 +589,13 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) { TIMER_TIC; +#ifdef SWIFT_DEBUG_CHECKS + if (c->nodeID != e->nodeID) + error("Running star formation task on a foreign node!"); +#endif + /* Anything to do here? */ + if (c->hydro.count == 0) return; if (!cell_is_active_hydro(c, e)) return; /* Recurse? */ @@ -641,6 +647,8 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) { /* Did we get a star? (Or did we run out of spare ones?) */ if (sp != NULL) { + message("Formed a star!!!"); + /* Copy the properties of the gas particle to the star particle */ star_formation_copy_properties(p, xp, sp, e, sf_props, cosmo, with_cosmology); diff --git a/src/space.c b/src/space.c index b3b63d4614..1dc7d5cbe6 100644 --- a/src/space.c +++ b/src/space.c @@ -236,6 +236,7 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements, c->grav.down = NULL; c->grav.mesh = NULL; c->grav.end_force = NULL; + c->top = c; c->super = c; c->hydro.super = c; c->grav.super = c; diff --git a/src/task.c b/src/task.c index 34c636b48e..78988d14cf 100644 --- a/src/task.c +++ b/src/task.c @@ -79,6 +79,8 @@ const char *taskID_names[task_type_count] = {"none", "grav_end_force", "cooling", "star_formation", + "star_formation_in", + "star_formation_out", "logger", "stars_in", "stars_out", diff --git a/src/task.h b/src/task.h index 704d1a5ef8..129d4ab85f 100644 --- a/src/task.h +++ b/src/task.h @@ -70,6 +70,8 @@ enum task_types { task_type_end_grav_force, task_type_cooling, task_type_star_formation, + task_type_star_formation_in, /* Implicit */ + task_type_star_formation_out, /* Implicit */ task_type_logger, task_type_stars_in, /* Implicit */ task_type_stars_out, /* Implicit */ diff --git a/tools/task_plots/analyse_tasks.py b/tools/task_plots/analyse_tasks.py index fc9df0e479..7e562b8e21 100755 --- a/tools/task_plots/analyse_tasks.py +++ b/tools/task_plots/analyse_tasks.py @@ -94,6 +94,8 @@ TASKTYPES = [ "grav_end_force", "cooling", "star_formation", + "star_formation_in", + "star_formation_out", "logger", "stars_in", "stars_out", diff --git a/tools/task_plots/plot_tasks.py b/tools/task_plots/plot_tasks.py index 54f34b2f82..324536fe71 100755 --- a/tools/task_plots/plot_tasks.py +++ b/tools/task_plots/plot_tasks.py @@ -179,6 +179,8 @@ TASKTYPES = [ "grav_end_force", "cooling", "star_formation", + "star_formation_in", + "star_formation_out", "logger", "stars_in", "stars_out", -- GitLab