diff --git a/examples/IsolatedGalaxy/IsolatedGalaxy_starformation/isolated_galaxy.yml b/examples/IsolatedGalaxy/IsolatedGalaxy_starformation/isolated_galaxy.yml index 7dac0a8a6c3b8d4c583ae6138513f0c5259227b1..341cae8a3fe87e01aecd6c77bf8f86a9cc940bf1 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 a6308faff68959516ee05950a72bf9872acd21e2..fa6c972e7a12fcaebd66a10fabb6a3611da4cf71 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 4db2feeb0a645845cf9d48ed2fcc46d5159296f5..b0912d33f272e800fdb71db816bde3006582d912 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 669b6353f2795a3ecd3dda444782f823fe0ba030..a8dd38f5ff14257e7d5da49be8c0af755dcc4766 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 277c9560318104d7b6d28696d751ee89db26b467..d2bd1719e28696eb1fd52196b05d9141c5024ec1 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 299e274e87fea05544c7e4711aa623c36d9d53e6..1a07da1069830e9a9969fd0b05457daf606d95eb 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 b3b63d4614cb9f0b8105ec030e81e59381823158..1dc7d5cbe6200badcc744fec8c630863840c90e1 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 34c636b48ed6ff3fefdf1e7847a67ca56ea79c89..78988d14cf864d94000483a1ffee6a15db7d771c 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 704d1a5ef80f1208bce69d0acf7625fb36fa19e1..129d4ab85fa0ea1f549e5b6bfa71d1c97c8604b2 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 fc9df0e4797cfb16e883df551af30dc0d3244edc..7e562b8e21508696780239dec28a6ab1aee078fc 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 54f34b2f828895d894b84253e366173827c03158..324536fe71d00ff504590c9a01e312cf551d0d1d 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",