From c5a5c663d8b25cbeffc2699e422df23ed242e007 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Mon, 11 Apr 2016 15:25:09 +0100 Subject: [PATCH] Code formatting --- src/partition.c | 4 +- src/physical_constants.c | 3 +- src/potentials.c | 4 +- src/potentials.h | 4 +- src/runner.c | 138 +++++++++++++++++++-------------------- src/space.c | 19 +++--- 6 files changed, 87 insertions(+), 85 deletions(-) diff --git a/src/partition.c b/src/partition.c index c4145422de..70249a679e 100644 --- a/src/partition.c +++ b/src/partition.c @@ -1044,7 +1044,6 @@ static int check_complete(struct space *s, int verbose, int nregions) { return (!failed); } - /** * @brief Partition a space of cells based on another space of cells. * @@ -1062,7 +1061,8 @@ static int check_complete(struct space *s, int verbose, int nregions) { * * @param oldh the cell dimensions of old space. * @param oldcdim number of cells per dimension in old space. - * @param oldnodeIDs the nodeIDs of cells in the old space, indexed by old cellid. + * @param oldnodeIDs the nodeIDs of cells in the old space, indexed by old + *cellid. * @param s the space to be partitioned. * * @return 1 if the new space contains nodeIDs from all nodes, 0 otherwise. diff --git a/src/physical_constants.c b/src/physical_constants.c index 4ad79d08a6..d00d63df1c 100644 --- a/src/physical_constants.c +++ b/src/physical_constants.c @@ -103,7 +103,8 @@ void phys_const_init(struct UnitSystem* us, struct phys_const* internal_const) { void phys_const_print(struct phys_const* internal_const) { - message("%25s = %e", "Gravitational constant", internal_const->const_newton_G); + message("%25s = %e", "Gravitational constant", + internal_const->const_newton_G); message("%25s = %e", "Speed of light", internal_const->const_speed_light_c); message("%25s = %e", "Planck constant", internal_const->const_planck_h); message("%25s = %e", "Boltzmann constant", internal_const->const_boltzmann_k); diff --git a/src/potentials.c b/src/potentials.c index 1781c67f72..98e57d7959 100644 --- a/src/potentials.c +++ b/src/potentials.c @@ -33,8 +33,8 @@ * @param potential The external potential properties to initialize */ void potential_init(const struct swift_params* parameter_file, - struct UnitSystem* us, - struct external_potential* potential) { + struct UnitSystem* us, + struct external_potential* potential) { #ifdef EXTERNAL_POTENTIAL_POINTMASS diff --git a/src/potentials.h b/src/potentials.h index 43d9bb48e8..638c4b0d16 100644 --- a/src/potentials.h +++ b/src/potentials.h @@ -112,8 +112,8 @@ __attribute__((always_inline)) INLINE static void external_gravity_pointmass( /* Now, some generic functions, defined in the source file */ void potential_init(const struct swift_params* parameter_file, - struct UnitSystem* us, - struct external_potential* potential); + struct UnitSystem* us, + struct external_potential* potential); void potential_print(const struct external_potential* potential); diff --git a/src/runner.c b/src/runner.c index 33b082d67b..7290522467 100644 --- a/src/runner.c +++ b/src/runner.c @@ -931,75 +931,75 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) { /* If the g-particle has no counterpart and needs to be kicked */ if (gp->id < 0) { - if (is_fixdt || gp->ti_end <= ti_current) { - - /* First, finish the force calculation */ - gravity_end_force(gp); - - /* Now we are ready to compute the next time-step size */ - int new_dti; - - if (is_fixdt) { - - /* Now we have a time step, proceed with the kick */ - new_dti = global_dt_max * timeBase_inv; - - } else { - - /* Compute the next timestep (gravity condition) */ - const float new_dt_external = - gravity_compute_timestep_external(potential, constants, gp); - const float new_dt_self = - gravity_compute_timestep_self(constants, gp); - - float new_dt = fminf(new_dt_external, new_dt_self); - - /* Limit timestep within the allowed range */ - new_dt = fminf(new_dt, global_dt_max); - new_dt = fmaxf(new_dt, global_dt_min); - - /* Convert to integer time */ - new_dti = new_dt * timeBase_inv; - - /* Recover the current timestep */ - const int current_dti = gp->ti_end - gp->ti_begin; - - /* Limit timestep increase */ - if (current_dti > 0) new_dti = min(new_dti, 2 * current_dti); - - /* Put this timestep on the time line */ - int dti_timeline = max_nr_timesteps; - while (new_dti < dti_timeline) dti_timeline /= 2; - - /* Now we have a time step, proceed with the kick */ - new_dti = dti_timeline; - } - - /* Compute the time step for this kick */ - const int ti_start = (gp->ti_begin + gp->ti_end) / 2; - const int ti_end = gp->ti_end + new_dti / 2; - const double dt = (ti_end - ti_start) * timeBase; - const double half_dt = (ti_end - gp->ti_end) * timeBase; - - /* Move particle forward in time */ - gp->ti_begin = gp->ti_end; - gp->ti_end = gp->ti_begin + new_dti; - - /* Kick particles in momentum space */ - gp->v_full[0] += gp->a_grav[0] * dt; - gp->v_full[1] += gp->a_grav[1] * dt; - gp->v_full[2] += gp->a_grav[2] * dt; - - /* Extra kick work */ - gravity_kick_extra(gp, dt, half_dt); - - /* Number of updated g-particles */ - g_updated++; - } - - /* Minimal time for next end of time-step */ - ti_end_min = min(gp->ti_end, ti_end_min); - ti_end_max = max(gp->ti_end, ti_end_max); + if (is_fixdt || gp->ti_end <= ti_current) { + + /* First, finish the force calculation */ + gravity_end_force(gp); + + /* Now we are ready to compute the next time-step size */ + int new_dti; + + if (is_fixdt) { + + /* Now we have a time step, proceed with the kick */ + new_dti = global_dt_max * timeBase_inv; + + } else { + + /* Compute the next timestep (gravity condition) */ + const float new_dt_external = + gravity_compute_timestep_external(potential, constants, gp); + const float new_dt_self = + gravity_compute_timestep_self(constants, gp); + + float new_dt = fminf(new_dt_external, new_dt_self); + + /* Limit timestep within the allowed range */ + new_dt = fminf(new_dt, global_dt_max); + new_dt = fmaxf(new_dt, global_dt_min); + + /* Convert to integer time */ + new_dti = new_dt * timeBase_inv; + + /* Recover the current timestep */ + const int current_dti = gp->ti_end - gp->ti_begin; + + /* Limit timestep increase */ + if (current_dti > 0) new_dti = min(new_dti, 2 * current_dti); + + /* Put this timestep on the time line */ + int dti_timeline = max_nr_timesteps; + while (new_dti < dti_timeline) dti_timeline /= 2; + + /* Now we have a time step, proceed with the kick */ + new_dti = dti_timeline; + } + + /* Compute the time step for this kick */ + const int ti_start = (gp->ti_begin + gp->ti_end) / 2; + const int ti_end = gp->ti_end + new_dti / 2; + const double dt = (ti_end - ti_start) * timeBase; + const double half_dt = (ti_end - gp->ti_end) * timeBase; + + /* Move particle forward in time */ + gp->ti_begin = gp->ti_end; + gp->ti_end = gp->ti_begin + new_dti; + + /* Kick particles in momentum space */ + gp->v_full[0] += gp->a_grav[0] * dt; + gp->v_full[1] += gp->a_grav[1] * dt; + gp->v_full[2] += gp->a_grav[2] * dt; + + /* Extra kick work */ + gravity_kick_extra(gp, dt, half_dt); + + /* Number of updated g-particles */ + g_updated++; + } + + /* Minimal time for next end of time-step */ + ti_end_min = min(gp->ti_end, ti_end_min); + ti_end_max = max(gp->ti_end, ti_end_max); } } diff --git a/src/space.c b/src/space.c index bfc51187d0..a3fb6e8d62 100644 --- a/src/space.c +++ b/src/space.c @@ -205,9 +205,9 @@ void space_regrid(struct space *s, double cell_max, int verbose) { "Must have at least 3 cells in each spatial dimension when periodicity " "is switched on."); - /* In MPI-Land, changing the top-level cell size requires that the - * global partition is recomputed and the particles redistributed. - * Be prepared to do that. */ +/* In MPI-Land, changing the top-level cell size requires that the + * global partition is recomputed and the particles redistributed. + * Be prepared to do that. */ #ifdef WITH_MPI double oldh[3]; double oldcdim[3]; @@ -301,10 +301,11 @@ void space_regrid(struct space *s, double cell_max, int verbose) { * cells around the nodes. We repartition using the old space node * positions as a grid to resample. */ if (s->e->nodeID == 0) - message("basic cell dimensions have increased - recalculating the " - "global partition."); + message( + "basic cell dimensions have increased - recalculating the " + "global partition."); - if (!partition_space_to_space(oldh, oldcdim, oldnodeIDs, s) ) { + if (!partition_space_to_space(oldh, oldcdim, oldnodeIDs, s)) { /* Failed, try another technique that requires no settings. */ message("Failed to get a new partition, trying less optimal method"); @@ -1407,7 +1408,7 @@ void space_init(struct space *s, const struct swift_params *params, space_maxsize = parser_get_param_int(params, "Scheduler:cell_max_size"); space_subsize = parser_get_param_int(params, "Scheduler:cell_sub_size"); space_splitsize = parser_get_param_int(params, "Scheduler:cell_split_size"); - if(verbose) + if (verbose) message("max_size set to %d, sub_size set to %d, split_size set to %d", space_maxsize, space_subsize, space_splitsize); @@ -1478,9 +1479,9 @@ void space_init(struct space *s, const struct swift_params *params, } /* Allocate the extra parts array. */ - if(Npart > 0) { + if (Npart > 0) { if (posix_memalign((void *)&s->xparts, xpart_align, - Npart * sizeof(struct xpart)) != 0) + Npart * sizeof(struct xpart)) != 0) error("Failed to allocate xparts."); bzero(s->xparts, Npart * sizeof(struct xpart)); } -- GitLab