Commit c445930d authored by Matthieu Schaller's avatar Matthieu Schaller

Applied code formatting tool

parent 66cdef89
......@@ -2345,7 +2345,7 @@ void engine_step(struct engine *e) {
e->all_gparts_active = 1;
/* Look for inactive gparts */
for (size_t i=0; i < nr_gparts; ++i) {
for (size_t i = 0; i < nr_gparts; ++i) {
struct gpart *gp = &e->s->gparts[i];
/* If one gpart is inactive we can stop. */
......@@ -2363,14 +2363,14 @@ void engine_step(struct engine *e) {
!e->force_checks_only_all_active) {
/* Is this a snapshot timestep (and the option is selected)? */
if ((e->brute_force_gravity_flag == 1 &&
e->force_checks_only_at_snapshots) ||
!e->force_checks_only_at_snapshots) {
/* Do checks */
gravity_exact_force_compute(e->s, e);
}
e->force_checks_only_at_snapshots) ||
!e->force_checks_only_at_snapshots) {
/* Do checks */
gravity_exact_force_compute(e->s, e);
}
}
}
#endif
/* Start all the tasks. */
......@@ -2396,17 +2396,17 @@ void engine_step(struct engine *e) {
!e->force_checks_only_all_active) {
/* Is this a snapshot timestep (and the option is selected)? */
if ((e->brute_force_gravity_flag == 1 &&
e->force_checks_only_at_snapshots) ||
!e->force_checks_only_at_snapshots) {
/* Do checks */
gravity_exact_force_check(e->s, e, 1e-1);
/* Reset flag waiting for next output time */
e->brute_force_gravity_flag = 0;
}
e->force_checks_only_at_snapshots) ||
!e->force_checks_only_at_snapshots) {
/* Do checks */
gravity_exact_force_check(e->s, e, 1e-1);
/* Reset flag waiting for next output time */
e->brute_force_gravity_flag = 0;
}
}
}
#endif
#ifdef SWIFT_DEBUG_CHECKS
......@@ -3639,9 +3639,9 @@ void engine_init(struct engine *e, struct space *s, struct swift_params *params,
#ifdef SWIFT_GRAVITY_FORCE_CHECKS
e->force_checks_only_all_active =
parser_get_opt_param_int(params, "ForceChecks:only_when_all_active", 0);
parser_get_opt_param_int(params, "ForceChecks:only_when_all_active", 0);
e->force_checks_only_at_snapshots =
parser_get_opt_param_int(params, "ForceChecks:only_at_snapshots", 0);
parser_get_opt_param_int(params, "ForceChecks:only_at_snapshots", 0);
#endif
/* Make the space link back to the engine. */
......
......@@ -688,10 +688,9 @@ void gravity_exact_force_check(struct space *s, const struct engine *e,
"%16s %16s %16s %16s %16s %16s %16s %16s %16s %16s %16s %16s %16s\n",
"id", "pos[0]", "pos[1]", "pos[2]", "a_swift[0]", "a_swift[1]",
"a_swift[2]", "potential", "a_PM[0]", "a_PM[1]", "a_PM[2]",
"potentialPM", "a_p2p[0]", "a_p2p[1]", "a_p2p[2]",
"a_m2p[0]", "a_m2p[1]", "a_m2p[2]",
"a_m2l[0]", "a_m2l[1]", "a_m2l[2]",
"n_p2p", "n_m2p", "n_m2l", "n_PM");
"potentialPM", "a_p2p[0]", "a_p2p[1]", "a_p2p[2]", "a_m2p[0]",
"a_m2p[1]", "a_m2p[2]", "a_m2l[0]", "a_m2l[1]", "a_m2l[2]", "n_p2p",
"n_m2p", "n_m2l", "n_PM");
/* Output particle SWIFT accelerations */
for (size_t i = 0; i < s->nr_gparts; ++i) {
......@@ -748,11 +747,13 @@ void gravity_exact_force_check(struct space *s, const struct engine *e,
fprintf(file_exact, "# periodic= %d\n", s->periodic);
fprintf(file_exact, "# Git Branch: %s\n", git_branch());
fprintf(file_exact, "# Git Revision: %s\n", git_revision());
fprintf(file_exact, "# %16s %16s %16s %16s %16s %16s %16s %16s %16s %16s %16s "
"%16s %16s %16s\n", "id", "pos[0]", "pos[1]", "pos[2]", "a_exact[0]",
"a_exact[1]", "a_exact[2]", "potential", "a_exact_short[0]",
"a_exact_short[1]", "a_exact_short[2]", "a_exact_long[0]",
"a_exact_long[1]", "a_exact_long[2]");
fprintf(file_exact,
"# %16s %16s %16s %16s %16s %16s %16s %16s %16s %16s %16s "
"%16s %16s %16s\n",
"id", "pos[0]", "pos[1]", "pos[2]", "a_exact[0]", "a_exact[1]",
"a_exact[2]", "potential", "a_exact_short[0]", "a_exact_short[1]",
"a_exact_short[2]", "a_exact_long[0]", "a_exact_long[1]",
"a_exact_long[2]");
/* Output particle exact accelerations */
for (size_t i = 0; i < s->nr_gparts; ++i) {
......@@ -773,13 +774,13 @@ void gravity_exact_force_check(struct space *s, const struct engine *e,
if (id % SWIFT_GRAVITY_FORCE_CHECKS == 0 && gpart_is_starting(gpi, e)) {
fprintf(file_exact,
"%18lld %16.8e %16.8e %16.8e %16.8e %16.8e %16.8e %16.8e "
"%16.8e %16.8e %16.8e %16.8e %16.8e %16.8e\n", id,
gpi->x[0], gpi->x[1], gpi->x[2], gpi->a_grav_exact[0],
"%16.8e %16.8e %16.8e %16.8e %16.8e %16.8e\n",
id, gpi->x[0], gpi->x[1], gpi->x[2], gpi->a_grav_exact[0],
gpi->a_grav_exact[1], gpi->a_grav_exact[2],
gpi->potential_exact, gpi->a_grav_exact_short[0],
gpi->a_grav_exact_short[1], gpi->a_grav_exact_short[2],
gpi->a_grav_exact_long[0], gpi->a_grav_exact_long[1],
gpi->a_grav_exact_long[2]);
gpi->a_grav_exact_long[2]);
}
}
......
......@@ -154,14 +154,14 @@ __attribute__((always_inline)) INLINE static void gravity_init_gpart(
gp->potential_PM = 0.f;
/* Track accelerations of each component. */
for (int i=0; i<3; i++) {
for (int i = 0; i < 3; i++) {
gp->a_grav_PM[i] = 0.f;
gp->a_grav_p2p[i] = 0.f;
gp->a_grav_m2p[i] = 0.f;
gp->a_grav_m2l[i] = 0.f;
}
/* Interaction counters. */
/* Interaction counters. */
gp->num_interacted_m2p = 0;
gp->num_interacted_m2l = 0;
gp->num_interacted_p2p = 0;
......
......@@ -164,7 +164,7 @@ __attribute__((always_inline)) INLINE static void gravity_init_gpart(
gp->potential_PM = 0.f;
/* Track accelerations of each component. */
for (int i=0; i<3; i++) {
for (int i = 0; i < 3; i++) {
gp->a_grav_PM[i] = 0.f;
gp->a_grav_p2p[i] = 0.f;
gp->a_grav_m2p[i] = 0.f;
......
......@@ -216,31 +216,31 @@ __attribute__((always_inline)) INLINE static void kernel_long_grav_force_eval(
* @param W (return) The value of the kernel function.
*/
__attribute__((always_inline)) INLINE static void
kernel_long_grav_force_eval_double(const double u, double *const W) {
kernel_long_grav_force_eval_double(const double u, double *const W) {
#ifdef SWIFT_GRAVITY_FORCE_CHECKS
#ifdef GADGET2_LONG_RANGE_CORRECTION
#ifdef GADGET2_LONG_RANGE_CORRECTION
const double one_over_sqrt_pi = ((double)(M_2_SQRTPI * 0.5));
const double one_over_sqrt_pi = ((double)(M_2_SQRTPI * 0.5));
const double arg1 = u * 0.5f;
const double arg2 = -arg1 * arg1;
const double arg1 = u * 0.5f;
const double arg2 = -arg1 * arg1;
const double term1 = approx_erfcf(arg1);
const double term2 = u * one_over_sqrt_pi * expf(arg2);
const double term1 = approx_erfcf(arg1);
const double term2 = u * one_over_sqrt_pi * expf(arg2);
*W = term1 + term2;
#else
*W = term1 + term2;
#else
const double x = 2.f * u;
const double exp_x = expf(x); // good_approx_expf(x);
const double alpha = 1.f / (1.f + exp_x);
const double x = 2.f * u;
const double exp_x = expf(x); // good_approx_expf(x);
const double alpha = 1.f / (1.f + exp_x);
/* We want 2*(x*alpha - x*alpha^2 - exp(x)*alpha + 1) */
*W = 1.f - alpha;
*W = *W * x - exp_x;
*W = *W * alpha + 1.f;
*W *= 2.f;
#endif
/* We want 2*(x*alpha - x*alpha^2 - exp(x)*alpha + 1) */
*W = 1.f - alpha;
*W = *W * x - exp_x;
*W = *W * alpha + 1.f;
*W *= 2.f;
#endif
#endif
}
......
......@@ -315,7 +315,7 @@ INLINE static void gravity_field_tensors_add(
struct grav_tensor *restrict la, const struct grav_tensor *restrict lb) {
#ifdef SWIFT_DEBUG_CHECKS
if (lb->num_interacted + lb->num_not_interacted == 0)
error("Adding tensors that did not interact");
error("Adding tensors that did not interact");
#endif
#if defined(SWIFT_DEBUG_CHECKS) || defined(SWIFT_GRAVITY_FORCE_CHECKS)
la->num_interacted += lb->num_interacted;
......@@ -2102,7 +2102,7 @@ INLINE static void gravity_L2L(struct grav_tensor *restrict la,
#ifdef SWIFT_DEBUG_CHECKS
if (lb->num_interacted + lb->num_not_interacted == 0)
error("Shifting tensors that did not interact");
error("Shifting tensors that did not interact");
#endif
#if defined(SWIFT_DEBUG_CHECKS) || defined(SWIFT_GRAVITY_FORCE_CHECKS)
la->num_interacted = lb->num_interacted;
......@@ -2459,7 +2459,7 @@ INLINE static void gravity_L2P(const struct grav_tensor *lb,
#ifdef SWIFT_DEBUG_CHECKS
if (lb->num_interacted + lb->num_not_interacted == 0)
error("Interacting with empty field tensor");
error("Interacting with empty field tensor");
#endif
#if defined(SWIFT_DEBUG_CHECKS) || defined(SWIFT_GRAVITY_FORCE_CHECKS)
gp->num_interacted += lb->num_interacted + lb->num_not_interacted;
......
......@@ -1184,9 +1184,9 @@ static INLINE void runner_doself_grav_pp_truncated(
#endif
#ifdef SWIFT_GRAVITY_FORCE_CHECKS
/* Update the P2P interaction counter if it's not a padded gpart */
if (pjd < gcount && !gpart_is_inhibited(&gparts[pjd], e))
gparts[pid].num_interacted_p2p++;
/* Update the P2P interaction counter if it's not a padded gpart */
if (pjd < gcount && !gpart_is_inhibited(&gparts[pjd], e))
gparts[pid].num_interacted_p2p++;
#endif
}
......
Markdown is supported
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