From c41249ddc057ccb04f7eb53bca278c0eb9fae80e Mon Sep 17 00:00:00 2001
From: James Willis <james.s.willis@durham.ac.uk>
Date: Thu, 17 May 2018 17:08:17 +0800
Subject: [PATCH] Removed unused variables and added comments.

---
 src/engine.c                       | 8 ++++----
 src/gravity/Default/gravity_part.h | 1 +
 src/space.h                        | 6 ------
 3 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/engine.c b/src/engine.c
index 5020a43159..cbf0d36d5c 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -4200,10 +4200,10 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs,
 
   message("Performing Friends Of Friends search.");
 
-  const double l_x = 0.2 * (s->dim[0] / pow(s->nr_gparts, 1. / 3.));
-  const double l_x2 = l_x * l_x;
-  s->l_x = l_x;
-  s->l_x2 = l_x2;
+  /* Calculate the particle linking length based upon the mean inter-particle spacing. */
+  const int total_nr_dmparts = e->total_nr_gparts - e->total_nr_parts;
+  const double l_x = 0.2 * (s->dim[0] / cbrt(total_nr_dmparts));
+  s->l_x2 = l_x * l_x;
 
   ticks tic = getticks();
   fof_search_serial(s);
diff --git a/src/gravity/Default/gravity_part.h b/src/gravity/Default/gravity_part.h
index ef93488f0b..d6bbc24b8d 100644
--- a/src/gravity/Default/gravity_part.h
+++ b/src/gravity/Default/gravity_part.h
@@ -50,6 +50,7 @@ struct gpart {
   /*! Type of the #gpart (DM, gas, star, ...) */
   enum part_type type;
 
+  /*! Particle offset into FOF group id array. */
   size_t offset;
 
 #ifdef SWIFT_DEBUG_CHECKS
diff --git a/src/space.h b/src/space.h
index 18cf089845..23f01fedbf 100644
--- a/src/space.h
+++ b/src/space.h
@@ -155,15 +155,9 @@ struct space {
   /*! The associated engine. */
   struct engine *e;
 
-  /*! The FOF linking length. */
-  double l_x;
-
   /*! The FOF linking length squared. */
   double l_x2;
 
-  /*! The cell search radius squared for FOF. */
-  double cell_search_r2;
-
 #ifdef WITH_MPI
 
   /*! Buffers for parts that we will receive from foreign cells. */
-- 
GitLab