Skip to content
Snippets Groups Projects
Commit fa54e95c authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Drift all particles before repartitioning

Drifting them afterwards can result in some cells having inconsistent particle lists, so this must be done first
parent 9ade785e
Branches
Tags
1 merge request!241Drift all particles before repartitioning
...@@ -39,4 +39,5 @@ PointMass: ...@@ -39,4 +39,5 @@ PointMass:
position_x: 50. # location of external point mass in internal units position_x: 50. # location of external point mass in internal units
position_y: 50. position_y: 50.
position_z: 50. position_z: 50.
mass: 1e10 # mass of external point mass in internal units mass: 1e11 # mass of external point mass in internal units
timestep_mult: 1e-2
...@@ -492,7 +492,7 @@ int main(int argc, char *argv[]) { ...@@ -492,7 +492,7 @@ int main(int argc, char *argv[]) {
engine_init_particles(&e, flag_entropy_ICs); engine_init_particles(&e, flag_entropy_ICs);
/* Write the state of the system before starting time integration. */ /* Write the state of the system before starting time integration. */
engine_dump_snapshot(&e); //engine_dump_snapshot(&e);
/* Legend */ /* Legend */
if (myrank == 0) if (myrank == 0)
...@@ -605,7 +605,7 @@ int main(int argc, char *argv[]) { ...@@ -605,7 +605,7 @@ int main(int argc, char *argv[]) {
#endif #endif
/* Write final output. */ /* Write final output. */
engine_dump_snapshot(&e); //engine_dump_snapshot(&e);
#ifdef WITH_MPI #ifdef WITH_MPI
if ((res = MPI_Finalize()) != MPI_SUCCESS) if ((res = MPI_Finalize()) != MPI_SUCCESS)
......
...@@ -2264,7 +2264,7 @@ void engine_prepare(struct engine *e) { ...@@ -2264,7 +2264,7 @@ void engine_prepare(struct engine *e) {
/* Run through the tasks and mark as skip or not. */ /* Run through the tasks and mark as skip or not. */
int rebuild = (e->forcerebuild || engine_marktasks(e)); int rebuild = (e->forcerebuild || engine_marktasks(e));
/* Collect the values of rebuild from all nodes. */ /* Collect the values of rebuild from all nodes. */
#ifdef WITH_MPI #ifdef WITH_MPI
int buff = 0; int buff = 0;
if (MPI_Allreduce(&rebuild, &buff, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD) != if (MPI_Allreduce(&rebuild, &buff, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD) !=
...@@ -2273,20 +2273,8 @@ void engine_prepare(struct engine *e) { ...@@ -2273,20 +2273,8 @@ void engine_prepare(struct engine *e) {
rebuild = buff; rebuild = buff;
#endif #endif
/* Did this not go through? */ /* And rebuild if necessary. */
if (rebuild) { if (rebuild) engine_rebuild(e);
/* First drift all particles to the current time */
e->drift_all = 1;
threadpool_map(&e->threadpool, runner_do_drift_mapper, e->s->cells_top,
e->s->nr_cells, sizeof(struct cell), 1, e);
/* Restore the default drifting policy */
e->drift_all = (e->policy & engine_policy_drift_all);
/* And now rebuild */
engine_rebuild(e);
}
/* Re-rank the tasks every now and then. */ /* Re-rank the tasks every now and then. */
if (e->tasks_age % engine_tasksreweight == 1) { if (e->tasks_age % engine_tasksreweight == 1) {
...@@ -2705,10 +2693,15 @@ void engine_step(struct engine *e) { ...@@ -2705,10 +2693,15 @@ void engine_step(struct engine *e) {
e->timeLastStatistics += e->deltaTimeStatistics; e->timeLastStatistics += e->deltaTimeStatistics;
} }
/* Drift only the necessary particles */ /* Drift only the necessary particles, that all means all particles
* if we are about to repartition. */
e->drift_all = (e->forcerepart != REPART_NONE) || e->drift_all;
threadpool_map(&e->threadpool, runner_do_drift_mapper, e->s->cells_top, threadpool_map(&e->threadpool, runner_do_drift_mapper, e->s->cells_top,
e->s->nr_cells, sizeof(struct cell), 1, e); e->s->nr_cells, sizeof(struct cell), 1, e);
/* Restore the default drifting policy */
e->drift_all = (e->policy & engine_policy_drift_all);
/* Re-distribute the particles amongst the nodes? */ /* Re-distribute the particles amongst the nodes? */
if (e->forcerepart != REPART_NONE) engine_repartition(e); if (e->forcerepart != REPART_NONE) engine_repartition(e);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment