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

Google style formatting

parent d4ad8e44
Branches
Tags
1 merge request!64Agreed upon version of the density vectorization test
......@@ -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.
*
......
......@@ -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 */
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment