Commit d8d71581 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Code formatting

parent 4ad965ea
...@@ -1453,7 +1453,7 @@ void cell_activate_drift_gpart(struct cell *c, struct scheduler *s) { ...@@ -1453,7 +1453,7 @@ void cell_activate_drift_gpart(struct cell *c, struct scheduler *s) {
if (parent->drift_gpart == NULL) if (parent->drift_gpart == NULL)
error("Trying to activate un-existing parent->drift_gpart"); error("Trying to activate un-existing parent->drift_gpart");
#endif #endif
scheduler_activate(s, parent->drift_gpart); scheduler_activate(s, parent->drift_gpart);
break; break;
} }
} }
...@@ -2706,8 +2706,7 @@ void cell_drift_all_multipoles(struct cell *c, const struct engine *e) { ...@@ -2706,8 +2706,7 @@ void cell_drift_all_multipoles(struct cell *c, const struct engine *e) {
dt_drift = (ti_current - ti_old_multipole) * e->time_base; dt_drift = (ti_current - ti_old_multipole) * e->time_base;
/* Drift the multipole */ /* Drift the multipole */
if (ti_current > ti_old_multipole) if (ti_current > ti_old_multipole) gravity_drift(c->multipole, dt_drift);
gravity_drift(c->multipole, dt_drift);
/* Are we not in a leaf ? */ /* Are we not in a leaf ? */
if (c->split) { if (c->split) {
...@@ -2748,8 +2747,7 @@ void cell_drift_multipole(struct cell *c, const struct engine *e) { ...@@ -2748,8 +2747,7 @@ void cell_drift_multipole(struct cell *c, const struct engine *e) {
else else
dt_drift = (ti_current - ti_old_multipole) * e->time_base; dt_drift = (ti_current - ti_old_multipole) * e->time_base;
if (ti_current > ti_old_multipole) if (ti_current > ti_old_multipole) gravity_drift(c->multipole, dt_drift);
gravity_drift(c->multipole, dt_drift);
/* Update the time of the last drift */ /* Update the time of the last drift */
c->ti_old_multipole = ti_current; c->ti_old_multipole = ti_current;
......
...@@ -2378,8 +2378,8 @@ void engine_make_self_gravity_tasks_mapper(void *map_data, int num_elements, ...@@ -2378,8 +2378,8 @@ void engine_make_self_gravity_tasks_mapper(void *map_data, int num_elements,
int delta_p = delta; int delta_p = delta;
/* Special case where every cell is in range of every other one */ /* Special case where every cell is in range of every other one */
if(delta >= cdim[0] / 2) { if (delta >= cdim[0] / 2) {
if(cdim[0] % 2 == 0) { if (cdim[0] % 2 == 0) {
delta_m = cdim[0] / 2; delta_m = cdim[0] / 2;
delta_p = cdim[0] / 2 - 1; delta_p = cdim[0] / 2 - 1;
} else { } else {
...@@ -6029,7 +6029,7 @@ void engine_config(int restart, struct engine *e, struct swift_params *params, ...@@ -6029,7 +6029,7 @@ void engine_config(int restart, struct engine *e, struct swift_params *params,
if (!(e->policy & engine_policy_cosmology)) if (!(e->policy & engine_policy_cosmology))
if (e->dt_max > (e->time_end - e->time_begin) && e->nodeID == 0) if (e->dt_max > (e->time_end - e->time_begin) && e->nodeID == 0)
error("Maximal time-step size larger than the simulation run time t=%e", error("Maximal time-step size larger than the simulation run time t=%e",
e->time_end - e->time_begin); e->time_end - e->time_begin);
/* Deal with outputs */ /* Deal with outputs */
if (e->policy & engine_policy_cosmology) { if (e->policy & engine_policy_cosmology) {
...@@ -6082,7 +6082,8 @@ void engine_config(int restart, struct engine *e, struct swift_params *params, ...@@ -6082,7 +6082,8 @@ void engine_config(int restart, struct engine *e, struct swift_params *params,
/* Reduce the total mass */ /* Reduce the total mass */
#ifdef WITH_MPI #ifdef WITH_MPI
MPI_Allreduce(MPI_IN_PLACE, &e->total_mass, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); MPI_Allreduce(MPI_IN_PLACE, &e->total_mass, 1, MPI_DOUBLE, MPI_SUM,
MPI_COMM_WORLD);
#endif #endif
/* Find the time of the first snapshot output */ /* Find the time of the first snapshot output */
......
...@@ -169,8 +169,7 @@ __attribute__((always_inline)) INLINE static void gravity_end_force( ...@@ -169,8 +169,7 @@ __attribute__((always_inline)) INLINE static void gravity_end_force(
const int periodic) { const int periodic) {
/* Apply the periodic correction to the peculiar potential */ /* Apply the periodic correction to the peculiar potential */
if(periodic) if (periodic) gp->potential += potential_normalisation;
gp->potential += potential_normalisation;
/* Let's get physical... */ /* Let's get physical... */
gp->a_grav[0] *= const_G; gp->a_grav[0] *= const_G;
......
...@@ -23,9 +23,11 @@ __attribute__((always_inline)) INLINE static void gravity_debug_particle( ...@@ -23,9 +23,11 @@ __attribute__((always_inline)) INLINE static void gravity_debug_particle(
const struct gpart* p) { const struct gpart* p) {
printf( printf(
"mass=%.3e time_bin=%d\n" "mass=%.3e time_bin=%d\n"
"x=[%.5e,%.5e,%.5e], v_full=[%.5e,%.5e,%.5e], a=[%.5e,%.5e,%.5e] pot=%.5e\n", "x=[%.5e,%.5e,%.5e], v_full=[%.5e,%.5e,%.5e], a=[%.5e,%.5e,%.5e] "
"pot=%.5e\n",
p->mass, p->time_bin, p->x[0], p->x[1], p->x[2], p->v_full[0], p->mass, p->time_bin, p->x[0], p->x[1], p->x[2], p->v_full[0],
p->v_full[1], p->v_full[2], p->a_grav[0], p->a_grav[1], p->a_grav[2], p->potential); p->v_full[1], p->v_full[2], p->a_grav[0], p->a_grav[1], p->a_grav[2],
p->potential);
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
printf("num_interacted=%lld ti_drift=%lld ti_kick=%lld\n", p->num_interacted, printf("num_interacted=%lld ti_drift=%lld ti_kick=%lld\n", p->num_interacted,
p->ti_drift, p->ti_kick); p->ti_drift, p->ti_kick);
......
...@@ -36,5 +36,4 @@ ...@@ -36,5 +36,4 @@
#error "Invalid choice of gravity variant" #error "Invalid choice of gravity variant"
#endif #endif
#endif #endif
...@@ -282,7 +282,7 @@ void mesh_to_gparts_CIC(struct gpart* gp, const double* pot, int N, double fac, ...@@ -282,7 +282,7 @@ void mesh_to_gparts_CIC(struct gpart* gp, const double* pot, int N, double fac,
* @param verbose Are we talkative? * @param verbose Are we talkative?
*/ */
void pm_mesh_compute_potential(struct pm_mesh* mesh, const struct space* s, void pm_mesh_compute_potential(struct pm_mesh* mesh, const struct space* s,
int verbose) { int verbose) {
#ifdef HAVE_FFTW #ifdef HAVE_FFTW
...@@ -323,9 +323,9 @@ void pm_mesh_compute_potential(struct pm_mesh* mesh, const struct space* s, ...@@ -323,9 +323,9 @@ void pm_mesh_compute_potential(struct pm_mesh* mesh, const struct space* s,
for (size_t i = 0; i < s->nr_gparts; ++i) for (size_t i = 0; i < s->nr_gparts; ++i)
gpart_to_mesh_CIC(&s->gparts[i], rho, N, cell_fac, dim); gpart_to_mesh_CIC(&s->gparts[i], rho, N, cell_fac, dim);
if(verbose) if (verbose)
message("gpart assignment took %.3f %s.", clocks_from_ticks(getticks() - tic), message("gpart assignment took %.3f %s.",
clocks_getunit()); clocks_from_ticks(getticks() - tic), clocks_getunit());
/* message("\n\n\n DENSITY"); */ /* message("\n\n\n DENSITY"); */
/* print_array(rho, N); */ /* print_array(rho, N); */
...@@ -407,9 +407,9 @@ void pm_mesh_compute_potential(struct pm_mesh* mesh, const struct space* s, ...@@ -407,9 +407,9 @@ void pm_mesh_compute_potential(struct pm_mesh* mesh, const struct space* s,
/* Let's store it in the structure */ /* Let's store it in the structure */
mesh->potential = rho; mesh->potential = rho;
if(verbose) if (verbose)
message("Fourier-space PM took %.3f %s.", clocks_from_ticks(getticks() - tic2), message("Fourier-space PM took %.3f %s.",
clocks_getunit()); clocks_from_ticks(getticks() - tic2), clocks_getunit());
/* message("\n\n\n POTENTIAL"); */ /* message("\n\n\n POTENTIAL"); */
/* print_array(potential, N); */ /* print_array(potential, N); */
......
...@@ -67,7 +67,7 @@ void pm_mesh_init(struct pm_mesh *mesh, const struct gravity_props *props, ...@@ -67,7 +67,7 @@ void pm_mesh_init(struct pm_mesh *mesh, const struct gravity_props *props,
double dim[3]); double dim[3]);
void pm_mesh_init_no_mesh(struct pm_mesh *mesh, double dim[3]); void pm_mesh_init_no_mesh(struct pm_mesh *mesh, double dim[3]);
void pm_mesh_compute_potential(struct pm_mesh *mesh, const struct space *s, void pm_mesh_compute_potential(struct pm_mesh *mesh, const struct space *s,
int verbose); int verbose);
void pm_mesh_interpolate_forces(const struct pm_mesh *mesh, void pm_mesh_interpolate_forces(const struct pm_mesh *mesh,
const struct engine *e, struct gpart *gparts, const struct engine *e, struct gpart *gparts,
int gcount); int gcount);
......
...@@ -240,30 +240,31 @@ INLINE static void gravity_drift(struct gravity_tensors *m, double dt) { ...@@ -240,30 +240,31 @@ INLINE static void gravity_drift(struct gravity_tensors *m, double dt) {
m->CoM[2] += dz; m->CoM[2] += dz;
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if(m->m_pole.vel[0] > m->m_pole.max_delta_vel[0]) if (m->m_pole.vel[0] > m->m_pole.max_delta_vel[0])
error("Invalid maximal velocity"); error("Invalid maximal velocity");
if(m->m_pole.vel[0] < m->m_pole.min_delta_vel[0]) if (m->m_pole.vel[0] < m->m_pole.min_delta_vel[0])
error("Invalid minimal velocity"); error("Invalid minimal velocity");
if(m->m_pole.vel[1] > m->m_pole.max_delta_vel[1]) if (m->m_pole.vel[1] > m->m_pole.max_delta_vel[1])
error("Invalid maximal velocity"); error("Invalid maximal velocity");
if(m->m_pole.vel[1] < m->m_pole.min_delta_vel[1]) if (m->m_pole.vel[1] < m->m_pole.min_delta_vel[1])
error("Invalid minimal velocity"); error("Invalid minimal velocity");
if(m->m_pole.vel[2] > m->m_pole.max_delta_vel[2]) if (m->m_pole.vel[2] > m->m_pole.max_delta_vel[2])
error("Invalid maximal velocity"); error("Invalid maximal velocity");
if(m->m_pole.vel[2] < m->m_pole.min_delta_vel[2]) if (m->m_pole.vel[2] < m->m_pole.min_delta_vel[2])
error("Invalid minimal velocity"); error("Invalid minimal velocity");
#endif #endif
/* Maximal distance covered by any particle */ /* Maximal distance covered by any particle */
float dv[3]; float dv[3];
dv[0] = max(m->m_pole.max_delta_vel[0] - m->m_pole.vel[0], dv[0] = max(m->m_pole.max_delta_vel[0] - m->m_pole.vel[0],
m->m_pole.vel[0] - m->m_pole.min_delta_vel[0]); m->m_pole.vel[0] - m->m_pole.min_delta_vel[0]);
dv[1] = max(m->m_pole.max_delta_vel[1] - m->m_pole.vel[1], dv[1] = max(m->m_pole.max_delta_vel[1] - m->m_pole.vel[1],
m->m_pole.vel[1] - m->m_pole.min_delta_vel[1]); m->m_pole.vel[1] - m->m_pole.min_delta_vel[1]);
dv[2] = max(m->m_pole.max_delta_vel[2] - m->m_pole.vel[2], dv[2] = max(m->m_pole.max_delta_vel[2] - m->m_pole.vel[2],
m->m_pole.vel[2] - m->m_pole.min_delta_vel[2]); m->m_pole.vel[2] - m->m_pole.min_delta_vel[2]);
const float max_delta_vel = sqrt(dv[0] * dv[0] + dv[1] * dv[1] + dv[2] * dv[2]); const float max_delta_vel =
sqrt(dv[0] * dv[0] + dv[1] * dv[1] + dv[2] * dv[2]);
const float x_diff = max_delta_vel * dt; const float x_diff = max_delta_vel * dt;
/* Conservative change in maximal radius containing all gpart */ /* Conservative change in maximal radius containing all gpart */
......
...@@ -1666,7 +1666,8 @@ void runner_do_end_force(struct runner *r, struct cell *c, int timer) { ...@@ -1666,7 +1666,8 @@ void runner_do_end_force(struct runner *r, struct cell *c, int timer) {
const float G_newton = e->physical_constants->const_newton_G; const float G_newton = e->physical_constants->const_newton_G;
const double r_s = e->mesh->r_s; const double r_s = e->mesh->r_s;
const double volume = s->dim[0] * s->dim[1] * s->dim[2]; const double volume = s->dim[0] * s->dim[1] * s->dim[2];
const float potential_normalisation = 4. * M_PI * e->total_mass * r_s * r_s / volume; const float potential_normalisation =
4. * M_PI * e->total_mass * r_s * r_s / volume;
TIMER_TIC; TIMER_TIC;
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
#include "active.h" #include "active.h"
#include "cell.h" #include "cell.h"
#include "gravity.h" #include "gravity.h"
#include "gravity_iact.h"
#include "gravity_cache.h" #include "gravity_cache.h"
#include "gravity_iact.h"
#include "inline.h" #include "inline.h"
#include "part.h" #include "part.h"
#include "space_getsid.h" #include "space_getsid.h"
......
...@@ -1903,17 +1903,17 @@ void space_split_recursive(struct space *s, struct cell *c, ...@@ -1903,17 +1903,17 @@ void space_split_recursive(struct space *s, struct cell *c,
CoM[1] += m->CoM[1] * m->m_pole.M_000; CoM[1] += m->CoM[1] * m->m_pole.M_000;
CoM[2] += m->CoM[2] * m->m_pole.M_000; CoM[2] += m->CoM[2] * m->m_pole.M_000;
vel[0] += m->m_pole.vel[0] * m->m_pole.M_000; vel[0] += m->m_pole.vel[0] * m->m_pole.M_000;
vel[1] += m->m_pole.vel[1] * m->m_pole.M_000; vel[1] += m->m_pole.vel[1] * m->m_pole.M_000;
vel[2] += m->m_pole.vel[2] * m->m_pole.M_000; vel[2] += m->m_pole.vel[2] * m->m_pole.M_000;
max_delta_vel[0] = max(m->m_pole.max_delta_vel[0], max_delta_vel[0]); max_delta_vel[0] = max(m->m_pole.max_delta_vel[0], max_delta_vel[0]);
max_delta_vel[1] = max(m->m_pole.max_delta_vel[1], max_delta_vel[1]); max_delta_vel[1] = max(m->m_pole.max_delta_vel[1], max_delta_vel[1]);
max_delta_vel[2] = max(m->m_pole.max_delta_vel[2], max_delta_vel[2]); max_delta_vel[2] = max(m->m_pole.max_delta_vel[2], max_delta_vel[2]);
min_delta_vel[0] = min(m->m_pole.min_delta_vel[0], min_delta_vel[0]); min_delta_vel[0] = min(m->m_pole.min_delta_vel[0], min_delta_vel[0]);
min_delta_vel[1] = min(m->m_pole.min_delta_vel[1], min_delta_vel[1]); min_delta_vel[1] = min(m->m_pole.min_delta_vel[1], min_delta_vel[1]);
min_delta_vel[2] = min(m->m_pole.min_delta_vel[2], min_delta_vel[2]); min_delta_vel[2] = min(m->m_pole.min_delta_vel[2], min_delta_vel[2]);
} }
} }
......
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