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

Escape small cells in cell_can_use_pair_mm() when doing the tree walk

parent 5d20def0
......@@ -3328,7 +3328,8 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj,
if (lock_unlock(&cj->grav.mlock) != 0) error("Impossible to unlock m-pole");
/* Can we use multipoles ? */
if (cell_can_use_pair_mm(ci, cj, e, sp, /*use_rebuild_data=*/0)) {
if (cell_can_use_pair_mm(ci, cj, e, sp, /*use_rebuild_data=*/0,
/*is_top_level=*/0)) {
/* Ok, no need to drift anything */
return;
}
......@@ -6390,12 +6391,17 @@ void cell_reorder_extra_gparts(struct cell *c, struct part *parts,
*/
int cell_can_use_pair_mm(const struct cell *restrict ci,
const struct cell *restrict cj, const struct engine *e,
const struct space *s, const int use_rebuild_data) {
const struct space *s, const int use_rebuild_data,
const int is_top_level) {
const struct gravity_props *props = e->gravity_properties;
const int periodic = s->periodic;
const double dim[3] = {s->dim[0], s->dim[1], s->dim[2]};
/* Check for trivial cases */
if (!is_top_level && ci->grav.count <= 1) return 0;
if (!is_top_level && cj->grav.count <= 1) return 0;
/* Recover the multipole information */
const struct gravity_tensors *restrict multi_i = ci->grav.multipole;
const struct gravity_tensors *restrict multi_j = cj->grav.multipole;
......
......@@ -960,7 +960,7 @@ void cell_reorder_extra_gparts(struct cell *c, struct part *parts,
void cell_reorder_extra_sparts(struct cell *c, const ptrdiff_t sparts_offset);
int cell_can_use_pair_mm(const struct cell *ci, const struct cell *cj,
const struct engine *e, const struct space *s,
const int use_rebuild_data);
const int use_rebuild_data, const int is_top_level);
/**
* @brief Compute the square of the minimal distance between any two points in
......
......@@ -1381,7 +1381,8 @@ void engine_make_self_gravity_tasks_mapper(void *map_data, int num_elements,
if (periodic && min_radius2 > max_distance2) continue;
/* Are the cells too close for a MM interaction ? */
if (!cell_can_use_pair_mm(ci, cj, e, s, /*use_rebuild_data=*/1)) {
if (!cell_can_use_pair_mm(ci, cj, e, s, /*use_rebuild_data=*/1,
/*is_top_level=*/1)) {
/* Ok, we need to add a direct pair calculation */
scheduler_addtask(sched, task_type_pair, task_subtype_grav, 0, 0,
......
......@@ -2401,7 +2401,8 @@ void runner_do_grav_long_range(struct runner *r, struct cell *ci,
}
}
if (cell_can_use_pair_mm(top, cj, e, e->s, /*use_rebuild_data=*/1)) {
if (cell_can_use_pair_mm(top, cj, e, e->s, /*use_rebuild_data=*/1,
/*is_top_level=*/1)) {
/* Call the PM interaction fucntion on the active sub-cells of ci */
runner_dopair_grav_mm_nonsym(r, ci, cj);
......
......@@ -873,7 +873,8 @@ static void scheduler_splittask_gravity(struct task *t, struct scheduler *s) {
if (cj->progeny[j] != NULL) {
/* Can we use a M-M interaction here? */
if (cell_can_use_pair_mm(ci->progeny[i], cj->progeny[j], e,
sp, /*use_rebuild_data=*/1)) {
sp, /*use_rebuild_data=*/1,
/*is_top_level=*/0)) {
/* Flag this pair as being treated by the M-M task.
* We use the 64 bits in the task->flags field to store
......
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