From d27f7fa8856c2e8aa03ce57a65d5618150bb2efc Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Tue, 18 Apr 2017 09:46:03 +0100
Subject: [PATCH] Added comments for suggestions of algorithmic improvements.

---
 src/multipole.h          | 14 +++++++++++---
 src/runner_doiact_grav.h | 12 +++++++++---
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/multipole.h b/src/multipole.h
index df3ecfc906..a633554490 100644
--- a/src/multipole.h
+++ b/src/multipole.h
@@ -207,10 +207,18 @@ INLINE static void gravity_reset(struct gravity_tensors *m) {
  */
 INLINE static void gravity_drift(struct gravity_tensors *m, double dt) {
 
+  const double dx = m->m_pole.vel[0] * dt;
+  const double dy = m->m_pole.vel[1] * dt;
+  const double dz = m->m_pole.vel[2] * dt;
+
   /* Move the whole thing according to bulk motion */
-  m->CoM[0] += m->m_pole.vel[0] * dt * 0;  // MATTHIEU
-  m->CoM[1] += m->m_pole.vel[1] * dt * 0;
-  m->CoM[2] += m->m_pole.vel[2] * dt * 0;
+  m->CoM[0] += dx;
+  m->CoM[1] += dy;
+  m->CoM[2] += dz;
+
+  /* Conservative change in maximal radius containing all gpart */
+  /* MATTHIEU: Use gpart->x_diff here ? */
+  m->r_max += sqrt(dx * dx + dy * dy + dz * dz);
 }
 
 /**
diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h
index 1831570c47..065e99dba8 100644
--- a/src/runner_doiact_grav.h
+++ b/src/runner_doiact_grav.h
@@ -185,6 +185,8 @@ void runner_dopair_grav_pp(struct runner *r, struct cell *ci, struct cell *cj) {
   }
 #endif
 
+  /* MATTHIEU: Should we use local DP accumulators ? */
+
   /* Loop over all particles in ci... */
   for (int pid = 0; pid < gcount_i; pid++) {
 
@@ -284,6 +286,8 @@ void runner_doself_grav_pp(struct runner *r, struct cell *c) {
   }
 #endif
 
+  /* MATTHIEU: Should we use local DP accumulators ? */
+
   /* Loop over all particles in ci... */
   for (int pid = 0; pid < gcount; pid++) {
 
@@ -400,6 +404,7 @@ void runner_dopair_grav(struct runner *r, struct cell *ci, struct cell *cj,
 
   /* Can we use M-M interactions ? */
   if (gravity_multipole_accept(ci->multipole, cj->multipole, theta_crit_inv)) {
+    /* MATTHIEU: make a symmetric M-M interaction function ! */
     runner_dopair_grav_mm(r, ci, cj);
     runner_dopair_grav_mm(r, cj, ci);
   }
@@ -426,6 +431,7 @@ void runner_dopair_grav(struct runner *r, struct cell *ci, struct cell *cj,
         }
 
       } else if (cj->split) {
+        /* MATTHIEU: This could maybe be replaced by P-M interactions ?  */
 
         /* Loop over cj's children */
         for (int k = 0; k < 8; k++) {
@@ -434,8 +440,7 @@ void runner_dopair_grav(struct runner *r, struct cell *ci, struct cell *cj,
         }
 
       } else {
-        message("oO");
-        // runner_dpoair_grav_pm(r, ci, cj);
+        error("Fundamental error in the logic");
       }
     } else {
 
@@ -449,6 +454,7 @@ void runner_dopair_grav(struct runner *r, struct cell *ci, struct cell *cj,
         }
 
       } else if (ci->split) {
+        /* MATTHIEU: This could maybe be replaced by P-M interactions ?  */
 
         /* Loop over ci's children */
         for (int k = 0; k < 8; k++) {
@@ -457,7 +463,7 @@ void runner_dopair_grav(struct runner *r, struct cell *ci, struct cell *cj,
         }
 
       } else {
-        message("oO");
+        error("Fundamental error in the logic");
       }
     }
   }
-- 
GitLab