From fbb51d98b56fc590b27bd37df1e58185bbab8aae Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Thu, 12 Sep 2019 13:19:08 +0200 Subject: [PATCH] Read the dithering ration from the parameter file. --- examples/main.c | 10 +++++++++- examples/main_fof.c | 3 ++- src/space.c | 10 ++++++++-- src/space.h | 4 ++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/examples/main.c b/examples/main.c index 9f9c0a4713..3cc4b2f9da 100644 --- a/examples/main.c +++ b/examples/main.c @@ -764,6 +764,13 @@ int main(int argc, char *argv[]) { params, "InitialConditions:cleanup_velocity_factors", 0); const int generate_gas_in_ics = parser_get_opt_param_int( params, "InitialConditions:generate_gas_in_ics", 0); + const int with_dithering = + parser_get_opt_param_int(params, "InitialConditions:dithering", 0); + int dithering_ratio = 0.; + if (with_dithering) { + dithering_ratio = + parser_get_param_double(params, "InitialConditions:dithering_ratio"); + } /* Initialise the cosmology */ if (with_cosmology) @@ -992,7 +999,8 @@ int main(int argc, char *argv[]) { space_init(&s, params, &cosmo, dim, parts, gparts, sparts, bparts, Ngas, Ngpart, Nspart, Nbpart, periodic, replicate, generate_gas_in_ics, with_hydro, with_self_gravity, with_star_formation, - with_DM_background_particles, talking, dry_run); + with_DM_background_particles, with_dithering, dithering_ratio, + talking, dry_run); if (myrank == 0) { clocks_gettime(&toc); diff --git a/examples/main_fof.c b/examples/main_fof.c index e4b1318743..98058e5c1a 100644 --- a/examples/main_fof.c +++ b/examples/main_fof.c @@ -511,7 +511,8 @@ int main(int argc, char *argv[]) { space_init(&s, params, &cosmo, dim, parts, gparts, sparts, bparts, Ngas, Ngpart, Nspart, Nbpart, periodic, replicate, /*generate_gas_in_ics=*/0, /*hydro=*/N_total[0] > 0, /*gravity=*/1, - /*with_star_formation=*/0, with_DM_background_particles, talking, + /*with_star_formation=*/0, with_DM_background_particles, + /*with_dithering=*/0, /*dithering_ratio=*/0., talking, /*dry_run=*/0); if (myrank == 0) { diff --git a/src/space.c b/src/space.c index f94b7cf8f3..95cfabe643 100644 --- a/src/space.c +++ b/src/space.c @@ -1187,6 +1187,10 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) { /* Tell everyone what value to use */ MPI_Bcast(s->pos_dithering, 3, MPI_DOUBLE, 0, MPI_COMM_WORLD); #endif + + if (verbose) + message("Dithering the particle positions by [%e %e %e]", + s->pos_dithering[0], s->pos_dithering[1], s->pos_dithering[2]); } } @@ -4629,8 +4633,8 @@ void space_init(struct space *s, struct swift_params *params, struct bpart *bparts, size_t Npart, size_t Ngpart, size_t Nspart, size_t Nbpart, int periodic, int replicate, int generate_gas_in_ics, int hydro, int self_gravity, - int star_formation, int DM_background, int verbose, - int dry_run) { + int star_formation, int DM_background, int dithering, + double dithering_ratio, int verbose, int dry_run) { /* Clean-up everything */ bzero(s, sizeof(struct space)); @@ -4672,6 +4676,8 @@ void space_init(struct space *s, struct swift_params *params, s->sum_gpart_vel_norm = 0.f; s->sum_spart_vel_norm = 0.f; s->sum_bpart_vel_norm = 0.f; + s->dithering = dithering; + s->dithering_ratio = dithering_ratio; s->nr_queues = 1; /* Temporary value until engine construction */ /* Initialise some randomness */ diff --git a/src/space.h b/src/space.h index 9d93b823f5..6efa2b4c9c 100644 --- a/src/space.h +++ b/src/space.h @@ -321,8 +321,8 @@ void space_init(struct space *s, struct swift_params *params, struct bpart *bparts, size_t Npart, size_t Ngpart, size_t Nspart, size_t Nbpart, int periodic, int replicate, int generate_gas_in_ics, int hydro, int gravity, - int star_formation, int DM_background, int verbose, - int dry_run); + int star_formation, int DM_background, int dithering, + double dithering_ratio, 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); -- GitLab