From 861e5f8ba2dadb50d1cfed0cb2035e600d351c20 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Tue, 26 May 2020 23:03:05 +0200
Subject: [PATCH] Better name for the new parameter of cell_can_use_pair_mm()

---
 src/cell.c               | 11 +++++++----
 src/cell.h               |  2 +-
 src/engine_maketasks.c   |  2 +-
 src/runner_doiact_grav.c |  2 +-
 src/scheduler.c          |  2 +-
 5 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/cell.c b/src/cell.c
index cc893824a7..396e473e75 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -3329,7 +3329,8 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj,
 
     /* Can we use multipoles ? */
     if (cell_can_use_pair_mm(ci, cj, e, sp, /*use_rebuild_data=*/0,
-                             /*is_top_level=*/0)) {
+                             /*is_tree_walk=*/1)) {
+
       /* Ok, no need to drift anything */
       return;
     }
@@ -6388,19 +6389,21 @@ void cell_reorder_extra_gparts(struct cell *c, struct part *parts,
  * @param s The #space.
  * @param use_rebuild_data Are we considering the data at the last tree-build
  * (1) or current data (0)?
+ * @param is_tree_walk Are we calling this in the tree walk (1) or for the
+ * top-level task construction (0)?
  */
 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 int is_top_level) {
+                         const int is_tree_walk) {
 
   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;
+  if (is_tree_walk && ci->grav.count <= 1) return 0;
+  if (is_tree_walk && cj->grav.count <= 1) return 0;
 
   /* Recover the multipole information */
   const struct gravity_tensors *restrict multi_i = ci->grav.multipole;
diff --git a/src/cell.h b/src/cell.h
index b4980a158e..b233dab755 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -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 is_top_level);
+                         const int use_rebuild_data, const int is_tree_walk);
 
 /**
  * @brief Compute the square of the minimal distance between any two points in
diff --git a/src/engine_maketasks.c b/src/engine_maketasks.c
index c931630fbd..b73aa475c0 100644
--- a/src/engine_maketasks.c
+++ b/src/engine_maketasks.c
@@ -1382,7 +1382,7 @@ void engine_make_self_gravity_tasks_mapper(void *map_data, int num_elements,
 
           /* Are the cells too close for a MM interaction ? */
           if (!cell_can_use_pair_mm(ci, cj, e, s, /*use_rebuild_data=*/1,
-                                    /*is_top_level=*/1)) {
+                                    /*is_tree_walk=*/0)) {
 
             /* Ok, we need to add a direct pair calculation */
             scheduler_addtask(sched, task_type_pair, task_subtype_grav, 0, 0,
diff --git a/src/runner_doiact_grav.c b/src/runner_doiact_grav.c
index bcddbbc283..731d7aa9f6 100644
--- a/src/runner_doiact_grav.c
+++ b/src/runner_doiact_grav.c
@@ -2402,7 +2402,7 @@ 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,
-                             /*is_top_level=*/1)) {
+                             /*is_tree_walk=*/0)) {
 
       /* Call the PM interaction fucntion on the active sub-cells of ci */
       runner_dopair_grav_mm_nonsym(r, ci, cj);
diff --git a/src/scheduler.c b/src/scheduler.c
index 98da3b10ec..bb380e5a51 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -874,7 +874,7 @@ static void scheduler_splittask_gravity(struct task *t, struct scheduler *s) {
                   /* 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,
-                                           /*is_top_level=*/0)) {
+                                           /*is_tree_walk=*/1)) {
 
                     /* Flag this pair as being treated by the M-M task.
                      * We use the 64 bits in the task->flags field to store
-- 
GitLab