diff --git a/examples/main.c b/examples/main.c index 6b77b9ffaaabe31f3e63a5ca7d519b6370edf346..596344d3276b3cf764a71dff74af48cd4c35cd55 100644 --- a/examples/main.c +++ b/examples/main.c @@ -140,7 +140,6 @@ int main(int argc, char *argv[]) { struct stars_props stars_properties; struct part *parts = NULL; struct phys_const prog_const; - struct sourceterms sourceterms; struct space s; struct spart *sparts = NULL; struct unit_system us; @@ -844,7 +843,7 @@ int main(int argc, char *argv[]) { if (myrank == 0) clocks_gettime(&tic); space_init(&s, params, &cosmo, dim, parts, gparts, sparts, Ngas, Ngpart, Nspart, periodic, replicate, generate_gas_in_ics, with_hydro, - with_self_gravity, talking, dry_run); + with_self_gravity, with_star_formation, talking, dry_run); if (myrank == 0) { clocks_gettime(&toc); @@ -947,7 +946,7 @@ int main(int argc, char *argv[]) { engine_init(&e, &s, params, N_total[0], N_total[1], N_total[2], engine_policies, talking, &reparttype, &us, &prog_const, &cosmo, &hydro_properties, &gravity_properties, &stars_properties, - &mesh, &potential, &cooling_func, &chemistry, &sourceterms); + &mesh, &potential, &cooling_func, &chemistry); engine_config(0, &e, params, nr_nodes, myrank, nr_threads, with_aff, talking, restart_file); diff --git a/src/space.c b/src/space.c index 66cea7a7c55552b0c9ee9a151dc7ef7ed0cec5ab..7cfdaa9a71db72139f42f9fb55d06dc5e113bff5 100644 --- a/src/space.c +++ b/src/space.c @@ -977,7 +977,7 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) { space_regrid(s, verbose); /* Allocate extra space for particles that will be created */ - space_allocate_extras(s, verbose); + if (s->with_star_formation) space_allocate_extras(s, verbose); struct cell *cells_top = s->cells_top; const integertime_t ti_current = (s->e != NULL) ? s->e->ti_current : 0; @@ -1027,9 +1027,9 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) { /* Initialise the counters, including buffer space for future particles */ for (int i = 0; i < s->nr_cells; ++i) { - cell_part_counts[i] = 0; // space_extra_parts; - cell_gpart_counts[i] = 0; // space_extra_gparts; - cell_spart_counts[i] = 0; // space_extra_sparts; + cell_part_counts[i] = 0; + cell_gpart_counts[i] = 0; + cell_spart_counts[i] = 0; } /* Run through the particles and get their cell index. */ @@ -1567,7 +1567,7 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) { /* Re-order the extra particles such that they are at the end of their cell's memory pool. */ - space_reorder_extras(s, verbose); + if (s->with_star_formation) space_reorder_extras(s, verbose); /* At this point, we have the upper-level cells. Now recursively split each cell to get the full AMR grid. */ @@ -3630,6 +3630,7 @@ void space_convert_quantities(struct space *s, int verbose) { * @param generate_gas_in_ics Are we generating gas particles from the gparts? * @param hydro flag whether we are doing hydro or not? * @param self_gravity flag whether we are doing gravity or not? + * @param star_formation flag whether we are doing star formation or not? * @param verbose Print messages to stdout or not. * @param dry_run If 1, just initialise stuff, don't do anything with the parts. * @@ -3643,7 +3644,8 @@ void space_init(struct space *s, struct swift_params *params, struct part *parts, struct gpart *gparts, struct spart *sparts, size_t Npart, size_t Ngpart, size_t Nspart, int periodic, int replicate, int generate_gas_in_ics, int hydro, - int self_gravity, int verbose, int dry_run) { + int self_gravity, int star_formation, int verbose, + int dry_run) { /* Clean-up everything */ bzero(s, sizeof(struct space)); @@ -3655,6 +3657,7 @@ void space_init(struct space *s, struct swift_params *params, s->periodic = periodic; s->with_self_gravity = self_gravity; s->with_hydro = hydro; + s->with_star_formation = star_formation; s->nr_parts = Npart; s->nr_gparts = Ngpart; s->nr_sparts = Nspart; @@ -3857,6 +3860,9 @@ void space_init(struct space *s, struct swift_params *params, last_cell_id = 1; #endif + /* Do we want any spare particles for on the fly cration? */ + if (!star_formation) space_extra_sparts = 0; + /* Build the cells recursively. */ if (!dry_run) space_regrid(s, verbose); } diff --git a/src/space.h b/src/space.h index c422bce97b39049fe3e45a5d9c4ec388a77da8fb..a1280945d2aa232cbb5e5b519266bc7058e5dc57 100644 --- a/src/space.h +++ b/src/space.h @@ -46,7 +46,7 @@ struct cosmology; #define space_maxsize_default 8000000 #define space_extra_parts_default 0 #define space_extra_gparts_default 0 -#define space_extra_sparts_default 40 +#define space_extra_sparts_default 100 #define space_expected_max_nr_strays_default 100 #define space_subsize_pair_hydro_default 256000000 #define space_subsize_self_hydro_default 32000 @@ -96,6 +96,9 @@ struct space { /*! Are we doing gravity? */ int with_self_gravity; + /*! Are we doing star formation? */ + int with_star_formation; + /*! Width of the top-level cells. */ double width[3]; @@ -266,7 +269,7 @@ void space_init(struct space *s, struct swift_params *params, struct part *parts, struct gpart *gparts, struct spart *sparts, size_t Npart, size_t Ngpart, size_t Nspart, int periodic, int replicate, int generate_gas_in_ics, int hydro, int gravity, - int verbose, int dry_run); + int star_formation, int verbose, int dry_run); void space_sanitize(struct space *s); void space_map_cells_pre(struct space *s, int full, void (*fun)(struct cell *c, void *data), void *data);