From 9bf02d19bac971b1bce3bb371f6c3448d4a449f7 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Thu, 15 Aug 2019 11:39:18 +0200
Subject: [PATCH] Documentation and debugging checks fixes.

---
 src/cell.c             | 31 +++++++++++++++++++++++++++++++
 src/engine_maketasks.c |  2 ++
 src/runner.c           |  3 ++-
 3 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/src/cell.c b/src/cell.c
index 2637a9703d..a2ce43c9bd 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -2399,6 +2399,11 @@ void cell_clear_limiter_flags(struct cell *c, void *data) {
                   cell_flag_do_hydro_limiter | cell_flag_do_hydro_sub_limiter);
 }
 
+/**
+ * @brief Recursively clear the stars_resort flag in a cell hierarchy.
+ *
+ * @param c The #cell to act on.
+ */
 void cell_set_star_resort_flag(struct cell *c) {
 
   cell_set_flag(c, cell_flag_do_stars_resort);
@@ -2412,8 +2417,24 @@ void cell_set_star_resort_flag(struct cell *c) {
   }
 }
 
+/**
+ * @brief Recurses in a cell hierarchy down to the level where the
+ * star resort tasks are and activates them.
+ *
+ * The function will fail if called *below* the super-level
+ *
+ * @param c The #cell to recurse into.
+ * @param s The #scheduler.
+ */
 void cell_activate_star_resort_tasks(struct cell *c, struct scheduler *s) {
 
+#ifdef SWIFT_DEBUG_CHECKS
+  if (c->hydro.super != NULL && c->hydro.super != c)
+    error("Function called below the super level!");
+#endif
+
+  /* The resort tasks are at either the chosen depth or the super level,
+   * whichever comes first. */
   if (c->depth == engine_star_resort_task_depth || c->hydro.super == c) {
     scheduler_activate(s, c->hydro.stars_resort);
   } else {
@@ -2425,9 +2446,19 @@ void cell_activate_star_resort_tasks(struct cell *c, struct scheduler *s) {
   }
 }
 
+/**
+ * @brief Activate the star formation task as well as the resorting of stars
+ *
+ * Must be called at the top-level in the tree (where the SF task is...)
+ *
+ * @param c The (top-level) #cell.
+ * @param s The #scheduler.
+ */
 void cell_activate_star_formation_tasks(struct cell *c, struct scheduler *s) {
 
+#ifdef SWIFT_DEBUG_CHECKS
   if (c->depth != 0) error("Function should be called at the top-level only");
+#endif
 
   /* Have we already unskipped that task? */
   if (c->hydro.star_formation->skip == 0) return;
diff --git a/src/engine_maketasks.c b/src/engine_maketasks.c
index 3759ac26f9..6a8341068c 100644
--- a/src/engine_maketasks.c
+++ b/src/engine_maketasks.c
@@ -977,6 +977,8 @@ void engine_add_ghosts(struct engine *e, struct cell *c, struct task *ghost_in,
  *
  * @param e The #engine.
  * @param c The #cell.
+ * @param star_resort_cell Pointer to the cell where the star_resort task has
+ * been created. NULL above that level or if not running with star formation.
  */
 void engine_make_hierarchical_tasks_hydro(struct engine *e, struct cell *c,
                                           struct cell *star_resort_cell) {
diff --git a/src/runner.c b/src/runner.c
index cfa33ca84d..18e3985425 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -1180,7 +1180,8 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) {
             /* Did we get a star? (Or did we run out of spare ones?) */
             if (sp != NULL) {
 
-              message("We formed a star id=%lld cellID=%d", sp->id, c->cellID);
+              /* message("We formed a star id=%lld cellID=%d", sp->id,
+               * c->cellID); */
 
               /* Copy the properties of the gas particle to the star particle */
               star_formation_copy_properties(p, xp, sp, e, sf_props, cosmo,
-- 
GitLab