diff --git a/src/tools.c b/src/tools.c index f387e3c14c8b08e4dbec4de209b6cc66f704bea2..56ec0522ede397f37eea50c61c36ac4e927e1f82 100644 --- a/src/tools.c +++ b/src/tools.c @@ -19,20 +19,17 @@ * ******************************************************************************/ - #include <math.h> #include <stdlib.h> #include <stddef.h> #include <stdio.h> - #include "error.h" #include "part.h" #include "cell.h" #include "tools.h" #include "swift.h" - /** * Factorize a given integer, attempts to keep larger pair of factors. */ @@ -50,8 +47,6 @@ void factor(int value, int *f1, int *f2) { } } - - /** * @brief Compute the average number of pairs per particle using * a brute-force O(N^2) computation. @@ -181,24 +176,22 @@ void pairs_single_density(double *dim, long long int pid, fflush(stdout); } - - void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) { float r2, hi, hj, hig2, hjg2, dx[3]; struct part *pi, *pj; /* Implements a double-for loop and checks every interaction */ - for( int i=0; i<ci->count; ++i) { + for (int i = 0; i < ci->count; ++i) { pi = &ci->parts[i]; - hi = pi->h; - hig2 = hi * hi * kernel_gamma2; - - for(int j=0; j<cj->count; ++j) { + hi = pi->h; + hig2 = hi * hi * kernel_gamma2; + + for (int j = 0; j < cj->count; ++j) { pj = &cj->parts[j]; - + /* Pairwise distance */ r2 = 0.0f; for (int k = 0; k < 3; k++) { @@ -209,28 +202,29 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) { /* Hit or miss? */ if (r2 < hig2) { - //message("hit %d %d %f %f %f %f", i, j, sqrt(r2), hi, pi->mass, pi->rho); - - /* Interact */ - runner_iact_nonsym_density(r2, dx, hi, pj->h, pi, pj); + // message("hit %d %d %f %f %f %f", i, j, sqrt(r2), hi, pi->mass, + // pi->rho); - //message("hit %d %d %f %f %f %f", i, j, sqrt(r2), hi, pi->mass, pi->rho); - } + /* Interact */ + runner_iact_nonsym_density(r2, dx, hi, pj->h, pi, pj); + + // message("hit %d %d %f %f %f %f", i, j, sqrt(r2), hi, pi->mass, + // pi->rho); + } } } - /* Reverse double-for loop and checks every interaction */ - for( int j=0; j<cj->count; ++j) { + for (int j = 0; j < cj->count; ++j) { - pj = &cj->parts[j]; + pj = &cj->parts[j]; hj = pj->h; - hjg2 = hj * hj * kernel_gamma2; - - for(int i=0; i<ci->count; ++i) { + hjg2 = hj * hj * kernel_gamma2; + + for (int i = 0; i < ci->count; ++i) { pi = &ci->parts[i]; - + /* Pairwise distance */ r2 = 0.0f; for (int k = 0; k < 3; k++) { @@ -241,18 +235,13 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) { /* Hit or miss? */ if (r2 < hjg2) { - /* Interact */ - runner_iact_nonsym_density(r2, dx, hj, pi->h, pj, pi); - - } + /* Interact */ + runner_iact_nonsym_density(r2, dx, hj, pi->h, pj, pi); + } } } - - - } - void pairs_single_grav(double *dim, long long int pid, struct gpart *__restrict__ parts, int N, int periodic) { @@ -307,7 +296,6 @@ void pairs_single_grav(double *dim, long long int pid, pi.part->id, a[0], a[1], a[2], aabs[0], aabs[1], aabs[2]); } - /** * @brief Test the density function by dumping it for two random parts. * diff --git a/src/tools.h b/src/tools.h index b70fd7b08fbb66cb877cd0a1944fb9fab0a1aabb..59646291bda46a7dd0f5a34e158e3e0a6f21d3ca 100644 --- a/src/tools.h +++ b/src/tools.h @@ -22,7 +22,6 @@ #ifndef SWIFT_TOOL_H #define SWIFT_TOOL_H - #include "runner.h" #include "cell.h" @@ -38,5 +37,4 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj); void pairs_n2(double *dim, struct part *__restrict__ parts, int N, int periodic); - #endif /* SWIFT_TOOL_H */ diff --git a/tests/testVectorize.c b/tests/testVectorize.c index e62b8f27a1c5f192b01654ee3621c9ce0369ba23..6c11446e4f9b6dce189e6a03925cd2e61ee650f5 100644 --- a/tests/testVectorize.c +++ b/tests/testVectorize.c @@ -20,7 +20,6 @@ struct cell *make_cell(size_t n, double *offset, double h, error("couldn't allocate particles, no. of particles: %d", (int)count); } - part = cell->parts; for (x = 0; x < n; ++x) { for (y = 0; y < n; ++y) { @@ -182,7 +181,6 @@ int main(int argc, char *argv[]) { pairs_all_density(&runner, ci, cj); dump_particle_fields("brute_force.dat", ci, cj); - /* Clean things to make the sanitizer happy ... */ clean_up(ci); clean_up(cj);