diff --git a/examples/main.c b/examples/main.c index 32168cbfbcea909eca782092f12ec8c627677c30..c5197a3c1619e7c73bd12e687438ac5fb4e8000b 100644 --- a/examples/main.c +++ b/examples/main.c @@ -98,6 +98,7 @@ void print_help_message(void) { printf(" %2s %14s %s\n", "-r", "", "Continue using restart files."); printf(" %2s %14s %s\n", "-s", "", "Run with hydrodynamics."); printf(" %2s %14s %s\n", "-S", "", "Run with stars."); + printf(" %2s %14s %s\n", "-b", "", "Run with stars feedback."); printf(" %2s %14s %s\n", "-t", "{int}", "The number of threads to use on each MPI rank. Defaults to 1 if not " "specified."); @@ -193,6 +194,7 @@ int main(int argc, char *argv[]) { int with_self_gravity = 0; int with_hydro = 0; int with_stars = 0; + int with_feedback = 0; int with_fp_exceptions = 0; int with_drift_all = 0; int with_mpole_reconstruction = 0; @@ -209,7 +211,7 @@ int main(int argc, char *argv[]) { /* Parse the parameters */ int c; - while ((c = getopt(argc, argv, "acCdDef:FgGhMn:o:P:rsSt:Tv:xy:Y:")) != -1) + while ((c = getopt(argc, argv, "abcCdDef:FgGhMn:o:P:rsSt:Tv:xy:Y:")) != -1) switch (c) { case 'a': #if defined(HAVE_SETAFFINITY) && defined(HAVE_LIBNUMA) @@ -218,6 +220,9 @@ int main(int argc, char *argv[]) { error("Need NUMA support for thread affinity"); #endif break; + case 'b': + with_feedback = 1; + break; case 'c': with_cosmology = 1; break; @@ -385,6 +390,15 @@ int main(int argc, char *argv[]) { return 1; } + if (!with_stars && with_feedback) { + if (myrank == 0) + printf( + "Error: Cannot process feedback without stars, -S must be " + "chosen.\n"); + if (myrank == 0) print_help_message(); + return 1; + } + /* Let's pin the main thread, now we know if affinity will be used. */ #if defined(HAVE_SETAFFINITY) && defined(HAVE_LIBNUMA) && defined(_GNU_SOURCE) if (with_aff && @@ -887,6 +901,7 @@ int main(int argc, char *argv[]) { if (with_cooling) engine_policies |= engine_policy_cooling; if (with_sourceterms) engine_policies |= engine_policy_sourceterms; if (with_stars) engine_policies |= engine_policy_stars; + if (with_feedback) engine_policies |= engine_policy_feedback; if (with_structure_finding) engine_policies |= engine_policy_structure_finding; diff --git a/src/engine.c b/src/engine.c index 9d918db11a1ad09ece2e6d6895118c8c0605659d..972edfaf5f40fb291ecedaa0c5c5b20cb5734162 100644 --- a/src/engine.c +++ b/src/engine.c @@ -110,7 +110,8 @@ const char *engine_policy_names[] = {"none", "cooling", "sourceterms", "stars", - "structure finding"}; + "structure finding", + "feedback"}; /** The rank of the engine as a global variable (for messages). */ int engine_rank; @@ -463,7 +464,7 @@ void engine_make_hierarchical_tasks_mapper(void *map_data, int num_elements, const int is_with_self_gravity = (e->policy & engine_policy_self_gravity); const int is_with_external_gravity = (e->policy & engine_policy_external_gravity); - const int is_with_stars = (e->policy & engine_policy_stars); + const int is_with_feedback = (e->policy & engine_policy_feedback); for (int ind = 0; ind < num_elements; ind++) { struct cell *c = &((struct cell *)map_data)[ind]; @@ -474,7 +475,7 @@ void engine_make_hierarchical_tasks_mapper(void *map_data, int num_elements, /* And the gravity stuff */ if (is_with_self_gravity || is_with_external_gravity) engine_make_hierarchical_tasks_gravity(e, c); - if (is_with_stars) engine_make_hierarchical_tasks_stars(e, c); + if (is_with_feedback) engine_make_hierarchical_tasks_stars(e, c); } } @@ -3431,7 +3432,7 @@ void engine_maketasks(struct engine *e) { tic2 = getticks(); /* Construct the stars hydro loop over neighbours */ - if (e->policy & engine_policy_stars) { + if (e->policy & engine_policy_feedback) { threadpool_map(&e->threadpool, engine_make_starsloop_tasks_mapper, NULL, s->nr_cells, 1, 0, e); } diff --git a/src/engine.h b/src/engine.h index 827bebec8dd8102567c2a7b7ddf902cd3f959ee7..4ca1cc9ad3510ffa18c12ae38302c1cd049464c0 100644 --- a/src/engine.h +++ b/src/engine.h @@ -71,9 +71,10 @@ enum engine_policy { engine_policy_cooling = (1 << 13), engine_policy_sourceterms = (1 << 14), engine_policy_stars = (1 << 15), - engine_policy_structure_finding = (1 << 16) + engine_policy_structure_finding = (1 << 16), + engine_policy_feedback = (1 << 17) }; -#define engine_maxpolicy 16 +#define engine_maxpolicy 17 extern const char *engine_policy_names[]; /** diff --git a/src/stars/Default/stars_io.h b/src/stars/Default/stars_io.h index 3001d7c68585ce1aa86b3ccb22e66302563eee90..4c8f1fd2e7031237e6003efe35ba7977478ecaac 100644 --- a/src/stars/Default/stars_io.h +++ b/src/stars/Default/stars_io.h @@ -45,7 +45,7 @@ INLINE static void stars_read_particles(struct spart *sparts, sparts, mass); list[3] = io_make_input_field("ParticleIDs", LONGLONG, 1, COMPULSORY, UNIT_CONV_NO_UNITS, sparts, id); - list[4] = io_make_input_field("SmoothingLength", FLOAT, 1, COMPULSORY, + list[4] = io_make_input_field("SmoothingLength", FLOAT, 1, OPTIONAL, UNIT_CONV_LENGTH, sparts, h); }