From c8b797ad30e01e91f578ff8deb544b2627e8597d Mon Sep 17 00:00:00 2001 From: James Willis Date: Mon, 25 Jul 2016 12:29:15 +0100 Subject: [PATCH 1/3] Renamed 'h' in cell struct to 'width' and renamed 'h' and 'ih' in the space struct to 'width' and 'iwidth'. --- src/cell.c | 14 +++++++------- src/cell.h | 2 +- src/engine.c | 14 +++++++------- src/map.c | 20 ++++++++++---------- src/partition.c | 24 ++++++++++++------------ src/runner_doiact.h | 12 ++++++------ src/runner_doiact_grav.h | 8 ++++---- src/space.c | 38 +++++++++++++++++++------------------- src/space.h | 2 +- tests/test27cells.c | 6 +++--- tests/testPair.c | 6 +++--- tests/testSPHStep.c | 6 +++--- 12 files changed, 76 insertions(+), 76 deletions(-) diff --git a/src/cell.c b/src/cell.c index 3fcb8c456..ddcf8defa 100644 --- a/src/cell.c +++ b/src/cell.c @@ -110,13 +110,13 @@ int cell_unpack(struct pcell *pc, struct cell *c, struct space *s) { temp->loc[0] = c->loc[0]; temp->loc[1] = c->loc[1]; temp->loc[2] = c->loc[2]; - temp->h[0] = c->h[0] / 2; - temp->h[1] = c->h[1] / 2; - temp->h[2] = c->h[2] / 2; + temp->width[0] = c->width[0] / 2; + temp->width[1] = c->width[1] / 2; + temp->width[2] = c->width[2] / 2; temp->dmin = c->dmin / 2; - if (k & 4) temp->loc[0] += temp->h[0]; - if (k & 2) temp->loc[1] += temp->h[1]; - if (k & 1) temp->loc[2] += temp->h[2]; + if (k & 4) temp->loc[0] += temp->width[0]; + if (k & 2) temp->loc[1] += temp->width[1]; + if (k & 1) temp->loc[2] += temp->width[2]; temp->depth = c->depth + 1; temp->split = 0; temp->dx_max = 0.f; @@ -425,7 +425,7 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset) { double pivot[3]; /* Init the pivots. */ - for (int k = 0; k < 3; k++) pivot[k] = c->loc[k] + c->h[k] / 2; + for (int k = 0; k < 3; k++) pivot[k] = c->loc[k] + c->width[k] / 2; /* Split along the x-axis. */ i = 0; diff --git a/src/cell.h b/src/cell.h index b5cc49d05..9f35f4386 100644 --- a/src/cell.h +++ b/src/cell.h @@ -68,7 +68,7 @@ struct cell { double loc[3]; /* The cell dimensions. */ - double h[3]; + double width[3]; /* Max radii in this cell. */ double h_max; diff --git a/src/engine.c b/src/engine.c index 1ae4dff25..1877aceaf 100644 --- a/src/engine.c +++ b/src/engine.c @@ -265,7 +265,7 @@ void engine_redistribute(struct engine *e) { struct cell *cells = s->cells; const int nr_cells = s->nr_cells; const int *cdim = s->cdim; - const double ih[3] = {s->ih[0], s->ih[1], s->ih[2]}; + const double iwidth[3] = {s->iwidth[0], s->iwidth[1], s->iwidth[2]}; const double dim[3] = {s->dim[0], s->dim[1], s->dim[2]}; struct part *parts = s->parts; struct xpart *xparts = s->xparts; @@ -299,8 +299,8 @@ void engine_redistribute(struct engine *e) { else if (parts[k].x[j] >= dim[j]) parts[k].x[j] -= dim[j]; } - const int cid = cell_getid(cdim, parts[k].x[0] * ih[0], - parts[k].x[1] * ih[1], parts[k].x[2] * ih[2]); + const int cid = cell_getid(cdim, parts[k].x[0] * iwidth[0], + parts[k].x[1] * iwidth[1], parts[k].x[2] * iwidth[2]); #ifdef SWIFT_DEBUG_CHECKS if (cid < 0 || cid >= s->nr_cells) error("Bad cell id %i for part %zi at [%.3e,%.3e,%.3e].", cid, k, @@ -354,8 +354,8 @@ void engine_redistribute(struct engine *e) { else if (gparts[k].x[j] >= dim[j]) gparts[k].x[j] -= dim[j]; } - const int cid = cell_getid(cdim, gparts[k].x[0] * ih[0], - gparts[k].x[1] * ih[1], gparts[k].x[2] * ih[2]); + const int cid = cell_getid(cdim, gparts[k].x[0] * iwidth[0], + gparts[k].x[1] * iwidth[1], gparts[k].x[2] * iwidth[2]); #ifdef SWIFT_DEBUG_CHECKS if (cid < 0 || cid >= s->nr_cells) error("Bad cell id %i for part %zi at [%.3e,%.3e,%.3e].", cid, k, @@ -540,8 +540,8 @@ void engine_redistribute(struct engine *e) { #ifdef SWIFT_DEBUG_CHECKS /* Verify that all parts are in the right place. */ for (int k = 0; k < nr_parts; k++) { - int cid = cell_getid(cdim, parts_new[k].x[0] * ih[0], - parts_new[k].x[1] * ih[1], parts_new[k].x[2] * ih[2]); + int cid = cell_getid(cdim, parts_new[k].x[0] * iwidth[0], + parts_new[k].x[1] * iwidth[1], parts_new[k].x[2] * iwidth[2]); if (cells[cid].nodeID != nodeID) error("Received particle (%i) that does not belong here (nodeID=%i).", k, cells[cid].nodeID); diff --git a/src/map.c b/src/map.c index f4f9ac7cf..844b18c75 100644 --- a/src/map.c +++ b/src/map.c @@ -38,7 +38,7 @@ void map_cells_plot(struct cell *c, void *data) { int depth = *(int *)data; - double *l = c->loc, *h = c->h; + double *l = c->loc, *h = c->width; if (c->depth <= depth) { @@ -90,9 +90,9 @@ void map_cells_plot(struct cell *c, void *data) { */ void map_check(struct part *p, struct cell *c, void *data) { - if (p->x[0] < c->loc[0] || p->x[0] > c->loc[0] + c->h[0] || - p->x[0] < c->loc[0] || p->x[0] > c->loc[0] + c->h[0] || - p->x[0] < c->loc[0] || p->x[0] > c->loc[0] + c->h[0]) + if (p->x[0] < c->loc[0] || p->x[0] > c->loc[0] + c->width[0] || + p->x[0] < c->loc[0] || p->x[0] > c->loc[0] + c->width[0] || + p->x[0] < c->loc[0] || p->x[0] > c->loc[0] + c->width[0]) printf("map_check: particle %lld is outside of its box.\n", p->id); } @@ -108,13 +108,13 @@ void map_cellcheck(struct cell *c, void *data) { for (int k = 0; k < c->count; k++) { struct part *p = &c->parts[k]; if (p->x[0] < c->loc[0] || p->x[1] < c->loc[1] || p->x[2] < c->loc[2] || - p->x[0] > c->loc[0] + c->h[0] || p->x[1] > c->loc[1] + c->h[1] || - p->x[2] > c->loc[2] + c->h[2]) { + p->x[0] > c->loc[0] + c->width[0] || p->x[1] > c->loc[1] + c->width[1] || + p->x[2] > c->loc[2] + c->width[2]) { printf( "map_cellcheck: particle at [ %.16e %.16e %.16e ] outside of cell [ " "%.16e %.16e %.16e ] - [ %.16e %.16e %.16e ].\n", p->x[0], p->x[1], p->x[2], c->loc[0], c->loc[1], c->loc[2], - c->loc[0] + c->h[0], c->loc[1] + c->h[1], c->loc[2] + c->h[2]); + c->loc[0] + c->width[0], c->loc[1] + c->width[1], c->loc[2] + c->width[2]); error("particle out of bounds!"); } } @@ -123,13 +123,13 @@ void map_cellcheck(struct cell *c, void *data) { for (int k = 0; k < c->gcount; k++) { struct gpart *p = &c->gparts[k]; if (p->x[0] < c->loc[0] || p->x[1] < c->loc[1] || p->x[2] < c->loc[2] || - p->x[0] > c->loc[0] + c->h[0] || p->x[1] > c->loc[1] + c->h[1] || - p->x[2] > c->loc[2] + c->h[2]) { + p->x[0] > c->loc[0] + c->width[0] || p->x[1] > c->loc[1] + c->width[1] || + p->x[2] > c->loc[2] + c->width[2]) { printf( "map_cellcheck: g-particle at [ %.16e %.16e %.16e ] outside of cell " "[ %.16e %.16e %.16e ] - [ %.16e %.16e %.16e ].\n", p->x[0], p->x[1], p->x[2], c->loc[0], c->loc[1], c->loc[2], - c->loc[0] + c->h[0], c->loc[1] + c->h[1], c->loc[2] + c->h[2]); + c->loc[0] + c->width[0], c->loc[1] + c->width[1], c->loc[2] + c->width[2]); error("g-particle out of bounds!"); } } diff --git a/src/partition.c b/src/partition.c index 12c90861d..0cc698de9 100644 --- a/src/partition.c +++ b/src/partition.c @@ -241,7 +241,7 @@ static void accumulate_counts(struct space *s, int *counts) { struct part *parts = s->parts; int *cdim = s->cdim; - double ih[3] = {s->ih[0], s->ih[1], s->ih[2]}; + double iwidth[3] = {s->iwidth[0], s->iwidth[1], s->iwidth[2]}; double dim[3] = {s->dim[0], s->dim[1], s->dim[2]}; bzero(counts, sizeof(int) * s->nr_cells); @@ -253,8 +253,8 @@ static void accumulate_counts(struct space *s, int *counts) { else if (parts[k].x[j] >= dim[j]) parts[k].x[j] -= dim[j]; } - const int cid = cell_getid(cdim, parts[k].x[0] * ih[0], - parts[k].x[1] * ih[1], parts[k].x[2] * ih[2]); + const int cid = cell_getid(cdim, parts[k].x[0] * iwidth[0], + parts[k].x[1] * iwidth[1], parts[k].x[2] * iwidth[2]); counts[cid]++; } } @@ -832,10 +832,10 @@ void partition_initial_partition(struct partition *initial_partition, /* Check each particle and accumilate the counts per cell. */ struct part *parts = s->parts; int *cdim = s->cdim; - double ih[3], dim[3]; - ih[0] = s->ih[0]; - ih[1] = s->ih[1]; - ih[2] = s->ih[2]; + double iwidth[3], dim[3]; + iwidth[0] = s->iwidth[0]; + iwidth[1] = s->iwidth[1]; + iwidth[2] = s->iwidth[2]; dim[0] = s->dim[0]; dim[1] = s->dim[1]; dim[2] = s->dim[2]; @@ -847,8 +847,8 @@ void partition_initial_partition(struct partition *initial_partition, parts[k].x[j] -= dim[j]; } const int cid = - cell_getid(cdim, parts[k].x[0] * ih[0], parts[k].x[1] * ih[1], - parts[k].x[2] * ih[2]); + cell_getid(cdim, parts[k].x[0] * iwidth[0], parts[k].x[1] * iwidth[1], + parts[k].x[2] * iwidth[2]); weights[cid]++; } @@ -1085,9 +1085,9 @@ int partition_space_to_space(double *oldh, double *oldcdim, int *oldnodeIDs, for (int k = 0; k < s->cdim[2]; k++) { /* Scale indices to old cell space. */ - int ii = rint(i * s->ih[0] * oldh[0]); - int jj = rint(j * s->ih[1] * oldh[1]); - int kk = rint(k * s->ih[2] * oldh[2]); + int ii = rint(i * s->iwidth[0] * oldh[0]); + int jj = rint(j * s->iwidth[1] * oldh[1]); + int kk = rint(k * s->iwidth[2] * oldh[2]); int cid = cell_getid(s->cdim, i, j, k); int oldcid = cell_getid(oldcdim, ii, jj, kk); diff --git a/src/runner_doiact.h b/src/runner_doiact.h index 193666ad2..c1479dee1 100644 --- a/src/runner_doiact.h +++ b/src/runner_doiact.h @@ -1727,7 +1727,7 @@ void DOSUB_PAIR1(struct runner *r, struct cell *ci, struct cell *cj, int sid, if (ci->ti_end_min > ti_current && cj->ti_end_min > ti_current) return; /* Get the cell dimensions. */ - const float h = fmin(ci->h[0], fmin(ci->h[1], ci->h[2])); + const float h = fmin(ci->width[0], fmin(ci->width[1], ci->width[2])); /* Get the type of pair if not specified explicitly. */ // if ( sid < 0 ) @@ -2011,7 +2011,7 @@ void DOSUB_PAIR2(struct runner *r, struct cell *ci, struct cell *cj, int sid, if (ci->ti_end_min > ti_current && cj->ti_end_min > ti_current) return; /* Get the cell dimensions. */ - const float h = fmin(ci->h[0], fmin(ci->h[1], ci->h[2])); + const float h = fmin(ci->width[0], fmin(ci->width[1], ci->width[2])); /* Get the type of pair if not specified explicitly. */ // if ( sid < 0 ) @@ -2286,13 +2286,13 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts, if (ci->progeny[k] != NULL) { // if ( parts[ ind[ 0 ] ].x[0] >= ci->progeny[k]->loc[0] && // parts[ ind[ 0 ] ].x[0] <= ci->progeny[k]->loc[0] + - // ci->progeny[k]->h[0] && + // ci->progeny[k]->width[0] && // parts[ ind[ 0 ] ].x[1] >= ci->progeny[k]->loc[1] && // parts[ ind[ 0 ] ].x[1] <= ci->progeny[k]->loc[1] + - // ci->progeny[k]->h[1] && + // ci->progeny[k]->width[1] && // parts[ ind[ 0 ] ].x[2] >= ci->progeny[k]->loc[2] && // parts[ ind[ 0 ] ].x[2] <= ci->progeny[k]->loc[2] + - // ci->progeny[k]->h[2] ) { + // ci->progeny[k]->width[2] ) { if (&parts[ind[0]] >= &ci->progeny[k]->parts[0] && &parts[ind[0]] < &ci->progeny[k]->parts[ci->progeny[k]->count]) { sub = ci->progeny[k]; @@ -2324,7 +2324,7 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts, else { /* Get the cell dimensions. */ - const float h = fmin(ci->h[0], fmin(ci->h[1], ci->h[2])); + const float h = fmin(ci->width[0], fmin(ci->width[1], ci->width[2])); /* Recurse? */ if (ci->split && cj->split && diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h index aaf416e2d..3c16c681c 100644 --- a/src/runner_doiact_grav.h +++ b/src/runner_doiact_grav.h @@ -72,7 +72,7 @@ void runner_dopair_grav_new(struct runner *r, struct cell *ci, /* Get some other useful values. */ h_max = - sqrtf(ci->h[0] * ci->h[0] + ci->h[1] * ci->h[1] + ci->h[2] * ci->h[2]) * + sqrtf(ci->width[0] * ci->width[0] + ci->width[1] * ci->width[1] + ci->width[2] * ci->width[2]) * const_theta_max; count_i = ci->gcount; count_j = cj->gcount; @@ -298,7 +298,7 @@ void runner_dograv_mm(struct runner *r, struct cell *restrict ci, } theta = sqrt((dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]) / - (ci->h[0] * ci->h[0] + ci->h[1] * ci->h[1] + ci->h[2] * ci->h[2])); + (ci->width[0] * ci->width[0] + ci->width[1] * ci->width[1] + ci->width[2] * ci->width[2])); /* Do an MM or an MP/PM? */ if (theta > const_theta_max * 4) { @@ -555,10 +555,10 @@ void runner_dosub_grav(struct runner *r, struct cell *ci, struct cell *cj, for (k = 0; k < 3; k++) { dx[k] = fabs(ci->loc[k] - cj->loc[k]); if (periodic && dx[k] > 0.5 * s->dim[k]) dx[k] = -dx[k] + s->dim[k]; - if (dx[k] > 0.0f) dx[k] -= ci->h[k]; + if (dx[k] > 0.0f) dx[k] -= ci->width[k]; } theta = (dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]) / - (ci->h[0] * ci->h[0] + ci->h[1] * ci->h[1] + ci->h[2] * ci->h[2]); + (ci->width[0] * ci->width[0] + ci->width[1] * ci->width[1] + ci->width[2] * ci->width[2]); /* Split the interaction? */ if (theta < const_theta_max * const_theta_max) { diff --git a/src/space.c b/src/space.c index 0b42a3643..823d9d440 100644 --- a/src/space.c +++ b/src/space.c @@ -218,9 +218,9 @@ void space_regrid(struct space *s, double cell_max, int verbose) { oldcdim[0] = s->cdim[0]; oldcdim[1] = s->cdim[1]; oldcdim[2] = s->cdim[2]; - oldh[0] = s->h[0]; - oldh[1] = s->h[1]; - oldh[2] = s->h[2]; + oldwidth[0] = s->width[0]; + oldwidth[1] = s->width[1]; + oldwidth[2] = s->width[2]; if ((oldnodeIDs = (int *)malloc(sizeof(int) * s->nr_cells)) == NULL) error("Failed to allocate temporary nodeIDs."); @@ -256,10 +256,10 @@ void space_regrid(struct space *s, double cell_max, int verbose) { /* Set the new cell dimensions only if smaller. */ for (int k = 0; k < 3; k++) { s->cdim[k] = cdim[k]; - s->h[k] = s->dim[k] / cdim[k]; - s->ih[k] = 1.0 / s->h[k]; + s->width[k] = s->dim[k] / cdim[k]; + s->iwidth[k] = 1.0 / s->width[k]; } - const float dmin = fminf(s->h[0], fminf(s->h[1], s->h[2])); + const float dmin = fminf(s->width[0], fminf(s->width[1], s->width[2])); /* Allocate the highest level of cells. */ s->tot_cells = s->nr_cells = cdim[0] * cdim[1] * cdim[2]; @@ -275,12 +275,12 @@ void space_regrid(struct space *s, double cell_max, int verbose) { for (int j = 0; j < cdim[1]; j++) for (int k = 0; k < cdim[2]; k++) { c = &s->cells[cell_getid(cdim, i, j, k)]; - c->loc[0] = i * s->h[0]; - c->loc[1] = j * s->h[1]; - c->loc[2] = k * s->h[2]; - c->h[0] = s->h[0]; - c->h[1] = s->h[1]; - c->h[2] = s->h[2]; + c->loc[0] = i * s->width[0]; + c->loc[1] = j * s->width[1]; + c->loc[2] = k * s->width[2]; + c->width[0] = s->width[0]; + c->width[1] = s->width[1]; + c->width[2] = s->width[2]; c->dmin = dmin; c->depth = 0; c->count = 0; @@ -386,7 +386,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { size_t nr_gparts = s->nr_gparts; struct cell *restrict cells = s->cells; - const double ih[3] = {s->ih[0], s->ih[1], s->ih[2]}; + const double ih[3] = {s->iwidth[0], s->iwidth[1], s->iwidth[2]}; const double dim[3] = {s->dim[0], s->dim[1], s->dim[2]}; const int cdim[3] = {s->cdim[0], s->cdim[1], s->cdim[2]}; @@ -1251,13 +1251,13 @@ void space_do_split(struct space *s, struct cell *c) { temp->loc[0] = c->loc[0]; temp->loc[1] = c->loc[1]; temp->loc[2] = c->loc[2]; - temp->h[0] = c->h[0] / 2; - temp->h[1] = c->h[1] / 2; - temp->h[2] = c->h[2] / 2; + temp->width[0] = c->width[0] / 2; + temp->width[1] = c->width[1] / 2; + temp->width[2] = c->width[2] / 2; temp->dmin = c->dmin / 2; - if (k & 4) temp->loc[0] += temp->h[0]; - if (k & 2) temp->loc[1] += temp->h[1]; - if (k & 1) temp->loc[2] += temp->h[2]; + if (k & 4) temp->loc[0] += temp->width[0]; + if (k & 2) temp->loc[1] += temp->width[1]; + if (k & 1) temp->loc[2] += temp->width[2]; temp->depth = c->depth + 1; temp->split = 0; temp->h_max = 0.0; diff --git a/src/space.h b/src/space.h index 5cfb2cb83..dd182e2cd 100644 --- a/src/space.h +++ b/src/space.h @@ -66,7 +66,7 @@ struct space { double dim[3]; /* Cell widths. */ - double h[3], ih[3]; + double width[3], iwidth[3]; /* The minimum and maximum cutoff radii. */ double h_max, cell_min; diff --git a/tests/test27cells.c b/tests/test27cells.c index 6f5de58d3..e58f0b199 100644 --- a/tests/test27cells.c +++ b/tests/test27cells.c @@ -111,9 +111,9 @@ struct cell *make_cell(size_t n, double *offset, double size, double h, cell->h_max = h; cell->count = count; cell->dx_max = 0.; - cell->h[0] = size; - cell->h[1] = size; - cell->h[2] = size; + cell->width[0] = size; + cell->width[1] = size; + cell->width[2] = size; cell->loc[0] = offset[0]; cell->loc[1] = offset[1]; cell->loc[2] = offset[2]; diff --git a/tests/testPair.c b/tests/testPair.c index 2c0bd908c..a1e9055d0 100644 --- a/tests/testPair.c +++ b/tests/testPair.c @@ -76,9 +76,9 @@ struct cell *make_cell(size_t n, double *offset, double size, double h, cell->h_max = h; cell->count = count; cell->dx_max = 0.; - cell->h[0] = n; - cell->h[1] = n; - cell->h[2] = n; + cell->width[0] = n; + cell->width[1] = n; + cell->width[2] = n; cell->loc[0] = offset[0]; cell->loc[1] = offset[1]; cell->loc[2] = offset[2]; diff --git a/tests/testSPHStep.c b/tests/testSPHStep.c index 675d088ac..dade82f1b 100644 --- a/tests/testSPHStep.c +++ b/tests/testSPHStep.c @@ -73,9 +73,9 @@ struct cell *make_cell(size_t N, float cellSize, int offset[3], int id_offset) { cell->count = count; cell->gcount = 0; cell->dx_max = 0.; - cell->h[0] = cellSize; - cell->h[1] = cellSize; - cell->h[2] = cellSize; + cell->width[0] = cellSize; + cell->width[1] = cellSize; + cell->width[2] = cellSize; cell->ti_end_min = 1; cell->ti_end_max = 1; -- GitLab From ccd154b1205e1b5c43e3467670139329388a2986 Mon Sep 17 00:00:00 2001 From: James Willis Date: Mon, 25 Jul 2016 12:36:01 +0100 Subject: [PATCH 2/3] Formatting. --- src/engine.c | 13 ++++++++----- src/map.c | 12 ++++++++---- src/partition.c | 9 +++++---- src/runner_doiact_grav.h | 15 ++++++++------- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/engine.c b/src/engine.c index 1877aceaf..8e471466f 100644 --- a/src/engine.c +++ b/src/engine.c @@ -299,8 +299,9 @@ void engine_redistribute(struct engine *e) { else if (parts[k].x[j] >= dim[j]) parts[k].x[j] -= dim[j]; } - const int cid = cell_getid(cdim, parts[k].x[0] * iwidth[0], - parts[k].x[1] * iwidth[1], parts[k].x[2] * iwidth[2]); + const int cid = + cell_getid(cdim, parts[k].x[0] * iwidth[0], parts[k].x[1] * iwidth[1], + parts[k].x[2] * iwidth[2]); #ifdef SWIFT_DEBUG_CHECKS if (cid < 0 || cid >= s->nr_cells) error("Bad cell id %i for part %zi at [%.3e,%.3e,%.3e].", cid, k, @@ -354,8 +355,9 @@ void engine_redistribute(struct engine *e) { else if (gparts[k].x[j] >= dim[j]) gparts[k].x[j] -= dim[j]; } - const int cid = cell_getid(cdim, gparts[k].x[0] * iwidth[0], - gparts[k].x[1] * iwidth[1], gparts[k].x[2] * iwidth[2]); + const int cid = + cell_getid(cdim, gparts[k].x[0] * iwidth[0], gparts[k].x[1] * iwidth[1], + gparts[k].x[2] * iwidth[2]); #ifdef SWIFT_DEBUG_CHECKS if (cid < 0 || cid >= s->nr_cells) error("Bad cell id %i for part %zi at [%.3e,%.3e,%.3e].", cid, k, @@ -541,7 +543,8 @@ void engine_redistribute(struct engine *e) { /* Verify that all parts are in the right place. */ for (int k = 0; k < nr_parts; k++) { int cid = cell_getid(cdim, parts_new[k].x[0] * iwidth[0], - parts_new[k].x[1] * iwidth[1], parts_new[k].x[2] * iwidth[2]); + parts_new[k].x[1] * iwidth[1], + parts_new[k].x[2] * iwidth[2]); if (cells[cid].nodeID != nodeID) error("Received particle (%i) that does not belong here (nodeID=%i).", k, cells[cid].nodeID); diff --git a/src/map.c b/src/map.c index 844b18c75..b0a311738 100644 --- a/src/map.c +++ b/src/map.c @@ -108,13 +108,15 @@ void map_cellcheck(struct cell *c, void *data) { for (int k = 0; k < c->count; k++) { struct part *p = &c->parts[k]; if (p->x[0] < c->loc[0] || p->x[1] < c->loc[1] || p->x[2] < c->loc[2] || - p->x[0] > c->loc[0] + c->width[0] || p->x[1] > c->loc[1] + c->width[1] || + p->x[0] > c->loc[0] + c->width[0] || + p->x[1] > c->loc[1] + c->width[1] || p->x[2] > c->loc[2] + c->width[2]) { printf( "map_cellcheck: particle at [ %.16e %.16e %.16e ] outside of cell [ " "%.16e %.16e %.16e ] - [ %.16e %.16e %.16e ].\n", p->x[0], p->x[1], p->x[2], c->loc[0], c->loc[1], c->loc[2], - c->loc[0] + c->width[0], c->loc[1] + c->width[1], c->loc[2] + c->width[2]); + c->loc[0] + c->width[0], c->loc[1] + c->width[1], + c->loc[2] + c->width[2]); error("particle out of bounds!"); } } @@ -123,13 +125,15 @@ void map_cellcheck(struct cell *c, void *data) { for (int k = 0; k < c->gcount; k++) { struct gpart *p = &c->gparts[k]; if (p->x[0] < c->loc[0] || p->x[1] < c->loc[1] || p->x[2] < c->loc[2] || - p->x[0] > c->loc[0] + c->width[0] || p->x[1] > c->loc[1] + c->width[1] || + p->x[0] > c->loc[0] + c->width[0] || + p->x[1] > c->loc[1] + c->width[1] || p->x[2] > c->loc[2] + c->width[2]) { printf( "map_cellcheck: g-particle at [ %.16e %.16e %.16e ] outside of cell " "[ %.16e %.16e %.16e ] - [ %.16e %.16e %.16e ].\n", p->x[0], p->x[1], p->x[2], c->loc[0], c->loc[1], c->loc[2], - c->loc[0] + c->width[0], c->loc[1] + c->width[1], c->loc[2] + c->width[2]); + c->loc[0] + c->width[0], c->loc[1] + c->width[1], + c->loc[2] + c->width[2]); error("g-particle out of bounds!"); } } diff --git a/src/partition.c b/src/partition.c index 0cc698de9..11de3a62b 100644 --- a/src/partition.c +++ b/src/partition.c @@ -253,8 +253,9 @@ static void accumulate_counts(struct space *s, int *counts) { else if (parts[k].x[j] >= dim[j]) parts[k].x[j] -= dim[j]; } - const int cid = cell_getid(cdim, parts[k].x[0] * iwidth[0], - parts[k].x[1] * iwidth[1], parts[k].x[2] * iwidth[2]); + const int cid = + cell_getid(cdim, parts[k].x[0] * iwidth[0], parts[k].x[1] * iwidth[1], + parts[k].x[2] * iwidth[2]); counts[cid]++; } } @@ -847,8 +848,8 @@ void partition_initial_partition(struct partition *initial_partition, parts[k].x[j] -= dim[j]; } const int cid = - cell_getid(cdim, parts[k].x[0] * iwidth[0], parts[k].x[1] * iwidth[1], - parts[k].x[2] * iwidth[2]); + cell_getid(cdim, parts[k].x[0] * iwidth[0], + parts[k].x[1] * iwidth[1], parts[k].x[2] * iwidth[2]); weights[cid]++; } diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h index 3c16c681c..401e48ffb 100644 --- a/src/runner_doiact_grav.h +++ b/src/runner_doiact_grav.h @@ -71,9 +71,9 @@ void runner_dopair_grav_new(struct runner *r, struct cell *ci, sort_j = &cj->gsort[sid * (cj->count + 1)]; /* Get some other useful values. */ - h_max = - sqrtf(ci->width[0] * ci->width[0] + ci->width[1] * ci->width[1] + ci->width[2] * ci->width[2]) * - const_theta_max; + h_max = sqrtf(ci->width[0] * ci->width[0] + ci->width[1] * ci->width[1] + + ci->width[2] * ci->width[2]) * + const_theta_max; count_i = ci->gcount; count_j = cj->gcount; parts_i = ci->gparts; @@ -296,9 +296,9 @@ void runner_dograv_mm(struct runner *r, struct cell *restrict ci, dx[k] += shift[k]; } } - theta = - sqrt((dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]) / - (ci->width[0] * ci->width[0] + ci->width[1] * ci->width[1] + ci->width[2] * ci->width[2])); + theta = sqrt((dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]) / + (ci->width[0] * ci->width[0] + ci->width[1] * ci->width[1] + + ci->width[2] * ci->width[2])); /* Do an MM or an MP/PM? */ if (theta > const_theta_max * 4) { @@ -558,7 +558,8 @@ void runner_dosub_grav(struct runner *r, struct cell *ci, struct cell *cj, if (dx[k] > 0.0f) dx[k] -= ci->width[k]; } theta = (dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]) / - (ci->width[0] * ci->width[0] + ci->width[1] * ci->width[1] + ci->width[2] * ci->width[2]); + (ci->width[0] * ci->width[0] + ci->width[1] * ci->width[1] + + ci->width[2] * ci->width[2]); /* Split the interaction? */ if (theta < const_theta_max * const_theta_max) { -- GitLab From dac0b613b6e37f854e21144ca0aae6ae61276a5f Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Mon, 25 Jul 2016 15:35:51 +0100 Subject: [PATCH 3/3] Fixes in MPI mode --- src/space.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/space.c b/src/space.c index 823d9d440..d251139ee 100644 --- a/src/space.c +++ b/src/space.c @@ -209,7 +209,7 @@ void space_regrid(struct space *s, double cell_max, int verbose) { * global partition is recomputed and the particles redistributed. * Be prepared to do that. */ #ifdef WITH_MPI - double oldh[3]; + double oldwidth[3]; double oldcdim[3]; int *oldnodeIDs = NULL; if (cdim[0] < s->cdim[0] || cdim[1] < s->cdim[1] || cdim[2] < s->cdim[2]) { @@ -305,7 +305,7 @@ void space_regrid(struct space *s, double cell_max, int verbose) { "basic cell dimensions have increased - recalculating the " "global partition."); - if (!partition_space_to_space(oldh, oldcdim, oldnodeIDs, s)) { + if (!partition_space_to_space(oldwidth, oldcdim, oldnodeIDs, s)) { /* Failed, try another technique that requires no settings. */ message("Failed to get a new partition, trying less optimal method"); -- GitLab