Skip to content
Snippets Groups Projects
Commit 8dfc2f12 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Only activate the creation of extra spart when we are running the star formation policy.

parent fbc6c104
No related branches found
No related tags found
2 merge requests!688Star formation (non-MPI),!684Add star particles on-the-fly
...@@ -140,7 +140,6 @@ int main(int argc, char *argv[]) { ...@@ -140,7 +140,6 @@ int main(int argc, char *argv[]) {
struct stars_props stars_properties; struct stars_props stars_properties;
struct part *parts = NULL; struct part *parts = NULL;
struct phys_const prog_const; struct phys_const prog_const;
struct sourceterms sourceterms;
struct space s; struct space s;
struct spart *sparts = NULL; struct spart *sparts = NULL;
struct unit_system us; struct unit_system us;
...@@ -844,7 +843,7 @@ int main(int argc, char *argv[]) { ...@@ -844,7 +843,7 @@ int main(int argc, char *argv[]) {
if (myrank == 0) clocks_gettime(&tic); if (myrank == 0) clocks_gettime(&tic);
space_init(&s, params, &cosmo, dim, parts, gparts, sparts, Ngas, Ngpart, space_init(&s, params, &cosmo, dim, parts, gparts, sparts, Ngas, Ngpart,
Nspart, periodic, replicate, generate_gas_in_ics, with_hydro, 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) { if (myrank == 0) {
clocks_gettime(&toc); clocks_gettime(&toc);
...@@ -947,7 +946,7 @@ int main(int argc, char *argv[]) { ...@@ -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_init(&e, &s, params, N_total[0], N_total[1], N_total[2],
engine_policies, talking, &reparttype, &us, &prog_const, &cosmo, engine_policies, talking, &reparttype, &us, &prog_const, &cosmo,
&hydro_properties, &gravity_properties, &stars_properties, &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, engine_config(0, &e, params, nr_nodes, myrank, nr_threads, with_aff,
talking, restart_file); talking, restart_file);
......
...@@ -977,7 +977,7 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) { ...@@ -977,7 +977,7 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) {
space_regrid(s, verbose); space_regrid(s, verbose);
/* Allocate extra space for particles that will be created */ /* 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; struct cell *cells_top = s->cells_top;
const integertime_t ti_current = (s->e != NULL) ? s->e->ti_current : 0; 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) { ...@@ -1027,9 +1027,9 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) {
/* Initialise the counters, including buffer space for future particles */ /* Initialise the counters, including buffer space for future particles */
for (int i = 0; i < s->nr_cells; ++i) { for (int i = 0; i < s->nr_cells; ++i) {
cell_part_counts[i] = 0; // space_extra_parts; cell_part_counts[i] = 0;
cell_gpart_counts[i] = 0; // space_extra_gparts; cell_gpart_counts[i] = 0;
cell_spart_counts[i] = 0; // space_extra_sparts; cell_spart_counts[i] = 0;
} }
/* Run through the particles and get their cell index. */ /* Run through the particles and get their cell index. */
...@@ -1567,7 +1567,7 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) { ...@@ -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 /* Re-order the extra particles such that they are at the end of their cell's
memory pool. */ 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 /* At this point, we have the upper-level cells. Now recursively split each
cell to get the full AMR grid. */ cell to get the full AMR grid. */
...@@ -3630,6 +3630,7 @@ void space_convert_quantities(struct space *s, int verbose) { ...@@ -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 generate_gas_in_ics Are we generating gas particles from the gparts?
* @param hydro flag whether we are doing hydro or not? * @param hydro flag whether we are doing hydro or not?
* @param self_gravity flag whether we are doing gravity 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 verbose Print messages to stdout or not.
* @param dry_run If 1, just initialise stuff, don't do anything with the parts. * @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, ...@@ -3643,7 +3644,8 @@ void space_init(struct space *s, struct swift_params *params,
struct part *parts, struct gpart *gparts, struct spart *sparts, struct part *parts, struct gpart *gparts, struct spart *sparts,
size_t Npart, size_t Ngpart, size_t Nspart, int periodic, size_t Npart, size_t Ngpart, size_t Nspart, int periodic,
int replicate, int generate_gas_in_ics, int hydro, 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 */ /* Clean-up everything */
bzero(s, sizeof(struct space)); bzero(s, sizeof(struct space));
...@@ -3655,6 +3657,7 @@ void space_init(struct space *s, struct swift_params *params, ...@@ -3655,6 +3657,7 @@ void space_init(struct space *s, struct swift_params *params,
s->periodic = periodic; s->periodic = periodic;
s->with_self_gravity = self_gravity; s->with_self_gravity = self_gravity;
s->with_hydro = hydro; s->with_hydro = hydro;
s->with_star_formation = star_formation;
s->nr_parts = Npart; s->nr_parts = Npart;
s->nr_gparts = Ngpart; s->nr_gparts = Ngpart;
s->nr_sparts = Nspart; s->nr_sparts = Nspart;
...@@ -3857,6 +3860,9 @@ void space_init(struct space *s, struct swift_params *params, ...@@ -3857,6 +3860,9 @@ void space_init(struct space *s, struct swift_params *params,
last_cell_id = 1; last_cell_id = 1;
#endif #endif
/* Do we want any spare particles for on the fly cration? */
if (!star_formation) space_extra_sparts = 0;
/* Build the cells recursively. */ /* Build the cells recursively. */
if (!dry_run) space_regrid(s, verbose); if (!dry_run) space_regrid(s, verbose);
} }
......
...@@ -46,7 +46,7 @@ struct cosmology; ...@@ -46,7 +46,7 @@ struct cosmology;
#define space_maxsize_default 8000000 #define space_maxsize_default 8000000
#define space_extra_parts_default 0 #define space_extra_parts_default 0
#define space_extra_gparts_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_expected_max_nr_strays_default 100
#define space_subsize_pair_hydro_default 256000000 #define space_subsize_pair_hydro_default 256000000
#define space_subsize_self_hydro_default 32000 #define space_subsize_self_hydro_default 32000
...@@ -96,6 +96,9 @@ struct space { ...@@ -96,6 +96,9 @@ struct space {
/*! Are we doing gravity? */ /*! Are we doing gravity? */
int with_self_gravity; int with_self_gravity;
/*! Are we doing star formation? */
int with_star_formation;
/*! Width of the top-level cells. */ /*! Width of the top-level cells. */
double width[3]; double width[3];
...@@ -266,7 +269,7 @@ void space_init(struct space *s, struct swift_params *params, ...@@ -266,7 +269,7 @@ void space_init(struct space *s, struct swift_params *params,
struct part *parts, struct gpart *gparts, struct spart *sparts, struct part *parts, struct gpart *gparts, struct spart *sparts,
size_t Npart, size_t Ngpart, size_t Nspart, int periodic, size_t Npart, size_t Ngpart, size_t Nspart, int periodic,
int replicate, int generate_gas_in_ics, int hydro, int gravity, 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_sanitize(struct space *s);
void space_map_cells_pre(struct space *s, int full, void space_map_cells_pre(struct space *s, int full,
void (*fun)(struct cell *c, void *data), void *data); void (*fun)(struct cell *c, void *data), void *data);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment