From 20f932f3bcc36e4c8bd63064e05248052f95770f Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Sun, 15 Jan 2017 23:39:44 +0000 Subject: [PATCH] Fixed all the tests but three. --- src/runner.h | 5 ++++- tests/test125cells.c | 34 ++++++++++++++++++++++++++-------- tests/test27cells.c | 11 +++++------ tests/testLogger.c | 1 + tests/testPair.c | 3 +-- tests/testSPHStep.c | 3 +-- tests/testTimeIntegration.c | 2 +- 7 files changed, 39 insertions(+), 20 deletions(-) diff --git a/src/runner.h b/src/runner.h index 2ee4b3e4c4..53e78b0065 100644 --- a/src/runner.h +++ b/src/runner.h @@ -56,7 +56,10 @@ struct runner { void runner_do_ghost(struct runner *r, struct cell *c, int timer); void runner_do_extra_ghost(struct runner *r, struct cell *c, int timer); void runner_do_sort(struct runner *r, struct cell *c, int flag, int clock); -void runner_do_kick(struct runner *r, struct cell *c, int timer); +void runner_do_drift(struct runner *r, struct cell *c, int timer); +void runner_do_kick1(struct runner *r, struct cell *c, int timer); +void runner_do_kick2(struct runner *r, struct cell *c, int timer); +void runner_do_end_force(struct runner *r, struct cell *c, int timer); void runner_do_init(struct runner *r, struct cell *c, int timer); void runner_do_cooling(struct runner *r, struct cell *c, int timer); void runner_do_grav_external(struct runner *r, struct cell *c, int timer); diff --git a/tests/test125cells.c b/tests/test125cells.c index 3ae80d952f..1c0e3e97b3 100644 --- a/tests/test125cells.c +++ b/tests/test125cells.c @@ -272,8 +272,7 @@ struct cell *make_cell(size_t n, const double offset[3], double size, double h, hydro_first_init_part(part, xpart); part->id = ++(*partId); - part->ti_begin = 0; - part->ti_end = 1; + part->time_bin = 1; #if defined(GIZMO_SPH) part->geometry.volume = part->conserved.mass / density; @@ -292,6 +291,11 @@ struct cell *make_cell(size_t n, const double offset[3], double size, double h, part->conserved.mass; #endif +#ifdef SWIFT_DEBUG_CHECKS + part->ti_drift = 1; + part->ti_kick = 1; +#endif + ++part; ++xpart; } @@ -364,10 +368,10 @@ void dump_particle_fields(char *fileName, struct cell *main_cell, #else main_cell->parts[pid].density.div_v, #endif - hydro_get_entropy(&main_cell->parts[pid], 0.f), - hydro_get_internal_energy(&main_cell->parts[pid], 0.f), - hydro_get_pressure(&main_cell->parts[pid], 0.f), - hydro_get_soundspeed(&main_cell->parts[pid], 0.f), + hydro_get_entropy(&main_cell->parts[pid]), + hydro_get_internal_energy(&main_cell->parts[pid]), + hydro_get_pressure(&main_cell->parts[pid]), + hydro_get_soundspeed(&main_cell->parts[pid]), main_cell->parts[pid].a_hydro[0], main_cell->parts[pid].a_hydro[1], main_cell->parts[pid].a_hydro[2], main_cell->parts[pid].force.h_dt, #if defined(GADGET2_SPH) @@ -572,6 +576,12 @@ int main(int argc, char *argv[]) { const ticks tic = getticks(); + /* Start with a gentle kick */ + //runner_do_kick1(&runner, main_cell, 0); + + /* And a gentle drift */ + //runner_do_drift(&runner, main_cell, 0); + /* First, sort stuff */ for (int j = 0; j < 125; ++j) runner_do_sort(&runner, cells[j], 0x1FFF, 0); @@ -640,7 +650,8 @@ int main(int argc, char *argv[]) { #endif /* Finally, give a gentle kick */ - runner_do_kick(&runner, main_cell, 0); + runner_do_end_force(&runner, main_cell, 0); + //runner_do_kick2(&runner, main_cell, 0); const ticks toc = getticks(); time += toc - tic; @@ -663,6 +674,12 @@ int main(int argc, char *argv[]) { const ticks tic = getticks(); + /* Kick the central cell */ + //runner_do_kick1(&runner, main_cell, 0); + + /* And drift it */ + runner_do_drift(&runner, main_cell, 0); + /* Initialise the particles */ for (int j = 0; j < 125; ++j) runner_do_init(&runner, cells[j], 0); @@ -728,7 +745,8 @@ int main(int argc, char *argv[]) { #endif /* Finally, give a gentle kick */ - runner_do_kick(&runner, main_cell, 0); + runner_do_end_force(&runner, main_cell, 0); + //runner_do_kick2(&runner, main_cell, 0); const ticks toc = getticks(); diff --git a/tests/test27cells.c b/tests/test27cells.c index fe628e8a5a..60d9ff8359 100644 --- a/tests/test27cells.c +++ b/tests/test27cells.c @@ -128,8 +128,7 @@ struct cell *make_cell(size_t n, double *offset, double size, double h, part->entropy_one_over_gamma = 1.f; #endif - part->ti_begin = 0; - part->ti_end = 1; + part->time_bin = 0; ++part; } } @@ -147,9 +146,9 @@ struct cell *make_cell(size_t n, double *offset, double size, double h, cell->loc[1] = offset[1]; cell->loc[2] = offset[2]; - cell->ti_old = 1; - cell->ti_end_min = 1; - cell->ti_end_max = 1; + cell->ti_old = 0; + cell->ti_end_min = 0; + cell->ti_end_max = 0; shuffle_particles(cell->parts, cell->count); @@ -390,7 +389,7 @@ int main(int argc, char *argv[]) { struct engine engine; engine.s = &space; engine.time = 0.1f; - engine.ti_current = 1; + engine.ti_current = 0; struct runner runner; runner.e = &engine; diff --git a/tests/testLogger.c b/tests/testLogger.c index 943e1d8b40..ec3b33b6a9 100644 --- a/tests/testLogger.c +++ b/tests/testLogger.c @@ -22,6 +22,7 @@ /* Some standard headers. */ #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> diff --git a/tests/testPair.c b/tests/testPair.c index ba1da815d9..09d820c54d 100644 --- a/tests/testPair.c +++ b/tests/testPair.c @@ -68,8 +68,7 @@ struct cell *make_cell(size_t n, double *offset, double size, double h, #else part->mass = density * volume / count; #endif - part->ti_begin = 0; - part->ti_end = 1; + part->time_bin = 1; ++part; } } diff --git a/tests/testSPHStep.c b/tests/testSPHStep.c index ff2ec841b2..0c7ae1d0d8 100644 --- a/tests/testSPHStep.c +++ b/tests/testSPHStep.c @@ -61,8 +61,7 @@ struct cell *make_cell(size_t N, float cellSize, int offset[3], int id_offset) { offset[2] * cellSize + z * cellSize / N + cellSize / (2 * N); part->h = h; part->id = x * N * N + y * N + z + id_offset; - part->ti_begin = 0; - part->ti_end = 1; + part->time_bin = 1; ++part; } } diff --git a/tests/testTimeIntegration.c b/tests/testTimeIntegration.c index f39adaee90..42a3d224f4 100644 --- a/tests/testTimeIntegration.c +++ b/tests/testTimeIntegration.c @@ -115,7 +115,7 @@ int main() { c.parts[0].a_hydro[1] = -(G * M_sun * c.parts[0].x[1] / r * r * r); /* Kick... */ - runner_do_kick(&run, &c, 0); + runner_do_kick2(&run, &c, 0); } /* Clean-up */ -- GitLab