diff --git a/src/cell.c b/src/cell.c index 3fcb8c45633926d71998f1ebbbab6f4162667b2e..ddcf8defaf8a38fe35ae9798bb33db439f4f5ce4 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 b5cc49d05c1cee6e0a884cdb708abbaff4281829..9f35f4386cb161517b1b0c57468f1c0317c0c6a7 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 1ae4dff2517b22aa4760a690c082b64743f54243..1877aceaf63bae71dfab20c446017a0dc2fb4540 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 f4f9ac7cfa7141606b578739517b66e951e65eab..844b18c75a82ddf136dba777be9e38aa05866b27 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 12c90861df80e33cd9199bb4236aea9b584991b6..0cc698de915204f4090ca7b1774217b4c0d68093 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 193666ad264ab2bc5efe092d4e5bebe525ba3c9a..c1479dee12ebdd7743c61e142fbbcd1721e678cd 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 aaf416e2dac76a3694b9bdf13b767d3b2a5e8722..3c16c681c490d5d7a406044ad730a765d2f090de 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 0b42a3643f5740881da85e0533c02f7d8a0ee958..823d9d440624cf5b904aca85a353d294a25eee22 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 5cfb2cb8368ed60586aad62e0f753aab17bf55d1..dd182e2cdbfb427d086f763bddbd915f15ada514 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 6f5de58d395c40e239b7da80fec22cd2bffb097f..e58f0b199577443c3fd0fe3d60446e46507306d7 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 2c0bd908cae4997250d40edb6ccfb8afeb8c5be1..a1e9055d0bd7cb4a87605fee689ec02148b38888 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 675d088acfea7bc9414d18995de3101115b5187e..dade82f1b4f358f5a80091007868650a0115dbfd 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;