Commit 081f101e authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Stylistic improvements

parent 915c6fbd
......@@ -166,7 +166,7 @@ external_gravity_get_potential_energy(
const struct external_potential* potential,
const struct phys_const* const phys_const, const struct part* p) {
return 0.;
return 0.f;
}
/**
......
......@@ -124,7 +124,6 @@ __attribute__((always_inline)) INLINE static void external_gravity_acceleration(
* @param phys_const Physical constants in internal units.
* @param g Pointer to the particle data.
*/
__attribute__((always_inline)) INLINE static float
external_gravity_get_potential_energy(
const struct external_potential* potential,
......@@ -134,8 +133,8 @@ external_gravity_get_potential_energy(
const float dy = g->x[1] - potential->y;
const float dz = g->x[2] - potential->z;
return potential->vrot * potential->vrot * 0.5 *
log(dx * dx + dy * dy * dz * dz);
return 0.5f * potential->vrot * potential->vrot *
logf(dx * dx + dy * dy * dz * dz);
}
/**
......
......@@ -75,13 +75,12 @@ __attribute__((always_inline)) INLINE static void external_gravity_acceleration(
* @param phys_const Physical constants in internal units.
* @param g Pointer to the particle data.
*/
__attribute__((always_inline)) INLINE static float
external_gravity_get_potential_energy(
const struct external_potential* potential,
const struct phys_const* const phys_const, const struct part* g) {
return 0.;
return 0.f;
}
/**
......
......@@ -124,7 +124,6 @@ __attribute__((always_inline)) INLINE static void external_gravity_acceleration(
* @param phys_const Physical constants in internal units.
* @param g Pointer to the particle data.
*/
__attribute__((always_inline)) INLINE static float
external_gravity_get_potential_energy(
const struct external_potential* potential,
......
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2016 Tom Theuns (tom.theuns@durham.ac.uk)
* Matthieu Schaller (matthieu.schaller@durham.ac.uk)
* Stefan Arridge (stefan.arridge@durham.ac.uk)
* Copyright (c) 2016 Stefan Arridge (stefan.arridge@durham.ac.uk)
* Matthieu Schaller (matthieu.schaller@durham.ac.uk)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
......@@ -132,7 +131,6 @@ __attribute__((always_inline)) INLINE static void external_gravity_acceleration(
* @param phys_const Physical constants in internal units.
* @param g Pointer to the particle data.
*/
__attribute__((always_inline)) INLINE static float
external_gravity_get_potential_energy(
const struct external_potential* potential,
......@@ -142,8 +140,8 @@ external_gravity_get_potential_energy(
const float dy = g->x[1] - potential->y;
const float dz = g->x[2] - potential->z;
return potential->vrot * potential->vrot * 0.5 *
log(dx * dx + dy * dy * dz * dz + potential->epsilon2);
return 0.5f * potential->vrot * potential->vrot *
logf(dx * dx + dy * dy * dz * dz + potential->epsilon2);
}
/**
* @brief Initialises the external potential properties in the internal system
......
......@@ -122,17 +122,16 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) {
/* Get the particle */
const struct part *p = &parts[k];
const struct xpart *xp = &xparts[k];
struct gpart *gp = NULL;
if (p->gpart != NULL) gp = p->gpart;
const struct gpart *gp = (p->gpart != NULL) ? gp = p->gpart : NULL;
/* Get useful variables */
const float dt = (ti_current - (p->ti_begin + p->ti_end) / 2) * timeBase;
const double x[3] = {p->x[0], p->x[1], p->x[2]};
float a_tot[3] = {p->a_hydro[0], p->a_hydro[1], p->a_hydro[2]};
if (p->gpart != NULL) {
a_tot[0] += p->gpart->a_grav[0];
a_tot[1] += p->gpart->a_grav[1];
a_tot[2] += p->gpart->a_grav[2];
if (gp != NULL) {
a_tot[0] += gp->a_grav[0];
a_tot[1] += gp->a_grav[1];
a_tot[2] += gp->a_grav[2];
}
const float v[3] = {xp->v_full[0] + a_tot[0] * dt,
xp->v_full[1] + a_tot[1] * dt,
......@@ -155,7 +154,7 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) {
/* Collect energies. */
stats.E_kin += 0.5f * m * (v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
stats.E_pot_self += 0.;
stats.E_pot_self += 0.f;
stats.E_pot_ext +=
m * external_gravity_get_potential_energy(potential, phys_const, gp);
stats.E_int += m * hydro_get_internal_energy(p, dt);
......@@ -229,7 +228,7 @@ void stats_collect_gpart_mapper(void *map_data, int nr_gparts,
/* Collect energies. */
stats.E_kin += 0.5f * m * (v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
stats.E_pot_self += 0.;
stats.E_pot_self += 0.f;
stats.E_pot_ext +=
m * external_gravity_get_potential_energy(potential, phys_const, gp);
}
......
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