diff --git a/src/cell.c b/src/cell.c index c7a58a96f1fa10e1194243e1602b72141612d0d9..69dd7b104f12d39723815ae2114a0ad60418e15b 100644 --- a/src/cell.c +++ b/src/cell.c @@ -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; diff --git a/src/cell.h b/src/cell.h index 53c5be312e8d67d51308bf973828f367b36e4539..ae73c944bca2d96bcbe369a3cc34746649616bd6 100644 --- a/src/cell.h +++ b/src/cell.h @@ -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. * diff --git a/src/engine_maketasks.c b/src/engine_maketasks.c index 3211e961d66feef27cea18724c99f334d754cda8..17dfbcaf2c94321850fca95034b954fee79cc502 100644 --- a/src/engine_maketasks.c +++ b/src/engine_maketasks.c @@ -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 */ diff --git a/src/engine_marktasks.c b/src/engine_marktasks.c index fc26b9982d8440c33adb966c0ddea3f102b8fdca..9c5c6c438f240207ead4f1ea97badbf9e0c223f6 100644 --- a/src/engine_marktasks.c +++ b/src/engine_marktasks.c @@ -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 } diff --git a/src/runner.c b/src/runner.c index d985130395d165369064072c3ca961e85faad942..e91557b5a5f4bb1b6f0c5605d5dbe47fc8131ebd 100644 --- a/src/runner.c +++ b/src/runner.c @@ -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); diff --git a/src/runner_doiact_stars.h b/src/runner_doiact_stars.h index e816d80399a0fef85645c914168dd4038f55988c..4af75f8b7bbb0a65fcbe28fad81a37f8548b371b 100644 --- a/src/runner_doiact_stars.h +++ b/src/runner_doiact_stars.h @@ -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++) { diff --git a/src/scheduler.c b/src/scheduler.c index 2ae8f6785434af021b52dd2d6586b4e2dc5d68bb..75f2fad3bb397f9a51bae10d92735d24964bd745 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -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"); diff --git a/src/space.c b/src/space.c index 67c08c892abd5581a29b09f3591d415205221a2d..7de8110cc4770980f60cb28de9c1eb2836148ab5 100644 --- a/src/space.c +++ b/src/space.c @@ -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; diff --git a/src/task.c b/src/task.c index dc0c692e743a755df7ef3e8492484e56475fb218..71d199cb31b638a707668e655ebbc937bcc7d821 100644 --- a/src/task.c +++ b/src/task.c @@ -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. */