From ed1fb797455100a925b69c605556f4cc4add937c Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Wed, 12 Sep 2018 12:13:04 +0200 Subject: [PATCH] Prevent users from generating gas from the ICs if they are running without the hydrodynamics policy. --- examples/main.c | 2 +- src/space.c | 13 +++++++++++-- src/space.h | 5 ++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/examples/main.c b/examples/main.c index a15b62b06c..18fc011d52 100644 --- a/examples/main.c +++ b/examples/main.c @@ -780,7 +780,7 @@ int main(int argc, char *argv[]) { /* Initialize the space with these data. */ if (myrank == 0) clocks_gettime(&tic); space_init(&s, params, &cosmo, dim, parts, gparts, sparts, Ngas, Ngpart, - Nspart, periodic, replicate, generate_gas_in_ics, + Nspart, periodic, replicate, generate_gas_in_ics, with_hydro, with_self_gravity, talking, dry_run); if (myrank == 0) { diff --git a/src/space.c b/src/space.c index 281c452a9d..604fbdd86f 100644 --- a/src/space.c +++ b/src/space.c @@ -2744,6 +2744,7 @@ void space_convert_quantities(struct space *s, int verbose) { * @param periodic flag whether the domain is periodic or not. * @param replicate How many replications along each direction do we want? * @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 verbose Print messages to stdout or not. * @param dry_run If 1, just initialise stuff, don't do anything with the parts. @@ -2757,8 +2758,8 @@ void space_init(struct space *s, struct swift_params *params, const struct cosmology *cosmo, double dim[3], 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 self_gravity, - int verbose, int dry_run) { + int replicate, int generate_gas_in_ics, int hydro, + int self_gravity, int verbose, int dry_run) { /* Clean-up everything */ bzero(s, sizeof(struct space)); @@ -2769,6 +2770,7 @@ void space_init(struct space *s, struct swift_params *params, s->dim[2] = dim[2]; s->periodic = periodic; s->gravity = self_gravity; + s->hydro = hydro; s->nr_parts = Npart; s->size_parts = Npart; s->parts = parts; @@ -3085,6 +3087,13 @@ void space_replicate(struct space *s, int replicate, int verbose) { void space_generate_gas(struct space *s, const struct cosmology *cosmo, int verbose) { + /* Check that this is a sensible ting to do */ + if (!s->hydro) + error( + "Cannot generate gas from ICs if we are running without " + "hydrodynamics. Need to run with -s and the corresponding " + "hydrodynamics parameters in the YAML file."); + if (verbose) message("Generating gas particles from gparts"); /* Store the current values */ diff --git a/src/space.h b/src/space.h index af6d58c6c7..94c7f5b388 100644 --- a/src/space.h +++ b/src/space.h @@ -79,6 +79,9 @@ struct space { /*! Extra space information needed for some hydro schemes. */ struct hydro_space hs; + /*! Are we doing hydrodynamics? */ + int hydro; + /*! Are we doing gravity? */ int gravity; @@ -212,7 +215,7 @@ void space_init(struct space *s, struct swift_params *params, const struct cosmology *cosmo, double dim[3], 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 gravity, + int replicate, int generate_gas_in_ics, int hydro, int gravity, int verbose, int dry_run); void space_sanitize(struct space *s); void space_map_cells_pre(struct space *s, int full, -- GitLab