Commit a16d066a authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Correctly accumulate the stars.h_max when construciting the tree. Correctly...

Correctly accumulate the stars.h_max when construciting the tree. Correctly check for rebuild for stars when marking the tasks. TEmporarily set the smoohting lengths of the stars to a fixed constant.
parent 2b01cd1d
......@@ -3052,7 +3052,7 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
struct engine *e = s->space->e;
const int nodeID = e->nodeID;
int rebuild = 0;
/* Un-skip the density tasks involved with this cell. */
for (struct link *l = c->stars.density; l != NULL; l = l->next) {
struct task *t = l->t;
......@@ -3116,7 +3116,7 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
cell_activate_subcell_stars_tasks(t->ci, t->cj, s);
}
}
/* Only interested in pair interactions as of here. */
if (t->type == task_type_pair || t->type == task_type_sub_pair) {
......@@ -3205,7 +3205,7 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
#endif
}
}
/* Un-skip the feedback tasks involved with this cell. */
for (struct link *l = c->stars.feedback; l != NULL; l = l->next) {
struct task *t = l->t;
......
......@@ -504,7 +504,7 @@ struct cell {
/*! Linked list of the tasks computing this cell's star density. */
struct link *density;
/*! Linked list of the tasks computing this cell's star feedback. */
struct link *feedback;
......@@ -954,6 +954,24 @@ __attribute__((always_inline)) INLINE static int cell_need_rebuild_for_pair(
cj->dmin);
}
/**
* @brief Have particles in a pair of cells moved too much and require a rebuild
* ?
*
* @param ci The first #cell.
* @param cj The second #cell.
*/
__attribute__((always_inline)) INLINE static int
cell_need_rebuild_for_stars_pair(const struct cell *ci, const struct cell *cj) {
/* Is the cut-off radius plus the max distance the parts in both cells have */
/* moved larger than the cell size ? */
/* Note ci->dmin == cj->dmin */
return (kernel_gamma * max(ci->stars.h_max, cj->stars.h_max) +
ci->stars.dx_max_part + cj->stars.dx_max_part >
cj->dmin);
}
/**
* @brief Add a unique tag to a cell, mostly for MPI communications.
*
......
......@@ -1612,7 +1612,8 @@ void engine_link_stars_tasks_mapper(void *map_data, int num_elements,
/* Now, build all the dependencies for the stars */
engine_make_stars_loops_dependencies(sched, t, t->ci);
}
if (t->type == task_type_self && t->subtype == task_subtype_stars_feedback) {
if (t->type == task_type_self &&
t->subtype == task_subtype_stars_feedback) {
/* Make the self-feedback tasks depend on the stars ghost task. */
scheduler_addunlock(sched, t->ci->super->stars.ghost_out, t);
......@@ -1656,12 +1657,11 @@ void engine_link_stars_tasks_mapper(void *map_data, int num_elements,
engine_make_stars_loops_dependencies(sched, t, t->cj);
}
}
else if (t->type == task_type_pair &&
t->subtype == task_subtype_stars_feedback) {
} else if (t->type == task_type_pair &&
t->subtype == task_subtype_stars_feedback) {
/* Make feedback task depend on ghost */
scheduler_addunlock(sched, t->ci->super->stars.ghost_out, t);
/* Make end_force depend on feedback */
if (t->ci == t->ci->super) {
scheduler_addunlock(sched, t, t->ci->super->end_force);
......@@ -1684,13 +1684,12 @@ void engine_link_stars_tasks_mapper(void *map_data, int num_elements,
engine_make_stars_loops_dependencies(sched, t, t->ci);
} else
error("oo");
}
else if (t->type == task_type_sub_self &&
t->subtype == task_subtype_stars_feedback) {
} else if (t->type == task_type_sub_self &&
t->subtype == task_subtype_stars_feedback) {
/* Make feedback task depend on ghost */
scheduler_addunlock(sched, t->ci->super->stars.ghost_out, t);
/* Make end_force depend on feedback */
if (t->ci == t->ci->super) {
scheduler_addunlock(sched, t, t->ci->super->end_force);
......@@ -1729,13 +1728,12 @@ void engine_link_stars_tasks_mapper(void *map_data, int num_elements,
if (t->ci->super != t->cj->super)
engine_make_stars_loops_dependencies(sched, t, t->cj);
}
}
else if (t->type == task_type_sub_pair &&
t->subtype == task_subtype_stars_feedback) {
} else if (t->type == task_type_sub_pair &&
t->subtype == task_subtype_stars_feedback) {
/* Make feedback task depend on ghost */
scheduler_addunlock(sched, t->ci->super->stars.ghost_out, t);
/* Make end_force depend on feedback */
if (t->ci == t->ci->super) {
scheduler_addunlock(sched, t, t->ci->super->end_force);
......@@ -1788,8 +1786,8 @@ void engine_make_starsloop_tasks_mapper(void *map_data, int num_elements,
if (ci->nodeID == nodeID) {
scheduler_addtask(sched, task_type_self, task_subtype_stars_density, 0, 0,
ci, NULL);
scheduler_addtask(sched, task_type_self, task_subtype_stars_feedback, 0, 0,
ci, NULL);
scheduler_addtask(sched, task_type_self, task_subtype_stars_feedback, 0,
0, ci, NULL);
}
/* Now loop over all the neighbours of this cell */
......
......@@ -126,6 +126,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
else if (t_type == task_type_self &&
t_subtype == task_subtype_stars_density) {
if (cell_is_active_stars(ci, e)) {
message("hello");
scheduler_activate(s, t);
cell_activate_drift_part(ci, s);
cell_activate_drift_spart(ci, s);
......@@ -423,16 +424,10 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
if (t->subtype == task_subtype_stars_density) {
/* Too much particle movement? */
if (cell_need_rebuild_for_pair(ci, cj)) *rebuild_space = 1;
// LOIC: Need implementing MPI case
}
/* Only interested in stars_feedback tasks as of here. */
if (t->subtype == task_subtype_stars_feedback) {
/* Too much particle movement? */
if (cell_need_rebuild_for_pair(ci, cj)) *rebuild_space = 1;
if (cell_need_rebuild_for_stars_pair(ci, cj)) {
message("OOOO");
*rebuild_space = 1;
}
// LOIC: Need implementing MPI case
}
......
......@@ -333,7 +333,8 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) {
}
}
/* Run through this cell's feedback interactions. */
for (struct link *l = finger->stars.feedback; l != NULL; l = l->next) {
for (struct link *l = finger->stars.feedback; l != NULL;
l = l->next) {
#ifdef SWIFT_DEBUG_CHECKS
if (l->t->ti_run < r->e->ti_current)
......@@ -343,7 +344,7 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) {
/* Self-interaction? */
if (l->t->type == task_type_self)
runner_doself_subset_branch_stars_feedback(r, finger, sparts, sid,
scount);
scount);
/* Otherwise, pair interaction? */
else if (l->t->type == task_type_pair) {
......@@ -360,7 +361,7 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) {
/* Otherwise, sub-self interaction? */
else if (l->t->type == task_type_sub_self)
runner_dosub_subset_stars_feedback(r, finger, sparts, sid, scount,
NULL, -1, 1);
NULL, -1, 1);
/* Otherwise, sub-pair interaction? */
else if (l->t->type == task_type_sub_pair) {
......@@ -368,10 +369,10 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) {
/* Left or right? */
if (l->t->ci == finger)
runner_dosub_subset_stars_feedback(r, finger, sparts, sid,
scount, l->t->cj, -1, 1);
scount, l->t->cj, -1, 1);
else
runner_dosub_subset_stars_feedback(r, finger, sparts, sid,
scount, l->t->ci, -1, 1);
scount, l->t->ci, -1, 1);
}
}
}
......@@ -2805,9 +2806,10 @@ void *runner_main(void *data) {
runner_doself_recursive_grav(r, ci, 1);
else if (t->subtype == task_subtype_external_grav)
runner_do_grav_external(r, ci, 1);
else if (t->subtype == task_subtype_stars_density)
else if (t->subtype == task_subtype_stars_density) {
message("hello");
runner_doself_stars_density(r, ci, 1);
else if (t->subtype == task_subtype_stars_feedback)
} else if (t->subtype == task_subtype_stars_feedback)
runner_doself_stars_feedback(r, ci, 1);
else
error("Unknown/invalid task subtype (%d).", t->subtype);
......
......@@ -101,6 +101,8 @@ void DOSELF1_STARS(struct runner *r, struct cell *c, int timer) {
(float)(si->x[1] - c->loc[1]),
(float)(si->x[2] - c->loc[2])};
message("hi=%e, c->width=%e", hi, c->width[0]);
/* Loop over the parts in cj. */
for (int pjd = 0; pjd < count; pjd++) {
......
......@@ -1532,6 +1532,8 @@ void scheduler_splittasks_mapper(void *map_data, int num_elements,
/* For future use */
} else if (t->subtype == task_subtype_stars_density) {
scheduler_splittask_stars(t, s);
} else if (t->subtype == task_subtype_stars_feedback) {
} else {
#ifdef SWIFT_DEBUG_CHECKS
error("Unexpected task sub-type");
......
......@@ -2179,7 +2179,7 @@ void space_split_recursive(struct space *s, struct cell *c,
/* Update the cell-wide properties */
h_max = max(h_max, cp->hydro.h_max);
stars_h_max = max(h_max, cp->stars.h_max);
stars_h_max = max(stars_h_max, cp->stars.h_max);
ti_hydro_end_min = min(ti_hydro_end_min, cp->hydro.ti_end_min);
ti_hydro_end_max = max(ti_hydro_end_max, cp->hydro.ti_end_max);
ti_hydro_beg_max = max(ti_hydro_beg_max, cp->hydro.ti_beg_max);
......@@ -2916,6 +2916,9 @@ void space_first_init_sparts_mapper(void *restrict map_data, int count,
sp[k].v[1] *= a_factor_vel;
sp[k].v[2] *= a_factor_vel;
// MATTHIEU: TO DO: Read smoothing lengths from ICs!!!!
sp[k].h = s->dim[0] / 10. / kernel_gamma;
#ifdef HYDRO_DIMENSION_2D
sp[k].x[2] = 0.f;
sp[k].v[2] = 0.f;
......
......@@ -84,9 +84,10 @@ const char *taskID_names[task_type_count] = {"none",
/* Sub-task type names. */
const char *subtaskID_names[task_subtype_count] = {
"none", "density", "gradient", "force", "grav",
"external_grav", "tend", "xv", "rho", "gpart",
"multipole", "spart", "stars_density", "stars_feedback" };
"none", "density", "gradient", "force",
"grav", "external_grav", "tend", "xv",
"rho", "gpart", "multipole", "spart",
"stars_density", "stars_feedback"};
#ifdef WITH_MPI
/* MPI communicators for the subtypes. */
......
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