Commit 800cc992 authored by Matthieu Schaller's avatar Matthieu Schaller

Patch the unit tests to work with the new gravity scheme and compile smoothly on cosma7

parent c5e1d7a0
......@@ -31,7 +31,7 @@
/**
* @brief Compute the exponential of a number.
*
* This function has a relative accuracy of 1.618e-6 over the input
* This function has a relative accuracy of 2.1e-6 over the input
* range [-32., 32.].
*
* @param x The number to take the exponential of.
......
......@@ -88,7 +88,7 @@ kernel_long_grav_derivatives(const float r, const float r_s_inv,
/* Compute erfcf(u) using eq. 7.1.26 of
* Abramowitz & Stegun, 1972.
*
* This has a *relative* error of less than 4e-3 over
* This has a *relative* error of less than 3.4e-3 over
* the range of interest (0 < u < 5)
*
* This is a good approximation to use since we already
......@@ -212,7 +212,7 @@ kernel_long_grav_eval(const float r_over_r_s, float *restrict corr_f,
/* Compute erfcf(u) using eq. 7.1.26 of
* Abramowitz & Stegun, 1972.
*
* This has a *relative* error of less than 4e-3 over
* This has a *relative* error of less than 3.4e-3 over
* the range of interest (0 < u < 5)\
*
* This is a good approximation to use since we already
......
......@@ -29,7 +29,7 @@
* Compute erfcf(u) using eq. 7.1.26 of
* Abramowitz & Stegun, 1972.
*
* This has a *relative* error of less than 4e-3 over
* This has a *relative* error of less than 3.4e-3 over
* the range of interest (0 < x < 5)
*/
float optimized_erfcf(const float x) {
......@@ -90,7 +90,7 @@ int main(int argc, char* argv[]) {
const double exact = erfc(x);
const double swift_erfcf = optimized_erfcf(x);
check_value(exact, swift_erfcf, 3.358e-3, 6e-7, x);
check_value(exact, swift_erfcf, 3.358e-3, 6.1e-7, x);
}
return 0;
......
......@@ -62,8 +62,8 @@ int main(int argc, char* argv[]) {
const double swift_exp_p = optimized_expf(x);
const double swift_exp_n = optimized_expf(-x);
check_value(exact_p, swift_exp_p, 1.618e-6, x);
check_value(exact_n, swift_exp_n, 1.618e-6, x);
check_value(exact_p, swift_exp_p, 2.1e-6, x);
check_value(exact_n, swift_exp_n, 2.1e-6, x);
}
return 0;
......
......@@ -60,7 +60,7 @@ void make_cell(struct cell *c, int N, const double loc[3], double width,
/* Create the particles */
c->grav.count = N;
c->grav.count_total = N;
c->grav.parts = malloc(N * sizeof(struct gpart));
c->grav.parts = (struct gpart *)malloc(N * sizeof(struct gpart));
bzero(c->grav.parts, N * sizeof(struct gpart));
for (int i = 0.; i < N; ++i) {
......@@ -74,7 +74,8 @@ void make_cell(struct cell *c, int N, const double loc[3], double width,
}
/* Create the multipoles */
c->grav.multipole = malloc(sizeof(struct gravity_tensors));
c->grav.multipole =
(struct gravity_tensors *)malloc(sizeof(struct gravity_tensors));
gravity_reset(c->grav.multipole);
gravity_P2M(c->grav.multipole, c->grav.parts, N, grav_props);
gravity_multipole_compute_power(&c->grav.multipole->m_pole);
......@@ -140,10 +141,10 @@ int main(int argc, char *argv[]) {
message("Number of runs: %d", num_M2L_runs);
/* Construct arrays of multipoles to prevent too much optimization */
struct gravity_tensors *tensors_i =
malloc(num_M2L_runs * sizeof(struct gravity_tensors));
struct gravity_tensors *tensors_j =
malloc(num_M2L_runs * sizeof(struct gravity_tensors));
struct gravity_tensors *tensors_i = (struct gravity_tensors *)malloc(
num_M2L_runs * sizeof(struct gravity_tensors));
struct gravity_tensors *tensors_j = (struct gravity_tensors *)malloc(
num_M2L_runs * sizeof(struct gravity_tensors));
for (int n = 0; n < num_M2L_runs; ++n) {
memcpy(&tensors_i[n], ci.grav.multipole, sizeof(struct gravity_tensors));
......
......@@ -204,6 +204,9 @@ int main(int argc, char *argv[]) {
gp->time_bin = 1;
gp->type = swift_type_dark_matter;
gp->id_or_neg_offset = n + 1;
#ifdef MULTI_SOFTENING_GRAVITY
gp->epsilon = eps;
#endif
#ifdef SWIFT_DEBUG_CHECKS
gp->ti_drift = 8;
gp->initialised = 1;
......@@ -222,6 +225,9 @@ int main(int argc, char *argv[]) {
ci.grav.parts[0].time_bin = 1;
ci.grav.parts[0].type = swift_type_dark_matter;
ci.grav.parts[0].id_or_neg_offset = 1;
#ifdef MULTI_SOFTENING_GRAVITY
ci.grav.parts[0].epsilon = eps;
#endif
#ifdef SWIFT_DEBUG_CHECKS
ci.grav.parts[0].ti_drift = 8;
ci.grav.parts[0].initialised = 1;
......@@ -270,10 +276,11 @@ int main(int argc, char *argv[]) {
bzero(&ci.grav.multipole->m_pole, sizeof(struct multipole));
bzero(&cj.grav.multipole->m_pole, sizeof(struct multipole));
ci.grav.multipole->m_pole.M_000 = 1.;
cj.grav.multipole->m_pole.M_000 = 1.;
cj.grav.multipole->m_pole.max_softening = eps;
/* Now compute the forces */
runner_dopair_grav_pp(&r, &ci, &cj, 1, 1);
runner_dopair_grav_pp(&r, &ci, &cj, /*symmetric*/ 1, /*allow_mpoles=*/1);
/* Verify everything */
for (int n = 0; n < num_tests; ++n) {
......@@ -379,6 +386,9 @@ int main(int argc, char *argv[]) {
ci.grav.parts[n].time_bin = 1;
ci.grav.parts[n].type = swift_type_dark_matter;
ci.grav.parts[n].id_or_neg_offset = 1;
#ifdef MULTI_SOFTENING_GRAVITY
ci.grav.parts[0].epsilon = eps;
#endif
#ifdef SWIFT_DEBUG_CHECKS
ci.grav.parts[n].ti_drift = 8;
ci.grav.parts[n].initialised = 1;
......
......@@ -156,6 +156,9 @@ int main(int argc, char *argv[]) {
c.grav.parts[0].time_bin = 1;
c.grav.parts[0].type = swift_type_dark_matter;
c.grav.parts[0].id_or_neg_offset = 1;
#ifdef MULTI_SOFTENING_GRAVITY
c.grav.parts[0].epsilon = eps;
#endif
#ifdef SWIFT_DEBUG_CHECKS
c.grav.parts[0].ti_drift = 8;
c.grav.parts[0].initialised = 1;
......@@ -173,6 +176,9 @@ int main(int argc, char *argv[]) {
gp->time_bin = 1;
gp->type = swift_type_dark_matter;
gp->id_or_neg_offset = n + 1;
#ifdef MULTI_SOFTENING_GRAVITY
gp->epsilon = eps;
#endif
#ifdef SWIFT_DEBUG_CHECKS
gp->ti_drift = 8;
gp->initialised = 1;
......
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