From 4aca34c7c18d48e88ced6ac82b2af8fd2e5b595f Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Tue, 3 Mar 2020 11:02:02 +0800 Subject: [PATCH] Only link the foreign stars and black holes if we are actually running with stars and black holes --- src/engine.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/engine.c b/src/engine.c index 4a5a66eea3..635fee0975 100644 --- a/src/engine.c +++ b/src/engine.c @@ -1256,6 +1256,9 @@ void engine_allocate_foreign_particles(struct engine *e) { #ifdef WITH_MPI const int nr_proxies = e->nr_proxies; + const int with_hydro = e->policy & engine_policy_hydro; + const int with_stars = e->policy & engine_policy_stars; + const int with_black_holes = e->policy & engine_policy_black_holes; struct space *s = e->s; ticks tic = getticks(); @@ -1284,6 +1287,17 @@ void engine_allocate_foreign_particles(struct engine *e) { } } + if (!with_hydro && count_parts_in) + error( + "Not running with hydro but about to receive gas particles in " + "proxies!"); + if (!with_stars && count_sparts_in) + error("Not running with stars but about to receive stars in proxies!"); + if (!with_black_holes && count_bparts_in) + error( + "Not running with black holes but about to receive black holes in " + "proxies!"); + if (e->verbose) message("Counting number of foreign particles took %.3f %s.", clocks_from_ticks(getticks() - tic), clocks_getunit()); @@ -1365,14 +1379,20 @@ void engine_allocate_foreign_particles(struct engine *e) { gparts = &gparts[count_gparts]; } - /* For stars, we just use the numbers in the top-level cells */ - cell_link_sparts(e->proxies[k].cells_in[j], sparts); - sparts = - &sparts[e->proxies[k].cells_in[j]->stars.count + space_extra_sparts]; + if (with_stars) { - /* For black holes, we just use the numbers in the top-level cells */ - cell_link_bparts(e->proxies[k].cells_in[j], bparts); - bparts = &bparts[e->proxies[k].cells_in[j]->black_holes.count]; + /* For stars, we just use the numbers in the top-level cells */ + cell_link_sparts(e->proxies[k].cells_in[j], sparts); + sparts = &sparts[e->proxies[k].cells_in[j]->stars.count + + space_extra_sparts]; + } + + if (with_black_holes) { + + /* For black holes, we just use the numbers in the top-level cells */ + cell_link_bparts(e->proxies[k].cells_in[j], bparts); + bparts = &bparts[e->proxies[k].cells_in[j]->black_holes.count]; + } } } -- GitLab