From a80b5fc5e25633d002e3625135eaad20dd074b9b Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Wed, 31 May 2017 13:13:43 +0100 Subject: [PATCH] Make the difffloat script use a new line in the files to set a limit below which values are ignored as too close to zero. --- configure.ac | 12 ++++++------ tests/difffloat.py | 14 ++++---------- tests/testPeriodicBC.c | 7 +++---- tests/tolerance_periodic_BC_normal.dat | 5 +++-- tests/tolerance_periodic_BC_perturbed.dat | 4 ++++ 5 files changed, 20 insertions(+), 22 deletions(-) create mode 100644 tests/tolerance_periodic_BC_perturbed.dat diff --git a/configure.ac b/configure.ac index d7adefe3a4..ef9051fbb3 100644 --- a/configure.ac +++ b/configure.ac @@ -861,6 +861,12 @@ AC_CONFIG_FILES([tests/testParser.sh], [chmod +x tests/testParser.sh]) # Save the compilation options AC_DEFINE_UNQUOTED([SWIFT_CONFIG_FLAGS],["$swift_config_flags"],[Flags passed to configure]) +# Make sure the latest git revision string gets included +touch src/version.c + +# Generate output. +AC_OUTPUT + # Report general configuration. AC_MSG_RESULT([ Compiler : $CC @@ -894,9 +900,3 @@ AC_MSG_RESULT([ Debugging checks : $enable_debugging_checks Gravity checks : $gravity_force_checks ]) - -# Make sure the latest git revision string gets included -touch src/version.c - -# Generate output. -AC_OUTPUT diff --git a/tests/difffloat.py b/tests/difffloat.py index 8c8713a8d2..ddcf7bcb29 100644 --- a/tests/difffloat.py +++ b/tests/difffloat.py @@ -42,11 +42,6 @@ if len(sys.argv) >= 4: if len(sys.argv) >= 5: number_to_check = int(sys.argv[4]) -if len(sys.argv) == 6: - ignoreSmallRhoDh = int(sys.argv[5]) -else: - ignoreSmallRhoDh = 0 - # Get the particle properties being compared from the header. with open(file1, 'r') as f: line = f.readline() @@ -69,7 +64,7 @@ n_lines = shape(data1)[0] n_columns = shape(data1)[1] if fileTol != "": - if n_linesTol != 2: + if n_linesTol != 3: print "Incorrect number of lines in tolerance file '%s'."%fileTol if n_columnsTol != n_columns: print "Incorrect number of columns in tolerance file '%s'."%fileTol @@ -79,10 +74,12 @@ if fileTol == "": print "Relative difference tolerance:", rel_tol absTol = ones(n_columns) * abs_tol relTol = ones(n_columns) * rel_tol + limTol = zeros(n_columns) else: print "Tolerances read from file" absTol = dataTol[0,:] relTol = dataTol[1,:] + limTol = dataTol[2,:] n_lines_to_check = 0 if number_to_check > 0: @@ -113,11 +110,8 @@ for i in range(n_lines_to_check): print "" error = True - if abs(data1[i,j]) < 4e-6 and abs(data2[i,j]) < 4e-6 : continue + if abs(data1[i,j]) + abs(data2[i,j]) < limTol[j] : continue - # Ignore pathological cases with rho_dh - if ignoreSmallRhoDh and j == 8 and abs(data1[i,j]) < 2e-4: continue - if( rel_diff > 1.1*relTol[j]): print "Relative difference larger than tolerance (%e) for particle %d, column %s:"%(relTol[j], data1[i,0], part_props[j]) print "%10s: a = %e"%("File 1", data1[i,j]) diff --git a/tests/testPeriodicBC.c b/tests/testPeriodicBC.c index c20f01bc44..23ba1f50e7 100644 --- a/tests/testPeriodicBC.c +++ b/tests/testPeriodicBC.c @@ -34,7 +34,7 @@ #if defined(WITH_VECTORIZATION) #define DOSELF1 runner_doself1_density_vec -#define DOPAIR1 runner_dopair1_density_vec +#define DOPAIR1 runner_dopair1_branch_density #define DOSELF1_NAME "runner_doself1_density_vec" #define DOPAIR1_NAME "runner_dopair1_density_vec" #endif @@ -277,9 +277,8 @@ int check_results(struct part *serial_parts, struct part *vec_parts, int count, /* Just a forward declaration... */ void runner_doself1_density(struct runner *r, struct cell *ci); void runner_doself1_density_vec(struct runner *r, struct cell *ci); -void runner_dopair1_density(struct runner *r, struct cell *ci, struct cell *cj); -void runner_dopair1_density_vec(struct runner *r, struct cell *ci, - struct cell *cj); +void runner_dopair1_branch_density(struct runner *r, struct cell *ci, + struct cell *cj); void test_boundary_conditions(struct cell **cells, struct runner runner, const int loc_i, const int loc_j, const int loc_k, diff --git a/tests/tolerance_periodic_BC_normal.dat b/tests/tolerance_periodic_BC_normal.dat index 31ee002bb9..f3fbdd2e3a 100644 --- a/tests/tolerance_periodic_BC_normal.dat +++ b/tests/tolerance_periodic_BC_normal.dat @@ -1,3 +1,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 2e-6 4e-5 2e-4 2e-3 1e-5 6e-6 6e-6 6e-6 - 0 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1.2e-4 1e-4 1e-4 2e-4 1e-4 1e-4 1e-4 + 0 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 3e-6 4e-5 2e-4 3e-3 2e-4 1e-4 1e-4 1e-4 + 0 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 2e-6 1.2e-4 1e-4 1e-4 2e-4 5e-4 5e-4 5e-4 + 0 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-4 1e-6 1e-4 1e-4 1e-4 1e-4 1e-4 diff --git a/tests/tolerance_periodic_BC_perturbed.dat b/tests/tolerance_periodic_BC_perturbed.dat new file mode 100644 index 0000000000..fe3b47b244 --- /dev/null +++ b/tests/tolerance_periodic_BC_perturbed.dat @@ -0,0 +1,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 3e-6 4e-5 2e-4 3e-3 2e-4 1e-4 1e-4 1e-4 + 0 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 2e-6 3e-3 1e-4 1e-4 2e-3 6e-3 6e-3 6e-3 + 0 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-3 1e-6 1e-4 1e-4 1e-4 1e-4 1e-4 -- GitLab