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

Compute a new dithering vector at each rebuild.

parent 900b183c
Branches
Tags
1 merge request!952Gravity dithering
...@@ -1166,6 +1166,30 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) { ...@@ -1166,6 +1166,30 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) {
/* Allocate extra space for particles that will be created */ /* Allocate extra space for particles that will be created */
if (s->with_star_formation) space_allocate_extras(s, verbose); if (s->with_star_formation) space_allocate_extras(s, verbose);
if (s->dithering) {
/* Store the old dithering vector */
s->pos_dithering_old[0] = s->pos_dithering[0];
s->pos_dithering_old[1] = s->pos_dithering[1];
s->pos_dithering_old[2] = s->pos_dithering[2];
if (s->e->nodeID == 0) {
/* Compute the new dithering vector */
s->pos_dithering[0] =
s->dithering_ratio * s->width[0] * rand() / ((double)RAND_MAX);
s->pos_dithering[1] =
s->dithering_ratio * s->width[1] * rand() / ((double)RAND_MAX);
s->pos_dithering[2] =
s->dithering_ratio * s->width[2] * rand() / ((double)RAND_MAX);
#ifdef WITH_MPI
/* Tell everyone what value to use */
MPI_Bcast(s->pos_dithering, 3, MPI_DOUBLE, 0, MPI_COMM_WORLD);
#endif
}
}
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;
const int local_nodeID = s->e->nodeID; const int local_nodeID = s->e->nodeID;
...@@ -4650,6 +4674,9 @@ void space_init(struct space *s, struct swift_params *params, ...@@ -4650,6 +4674,9 @@ void space_init(struct space *s, struct swift_params *params,
s->sum_bpart_vel_norm = 0.f; s->sum_bpart_vel_norm = 0.f;
s->nr_queues = 1; /* Temporary value until engine construction */ s->nr_queues = 1; /* Temporary value until engine construction */
/* Initialise some randomness */
srand(42);
/* Are we generating gas from the DM-only ICs? */ /* Are we generating gas from the DM-only ICs? */
if (generate_gas_in_ics) { if (generate_gas_in_ics) {
space_generate_gas(s, cosmo, periodic, dim, verbose); space_generate_gas(s, cosmo, periodic, dim, verbose);
......
...@@ -123,6 +123,9 @@ struct space { ...@@ -123,6 +123,9 @@ struct space {
time (value at the previous rebuild) */ time (value at the previous rebuild) */
double pos_dithering_old[3]; double pos_dithering_old[3];
/*! Max dithering distance in units of the top-level cell sizes */
double dithering_ratio;
/*! The minimum top-level cell width allowed. */ /*! The minimum top-level cell width allowed. */
double cell_min; double cell_min;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment