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

Updated the unit tests with the new function signature.

parent f9ad06f3
Branches
Tags
1 merge request!509Cosmological time integration
......@@ -225,9 +225,9 @@ void zero_particle_fields(struct cell *c) {
/**
* @brief Ends the loop by adding the appropriate coefficients
*/
void end_calculation(struct cell *c) {
void end_calculation(struct cell *c, const struct cosmology *cosmo) {
for (int pid = 0; pid < c->count; pid++) {
hydro_end_density(&c->parts[pid]);
hydro_end_density(&c->parts[pid], cosmo);
/* Recover the common "Neighbour number" definition */
c->parts[pid].density.wcount *= pow_dimension(c->parts[pid].h);
......@@ -447,6 +447,10 @@ int main(int argc, char *argv[]) {
engine.hydro_properties = &hp;
engine.nodeID = NODE_ID;
struct cosmology cosmo;
cosmology_init_no_cosmo(&cosmo);
engine.cosmology = &cosmo;
struct runner runner;
runner.e = &engine;
......@@ -536,7 +540,7 @@ int main(int argc, char *argv[]) {
time += toc - tic;
/* Let's get physical ! */
end_calculation(main_cell);
end_calculation(main_cell, &cosmo);
/* Dump if necessary */
if (i % 50 == 0) {
......@@ -584,7 +588,7 @@ int main(int argc, char *argv[]) {
const ticks toc = getticks();
/* Let's get physical ! */
end_calculation(main_cell);
end_calculation(main_cell, &cosmo);
/* Dump */
sprintf(outputFileName, "brute_force_27_%s.dat", outputFileNameExtension);
......
......@@ -179,9 +179,9 @@ void zero_particle_fields(struct cell *c) {
/**
* @brief Ends the loop by adding the appropriate coefficients
*/
void end_calculation(struct cell *c) {
void end_calculation(struct cell *c, const struct cosmology *cosmo) {
for (int pid = 0; pid < c->count; pid++) {
hydro_end_density(&c->parts[pid]);
hydro_end_density(&c->parts[pid], cosmo);
/* Recover the common "Neighbour number" definition */
c->parts[pid].density.wcount *= pow_dimension(c->parts[pid].h);
......@@ -246,8 +246,8 @@ void test_pair_interactions(struct runner *runner, struct cell **ci,
vec_interaction(runner, *ci, *cj);
/* Let's get physical ! */
end_calculation(*ci);
end_calculation(*cj);
end_calculation(*ci, runner->e->cosmology);
end_calculation(*cj, runner->e->cosmology);
/* Dump if necessary */
dump_particle_fields(swiftOutputFileName, *ci, *cj);
......@@ -262,8 +262,8 @@ void test_pair_interactions(struct runner *runner, struct cell **ci,
serial_interaction(runner, *ci, *cj);
/* Let's get physical ! */
end_calculation(*ci);
end_calculation(*cj);
end_calculation(*ci, runner->e->cosmology);
end_calculation(*cj, runner->e->cosmology);
dump_particle_fields(bruteForceOutputFileName, *ci, *cj);
}
......@@ -425,6 +425,7 @@ int main(int argc, char *argv[]) {
double perturbation = 0.1, h_pert = 1.1;
struct space space;
struct engine engine;
struct cosmology cosmo;
struct runner *runner;
char c;
static long long partId = 0;
......@@ -507,6 +508,9 @@ int main(int argc, char *argv[]) {
engine.max_active_bin = num_time_bins;
engine.nodeID = NODE_ID;
cosmology_init_no_cosmo(&cosmo);
engine.cosmology = &cosmo;
if (posix_memalign((void **)&runner, SWIFT_STRUCT_ALIGNMENT,
sizeof(struct runner)) != 0) {
error("couldn't allocate runner");
......
......@@ -204,9 +204,9 @@ void zero_particle_fields(struct cell *c) {
/**
* @brief Ends the loop by adding the appropriate coefficients
*/
void end_calculation(struct cell *c) {
void end_calculation(struct cell *c, const struct cosmology *cosmo) {
for (int pid = 0; pid < c->count; pid++) {
hydro_end_density(&c->parts[pid]);
hydro_end_density(&c->parts[pid], cosmo);
}
}
......@@ -332,7 +332,7 @@ void test_boundary_conditions(struct cell **cells, struct runner runner,
#endif
/* Let's get physical ! */
end_calculation(main_cell);
end_calculation(main_cell, runner.e->cosmology);
/* Dump particles from the main cell. */
dump_particle_fields(swiftOutputFileName, main_cell, loc_i, loc_j, loc_k);
......@@ -370,7 +370,7 @@ void test_boundary_conditions(struct cell **cells, struct runner runner,
#endif
/* Let's get physical ! */
end_calculation(main_cell);
end_calculation(main_cell, runner.e->cosmology);
/* Dump */
dump_particle_fields(bruteForceOutputFileName, main_cell, loc_i, loc_j,
......@@ -493,6 +493,10 @@ int main(int argc, char *argv[]) {
struct runner runner;
runner.e = &engine;
struct cosmology cosmo;
cosmology_init_no_cosmo(&cosmo);
engine.cosmology = &cosmo;
/* Construct some cells */
struct cell *cells[dim * dim * dim];
static long long partId = 0;
......
......@@ -40,6 +40,10 @@ int main(int argc, char *argv[]) {
/* voronoi_set_box(box_anchor, box_side);*/
#endif
/* Start with some values for the cosmological paramters */
const float a = (float)random_uniform(0.8, 1.);
const float H = 0.f;
/* Create two random particles (don't do this at home !) */
struct part pi, pj;
for (size_t i = 0; i < sizeof(struct part) / sizeof(float); ++i) {
......@@ -136,14 +140,14 @@ int main(int argc, char *argv[]) {
/* --- Test the density loop --- */
/* Call the symmetric version */
runner_iact_density(r2, dx, pi.h, pj.h, &pi, &pj);
runner_iact_density(r2, dx, pi.h, pj.h, &pi, &pj, a, H);
/* Call the non-symmetric version */
runner_iact_nonsym_density(r2, dx, pi2.h, pj2.h, &pi2, &pj2);
runner_iact_nonsym_density(r2, dx, pi2.h, pj2.h, &pi2, &pj2, a, H);
dx[0] = -dx[0];
dx[1] = -dx[1];
dx[2] = -dx[2];
runner_iact_nonsym_density(r2, dx, pj2.h, pi2.h, &pj2, &pi2);
runner_iact_nonsym_density(r2, dx, pj2.h, pi2.h, &pj2, &pi2, a, H);
/* Check that the particles are the same */
i_ok = memcmp(&pi, &pi2, sizeof(struct part));
......@@ -155,14 +159,14 @@ int main(int argc, char *argv[]) {
/* --- Test the force loop --- */
/* Call the symmetric version */
runner_iact_force(r2, dx, pi.h, pj.h, &pi, &pj);
runner_iact_force(r2, dx, pi.h, pj.h, &pi, &pj, a, H);
/* Call the non-symmetric version */
runner_iact_nonsym_force(r2, dx, pi2.h, pj2.h, &pi2, &pj2);
runner_iact_nonsym_force(r2, dx, pi2.h, pj2.h, &pi2, &pj2, a, H);
dx[0] = -dx[0];
dx[1] = -dx[1];
dx[2] = -dx[2];
runner_iact_nonsym_force(r2, dx, pj2.h, pi2.h, &pj2, &pi2);
runner_iact_nonsym_force(r2, dx, pj2.h, pi2.h, &pj2, &pi2, a, H);
/* Check that the particles are the same */
#if defined(GIZMO_SPH)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment