Commit 3667310c authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

No need to store the nodeID in the space structure. Documentation fixes.

parent 3da8de63
......@@ -544,8 +544,8 @@ int main(int argc, char *argv[]) {
/* Initialize the space with these data. */
if (myrank == 0) clocks_gettime(&tic);
struct space s;
space_init(&s, myrank, params, dim, parts, gparts, sparts, Ngas, Ngpart,
Nspart, periodic, replicate, with_self_gravity, talking, dry_run);
space_init(&s, params, dim, parts, gparts, sparts, Ngas, Ngpart, Nspart,
periodic, replicate, with_self_gravity, talking, dry_run);
if (myrank == 0) {
clocks_gettime(&toc);
message("space_init took %.3f %s.", clocks_diff(&tic, &toc),
......
......@@ -2064,6 +2064,13 @@ void cell_set_super(struct cell *c, struct cell *super) {
if (c->progeny[k] != NULL) cell_set_super(c->progeny[k], super);
}
/**
* @brief Mapper function to set the super pointer of the cells.
*
* @param map_data The top-level cells.
* @param num_elements The number of top-level cells.
* @param extra_data Unused parameter.
*/
void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data) {
for (int ind = 0; ind < num_elements; ind++) {
struct cell *c = &((struct cell *)map_data)[ind];
......@@ -2071,13 +2078,21 @@ void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data) {
}
}
/**
* @brief Does this cell or any of its children have any task ?
*
* We use the timestep-related tasks to probe this as these always
* exist in a cell hierarchy that has any kind of task.
*
* @param c The #cell to probe.
*/
int cell_has_tasks(struct cell *c) {
#ifdef WITH_MPI
if (c->timestep != NULL || c->recv_ti != NULL) return 1;
#else
if (c->timestep != NULL) return 1;
#endif /* WITH_MPI */
#endif
if (c->split) {
int count = 0;
......
......@@ -2473,6 +2473,14 @@ void space_getcells(struct space *s, int nr_cells, struct cell **cells) {
}
}
/**
* @brief Construct the list of top-level cells that have any tasks in
* their hierarchy.
*
* This assumes the list has been pre-allocated at a regrid.
*
* @param s The #space.
*/
void space_list_cells_with_tasks(struct space *s) {
/* Let's rebuild the list of local top-level cells */
......@@ -2480,7 +2488,7 @@ void space_list_cells_with_tasks(struct space *s) {
for (int i = 0; i < s->nr_cells; ++i)
if (cell_has_tasks(&s->cells_top[i])) {
s->local_cells_top[s->nr_local_cells] = i;
++s->nr_local_cells;
s->nr_local_cells++;
}
if (s->e->verbose)
message("Have %d local cells (total=%d)", s->nr_local_cells, s->nr_cells);
......@@ -2672,7 +2680,7 @@ void space_init_sparts(struct space *s) {
* parts with a cutoff below half the cell width are then split
* recursively.
*/
void space_init(struct space *s, int nodeID, const struct swift_params *params,
void space_init(struct space *s, const struct swift_params *params,
double dim[3], struct part *parts, struct gpart *gparts,
struct spart *sparts, size_t Npart, size_t Ngpart,
size_t Nspart, int periodic, int replicate, int gravity,
......@@ -2682,7 +2690,6 @@ void space_init(struct space *s, int nodeID, const struct swift_params *params,
bzero(s, sizeof(struct space));
/* Store everything in the space. */
s->nodeID = nodeID;
s->dim[0] = dim[0];
s->dim[1] = dim[1];
s->dim[2] = dim[2];
......
......@@ -74,9 +74,6 @@ struct space {
/*! Extra space information needed for some hydro schemes. */
struct hydro_space hs;
/*! The MPI rank of this space */
int nodeID;
/*! Are we doing gravity? */
int gravity;
......@@ -182,7 +179,7 @@ void space_sparts_sort(struct space *s, int *ind, size_t N, int min, int max,
void space_getcells(struct space *s, int nr_cells, struct cell **cells);
int space_getsid(struct space *s, struct cell **ci, struct cell **cj,
double *shift);
void space_init(struct space *s, int nodeID, const struct swift_params *params,
void space_init(struct space *s, const struct swift_params *params,
double dim[3], struct part *parts, struct gpart *gparts,
struct spart *sparts, size_t Npart, size_t Ngpart,
size_t Nspart, int periodic, int replicate, int gravity,
......
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