From b3dbade26b4de9cb90ef770c627473a54c47f5d8 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Fri, 9 Dec 2016 12:55:31 +0000 Subject: [PATCH] Cleaning up --- examples/SedovBlast_3D/sedov.yml | 3 --- src/active.h | 26 ------------------ src/cell.c | 15 +---------- src/engine.c | 45 +++----------------------------- src/engine.h | 3 --- src/runner.c | 14 +++------- 6 files changed, 8 insertions(+), 98 deletions(-) diff --git a/examples/SedovBlast_3D/sedov.yml b/examples/SedovBlast_3D/sedov.yml index dc22950378..1cc4aced9a 100644 --- a/examples/SedovBlast_3D/sedov.yml +++ b/examples/SedovBlast_3D/sedov.yml @@ -6,9 +6,6 @@ InternalUnitSystem: UnitCurrent_in_cgs: 1 # Amperes UnitTemp_in_cgs: 1 # Kelvin -#Scheduler: -# max_top_level_cells: 3 - # Parameters governing the time integration TimeIntegration: time_begin: 0. # The starting time of the simulation (in internal units). diff --git a/src/active.h b/src/active.h index 903b3c092e..df7cbd6a63 100644 --- a/src/active.h +++ b/src/active.h @@ -47,32 +47,6 @@ __attribute__((always_inline)) INLINE static int cell_is_drifted( c->ti_old, e->ti_current); #endif - /* if (c->ti_old != e->ti_current) { */ - - /* int wrong = 0; */ - /* for (int i = 0; i < c->count; ++i) { */ - /* if (c->parts[i].ti_old < e->ti_current) ++wrong; */ - /* } */ - - /* message( */ - /* "Cell has not been drifted to the current time c->ti_old=%d, " */ - /* "e->ti_current=%d wrong=%d c->count=%d c->drift=%p, c->depth=%d, - * c=%p, c->super=%p, c->parent=%p ", */ - /* c->ti_old, e->ti_current, wrong, c->count, c->drift, c->depth, c, - * c->super, c->parent); */ - - /* cell_drift((struct cell*)c, e); */ - - /* message( */ - /* "Cell has not been drifted to the current time c->ti_old=%d, " */ - /* "e->ti_current=%d wrong=%d c->count=%d c->drift=%p, c->depth=%d, - * c=%p, c->super=%p, c->parent=%p ", */ - /* c->ti_old, e->ti_current, wrong, c->count, c->drift, c->depth, c, - * c->super, c->parent); */ - - /* error("AAAAA"); */ - /* } */ - return (c->ti_old == e->ti_current); } diff --git a/src/cell.c b/src/cell.c index 2b34bfcada..e6fa623e0a 100644 --- a/src/cell.c +++ b/src/cell.c @@ -717,14 +717,6 @@ void cell_check_drift_point(struct cell *c, void *data) { if (c->ti_old != ti_current) error("Cell in an incorrect time-zone! c->ti_old=%d ti_current=%d", c->ti_old, ti_current); - - /* for (int i = 0; i < c->count; ++i) */ - /* if (c->parts[i].ti_old != ti_current) */ - /* error( */ - /* "Particle in an incorrect time-zone! part->ti_old=%d c->ti_old=%d " - */ - /* "ti_current=%d", */ - /* c->parts[i].ti_old, c->ti_old, ti_current); */ } /** @@ -887,12 +879,6 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { } } - /* Activate the drift on both sides */ - if (ci == c && cj != NULL && cj->drift != NULL) - scheduler_activate(s, cj->drift); - if (cj == c && ci != NULL && ci->drift != NULL) - scheduler_activate(s, ci->drift); - /* Check whether there was too much particle motion */ if (t->type == task_type_pair || t->type == task_type_sub_pair) { if (t->tight && @@ -970,6 +956,7 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { if (c->extra_ghost != NULL) scheduler_activate(s, c->extra_ghost); if (c->ghost != NULL) scheduler_activate(s, c->ghost); if (c->init != NULL) scheduler_activate(s, c->init); + if (c->drift != NULL) scheduler_activate(s, c->drift); if (c->kick != NULL) scheduler_activate(s, c->kick); if (c->cooling != NULL) scheduler_activate(s, c->cooling); if (c->sourceterms != NULL) scheduler_activate(s, c->sourceterms); diff --git a/src/engine.c b/src/engine.c index 08811e3502..1215e789c2 100644 --- a/src/engine.c +++ b/src/engine.c @@ -1988,16 +1988,6 @@ void engine_marktasks_mapper(void *map_data, int num_elements, if (t->ci->ti_end_min <= ti_end) scheduler_activate(s, t); } - /* Self? */ - else if (t->type == task_type_self || t->type == task_type_sub_self) { - - /* Local pointers. */ - // const struct cell *ci = t->ci; - - /* Activate the drift */ - // if (ci->drift) scheduler_activate(s, ci->drift); - } - /* Pair? */ else if (t->type == task_type_pair || t->type == task_type_sub_pair) { @@ -2005,10 +1995,6 @@ void engine_marktasks_mapper(void *map_data, int num_elements, const struct cell *ci = t->ci; const struct cell *cj = t->cj; - /* Activate the drift on both sides */ - // if (ci->drift) scheduler_activate(s, ci->drift); - // if (cj->drift) scheduler_activate(s, cj->drift); - /* Too much particle movement? */ if (t->tight && (max(ci->h_max, cj->h_max) + ci->dx_max + cj->dx_max > cj->dmin || @@ -2258,13 +2244,7 @@ void engine_prepare(struct engine *e, int nodrift) { if (rebuild) { /* Drift all particles to the current time if needed. */ - if (!nodrift) { - // e->drift_all = 1; - engine_drift_all(e); - - /* Restore the default drifting policy */ - // e->drift_all = (e->policy & engine_policy_drift_all); - } + if (!nodrift) engine_drift_all(e); #ifdef SWIFT_DEBUG_CHECKS /* Check that all cells have been drifted to the current time */ @@ -2272,11 +2252,6 @@ void engine_prepare(struct engine *e, int nodrift) { #endif engine_rebuild(e); - -#ifdef SWIFT_DEBUG_CHECKS - /* Check that all cells have been drifted to the current time */ - space_check_drift_point(e->s, e->ti_current); -#endif } /* Re-rank the tasks every now and then. */ @@ -2621,12 +2596,8 @@ void engine_step(struct engine *e) { snapshot_drift_time = e->timeStep; /* Drift everybody to the snapshot position */ - // e->drift_all = 1; engine_drift_all(e); - /* Restore the default drifting policy */ - // e->drift_all = (e->policy & engine_policy_drift_all); - /* Dump... */ engine_dump_snapshot(e); @@ -2658,17 +2629,14 @@ void engine_step(struct engine *e) { /* Drift only the necessary particles, that means all particles * if we are about to repartition. */ const int repart = (e->forcerepart != REPART_NONE); - // e->drift_all = repart || e->drift_all; - if (repart) engine_drift_all(e); + const int drift_all = (e->policy & engine_policy_drift_all); + if (repart || drift_all) engine_drift_all(e); /* Re-distribute the particles amongst the nodes? */ if (repart) engine_repartition(e); /* Prepare the space. */ - engine_prepare(e, (e->drift_all || repart)); - - /* Restore the default drifting policy */ - // e->drift_all = (e->policy & engine_policy_drift_all); + engine_prepare(e, (drift_all || repart)); if (e->verbose) engine_print_task_counts(e); @@ -2716,14 +2684,10 @@ void engine_unskip(struct engine *e) { void engine_drift_all(struct engine *e) { - e->drift_all = 1; - const ticks tic = getticks(); threadpool_map(&e->threadpool, runner_do_drift_mapper, e->s->cells_top, e->s->nr_cells, sizeof(struct cell), 1, e); - e->drift_all = e->policy & engine_policy_drift_all; - if (e->verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), clocks_getunit()); @@ -3064,7 +3028,6 @@ void engine_init(struct engine *e, struct space *s, e->timeStep = 0.; e->timeBase = 0.; e->timeBase_inv = 0.; - e->drift_all = (policy & engine_policy_drift_all); e->internalUnits = internal_units; e->timeFirstSnapshot = parser_get_param_double(params, "Snapshots:time_first"); diff --git a/src/engine.h b/src/engine.h index 1960b3dc4a..5d72c23cda 100644 --- a/src/engine.h +++ b/src/engine.h @@ -133,9 +133,6 @@ struct engine { /* Minimal ti_end for the next time-step */ int ti_end_min; - /* Are we drifting all particles now ? */ - int drift_all; - /* Number of particles updated */ size_t updates, g_updates; diff --git a/src/runner.c b/src/runner.c index baacd5c5ab..3865b1b2ae 100644 --- a/src/runner.c +++ b/src/runner.c @@ -733,17 +733,9 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) { } } - if (count) { + if (count) message("Smoothing length failed to converge on %i particles.", count); - for (int i = 0; i < count; ++i) { - struct part *restrict p = &parts[pid[i]]; - struct xpart *restrict xp = &xparts[pid[i]]; - - printParticle_single(p, xp); - } - } - /* Be clean */ free(pid); } @@ -772,8 +764,8 @@ static void runner_do_unskip(struct cell *c, struct engine *e, int drift) { if (c->split) { for (int k = 0; k < 8; k++) { if (c->progeny[k] != NULL) { - struct cell *cp = c->progeny[k]; - runner_do_unskip(cp, e, 0); + struct cell *cp = c->progeny[k]; + runner_do_unskip(cp, e, 0); } } } -- GitLab