diff --git a/src/collectgroup.c b/src/collectgroup.c index d115f5ab1b612fc0c82fb219fca392c5e28d7a6f..0b4ddc405772a45a1e444ef48b65fcb7d37a248f 100644 --- a/src/collectgroup.c +++ b/src/collectgroup.c @@ -89,7 +89,8 @@ void collectgroup1_apply(struct collectgroup1 *grp1, struct engine *e) { * * @param grp1 The #collectgroup1 to initialise * @param updates the number of updated hydro particles on this node this step. - * @param g_updates the number of updated gravity particles on this node this step. + * @param g_updates the number of updated gravity particles on this node this + * step. * @param s_updates the number of updated star particles on this node this step. * @param ti_end_min the minimum end time for next time step after this step. * @param ti_end_max the maximum end time for next time step after this step. @@ -98,10 +99,8 @@ void collectgroup1_apply(struct collectgroup1 *grp1, struct engine *e) { */ void collectgroup1_init(struct collectgroup1 *grp1, size_t updates, size_t g_updates, size_t s_updates, - integertime_t ti_end_min, - integertime_t ti_end_max, - integertime_t ti_beg_max, - int forcerebuild) { + integertime_t ti_end_min, integertime_t ti_end_max, + integertime_t ti_beg_max, int forcerebuild) { grp1->updates = updates; grp1->g_updates = g_updates; grp1->s_updates = s_updates; @@ -133,8 +132,7 @@ void collectgroup1_reduce(struct collectgroup1 *grp1) { struct mpicollectgroup1 mpigrp12; if (MPI_Allreduce(&mpigrp11, &mpigrp12, 1, mpicollectgroup1_type, - mpicollectgroup1_reduce_op, MPI_COMM_WORLD) - != MPI_SUCCESS) + mpicollectgroup1_reduce_op, MPI_COMM_WORLD) != MPI_SUCCESS) error("Failed to reduce mpicollection1."); /* And update. */ @@ -147,7 +145,6 @@ void collectgroup1_reduce(struct collectgroup1 *grp1) { #endif } - #ifdef WITH_MPI /** * @brief Do the reduction of two structs. @@ -176,7 +173,7 @@ static void doreduce1(struct mpicollectgroup1 *mpigrp11, * @brief MPI reduce operator for #mpicollectgroup structures. */ static void mpicollectgroup1_reduce(void *in, void *inout, int *len, - MPI_Datatype *datatype) { + MPI_Datatype *datatype) { for (int i = 0; i < *len; ++i) doreduce1(&((struct mpicollectgroup1 *)inout)[0], diff --git a/src/collectgroup.h b/src/collectgroup.h index f9b8e9ccca335a1fdfe2d6cd60af1573754feccd..b0cbf0763d94dec65ea1aae2c521c1c4b9f7bf83 100644 --- a/src/collectgroup.h +++ b/src/collectgroup.h @@ -48,10 +48,8 @@ void collectgroup_init(); void collectgroup1_apply(struct collectgroup1 *grp1, struct engine *e); void collectgroup1_init(struct collectgroup1 *grp1, size_t updates, size_t g_updates, size_t s_updates, - integertime_t ti_end_min, - integertime_t ti_end_max, - integertime_t ti_beg_max, - int forcerebuild); + integertime_t ti_end_min, integertime_t ti_end_max, + integertime_t ti_beg_max, int forcerebuild); void collectgroup1_reduce(struct collectgroup1 *grp1); #endif /* SWIFT_COLLECTGROUP_H */ diff --git a/src/engine.c b/src/engine.c index 194b8af954f9646582c457eb9045081f290dce59..c8ce267982adbf67349fb9fc81fe08989b0b12a4 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2852,8 +2852,8 @@ void engine_collect_timestep_and_rebuild(struct engine *e, int apply) { } /* Store these in the temporary collection group. */ - collectgroup1_init(&e->collect_group1, updates,g_updates, s_updates, - ti_end_min,ti_end_max,ti_beg_max,e->forcerebuild); + collectgroup1_init(&e->collect_group1, updates, g_updates, s_updates, + ti_end_min, ti_end_max, ti_beg_max, e->forcerebuild); /* Aggregate collective data from the different nodes for this step. */ #ifdef WITH_MPI @@ -2869,8 +2869,8 @@ void engine_collect_timestep_and_rebuild(struct engine *e, int apply) { MPI_COMM_WORLD) != MPI_SUCCESS) error("Failed to aggregate ti_end_min."); if (in_i[0] != (long long)e->collect_group1.ti_end_min) - error("Failed to get same ti_end_min, is %lld, should be %lld", - in_i[0], e->collect_group1.ti_end_min); + error("Failed to get same ti_end_min, is %lld, should be %lld", in_i[0], + e->collect_group1.ti_end_min); long long in_ll[3], out_ll[3]; out_ll[0] = updates; @@ -2880,29 +2880,30 @@ void engine_collect_timestep_and_rebuild(struct engine *e, int apply) { MPI_COMM_WORLD) != MPI_SUCCESS) error("Failed to aggregate particle counts."); if (in_ll[0] != (long long)e->collect_group1.updates) - error("Failed to get same updates, is %lld, should be %ld", - in_ll[0], e->collect_group1.updates); + error("Failed to get same updates, is %lld, should be %ld", in_ll[0], + e->collect_group1.updates); if (in_ll[1] != (long long)e->collect_group1.g_updates) - error("Failed to get same g_updates, is %lld, should be %ld", - in_ll[1], e->collect_group1.g_updates); + error("Failed to get same g_updates, is %lld, should be %ld", in_ll[1], + e->collect_group1.g_updates); if (in_ll[2] != (long long)e->collect_group1.s_updates) - error("Failed to get same s_updates, is %lld, should be %ld", - in_ll[2], e->collect_group1.s_updates); + error("Failed to get same s_updates, is %lld, should be %ld", in_ll[2], + e->collect_group1.s_updates); int buff = 0; if (MPI_Allreduce(&e->forcerebuild, &buff, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD) != MPI_SUCCESS) error("Failed to aggregate the rebuild flag across nodes."); if (!!buff != !!e->collect_group1.forcerebuild) - error("Failed to get same rebuild flag from all nodes, is %d," - "should be %d", buff, e->collect_group1.forcerebuild); + error( + "Failed to get same rebuild flag from all nodes, is %d," + "should be %d", + buff, e->collect_group1.forcerebuild); } #endif #endif /* Apply to the engine, if requested. */ - if (apply) - collectgroup1_apply(&e->collect_group1, e); + if (apply) collectgroup1_apply(&e->collect_group1, e); if (e->verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), @@ -3222,8 +3223,10 @@ void engine_step(struct engine *e) { for (int i = 0; i < e->s->nr_cells; ++i) num_gpart_mpole += e->s->cells_top[i].multipole->m_pole.num_gpart; if (num_gpart_mpole != e->s->nr_gparts) - error("Multipoles don't contain the total number of gpart mpoles=%zd ngparts=%zd", - num_gpart_mpole, e->s->nr_gparts); + error( + "Multipoles don't contain the total number of gpart mpoles=%zd " + "ngparts=%zd", + num_gpart_mpole, e->s->nr_gparts); } #endif @@ -3245,7 +3248,8 @@ void engine_step(struct engine *e) { gravity_exact_force_check(e->s, e, 1e-1); #endif - if (!(e->policy & engine_policy_hydro) && (e->policy & engine_policy_self_gravity) && e->step % 20 == 0) + if (!(e->policy & engine_policy_hydro) && + (e->policy & engine_policy_self_gravity) && e->step % 20 == 0) e->forcerebuild = 1; /* Collect the values of rebuild from all nodes and recover the (integer) @@ -4075,7 +4079,7 @@ void engine_init(struct engine *e, struct space *s, /* Find the time of the first output */ engine_compute_next_snapshot_time(e); - /* Construct types for MPI communications */ +/* Construct types for MPI communications */ #ifdef WITH_MPI part_create_mpi_types(); stats_create_MPI_type(); diff --git a/src/space.c b/src/space.c index 04bb3a513f8acba84e816289cae05198163daf16..d9ce5f5a582a47cb79057c9e60787e2a0f64714b 100644 --- a/src/space.c +++ b/src/space.c @@ -2151,13 +2151,13 @@ void space_split_recursive(struct space *s, struct cell *c, /* Construct the multipole and the centre of mass*/ if (s->gravity) { - if(gcount > 0) - gravity_P2M(c->multipole, c->gparts, c->gcount); + if (gcount > 0) + gravity_P2M(c->multipole, c->gparts, c->gcount); else { - gravity_multipole_init(&c->multipole->m_pole); - 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.; + gravity_multipole_init(&c->multipole->m_pole); + 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.; } } }