From 20942f212d878d9ae8e7369d318f802c7fd7cad5 Mon Sep 17 00:00:00 2001
From: James Willis <james.s.willis@durham.ac.uk>
Date: Wed, 4 Oct 2017 18:35:21 +0100
Subject: [PATCH] pairs_all_force now only updates active particles. Removed
 error message in shuffle_particles for arrays of length 1.

---
 src/tools.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/tools.c b/src/tools.c
index f4c00446ce..5b93ae7e64 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -254,6 +254,7 @@ void pairs_all_force(struct runner *r, struct cell *ci, struct cell *cj) {
   float r2, hi, hj, hig2, hjg2, dx[3];
   struct part *pi, *pj;
   const double dim[3] = {r->e->s->dim[0], r->e->s->dim[1], r->e->s->dim[2]};
+  const struct engine *e = r->e;
 
   /* Implements a double-for loop and checks every interaction */
   for (int i = 0; i < ci->count; ++i) {
@@ -262,6 +263,9 @@ void pairs_all_force(struct runner *r, struct cell *ci, struct cell *cj) {
     hi = pi->h;
     hig2 = hi * hi * kernel_gamma2;
 
+    /* Skip inactive particles. */
+    if (!part_is_active(pi, e)) continue;
+    
     for (int j = 0; j < cj->count; ++j) {
 
       pj = &cj->parts[j];
@@ -292,6 +296,9 @@ void pairs_all_force(struct runner *r, struct cell *ci, struct cell *cj) {
     hj = pj->h;
     hjg2 = hj * hj * kernel_gamma2;
 
+    /* Skip inactive particles. */
+    if (!part_is_active(pj, e)) continue;
+    
     for (int i = 0; i < ci->count; ++i) {
 
       pi = &ci->parts[i];
@@ -511,8 +518,7 @@ void shuffle_particles(struct part *parts, const int count) {
       parts[i] = particle;
     }
 
-  } else
-    message("Array not big enough to shuffle!");
+  }
 }
 
 /**
-- 
GitLab