From 8053d50af88c4622e66a0a531d9c237df41c6bf5 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Mon, 18 Dec 2017 16:20:16 +0100
Subject: [PATCH] Also activate the gradient self and pair tasks in
 engine_marktasks() when running with the extra hydro loop

---
 src/engine.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/engine.c b/src/engine.c
index fe04187cef..e75a8c3f36 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -3148,6 +3148,18 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
         if (cell_is_active_hydro(ci, e)) scheduler_activate(s, t);
       }
 
+#ifdef EXTRA_HYDRO_LOOP
+      else if (t->type == task_type_self &&
+               t->subtype == task_subtype_gradient) {
+        if (cell_is_active_hydro(ci, e)) scheduler_activate(s, t);
+      }
+
+      else if (t->type == task_type_sub_self &&
+               t->subtype == task_subtype_gradient) {
+        if (cell_is_active_hydro(ci, e)) scheduler_activate(s, t);
+      }
+#endif
+
       /* Activate the gravity drift */
       else if (t->type == task_type_self && t->subtype == task_subtype_grav) {
         if (cell_is_active_gravity(ci, e)) {
@@ -3156,10 +3168,11 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
         }
       }
 
-      else if (t->type == task_type_sub_self &&
-               t->subtype == task_subtype_grav) {
-        error("Invalid task sub-type encountered");
+#ifdef SWIFT_DEBUG_CHECKS
+      else {
+        error("Invalid task type / sub-type encountered");
       }
+#endif
     }
 
     /* Pair? */
@@ -3175,6 +3188,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
 
       /* Only activate tasks that involve a local active cell. */
       if ((t->subtype == task_subtype_density ||
+           t->subtype == task_subtype_gradient ||
            t->subtype == task_subtype_force) &&
           ((ci_active_hydro && ci->nodeID == engine_rank) ||
            (cj_active_hydro && cj->nodeID == engine_rank))) {
-- 
GitLab