From 139fe38ba759f2ba9632ca03719c49fc8edff10f Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Tue, 24 Jan 2017 18:55:55 +0000
Subject: [PATCH] Only need to update h_max on the receiving side if the cell
 is active.

---
 src/runner.c    |  3 +++
 src/scheduler.c | 14 +++++++-------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/runner.c b/src/runner.c
index 2f072ffd4b..71fcca63f4 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -1537,6 +1537,9 @@ void *runner_main(void *data) {
             free(t->buff);
           } else if (t->subtype == task_subtype_xv) {
             runner_do_recv_part(r, ci, 1);
+            /* Only need to update h_max if the cell has active particles */
+          } else if (t->subtype == task_subtype_rho && cell_is_active(ci, e)) {
+            runner_do_recv_part(r, ci, 1);
           } else if (t->subtype == task_subtype_gpart) {
             runner_do_recv_gpart(r, ci, 1);
           }
diff --git a/src/scheduler.c b/src/scheduler.c
index af2d1d0fb0..8b111a353d 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -1202,9 +1202,9 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
                    t->subtype == task_subtype_rho) {
           err = MPI_Irecv(t->ci->parts, t->ci->count, part_mpi_type,
                           t->ci->nodeID, t->flags, MPI_COMM_WORLD, &t->req);
-	  // message( "receiving %i parts with tag=%i from %i to %i." ,
-	  //     t->ci->count , t->flags , t->ci->nodeID , s->nodeID );
-	  // fflush(stdout);
+          // message( "receiving %i parts with tag=%i from %i to %i." ,
+          //     t->ci->count , t->flags , t->ci->nodeID , s->nodeID );
+          // fflush(stdout);
         } else if (t->subtype == task_subtype_gpart) {
           err = MPI_Irecv(t->ci->gparts, t->ci->gcount, gpart_mpi_type,
                           t->ci->nodeID, t->flags, MPI_COMM_WORLD, &t->req);
@@ -1237,10 +1237,10 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
           err = MPI_Isend(t->ci->parts, t->ci->count, part_mpi_type,
                           t->cj->nodeID, t->flags, MPI_COMM_WORLD, &t->req);
 
-	  // message( "sending %i parts with tag=%i from %i to %i." ,
-	  //     t->ci->count , t->flags , s->nodeID , t->cj->nodeID );
-	  // fflush(stdout);
-	} else if (t->subtype == task_subtype_gpart) {
+          // message( "sending %i parts with tag=%i from %i to %i." ,
+          //     t->ci->count , t->flags , s->nodeID , t->cj->nodeID );
+          // fflush(stdout);
+        } else if (t->subtype == task_subtype_gpart) {
           err = MPI_Isend(t->ci->gparts, t->ci->gcount, gpart_mpi_type,
                           t->cj->nodeID, t->flags, MPI_COMM_WORLD, &t->req);
         } else {
-- 
GitLab