Commit 329517a3 authored by James Willis's avatar James Willis
Browse files

Updated brute force density pair calculations to include periodic boundary conditions.

parent 5022edc1
......@@ -182,6 +182,16 @@ 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;
const struct engine *restrict e = r->e;
/* Get the sort ID. */
double shift[3] = {0.0, 0.0, 0.0};
const int sid = space_getsid(e->s, &ci, &cj, shift);
/* Get the cutoff shift. */
double rshift = 0.0;
for (int k = 0; k < 3; k++) rshift += shift[k] * runner_shift[sid][k];
/* Implements a double-for loop and checks every interaction */
for (int i = 0; i < ci->count; ++i) {
......@@ -196,7 +206,7 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) {
/* Pairwise distance */
r2 = 0.0f;
for (int k = 0; k < 3; k++) {
dx[k] = ci->parts[i].x[k] - cj->parts[j].x[k];
dx[k] = (ci->parts[i].x[k] - shift[k]) - cj->parts[j].x[k];
r2 += dx[k] * dx[k];
}
......@@ -223,7 +233,7 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) {
/* Pairwise distance */
r2 = 0.0f;
for (int k = 0; k < 3; k++) {
dx[k] = cj->parts[j].x[k] - ci->parts[i].x[k];
dx[k] = (cj->parts[j].x[k] + shift[k]) - ci->parts[i].x[k];
r2 += dx[k] * dx[k];
}
......
Supports Markdown
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