Commit 3f976040 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Code formatting.

parent c41cc356
......@@ -337,7 +337,8 @@ int cell_unpack_end_step(struct cell *restrict c,
}
/**
* @brief Pack the multipole information of the given cell and all it's sub-cells.
* @brief Pack the multipole information of the given cell and all it's
* sub-cells.
*
* @param c The #cell.
* @param pcells (output) The multipole information we pack into
......@@ -345,7 +346,7 @@ int cell_unpack_end_step(struct cell *restrict c,
* @return The number of packed cells.
*/
int cell_pack_multipoles(struct cell *restrict c,
struct gravity_tensors *restrict pcells) {
struct gravity_tensors *restrict pcells) {
#ifdef WITH_MPI
......@@ -377,7 +378,7 @@ int cell_pack_multipoles(struct cell *restrict c,
* @return The number of cells created.
*/
int cell_unpack_multipoles(struct cell *restrict c,
struct gravity_tensors *restrict pcells) {
struct gravity_tensors *restrict pcells) {
#ifdef WITH_MPI
......@@ -400,7 +401,6 @@ int cell_unpack_multipoles(struct cell *restrict c,
#endif
}
/**
* @brief Lock a cell for access to its array of #part and hold its parents.
*
......@@ -2077,7 +2077,7 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
cell_activate_subcell_grav_tasks(t->ci, NULL, s);
} else if (t->type == task_type_pair) {
cell_activate_subcell_grav_tasks(t->ci, t->cj, s);
#ifdef WITH_MPI
/* Activate the send/recv tasks. */
if (ci->nodeID != engine_rank) {
......@@ -2085,7 +2085,7 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
/* If the local cell is active, receive data from the foreign cell. */
if (cj_active) {
scheduler_activate(s, ci->recv_grav);
}
}
/* If the foreign cell is active, we want its ti_end values. */
if (ci_active) scheduler_activate(s, ci->recv_ti);
......@@ -2093,42 +2093,41 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
/* Is the foreign cell active and will need stuff from us? */
if (ci_active) {
scheduler_activate_send(s, cj->send_grav, ci->nodeID);
scheduler_activate_send(s, cj->send_grav, ci->nodeID);
/* Drift the cell which will be sent at the level at which it is
sent, i.e. drift the cell specified in the send task (l->t)
itself. */
cell_activate_drift_gpart(cj, s);
}
}
/* If the local cell is active, send its ti_end values. */
if (cj_active) scheduler_activate_send(s, cj->send_ti, ci->nodeID);
} else if (cj->nodeID != engine_rank) {
} else if (cj->nodeID != engine_rank) {
/* If the local cell is active, receive data from the foreign cell. */
if (ci_active) {
scheduler_activate(s, cj->recv_grav);
}
}
/* If the foreign cell is active, we want its ti_end values. */
if (cj_active) scheduler_activate(s, cj->recv_ti);
/* Is the foreign cell active and will need stuff from us? */
if (cj_active) {
scheduler_activate_send(s, ci->send_grav, cj->nodeID);
scheduler_activate_send(s, ci->send_grav, cj->nodeID);
/* Drift the cell which will be sent at the level at which it is
sent, i.e. drift the cell specified in the send task (l->t)
itself. */
cell_activate_drift_gpart(ci, s);
}
}
/* If the local cell is active, send its ti_end values. */
if (ci_active) scheduler_activate_send(s, ci->send_ti, cj->nodeID);
}
}
#endif
}
}
......
......@@ -248,7 +248,7 @@ struct cell {
struct task *recv_grav;
/* Task receiving multipole data. */
//struct task *recv_multipole;
// struct task *recv_multipole;
/* Task receiving data (time-step). */
struct task *recv_ti;
......@@ -266,7 +266,7 @@ struct cell {
struct link *send_grav;
/* Linked list for sending multipole data. */
//struct link *send_multipole;
// struct link *send_multipole;
/* Linked list for sending data (time-step). */
struct link *send_ti;
......
This diff is collapsed.
......@@ -265,8 +265,8 @@ void engine_print_stats(struct engine *e);
void engine_dump_snapshot(struct engine *e);
void engine_init(struct engine *e, struct space *s,
const struct swift_params *params, int nr_nodes, int nodeID,
int nr_threads, long long Ngas, long long Ndm, int with_aff, int policy,
int verbose, struct repartition *reparttype,
int nr_threads, long long Ngas, long long Ndm, int with_aff,
int policy, int verbose, struct repartition *reparttype,
const struct unit_system *internal_units,
const struct phys_const *physical_constants,
const struct hydro_props *hydro,
......
......@@ -52,7 +52,7 @@ void gravity_props_init(struct gravity_props *p,
/* Opening angle */
p->theta_crit = parser_get_param_double(params, "Gravity:theta");
//if (p->theta_crit >= 1.) error("Theta too large. FMM won't converge.");
// if (p->theta_crit >= 1.) error("Theta too large. FMM won't converge.");
p->theta_crit2 = p->theta_crit * p->theta_crit;
p->theta_crit_inv = 1. / p->theta_crit;
......
......@@ -181,19 +181,19 @@ struct gravity_tensors {
/*! Multipole mass */
struct multipole m_pole;
/*! Field tensor for the potential */
struct grav_tensor pot;
/*! Centre of mass of the matter dsitribution */
double CoM[3];
/*! Centre of mass of the matter dsitribution at the last rebuild */
double CoM_rebuild[3];
/*! Upper limit of the CoM<->gpart distance */
double r_max;
/*! Upper limit of the CoM<->gpart distance at the last rebuild */
double r_max_rebuild;
};
......@@ -232,7 +232,7 @@ INLINE static void gravity_drift(struct gravity_tensors *m, double dt,
m->CoM[2] += dz;
/* Conservative change in maximal radius containing all gpart */
m->r_max = m->r_max_rebuild + 0.*x_diff;
m->r_max = m->r_max_rebuild + 0. * x_diff;
}
/**
......
......@@ -553,7 +553,7 @@ void runner_do_init_grav(struct runner *r, struct cell *c, int timer) {
if (!cell_is_active(c, e)) return;
/* Drift the multipole */
//cell_drift_multipole(c, e);
// cell_drift_multipole(c, e);
/* Reset the gravity acceleration tensors */
gravity_field_tensors_init(&c->multipole->pot, e->ti_current);
......@@ -1419,15 +1419,14 @@ void runner_do_end_force(struct runner *r, struct cell *c, int timer) {
TIMER_TIC;
#if (ICHECK != 0)
for(int i=0; i < c->gcount; ++i)
if(c->gparts[i].id_or_neg_offset == ICHECK) {
message("Found gpart"); fflush(stdout);
for (int i = 0; i < c->gcount; ++i)
if (c->gparts[i].id_or_neg_offset == ICHECK) {
message("Found gpart");
fflush(stdout);
}
#endif
/* Anything to do here? */
if (!cell_is_active(c, e)) return;
......@@ -1485,15 +1484,15 @@ void runner_do_end_force(struct runner *r, struct cell *c, int timer) {
/* Check that this gpart has interacted with all the other
* particles (via direct or multipoles) in the box */
if (gp->num_interacted != e->total_nr_gparts && gp->id_or_neg_offset == ICHECK)
if (gp->num_interacted != e->total_nr_gparts &&
gp->id_or_neg_offset == ICHECK)
error(
"g-particle (id=%lld, type=%s) did not interact "
"gravitationally "
"with all other gparts gp->num_interacted=%lld, "
"total_gparts=%zd (local num_gparts=%zd)",
gp->id_or_neg_offset, part_type_names[gp->type],
gp->num_interacted, e->total_nr_gparts,
e->s->nr_gparts);
gp->num_interacted, e->total_nr_gparts, e->s->nr_gparts);
}
#endif
}
......@@ -1985,7 +1984,7 @@ void *runner_main(void *data) {
runner_do_recv_spart(r, ci, 1);
} else if (t->subtype == task_subtype_multipole) {
cell_unpack_multipoles(ci, t->buff);
free(t->buff);
free(t->buff);
} else {
error("Unknown/invalid task subtype (%d).", t->subtype);
}
......
......@@ -45,10 +45,10 @@ void runner_do_grav_down(struct runner *r, struct cell *c, int timer) {
const int gcount = c->gcount;
#if (ICHECK != 0)
for(int i=0; i < c->gcount; ++i)
if(c->gparts[i].id_or_neg_offset == ICHECK)
message("Found gpart depth=%d split=%d m->num_interacted=%lld",
c->depth, c->split, c->multipole->pot.num_interacted);
for (int i = 0; i < c->gcount; ++i)
if (c->gparts[i].id_or_neg_offset == ICHECK)
message("Found gpart depth=%d split=%d m->num_interacted=%lld", c->depth,
c->split, c->multipole->pot.num_interacted);
#endif
TIMER_TIC;
......@@ -136,7 +136,6 @@ void runner_do_grav_down(struct runner *r, struct cell *c, int timer) {
void runner_dopair_grav_mm(const struct runner *r, struct cell *restrict ci,
struct cell *restrict cj) {
/* Some constants */
const struct engine *e = r->e;
const struct space *s = e->s;
......@@ -157,7 +156,8 @@ void runner_dopair_grav_mm(const struct runner *r, struct cell *restrict ci,
#ifdef SWIFT_DEBUG_CHECKS
if (ci == cj) error("Interacting a cell with itself using M2L");
if (multi_j->num_gpart == 0) error("Multipole does not seem to have been set.");
if (multi_j->num_gpart == 0)
error("Multipole does not seem to have been set.");
if (ci->multipole->pot.ti_init != e->ti_current)
error("ci->grav tensor not initialised.");
......@@ -1156,8 +1156,8 @@ void runner_do_grav_long_range(struct runner *r, struct cell *ci, int timer) {
int direct_ngbs = 0;
int direct_ngbs_gpart = 0;
int other_ngbs_gpart = 0;
for(int i=0; i < ci->gcount; ++i)
if(ci->gparts[i].id_or_neg_offset == ICHECK) {
for (int i = 0; i < ci->gcount; ++i)
if (ci->gparts[i].id_or_neg_offset == ICHECK) {
message("Found gpart");
check = 1;
}
......@@ -1178,7 +1178,7 @@ void runner_do_grav_long_range(struct runner *r, struct cell *ci, int timer) {
if (ci->nodeID != engine_rank)
error("Non-local cell in long-range gravity task!");
/* Check multipole has been drifted */
if (ci->ti_old_multipole != e->ti_current)
error("Interacting un-drifted multipole");
......@@ -1191,7 +1191,7 @@ void runner_do_grav_long_range(struct runner *r, struct cell *ci, int timer) {
/* multi_i->CoM_rebuild[2]}; */
/* Get the cell index. MATTHIEU */
const int cid = (ci - cells);// / sizeof(struct cell);
const int cid = (ci - cells); // / sizeof(struct cell);
const int i = cid / (cdim[1] * cdim[2]);
const int j = (cid / cdim[2]) % cdim[1];
const int k = cid % cdim[2];
......@@ -1212,7 +1212,7 @@ void runner_do_grav_long_range(struct runner *r, struct cell *ci, int timer) {
#endif
// MATTHIEU
const int cjd = (cj - cells);// / sizeof(struct cell);
const int cjd = (cj - cells); // / sizeof(struct cell);
const int ii = cjd / (cdim[1] * cdim[2]);
const int jj = (cjd / cdim[2]) % cdim[1];
const int kk = cjd % cdim[2];
......@@ -1235,27 +1235,29 @@ void runner_do_grav_long_range(struct runner *r, struct cell *ci, int timer) {
/* Are we in charge of this cell pair? MATTHIEU*/
/* if (gravity_M2L_accept(multi_i->r_max_rebuild, multi_j->r_max_rebuild, */
/* theta_crit2, r2_rebuild)) { */
if((abs(i-ii) <= 1 || abs(i-ii - cdim[0]) <= 1 || abs(i-ii + cdim[0]) <= 1) &&
(abs(j-jj) <= 1 || abs(j-jj - cdim[1]) <= 1 || abs(j-jj + cdim[1]) <= 1) &&
(abs(k-kk) <= 1 || abs(k-kk - cdim[2]) <= 1 || abs(k-kk + cdim[2]) <= 1)) {
if ((abs(i - ii) <= 1 || abs(i - ii - cdim[0]) <= 1 ||
abs(i - ii + cdim[0]) <= 1) &&
(abs(j - jj) <= 1 || abs(j - jj - cdim[1]) <= 1 ||
abs(j - jj + cdim[1]) <= 1) &&
(abs(k - kk) <= 1 || abs(k - kk - cdim[2]) <= 1 ||
abs(k - kk + cdim[2]) <= 1)) {
#if (ICHECK != 0)
if(check) {
++direct_ngbs;
direct_ngbs_gpart += cj->multipole->m_pole.num_gpart;
message("Found direct neighbour %d: (i,j,k)=(%d,%d,%d) (ii,jj,kk)=(%d,%d,%d) nodeID=%d",
direct_ngbs, i,j,k, ii,jj,kk, cj->nodeID);
if (check) {
++direct_ngbs;
direct_ngbs_gpart += cj->multipole->m_pole.num_gpart;
message(
"Found direct neighbour %d: (i,j,k)=(%d,%d,%d) "
"(ii,jj,kk)=(%d,%d,%d) nodeID=%d",
direct_ngbs, i, j, k, ii, jj, kk, cj->nodeID);
}
#endif
}else{
} else {
#if (ICHECK != 0)
if(check)
other_ngbs_gpart += cj->multipole->m_pole.num_gpart;
#endif
if (check) other_ngbs_gpart += cj->multipole->m_pole.num_gpart;
#endif
/* Let's compute the current distance between the cell pair*/
double dx = CoM_i[0] - multi_j->CoM[0];
......@@ -1292,17 +1294,19 @@ void runner_do_grav_long_range(struct runner *r, struct cell *ci, int timer) {
}
} /* We are in charge of this pair */
} /* Loop over top-level cells */
#ifdef SWIFT_DEBUG_CHECKS
counter += ci->multipole->m_pole.num_gpart;
if(counter != e->total_nr_gparts)
if (counter != e->total_nr_gparts)
error("Not found the right number of particles in top-level interactions");
#endif
if(check)
message("Interacted with %d indirectly and ignored %d direct interactions (counter=%lld) nr_cells=%d total=%lld",
other_ngbs_gpart, direct_ngbs_gpart, counter, nr_cells, e->total_nr_gparts);
if (check)
message(
"Interacted with %d indirectly and ignored %d direct interactions "
"(counter=%lld) nr_cells=%d total=%lld",
other_ngbs_gpart, direct_ngbs_gpart, counter, nr_cells,
e->total_nr_gparts);
if (timer) TIMER_TOC(timer_dograv_long_range);
}
......
......@@ -1293,10 +1293,10 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
err = MPI_Irecv(t->ci->sparts, t->ci->scount, spart_mpi_type,
t->ci->nodeID, t->flags, MPI_COMM_WORLD, &t->req);
} else if (t->subtype == task_subtype_multipole) {
t->buff = malloc(sizeof(struct gravity_tensors) * t->ci->pcell_size);
err = MPI_Irecv(t->buff, sizeof(struct gravity_tensors) * t->ci->pcell_size,
MPI_BYTE, t->ci->nodeID, t->flags, MPI_COMM_WORLD,
&t->req);
t->buff = malloc(sizeof(struct gravity_tensors) * t->ci->pcell_size);
err = MPI_Irecv(
t->buff, sizeof(struct gravity_tensors) * t->ci->pcell_size,
MPI_BYTE, t->ci->nodeID, t->flags, MPI_COMM_WORLD, &t->req);
} else {
error("Unknown communication sub-type");
}
......@@ -1330,13 +1330,13 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
} else if (t->subtype == task_subtype_spart) {
err = MPI_Isend(t->ci->sparts, t->ci->scount, spart_mpi_type,
t->cj->nodeID, t->flags, MPI_COMM_WORLD, &t->req);
} else if (t->subtype == task_subtype_multipole) {
} else if (t->subtype == task_subtype_multipole) {
t->buff = malloc(sizeof(struct gravity_tensors) * t->ci->pcell_size);
cell_pack_multipoles(t->ci, t->buff);
err = MPI_Isend(
t->buff, t->ci->pcell_size * sizeof(struct gravity_tensors), MPI_BYTE,
t->cj->nodeID, t->flags, MPI_COMM_WORLD, &t->req);
} else {
t->buff, t->ci->pcell_size * sizeof(struct gravity_tensors),
MPI_BYTE, t->cj->nodeID, t->flags, MPI_COMM_WORLD, &t->req);
} else {
error("Unknown communication sub-type");
}
if (err != MPI_SUCCESS) {
......
......@@ -234,8 +234,7 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements,
c->xparts = NULL;
c->gparts = NULL;
c->sparts = NULL;
if(s->gravity)
bzero(c->multipole, sizeof(struct gravity_tensors));
if (s->gravity) bzero(c->multipole, sizeof(struct gravity_tensors));
for (int i = 0; i < 13; i++)
if (c->sort[i] != NULL) {
free(c->sort[i]);
......@@ -246,14 +245,14 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements,
c->recv_rho = NULL;
c->recv_gradient = NULL;
c->recv_grav = NULL;
//c->recv_multipole = NULL;
// c->recv_multipole = NULL;
c->recv_ti = NULL;
c->send_xv = NULL;
c->send_rho = NULL;
c->send_gradient = NULL;
c->send_grav = NULL;
//c->send_multipole = NULL;
// c->send_multipole = NULL;
c->send_ti = NULL;
#endif
}
......@@ -266,7 +265,8 @@ void space_free_cells(struct space *s) {
threadpool_map(&s->e->threadpool, space_rebuild_recycle_mapper, s->cells_top,
s->nr_cells, sizeof(struct cell), 0, s);
s->maxdepth = 0;
message("Done"); fflush(stdout);
message("Done");
fflush(stdout);
}
/**
......@@ -2243,12 +2243,12 @@ void space_split_recursive(struct space *s, struct cell *c,
c->multipole->r_max = sqrt(dx * dx + dy * dy + dz * dz);
} else {
gravity_multipole_init(&c->multipole->m_pole);
if(c->nodeID == engine_rank) {
c->multipole->CoM[0] = c->loc[0] + c->width[0] / 2.;
c->multipole->CoM[1] = c->loc[1] + c->width[1] / 2.;
c->multipole->CoM[2] = c->loc[2] + c->width[2] / 2.;
c->multipole->r_max = 0.;
}
if (c->nodeID == engine_rank) {
c->multipole->CoM[0] = c->loc[0] + c->width[0] / 2.;
c->multipole->CoM[1] = c->loc[1] + c->width[1] / 2.;
c->multipole->CoM[2] = c->loc[2] + c->width[2] / 2.;
c->multipole->r_max = 0.;
}
}
c->multipole->r_max_rebuild = c->multipole->r_max;
c->multipole->CoM_rebuild[0] = c->multipole->CoM[0];
......
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