From 8637788b4b82be3f4c53d6ad958e62cd5556e40a Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Tue, 13 Sep 2016 12:39:29 +0100 Subject: [PATCH] Generalized the mechanism to add an extra initialisation loop to the SPH set-up. --- src/engine.c | 11 +++++++++-- src/part.h | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/engine.c b/src/engine.c index 4a6460d8cd..b73ad2e24f 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2658,8 +2658,15 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs) { TIMER_TOC(timer_runners); /* Apply some conversions (e.g. internal energy -> entropy) */ - if (!flag_entropy_ICs) space_map_cells_pre(s, 0, cell_convert_hydro, NULL); - if (1) engine_launch(e, e->nr_threads, mask, submask); + if (!flag_entropy_ICs) { + + /* Apply the conversion */ + space_map_cells_pre(s, 0, cell_convert_hydro, NULL); + + /* Correct what we did (e.g. in PE-SPH, need to recompute rho_bar) */ + if (hydro_need_extra_init_loop) + engine_launch(e, e->nr_threads, mask, submask); + } clocks_gettime(&time2); diff --git a/src/part.h b/src/part.h index ca5eacc7e2..6832e0c6c2 100644 --- a/src/part.h +++ b/src/part.h @@ -42,14 +42,19 @@ /* Import the right hydro particle definition */ #if defined(MINIMAL_SPH) #include "./hydro/Minimal/hydro_part.h" +#define hydro_need_extra_init_loop 0 #elif defined(GADGET2_SPH) #include "./hydro/Gadget2/hydro_part.h" +#define hydro_need_extra_init_loop 0 #elif defined(HOPKINS_PE_SPH) #include "./hydro/PressureEntropy/hydro_part.h" +#define hydro_need_extra_init_loop 1 #elif defined(DEFAULT_SPH) #include "./hydro/Default/hydro_part.h" +#define hydro_need_extra_init_loop 0 #elif defined(GIZMO_SPH) #include "./hydro/Gizmo/hydro_part.h" +#define hydro_need_extra_init_loop 0 #define EXTRA_HYDRO_LOOP #else #error "Invalid choice of SPH variant" -- GitLab