From d2473e20e1099f9d807d106a48dec9a07a89ffed Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Sun, 5 May 2019 13:47:11 +0100
Subject: [PATCH] In marktasks, with SF on, also activate the star tasks if the
 cell is active for hydro purposes.

---
 src/engine_marktasks.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/engine_marktasks.c b/src/engine_marktasks.c
index c64487fcc8..da49cc9ee3 100644
--- a/src/engine_marktasks.c
+++ b/src/engine_marktasks.c
@@ -93,9 +93,10 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
 #endif
       const int ci_active_hydro = cell_is_active_hydro(ci, e);
       const int ci_active_gravity = cell_is_active_gravity(ci, e);
-      const int ci_active_stars = cell_is_active_stars(ci, e);
       const int ci_active_black_holes = cell_is_active_black_holes(ci, e);
-      
+      const int ci_active_stars = cell_is_active_stars(ci, e) ||
+                                  (with_star_formation && ci_active_hydro);
+
       /* Activate the hydro drift */
       if (t_type == task_type_self && t_subtype == task_subtype_density) {
         if (ci_active_hydro) {
@@ -248,12 +249,14 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
       const int ci_active_gravity = cell_is_active_gravity(ci, e);
       const int cj_active_gravity = cell_is_active_gravity(cj, e);
 
-      const int ci_active_stars = cell_is_active_stars(ci, e);
-      const int cj_active_stars = cell_is_active_stars(cj, e);
-
       const int ci_active_black_holes = cell_is_active_black_holes(ci, e);
       const int cj_active_black_holes = cell_is_active_black_holes(cj, e);
 
+      const int ci_active_stars = cell_is_active_stars(ci, e) ||
+                                  (with_star_formation && ci_active_hydro);
+      const int cj_active_stars = cell_is_active_stars(cj, e) ||
+                                  (with_star_formation && cj_active_hydro);
+
       /* Only activate tasks that involve a local active cell. */
       if ((t_subtype == task_subtype_density ||
            t_subtype == task_subtype_gradient ||
@@ -868,12 +871,16 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
 
     /* Star ghost tasks ? */
     else if (t_type == task_type_stars_ghost) {
-      if (cell_is_active_stars(t->ci, e)) scheduler_activate(s, t);
+      if (cell_is_active_stars(t->ci, e) ||
+          (with_star_formation && cell_is_active_hydro(t->ci, e)))
+        scheduler_activate(s, t);
     }
 
     /* Feedback implicit tasks? */
     else if (t_type == task_type_stars_in || t_type == task_type_stars_out) {
-      if (cell_is_active_stars(t->ci, e)) scheduler_activate(s, t);
+      if (cell_is_active_stars(t->ci, e) ||
+          (with_star_formation && cell_is_active_hydro(t->ci, e)))
+        scheduler_activate(s, t);
     }
 
     /* Black hole ghost tasks ? */
-- 
GitLab