From 42b07bad547de634647d2d149226f03ca6d6373f Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Mon, 15 Oct 2018 10:59:51 +0200
Subject: [PATCH] Also take the stars into account when computing the linking
 length

---
 examples/main.c     | 2 +-
 examples/main_fof.c | 2 +-
 src/fof.c           | 4 ++--
 src/fof.h           | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/examples/main.c b/examples/main.c
index 0c68ace030..768640afe5 100644
--- a/examples/main.c
+++ b/examples/main.c
@@ -941,7 +941,7 @@ int main(int argc, char *argv[]) {
                   talking, restart_file);
 
     /* Initialise the FOF parameters. */
-    if (with_fof) fof_init(&s, N_total[0], N_total[1]);
+    if (with_fof) fof_init(&s, N_total[0], N_total[1], N_total[2]);
     
     if (myrank == 0) {
       clocks_gettime(&toc);
diff --git a/examples/main_fof.c b/examples/main_fof.c
index b8a44227c5..2ddc1f24a6 100644
--- a/examples/main_fof.c
+++ b/examples/main_fof.c
@@ -936,7 +936,7 @@ int main(int argc, char *argv[]) {
                   talking, restart_file);
 
     /* Initialise the FOF parameters. */
-    fof_init(&s, N_total[0], N_total[1]);
+    fof_init(&s, N_total[0], N_total[1], N_total[2]);
     
     if (myrank == 0) {
       clocks_gettime(&toc);
diff --git a/src/fof.c b/src/fof.c
index 75236cdf50..d23b3c1d91 100644
--- a/src/fof.c
+++ b/src/fof.c
@@ -46,7 +46,7 @@ MPI_Datatype group_length_mpi_type;
 size_t node_offset;
 
 /* Initialises parameters for the FOF search. */
-void fof_init(struct space *s, long long Ngas, long long Ngparts) {
+void fof_init(struct space *s, long long Ngas, long long Ngparts, long long Nstars) {
 
   struct engine *e = s->e;
 
@@ -78,7 +78,7 @@ void fof_init(struct space *s, long long Ngas, long long Ngparts) {
 
   /* Calculate the particle linking length based upon the mean inter-particle
    * spacing of the DM particles. */
-  const int total_nr_dmparts = Ngparts - Ngas;
+  const long long total_nr_dmparts = Ngparts - Ngas - Nstars;
   double l_x = l_x_scale * (s->dim[0] / cbrt(total_nr_dmparts));
 
   l_x = parser_get_opt_param_double(e->parameter_file, "FOF:absolute_linking_length", l_x);
diff --git a/src/fof.h b/src/fof.h
index ba445d2cf6..3061c6a14d 100644
--- a/src/fof.h
+++ b/src/fof.h
@@ -62,7 +62,7 @@ struct cell_pair_indices {
 } SWIFT_STRUCT_ALIGN;
 
 /* Function prototypes. */
-void fof_init(struct space *s, long long Ngas, long long Ngparts);
+void fof_init(struct space *s, long long Ngas, long long Ngparts, long long Nstars);
 void fof_search_cell(struct space *s, struct cell *c);
 void fof_search_pair_cells(struct space *s, struct cell *ci, struct cell *cj);
 void fof_search_pair_cells_foreign(struct space *s, struct cell *ci, struct cell *cj, int *link_count, struct fof_mpi **group_links, int *group_links_size);
-- 
GitLab