Commit 92662f45 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Move the star-formation task to the top-level and not the super-level to avoid dependency problems.

parent dc299bdd
......@@ -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
......
......@@ -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);
}
}
......
......@@ -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;
......
......@@ -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);
}
}
}
......
......@@ -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);
}
}
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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",
......
......@@ -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 */
......
......@@ -94,6 +94,8 @@ TASKTYPES = [
"grav_end_force",
"cooling",
"star_formation",
"star_formation_in",
"star_formation_out",
"logger",
"stars_in",
"stars_out",
......
......@@ -179,6 +179,8 @@ TASKTYPES = [
"grav_end_force",
"cooling",
"star_formation",
"star_formation_in",
"star_formation_out",
"logger",
"stars_in",
"stars_out",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment