Commit a84ce73e authored by Matthieu Schaller's avatar Matthieu Schaller

Merge branch 'test125cells' into 'master'

New addition to the test suite: A perturbed version of the 125 cells case



See merge request !341
parents 0058b193 2b171049
......@@ -47,6 +47,8 @@ tests/brute_force_27_perturbed.dat
tests/swift_dopair_27_perturbed.dat
tests/brute_force_125_standard.dat
tests/swift_dopair_125_standard.dat
tests/brute_force_125_perturbed.dat
tests/swift_dopair_125_perturbed.dat
tests/testGreetings
tests/testReading
tests/input.hdf5
......@@ -65,6 +67,7 @@ tests/parser_output.yml
tests/test27cells.sh
tests/test27cellsPerturbed.sh
tests/test125cells.sh
tests/test125cellsPerturbed.sh
tests/testPair.sh
tests/testPairPerturbed.sh
tests/testParser.sh
......
......@@ -853,6 +853,7 @@ AC_CONFIG_FILES([tests/testPairPerturbed.sh], [chmod +x tests/testPairPerturbed.
AC_CONFIG_FILES([tests/test27cells.sh], [chmod +x tests/test27cells.sh])
AC_CONFIG_FILES([tests/test27cellsPerturbed.sh], [chmod +x tests/test27cellsPerturbed.sh])
AC_CONFIG_FILES([tests/test125cells.sh], [chmod +x tests/test125cells.sh])
AC_CONFIG_FILES([tests/test125cellsPerturbed.sh], [chmod +x tests/test125cellsPerturbed.sh])
AC_CONFIG_FILES([tests/testParser.sh], [chmod +x tests/testParser.sh])
# Save the compilation options
......
......@@ -1669,10 +1669,10 @@ void engine_make_self_gravity_tasks(struct engine *e) {
/* Make the ghosts implicit and add the dependencies */
for (int n = 0; n < n_ghosts / 2; ++n) {
ghosts[2 * n + 0] = scheduler_addtask(sched, task_type_grav_ghost,
task_subtype_none, 0, 0, NULL, NULL);
ghosts[2 * n + 1] = scheduler_addtask(sched, task_type_grav_ghost,
task_subtype_none, 0, 0, NULL, NULL);
ghosts[2 * n + 0] = scheduler_addtask(
sched, task_type_grav_ghost, task_subtype_none, 0, 0, NULL, NULL);
ghosts[2 * n + 1] = scheduler_addtask(
sched, task_type_grav_ghost, task_subtype_none, 0, 0, NULL, NULL);
ghosts[2 * n + 0]->implicit = 1;
ghosts[2 * n + 1]->implicit = 1;
scheduler_addunlock(sched, ghosts[2 * n + 0], s->grav_top_level);
......@@ -3063,7 +3063,7 @@ void engine_print_stats(struct engine *e) {
e->policy & engine_policy_self_gravity);
/* Be verbose about this */
if(e->nodeID == 0) message("Saving statistics at t=%e.", e->time);
if (e->nodeID == 0) message("Saving statistics at t=%e.", e->time);
#else
if (e->verbose) message("Saving statistics at t=%e.", e->time);
#endif
......
......@@ -37,6 +37,8 @@
#include "space.h"
#include "timers.h"
#ifdef HAVE_FFTW
/**
* @brief Returns 1D index of a 3D NxNxN array using row-major style.
*
......@@ -137,6 +139,8 @@ __attribute__((always_inline)) INLINE static void mesh_to_multipole_CIC(
m->pot.F_000 += pot[row_major_id(i + 1, j + 1, k + 1, N)] * dx * dy * dz;
}
#endif
/**
* @brief Computes the potential on the top multipoles using a Fourier transform
*
......
......@@ -2432,19 +2432,20 @@ void space_getcells(struct space *s, int nr_cells, struct cell **cells) {
}
void space_synchronize_particle_positions_mapper(void *map_data, int nr_gparts,
void *extra_data) {
void *extra_data) {
/* Unpack the data */
struct gpart *restrict gparts = (struct gpart *)map_data;
struct space *s = (struct space*) extra_data;
struct space *s = (struct space *)extra_data;
for (int k = 0; k < nr_gparts; k++) {
/* Get the particle */
const struct gpart *restrict gp = &gparts[k];
if(gp->type == swift_type_dark_matter) continue;
else if(gp->type == swift_type_gas) {
if (gp->type == swift_type_dark_matter)
continue;
else if (gp->type == swift_type_gas) {
/* Get it's gassy friend */
struct part *p = &s->parts[-gp->id_or_neg_offset];
......@@ -2460,7 +2461,7 @@ void space_synchronize_particle_positions_mapper(void *map_data, int nr_gparts,
xp->v_full[2] = gp->v_full[2];
}
else if(gp->type == swift_type_star) {
else if (gp->type == swift_type_star) {
/* Get it's stellar friend */
struct spart *sp = &s->sparts[-gp->id_or_neg_offset];
......@@ -2470,17 +2471,16 @@ void space_synchronize_particle_positions_mapper(void *map_data, int nr_gparts,
sp->x[1] = gp->x[1];
sp->x[2] = gp->x[2];
}
}
}
void space_synchronize_particle_positions(struct space *s) {
if ((s->nr_gparts > 0 && s->nr_parts > 0) ||
(s->nr_gparts > 0 && s->nr_sparts > 0))
threadpool_map(&s->e->threadpool, space_synchronize_particle_positions_mapper,
s->gparts, s->nr_gparts, sizeof(struct gpart), 1000, (void*)s);
if ((s->nr_gparts > 0 && s->nr_parts > 0) ||
(s->nr_gparts > 0 && s->nr_sparts > 0))
threadpool_map(&s->e->threadpool,
space_synchronize_particle_positions_mapper, s->gparts,
s->nr_gparts, sizeof(struct gpart), 1000, (void *)s);
}
/**
......
......@@ -22,7 +22,7 @@ AM_LDFLAGS = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(FFTW_LIBS
# List of programs and scripts to run in the test suite
TESTS = testGreetings testMaths testReading.sh testSingle testKernel testSymmetry \
testPair.sh testPairPerturbed.sh test27cells.sh test27cellsPerturbed.sh \
testParser.sh testSPHStep test125cells.sh testFFT \
testParser.sh testSPHStep test125cells.sh test125cellsPerturbed.sh testFFT \
testAdiabaticIndex testRiemannExact testRiemannTRRS testRiemannHLLC \
testMatrixInversion testThreadpool testDump testLogger \
testVoronoi1D testVoronoi2D testVoronoi3D
......@@ -92,7 +92,7 @@ testLogger_SOURCES = testLogger.c
# Files necessary for distribution
EXTRA_DIST = testReading.sh makeInput.py testPair.sh testPairPerturbed.sh \
test27cells.sh test27cellsPerturbed.sh testParser.sh \
test125cells.sh testParserInput.yaml difffloat.py \
test125cells.sh test125cellsPerturbed.sh testParserInput.yaml difffloat.py \
tolerance_125.dat tolerance_27_normal.dat tolerance_27_perturbed.dat \
tolerance_pair_normal.dat tolerance_pair_perturbed.dat \
fft_params.yml
......@@ -107,7 +107,7 @@ for i in range(n_lines_to_check):
print ""
error = True
if abs(data1[i,j]) + abs(data2[i,j]) < 1e-6 : continue
if abs(data1[i,j]) < 4e-6 and abs(data2[i,j]) < 4e-6 : continue
# Ignore pathological cases with rho_dh
if ignoreSmallRhoDh and j == 8 and abs(data1[i,j]) < 2e-4: continue
......
......@@ -237,11 +237,13 @@ void reset_particles(struct cell *c, struct hydro_space *hs,
* separation.
* @param density The density of the fluid.
* @param partId The running counter of IDs.
* @param pert The perturbation to apply to the particles in the cell in units
*of the inter-particle separation.
* @param vel The type of velocity field.
* @param press The type of pressure field.
*/
struct cell *make_cell(size_t n, const double offset[3], double size, double h,
double density, long long *partId,
double density, long long *partId, double pert,
enum velocity_field vel, enum pressure_field press) {
const size_t count = n * n * n;
......@@ -264,9 +266,15 @@ struct cell *make_cell(size_t n, const double offset[3], double size, double h,
for (size_t x = 0; x < n; ++x) {
for (size_t y = 0; y < n; ++y) {
for (size_t z = 0; z < n; ++z) {
part->x[0] = offset[0] + size * (x + 0.5) / (float)n;
part->x[1] = offset[1] + size * (y + 0.5) / (float)n;
part->x[2] = offset[2] + size * (z + 0.5) / (float)n;
part->x[0] =
offset[0] +
size * (x + 0.5 + random_uniform(-0.5, 0.5) * pert) / (float)n;
part->x[1] =
offset[1] +
size * (y + 0.5 + random_uniform(-0.5, 0.5) * pert) / (float)n;
part->x[2] =
offset[2] +
size * (z + 0.5 + random_uniform(-0.5, 0.5) * pert) / (float)n;
part->h = size * h / (float)n;
#if defined(GIZMO_SPH) || defined(SHADOWFAX_SPH)
......@@ -355,8 +363,8 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
/* Write header */
fprintf(file,
"# %4s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s "
"%8s %8s %8s %8s %8s\n",
"# %4s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %13s %13s "
"%13s %13s %13s %8s %8s\n",
"ID", "pos_x", "pos_y", "pos_z", "v_x", "v_y", "v_z", "h", "rho",
"div_v", "S", "u", "P", "c", "a_x", "a_y", "a_z", "h_dt", "v_sig",
"dS/dt", "du/dt");
......@@ -368,7 +376,7 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
fprintf(file,
"%6llu %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f "
"%8.5f "
"%8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f\n",
"%8.5f %8.5f %13e %13e %13e %13e %13e %8.5f %8.5f\n",
main_cell->parts[pid].id, main_cell->parts[pid].x[0],
main_cell->parts[pid].x[1], main_cell->parts[pid].x[2],
main_cell->parts[pid].v[0], main_cell->parts[pid].v[1],
......@@ -407,7 +415,7 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
fprintf(file,
"%6llu %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f "
"%8.5f %8.5f "
"%8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f\n",
"%8.5f %8.5f %13f %13f %13f %13f %13f %8.5f %8.5f\n",
solution[pid].id, solution[pid].x[0], solution[pid].x[1],
solution[pid].x[2], solution[pid].v[0], solution[pid].v[1],
solution[pid].v[2], solution[pid].h, solution[pid].rho,
......@@ -433,6 +441,7 @@ int main(int argc, char *argv[]) {
size_t runs = 0, particles = 0;
double h = 1.23485, size = 1., rho = 2.5;
double perturbation = 0.;
char outputFileNameExtension[200] = "";
char outputFileName[200] = "";
enum velocity_field vel = velocity_zero;
......@@ -463,6 +472,9 @@ int main(int argc, char *argv[]) {
case 'r':
sscanf(optarg, "%zu", &runs);
break;
case 'd':
sscanf(optarg, "%lf", &perturbation);
break;
case 'm':
sscanf(optarg, "%lf", &rho);
break;
......@@ -492,6 +504,7 @@ int main(int argc, char *argv[]) {
"\n-h DISTANCE=1.2348 - Smoothing length in units of <x>"
"\n-m rho - Physical density in the cell"
"\n-s size - Physical size of the cell"
"\n-d pert - Perturbation to apply to the particles [0,1["
"\n-v type (0,1,2,3) - Velocity field: (zero, constant, divergent, "
"rotating)"
"\n-p type (0,1,2) - Pressure field: (constant, gradient divergent)"
......@@ -536,7 +549,8 @@ int main(int argc, char *argv[]) {
struct hydro_props hp;
hp.target_neighbours = pow_dimension(h) * kernel_norm;
hp.delta_neighbours = 2.;
hp.delta_neighbours = 4.;
hp.h_max = FLT_MAX;
hp.max_smoothing_iterations = 1;
hp.CFL_condition = 0.1;
......@@ -566,8 +580,8 @@ int main(int argc, char *argv[]) {
const double offset[3] = {i * size, j * size, k * size};
/* Construct it */
cells[i * 25 + j * 5 + k] =
make_cell(particles, offset, size, h, rho, &partId, vel, press);
cells[i * 25 + j * 5 + k] = make_cell(
particles, offset, size, h, rho, &partId, perturbation, vel, press);
/* Store the inner cells */
if (i > 0 && i < 4 && j > 0 && j < 4 && k > 0 && k < 4) {
......@@ -595,6 +609,12 @@ int main(int argc, char *argv[]) {
/* Initialise the particles */
for (int j = 0; j < 125; ++j) runner_do_drift_part(&runner, cells[j], 0);
/* Reset particles. */
for (int i = 0; i < 125; ++i) {
for (int n = 0; n < cells[i]->count; ++n)
hydro_init_part(&cells[i]->parts[n], &space.hs);
}
/* First, sort stuff */
for (int j = 0; j < 125; ++j) runner_do_sort(&runner, cells[j], 0x1FFF, 0);
......
......@@ -7,15 +7,25 @@ do
rm -f brute_force_125_standard.dat swift_dopair_125_standard.dat
echo "Running ./test125cells -n 6 -r 1 -v $v -p $p -f standard"
./test125cells -n 6 -r 1 -v $v -p $p -f standard
if [ -e brute_force_125_standard.dat ]
then
python @srcdir@/difffloat.py brute_force_125_standard.dat swift_dopair_125_standard.dat @srcdir@/tolerance_125.dat 6
if python @srcdir@/difffloat.py brute_force_125_standard.dat swift_dopair_125_standard.dat @srcdir@/tolerance_125_normal.dat 6
then
echo "Accuracy test passed"
else
echo "Accuracy test failed"
exit 1
fi
else
echo "Error Missing test output file"
exit 1
fi
echo "------------"
done
done
......
#!/bin/bash
for v in {0..3}
do
for p in {0..2}
do
echo ""
rm -f brute_force_125_perturbed.dat swift_dopair_125_perturbed.dat
echo "Running ./test125cells -n 6 -r 1 -d 0.1 -v $v -p $p -f perturbed"
./test125cells -n 6 -r 1 -d 0.1 -v $v -p $p -f perturbed
if [ -e brute_force_125_perturbed.dat ]
then
if python @srcdir@/difffloat.py brute_force_125_perturbed.dat swift_dopair_125_perturbed.dat @srcdir@/tolerance_125_perturbed.dat 6
then
echo "Accuracy test passed"
else
echo "Accuracy test failed"
exit 1
fi
else
echo "Error Missing test output file"
exit 1
fi
echo "------------"
done
done
exit $?
......@@ -3,18 +3,28 @@
for v in {0..3}
do
echo ""
rm -f brute_force_27_standard.dat swift_dopair_27_standard.dat
echo "Running ./test27cells -n 6 -r 1 -d 0 -f standard -v $v -a 1e-4"
./test27cells -n 6 -r 1 -d 0 -f standard -v $v -a 1e-4
if [ -e brute_force_27_standard.dat ]
then
python @srcdir@/difffloat.py brute_force_27_standard.dat swift_dopair_27_standard.dat @srcdir@/tolerance_27_normal.dat 6
if python @srcdir@/difffloat.py brute_force_27_standard.dat swift_dopair_27_standard.dat @srcdir@/tolerance_27_normal.dat 6
then
echo "Accuracy test passed"
else
echo "Accuracy test failed"
exit 1
fi
else
echo "Error Missing test output file"
exit 1
fi
echo "------------"
done
exit $?
......@@ -6,15 +6,25 @@ do
rm -f brute_force_27_perturbed.dat swift_dopair_27_perturbed.dat
echo "Running ./test27cells -n 6 -r 1 -d 0.1 -f perturbed -v $v -a 5e-4"
./test27cells -n 6 -r 1 -d 0.1 -f perturbed -v $v -a 5e-4
if [ -e brute_force_27_perturbed.dat ]
then
python @srcdir@/difffloat.py brute_force_27_perturbed.dat swift_dopair_27_perturbed.dat @srcdir@/tolerance_27_perturbed.dat 6 1
if python @srcdir@/difffloat.py brute_force_27_perturbed.dat swift_dopair_27_perturbed.dat @srcdir@/tolerance_27_perturbed.dat 6 1
then
echo "Accuracy test passed"
else
echo "Accuracy test failed"
exit 1
fi
else
echo "Error Missing test output file"
exit 1
fi
echo "------------"
done
exit $?
# ID pos_x pos_y pos_z v_x v_y v_z h rho div_v S u P c a_x a_y a_z h_dt v_sig dS/dt du/dt
0 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4
0 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 5e-3 5e-3 5e-3 1e-4 1e-4 1e-4 1e-4
# ID pos_x pos_y pos_z v_x v_y v_z rho rho_dh wcount wcount_dh div_v curl_vx curl_vy curl_vz
0 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1.2e-6 1e-4 5e-5 2e-3 3.1e-6 3e-6 3e-6 3e-6
0 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 2e-3 1e-5 1e-4 2e-5 2e-3 2e-3 2e-3
0 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1.2e-6 1e-4 5e-5 2e-3 4e-6 3e-6 3e-6 3e-6
0 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 2e-3 1e-5 1e-4 4e-5 2e-3 2e-3 2e-3
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment