Commit c8b797ad authored by James Willis's avatar James Willis
Browse files

Renamed 'h' in cell struct to 'width' and renamed 'h' and 'ih' in the space...

Renamed 'h' in cell struct to 'width' and renamed 'h' and 'ih' in the space struct to 'width' and 'iwidth'.
parent 7a73ec6d
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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!");
}
}
......
......@@ -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);
......
......@@ -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 &&
......
......@@ -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) {
......
......@@ -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;
......
......@@ -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;
......
......@@ -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];
......
......@@ -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];
......
......@@ -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;
......
Markdown is supported
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