Skip to content
Snippets Groups Projects
Commit 9ab76ca7 authored by Loic Hausammann's avatar Loic Hausammann
Browse files

Stars: optimized dopair1 works

parent 285cbdea
No related branches found
No related tags found
1 merge request!750Stars use sort
...@@ -259,7 +259,6 @@ void DO_SYM_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj, cons ...@@ -259,7 +259,6 @@ void DO_SYM_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj, cons
if (do_ci_stars) { if (do_ci_stars) {
/* Pick-out the sorted lists. */ /* Pick-out the sorted lists. */
const struct entry *restrict sort_i = ci->stars.sort[sid];
const struct entry *restrict sort_j = cj->hydro.sort[sid]; const struct entry *restrict sort_j = cj->hydro.sort[sid];
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
...@@ -285,21 +284,23 @@ void DO_SYM_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj, cons ...@@ -285,21 +284,23 @@ void DO_SYM_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj, cons
(ci->stars.dx_max_sort + cj->hydro.dx_max_sort) - rshift; (ci->stars.dx_max_sort + cj->hydro.dx_max_sort) - rshift;
/* Loop over the sparts in ci. */ /* Loop over the sparts in ci. */
for (int pid = count_i - 1; pid >= 0; pid--) { for (int pid = 0; pid < count_i; pid++) {
/* Get a hold of the ith part in ci. */ /* Get a hold of the ith part in ci. */
struct spart *restrict spi = &sparts_i[sort_i[pid].i]; struct spart *restrict spi = &sparts_i[pid];
const float hi = spi->h;
if (sort_i[pid].d + spi->h * kernel_gamma + dx_max_rshift < dj_min)
continue;
/* Skip inactive particles */ /* Skip inactive particles */
if (!spart_is_active(spi, e) || spart_is_inhibited(spi, e)) continue; if (!spart_is_active(spi, e) || spart_is_inhibited(spi, e)) continue;
const float hi = spi->h; /* Compute distance from the other cell. */
const double px[3] = {spi->x[0], spi->x[1], spi->x[2]};
float dist = px[0] * runner_shift[sid][0] +
px[1] * runner_shift[sid][1] +
px[2] * runner_shift[sid][2];
/* Is there anything we need to interact with ? */ /* Is there anything we need to interact with ? */
const double di = sort_i[pid].d + hi * kernel_gamma + dx_max_rshift; const double di = dist + hi * kernel_gamma + dx_max_rshift;
if (di < dj_min) continue; if (di < dj_min) continue;
/* Get some additional information about pi */ /* Get some additional information about pi */
...@@ -374,7 +375,6 @@ void DO_SYM_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj, cons ...@@ -374,7 +375,6 @@ void DO_SYM_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj, cons
if (do_cj_stars) { if (do_cj_stars) {
/* Pick-out the sorted lists. */ /* Pick-out the sorted lists. */
const struct entry *restrict sort_i = ci->hydro.sort[sid]; const struct entry *restrict sort_i = ci->hydro.sort[sid];
const struct entry *restrict sort_j = cj->stars.sort[sid];
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
/* Some constants used to checks that the parts are in the right frame */ /* Some constants used to checks that the parts are in the right frame */
...@@ -395,25 +395,28 @@ void DO_SYM_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj, cons ...@@ -395,25 +395,28 @@ void DO_SYM_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj, cons
struct part *restrict parts_i = ci->hydro.parts; struct part *restrict parts_i = ci->hydro.parts;
struct spart *restrict sparts_j = cj->stars.parts; struct spart *restrict sparts_j = cj->stars.parts;
const double di_max = sort_i[count_i - 1].d - rshift; const double di_max = sort_i[count_i - 1].d - rshift;
const float dx_max = (ci->hydro.dx_max_sort + cj->stars.dx_max_sort); const float dx_max_rshift =
(ci->hydro.dx_max_sort + cj->stars.dx_max_sort) + rshift;
/* Loop over the parts in cj. */ /* Loop over the parts in cj. */
for (int pjd = 0; pjd < count_j; pjd++) { for (int pjd = 0; pjd < count_j; pjd++) {
/* Get a hold of the jth part in cj. */ /* Get a hold of the jth part in cj. */
struct spart *spj = &sparts_j[sort_j[pjd].i]; struct spart *spj = &sparts_j[pjd];
const float hj = spj->h;
/* Is it possible to interact with a particle? */
if (sort_j[pjd].d - spj->h * kernel_gamma - dx_max > di_max)
continue;
/* Skip inactive particles */ /* Skip inactive particles */
if (!spart_is_active(spj, e) || spart_is_inhibited(spj, e)) continue; if (!spart_is_active(spj, e) || spart_is_inhibited(spj, e)) continue;
const float hj = spj->h;
/* Compute distance from the other cell. */
const double px[3] = {spj->x[0], spj->x[1], spj->x[2]};
float dist = px[0] * runner_shift[sid][0] +
px[1] * runner_shift[sid][1] +
px[2] * runner_shift[sid][2];
/* Is there anything we need to interact with ? */ /* Is there anything we need to interact with ? */
const double dj = sort_j[pjd].d - hj * kernel_gamma - dx_max + rshift; const double dj = dist - hj * kernel_gamma - dx_max_rshift;
if (dj - rshift > di_max) continue; if (dj - rshift > di_max) continue;
/* Get some additional information about pj */ /* Get some additional information about pj */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment