From a8ca5cfbae328eab99c77ece253af76ab84f359e Mon Sep 17 00:00:00 2001
From: James Willis <james.s.willis@durham.ac.uk>
Date: Thu, 24 May 2018 13:09:08 +0100
Subject: [PATCH] Call VELOCIraptor for the first time after the first snapshot
 dump. Make sure to drift all particles before calling VELOCIraptor.

---
 examples/main.c | 3 +++
 src/engine.c    | 5 +----
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/examples/main.c b/examples/main.c
index d736d0b63a..2150e36abb 100644
--- a/examples/main.c
+++ b/examples/main.c
@@ -883,6 +883,9 @@ int main(int argc, char *argv[]) {
     /* Write the state of the system before starting time integration. */
     engine_dump_snapshot(&e);
     engine_print_stats(&e);
+  
+    /* Call VELOCIraptor for the first time after the first snapshot dump. */
+    if (e.policy & engine_policy_structure_finding) velociraptor_invoke(&e);
 
   }
 
diff --git a/src/engine.c b/src/engine.c
index 4949534ac7..62b90bf8e8 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -4347,9 +4347,6 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs,
   space_init_parts(s, e->verbose);
   space_init_gparts(s, e->verbose);
 
-  /* Call VELOCIraptor before first step and before velocities are kicked. */
-  if (e->policy & engine_policy_structure_finding) velociraptor_invoke(e);
-  
   /* Now, launch the calculation */
   TIMER_TIC;
   engine_launch(e);
@@ -4648,7 +4645,7 @@ void engine_step(struct engine *e) {
   /* Drift everybody (i.e. what has not yet been drifted) */
   /* to the current time */
   int drifted_all =
-      (e->dump_snapshot || e->forcerebuild || e->forcerepart || e->save_stats);
+      (e->dump_snapshot || e->forcerebuild || e->forcerepart || e->save_stats || e->run_stf);
   if (drifted_all) engine_drift_all(e);
 
   /* Write a snapshot ? */
-- 
GitLab