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

Merge branch 'bug_fixes' into 'master'

Bug fixes



See merge request !202
parents f53617b2 5ca16c2f
...@@ -23,11 +23,6 @@ Snapshots: ...@@ -23,11 +23,6 @@ Snapshots:
basename: cosmo # Common part of the name of output files basename: cosmo # Common part of the name of output files
time_first: 0. # Time of the first output (in internal units) time_first: 0. # Time of the first output (in internal units)
delta_time: 0.05 # Time difference between consecutive outputs (in internal units) delta_time: 0.05 # Time difference between consecutive outputs (in internal units)
UnitMass_in_cgs: 1 # Grams
UnitLength_in_cgs: 1 # Centimeters
UnitVelocity_in_cgs: 1 # Centimeters per second
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Parameters governing the conserved quantities statistics # Parameters governing the conserved quantities statistics
Statistics: Statistics:
......
# Define the system of units to use internally. # Define the system of units to use internally.
InternalUnitSystem: InternalUnitSystem:
UnitMass_in_cgs: 1 # Grams UnitMass_in_cgs: 1.989e43 # 10^10 M_sun in grams
UnitLength_in_cgs: 1 # Centimeters UnitLength_in_cgs: 3.085678e24 # Mpc in centimeters
UnitVelocity_in_cgs: 1 # Centimeters per second UnitVelocity_in_cgs: 1e5 # km/s in centimeters per second
UnitCurrent_in_cgs: 1 # Amperes UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin UnitTemp_in_cgs: 1 # Kelvin
# Parameters for the task scheduling # Parameters for the task scheduling
Scheduler: Scheduler:
...@@ -14,20 +14,15 @@ Scheduler: ...@@ -14,20 +14,15 @@ Scheduler:
# Parameters governing the time integration # Parameters governing the time integration
TimeIntegration: TimeIntegration:
time_begin: 0. # The starting time of the simulation (in internal units). time_begin: 0. # The starting time of the simulation (in internal units).
time_end: 1. # The end time of the simulation (in internal units). time_end: 1e-2 # The end time of the simulation (in internal units).
dt_min: 1e-7 # The minimal time-step size of the simulation (in internal units). dt_min: 1e-10 # The minimal time-step size of the simulation (in internal units).
dt_max: 1e-2 # The maximal time-step size of the simulation (in internal units). dt_max: 1e-4 # The maximal time-step size of the simulation (in internal units).
# Parameters governing the snapshots # Parameters governing the snapshots
Snapshots: Snapshots:
basename: eagle # Common part of the name of output files basename: eagle # Common part of the name of output files
time_first: 0. # Time of the first output (in internal units) time_first: 0. # Time of the first output (in internal units)
delta_time: 0.05 # Time difference between consecutive outputs (in internal units) delta_time: 1e-3 # Time difference between consecutive outputs (in internal units)
UnitMass_in_cgs: 1 # Grams
UnitLength_in_cgs: 1 # Centimeters
UnitVelocity_in_cgs: 1 # Centimeters per second
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Parameters governing the conserved quantities statistics # Parameters governing the conserved quantities statistics
Statistics: Statistics:
......
# Define the system of units to use internally. # Define the system of units to use internally.
InternalUnitSystem: InternalUnitSystem:
UnitMass_in_cgs: 1 # Grams UnitMass_in_cgs: 1.989e43 # 10^10 M_sun in grams
UnitLength_in_cgs: 1 # Centimeters UnitLength_in_cgs: 3.085678e24 # Mpc in centimeters
UnitVelocity_in_cgs: 1 # Centimeters per second UnitVelocity_in_cgs: 1e5 # km/s in centimeters per second
UnitCurrent_in_cgs: 1 # Amperes UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin UnitTemp_in_cgs: 1 # Kelvin
# Parameters for the task scheduling # Parameters for the task scheduling
Scheduler: Scheduler:
...@@ -14,20 +14,15 @@ Scheduler: ...@@ -14,20 +14,15 @@ Scheduler:
# Parameters governing the time integration # Parameters governing the time integration
TimeIntegration: TimeIntegration:
time_begin: 0. # The starting time of the simulation (in internal units). time_begin: 0. # The starting time of the simulation (in internal units).
time_end: 1. # The end time of the simulation (in internal units). time_end: 1e-2 # The end time of the simulation (in internal units).
dt_min: 1e-7 # The minimal time-step size of the simulation (in internal units). dt_min: 1e-10 # The minimal time-step size of the simulation (in internal units).
dt_max: 1e-2 # The maximal time-step size of the simulation (in internal units). dt_max: 1e-4 # The maximal time-step size of the simulation (in internal units).
# Parameters governing the snapshots # Parameters governing the snapshots
Snapshots: Snapshots:
basename: eagle # Common part of the name of output files basename: eagle # Common part of the name of output files
time_first: 0. # Time of the first output (in internal units) time_first: 0. # Time of the first output (in internal units)
delta_time: 0.05 # Time difference between consecutive outputs (in internal units) delta_time: 1e-3 # Time difference between consecutive outputs (in internal units)
UnitMass_in_cgs: 1 # Grams
UnitLength_in_cgs: 1 # Centimeters
UnitVelocity_in_cgs: 1 # Centimeters per second
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Parameters governing the conserved quantities statistics # Parameters governing the conserved quantities statistics
Statistics: Statistics:
......
# Define the system of units to use internally. # Define the system of units to use internally.
InternalUnitSystem: InternalUnitSystem:
UnitMass_in_cgs: 1 # Grams UnitMass_in_cgs: 1.989e43 # 10^10 M_sun in grams
UnitLength_in_cgs: 1 # Centimeters UnitLength_in_cgs: 3.085678e24 # Mpc in centimeters
UnitVelocity_in_cgs: 1 # Centimeters per second UnitVelocity_in_cgs: 1e5 # km/s in centimeters per second
UnitCurrent_in_cgs: 1 # Amperes UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin UnitTemp_in_cgs: 1 # Kelvin
# Parameters for the task scheduling # Parameters for the task scheduling
Scheduler: Scheduler:
...@@ -14,20 +14,15 @@ Scheduler: ...@@ -14,20 +14,15 @@ Scheduler:
# Parameters governing the time integration # Parameters governing the time integration
TimeIntegration: TimeIntegration:
time_begin: 0. # The starting time of the simulation (in internal units). time_begin: 0. # The starting time of the simulation (in internal units).
time_end: 1. # The end time of the simulation (in internal units). time_end: 1e-2 # The end time of the simulation (in internal units).
dt_min: 1e-7 # The minimal time-step size of the simulation (in internal units). dt_min: 1e-10 # The minimal time-step size of the simulation (in internal units).
dt_max: 1e-2 # The maximal time-step size of the simulation (in internal units). dt_max: 1e-4 # The maximal time-step size of the simulation (in internal units).
# Parameters governing the snapshots # Parameters governing the snapshots
Snapshots: Snapshots:
basename: eagle # Common part of the name of output files basename: eagle # Common part of the name of output files
time_first: 0. # Time of the first output (in internal units) time_first: 0. # Time of the first output (in internal units)
delta_time: 0.05 # Time difference between consecutive outputs (in internal units) delta_time: 1e-3 # Time difference between consecutive outputs (in internal units)
UnitMass_in_cgs: 1 # Grams
UnitLength_in_cgs: 1 # Centimeters
UnitVelocity_in_cgs: 1 # Centimeters per second
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Parameters governing the conserved quantities statistics # Parameters governing the conserved quantities statistics
Statistics: Statistics:
......
...@@ -18,11 +18,6 @@ Snapshots: ...@@ -18,11 +18,6 @@ Snapshots:
basename: pointMass # Common part of the name of output files basename: pointMass # Common part of the name of output files
time_first: 0. # Time of the first output (in internal units) time_first: 0. # Time of the first output (in internal units)
delta_time: 0.02 # Time difference between consecutive outputs (in internal units) delta_time: 0.02 # Time difference between consecutive outputs (in internal units)
UnitMass_in_cgs: 1.9885e33 # Grams
UnitLength_in_cgs: 3.0856776e21 # Centimeters
UnitVelocity_in_cgs: 1e5 # Centimeters per second
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Parameters governing the conserved quantities statistics # Parameters governing the conserved quantities statistics
Statistics: Statistics:
......
...@@ -18,11 +18,6 @@ Snapshots: ...@@ -18,11 +18,6 @@ Snapshots:
basename: multiTypes # Common part of the name of output files basename: multiTypes # Common part of the name of output files
time_first: 0. # Time of the first output (in internal units) time_first: 0. # Time of the first output (in internal units)
delta_time: 0.01 # Time difference between consecutive outputs (in internal units) delta_time: 0.01 # Time difference between consecutive outputs (in internal units)
UnitMass_in_cgs: 1 # Grams
UnitLength_in_cgs: 1 # Centimeters
UnitVelocity_in_cgs: 1 # Centimeters per second
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Parameters governing the conserved quantities statistics # Parameters governing the conserved quantities statistics
Statistics: Statistics:
......
...@@ -18,11 +18,6 @@ Snapshots: ...@@ -18,11 +18,6 @@ Snapshots:
basename: sedov # Common part of the name of output files basename: sedov # Common part of the name of output files
time_first: 0. # Time of the first output (in internal units) time_first: 0. # Time of the first output (in internal units)
delta_time: 0.1 # Time difference between consecutive outputs (in internal units) delta_time: 0.1 # Time difference between consecutive outputs (in internal units)
UnitMass_in_cgs: 1 # Grams
UnitLength_in_cgs: 1 # Centimeters
UnitVelocity_in_cgs: 1 # Centimeters per second
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Parameters governing the conserved quantities statistics # Parameters governing the conserved quantities statistics
Statistics: Statistics:
......
...@@ -18,11 +18,6 @@ Snapshots: ...@@ -18,11 +18,6 @@ Snapshots:
basename: sod # Common part of the name of output files basename: sod # Common part of the name of output files
time_first: 0. # Time of the first output (in internal units) time_first: 0. # Time of the first output (in internal units)
delta_time: 0.1 # Time difference between consecutive outputs (in internal units) delta_time: 0.1 # Time difference between consecutive outputs (in internal units)
UnitMass_in_cgs: 1 # Grams
UnitLength_in_cgs: 1 # Centimeters
UnitVelocity_in_cgs: 1 # Centimeters per second
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Parameters governing the conserved quantities statistics # Parameters governing the conserved quantities statistics
Statistics: Statistics:
......
...@@ -18,11 +18,6 @@ Snapshots: ...@@ -18,11 +18,6 @@ Snapshots:
basename: uniformBox # Common part of the name of output files basename: uniformBox # Common part of the name of output files
time_first: 0. # Time of the first output (in internal units) time_first: 0. # Time of the first output (in internal units)
delta_time: 0.01 # Time difference between consecutive outputs (in internal units) delta_time: 0.01 # Time difference between consecutive outputs (in internal units)
UnitMass_in_cgs: 1 # Grams
UnitLength_in_cgs: 1 # Centimeters
UnitVelocity_in_cgs: 1 # Centimeters per second
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Parameters governing the conserved quantities statistics # Parameters governing the conserved quantities statistics
Statistics: Statistics:
......
...@@ -358,8 +358,8 @@ int main(int argc, char *argv[]) { ...@@ -358,8 +358,8 @@ int main(int argc, char *argv[]) {
&periodic, &flag_entropy_ICs, myrank, nr_nodes, &periodic, &flag_entropy_ICs, myrank, nr_nodes,
MPI_COMM_WORLD, MPI_INFO_NULL, dry_run); MPI_COMM_WORLD, MPI_INFO_NULL, dry_run);
#else #else
read_ic_serial(ICfileName, &us, dim, &parts, &gparts, &Ngas, &Ngpart, &periodic, read_ic_serial(ICfileName, &us, dim, &parts, &gparts, &Ngas, &Ngpart,
&flag_entropy_ICs, myrank, nr_nodes, MPI_COMM_WORLD, &periodic, &flag_entropy_ICs, myrank, nr_nodes, MPI_COMM_WORLD,
MPI_INFO_NULL, dry_run); MPI_INFO_NULL, dry_run);
#endif #endif
#else #else
......
...@@ -25,11 +25,11 @@ Snapshots: ...@@ -25,11 +25,11 @@ Snapshots:
basename: output # Common part of the name of output files basename: output # Common part of the name of output files
time_first: 0. # Time of the first output (in internal units) time_first: 0. # Time of the first output (in internal units)
delta_time: 0.01 # Time difference between consecutive outputs (in internal units) delta_time: 0.01 # Time difference between consecutive outputs (in internal units)
UnitMass_in_cgs: 1 # Unit system for the outputs (Grams) UnitMass_in_cgs: 1 # (Optional) Unit system for the outputs (Grams)
UnitLength_in_cgs: 1 # Unit system for the outputs (Centimeters) UnitLength_in_cgs: 1 # (Optional) Unit system for the outputs (Centimeters)
UnitVelocity_in_cgs: 1 # Unit system for the outputs (Centimeters per second) UnitVelocity_in_cgs: 1 # (Optional) Unit system for the outputs (Centimeters per second)
UnitCurrent_in_cgs: 1 # Unit system for the outputs (Amperes) UnitCurrent_in_cgs: 1 # (Optional) Unit system for the outputs (Amperes)
UnitTemp_in_cgs: 1 # Unit system for the outputs (Kelvin) UnitTemp_in_cgs: 1 # (Optional) Unit system for the outputs (Kelvin)
# Parameters governing the conserved quantities statistics # Parameters governing the conserved quantities statistics
Statistics: Statistics:
......
...@@ -60,15 +60,12 @@ __attribute__((always_inline)) INLINE static float pow_gamma(float x) { ...@@ -60,15 +60,12 @@ __attribute__((always_inline)) INLINE static float pow_gamma(float x) {
#if defined(HYDRO_GAMMA_5_3) #if defined(HYDRO_GAMMA_5_3)
const float x2 = x * x; const float cbrt = cbrtf(x); /* x^(1/3) */
const float x5 = x2 * x2 * x; return cbrt * cbrt * x; /* x^(5/3) */
return cbrtf(x5);
#elif defined(HYDRO_GAMMA_4_3) #elif defined(HYDRO_GAMMA_4_3)
const float x2 = x * x; return cbrtf(x) * x; /* x^(4/3) */
const float x4 = x2 * x2;
return cbrtf(x4);
#elif defined(HYDRO_GAMMA_2_1) #elif defined(HYDRO_GAMMA_2_1)
...@@ -93,11 +90,12 @@ __attribute__((always_inline)) INLINE static float pow_gamma_minus_one( ...@@ -93,11 +90,12 @@ __attribute__((always_inline)) INLINE static float pow_gamma_minus_one(
#if defined(HYDRO_GAMMA_5_3) #if defined(HYDRO_GAMMA_5_3)
return cbrtf(x * x); const float cbrt = cbrtf(x); /* x^(1/3) */
return cbrt * cbrt; /* x^(2/3) */
#elif defined(HYDRO_GAMMA_4_3) #elif defined(HYDRO_GAMMA_4_3)
return cbrtf(x); return cbrtf(x); /* x^(1/3) */
#elif defined(HYDRO_GAMMA_2_1) #elif defined(HYDRO_GAMMA_2_1)
...@@ -122,11 +120,12 @@ __attribute__((always_inline)) INLINE static float pow_minus_gamma_minus_one( ...@@ -122,11 +120,12 @@ __attribute__((always_inline)) INLINE static float pow_minus_gamma_minus_one(
#if defined(HYDRO_GAMMA_5_3) #if defined(HYDRO_GAMMA_5_3)
return 1.f / cbrtf(x * x); const float inv_cbrt = 1.f / cbrtf(x); /* x^(-1/3) */
return inv_cbrt * inv_cbrt; /* x^(-2/3) */
#elif defined(HYDRO_GAMMA_4_3) #elif defined(HYDRO_GAMMA_4_3)
return 1.f / cbrtf(x); return 1.f / cbrtf(x); /* x^(-1/3) */
#elif defined(HYDRO_GAMMA_2_1) #elif defined(HYDRO_GAMMA_2_1)
......
...@@ -120,7 +120,7 @@ size_t sizeOfType(enum DATA_TYPE type) { ...@@ -120,7 +120,7 @@ size_t sizeOfType(enum DATA_TYPE type) {
* Returns an error if the type is not FLOAT or DOUBLE * Returns an error if the type is not FLOAT or DOUBLE
*/ */
int isDoublePrecision(enum DATA_TYPE type) { int isDoublePrecision(enum DATA_TYPE type) {
switch (type) { switch (type) {
case FLOAT: case FLOAT:
return 0; return 0;
......
...@@ -37,7 +37,8 @@ ...@@ -37,7 +37,8 @@
* @param ti_current Integer end of time-step * @param ti_current Integer end of time-step
*/ */
__attribute__((always_inline)) INLINE static void drift_gpart( __attribute__((always_inline)) INLINE static void drift_gpart(
struct gpart* gp, float dt, double timeBase, int ti_old, int ti_current) { struct gpart *restrict gp, float dt, double timeBase, int ti_old,
int ti_current) {
/* Drift... */ /* Drift... */
gp->x[0] += gp->v_full[0] * dt; gp->x[0] += gp->v_full[0] * dt;
gp->x[1] += gp->v_full[1] * dt; gp->x[1] += gp->v_full[1] * dt;
...@@ -60,8 +61,8 @@ __attribute__((always_inline)) INLINE static void drift_gpart( ...@@ -60,8 +61,8 @@ __attribute__((always_inline)) INLINE static void drift_gpart(
* @param ti_current Integer end of time-step * @param ti_current Integer end of time-step
*/ */
__attribute__((always_inline)) INLINE static void drift_part( __attribute__((always_inline)) INLINE static void drift_part(
struct part* p, struct xpart* xp, float dt, double timeBase, int ti_old, struct part *restrict p, struct xpart *restrict xp, float dt,
int ti_current) { double timeBase, int ti_old, int ti_current) {
/* Useful quantity */ /* Useful quantity */
const float h_inv = 1.0f / p->h; const float h_inv = 1.0f / p->h;
......
...@@ -2672,7 +2672,7 @@ void engine_dump_snapshot(struct engine *e) { ...@@ -2672,7 +2672,7 @@ void engine_dump_snapshot(struct engine *e) {
struct clocks_time time1, time2; struct clocks_time time1, time2;
clocks_gettime(&time1); clocks_gettime(&time1);
if (e->verbose) message("writing snapshot at t=%f.", e->time); if (e->verbose) message("writing snapshot at t=%e.", e->time);
/* Dump... */ /* Dump... */
#if defined(WITH_MPI) #if defined(WITH_MPI)
...@@ -2808,7 +2808,7 @@ void engine_init(struct engine *e, struct space *s, ...@@ -2808,7 +2808,7 @@ void engine_init(struct engine *e, struct space *s,
e->ti_nextSnapshot = 0; e->ti_nextSnapshot = 0;
parser_get_param_string(params, "Snapshots:basename", e->snapshotBaseName); parser_get_param_string(params, "Snapshots:basename", e->snapshotBaseName);
e->snapshotUnits = malloc(sizeof(struct UnitSystem)); e->snapshotUnits = malloc(sizeof(struct UnitSystem));
units_init(e->snapshotUnits, params, "Snapshots"); units_init_default(e->snapshotUnits, params, "Snapshots", internal_units);
e->dt_min = parser_get_param_double(params, "TimeIntegration:dt_min"); e->dt_min = parser_get_param_double(params, "TimeIntegration:dt_min");
e->dt_max = parser_get_param_double(params, "TimeIntegration:dt_max"); e->dt_max = parser_get_param_double(params, "TimeIntegration:dt_max");
e->file_stats = NULL; e->file_stats = NULL;
...@@ -3228,6 +3228,6 @@ void engine_compute_next_snapshot_time(struct engine *e) { ...@@ -3228,6 +3228,6 @@ void engine_compute_next_snapshot_time(struct engine *e) {
const float next_snapshot_time = const float next_snapshot_time =
e->ti_nextSnapshot * e->timeBase + e->timeBegin; e->ti_nextSnapshot * e->timeBase + e->timeBegin;
if (e->verbose) if (e->verbose)
message("Next output time set to t=%f.", next_snapshot_time); message("Next output time set to t=%e.", next_snapshot_time);
} }
} }
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
* *
*/ */
__attribute__((always_inline)) INLINE static float hydro_compute_timestep( __attribute__((always_inline)) INLINE static float hydro_compute_timestep(
const struct part* p, const struct xpart* xp, const struct part *restrict p, const struct xpart *restrict xp,
const struct hydro_props* hydro_properties) { const struct hydro_props *restrict hydro_properties) {
const float CFL_condition = hydro_properties->CFL_condition; const float CFL_condition = hydro_properties->CFL_condition;
...@@ -55,7 +55,7 @@ __attribute__((always_inline)) INLINE static float hydro_compute_timestep( ...@@ -55,7 +55,7 @@ __attribute__((always_inline)) INLINE static float hydro_compute_timestep(
* @param xp The extended particle data to act upon * @param xp The extended particle data to act upon
*/ */
__attribute__((always_inline)) INLINE static void hydro_first_init_part( __attribute__((always_inline)) INLINE static void hydro_first_init_part(
struct part* p, struct xpart* xp) {} struct part *restrict p, struct xpart *restrict xp) {}
/** /**
* @brief Prepares a particle for the density calculation. * @brief Prepares a particle for the density calculation.
...@@ -66,15 +66,15 @@ __attribute__((always_inline)) INLINE static void hydro_first_init_part( ...@@ -66,15 +66,15 @@ __attribute__((always_inline)) INLINE static void hydro_first_init_part(
* @param p The particle to act upon * @param p The particle to act upon
*/ */
__attribute__((always_inline)) INLINE static void hydro_init_part( __attribute__((always_inline)) INLINE static void hydro_init_part(
struct part* p) { struct part *restrict p) {
p->density.wcount = 0.f; p->density.wcount = 0.f;
p->density.wcount_dh = 0.f; p->density.wcount_dh = 0.f;
p->rho = 0.f; p->rho = 0.f;
p->rho_dh = 0.f; p->rho_dh = 0.f;
p->density.div_v = 0.f; p->density.div_v = 0.f;
p->density.curl_v[0] = 0.f; p->density.rot_v[0] = 0.f;
p->density.curl_v[1] = 0.f; p->density.rot_v[1] = 0.f;
p->density.curl_v[2] = 0.f; p->density.rot_v[2] = 0.f;
} }
/** /**
...@@ -87,7 +87,7 @@ __attribute__((always_inline)) INLINE static void hydro_init_part( ...@@ -87,7 +87,7 @@ __attribute__((always_inline)) INLINE static void hydro_init_part(
* @param time The current time * @param time The current time
*/ */
__attribute__((always_inline)) INLINE static void hydro_end_density( __attribute__((always_inline)) INLINE static void hydro_end_density(
struct part* p, float time) { struct part *restrict p, float time) {
/* Some smoothing length multiples. */ /* Some smoothing length multiples. */
const float h = p->h; const float h = p->h;
...@@ -110,6 +110,14 @@ __attribute__((always_inline)) INLINE static void hydro_end_density( ...@@ -110,6 +110,14 @@ __attribute__((always_inline)) INLINE static void hydro_end_density(
/* Compute the derivative term */ /* Compute the derivative term */
p->rho_dh = 1.f / (1.f + 0.33333333f * p->h * p->rho_dh * irho); p->rho_dh = 1.f / (1.f + 0.33333333f * p->h * p->rho_dh * irho);
/* Finish calculation of the velocity curl components */
p->density.rot_v[0] *= ih4 * irho;
p->density.rot_v[1] *= ih4 * irho;
p->density.rot_v[2] *= ih4 * irho;
/* Finish calculation of the velocity divergence */
p->density.div_v *= ih4 * irho;
} }
/** /**
...@@ -122,7 +130,8 @@ __attribute__((always_inline)) INLINE static void hydro_end_density( ...@@ -122,7 +130,8 @@ __attribute__((always_inline)) INLINE static void hydro_end_density(
* @param time The current time * @param time The current time
*/ */
__attribute__((always_inline)) INLINE static void hydro_prepare_force( __attribute__((always_inline)) INLINE static void hydro_prepare_force(
struct part* p, struct xpart* xp, int ti_current, double timeBase) { struct part *restrict p, struct xpart *restrict xp, int ti_current,
double timeBase) {
/* Some smoothing length multiples. */ /* Some smoothing length multiples. */
const float h = p->h; const float h = p->h;
...@@ -132,10 +141,10 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force( ...@@ -132,10 +141,10 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
/* Pre-compute some stuff for the balsara switch. */ /* Pre-compute some stuff for the balsara switch. */
const float normDiv_v = fabs(p->density.div_v / p->rho * ih4); const float normDiv_v = fabs(p->density.div_v / p->rho * ih4);
const float normCurl_v = sqrtf(p->density.curl_v[0] * p->density.curl_v[0] + const float normRot_v = sqrtf(p->density.rot_v[0] * p->density.rot_v[0] +
p->density.curl_v[1] * p->density.curl_v[1] + p->density.rot_v[1] * p->density.rot_v[1] +
p->density.curl_v[2] * p->density.curl_v[2]) / p->density.rot_v[2] * p->density.rot_v[2]) /
p->rho * ih4; p->rho * ih4;
/* Compute this particle's sound speed. */ /* Compute this particle's sound speed. */
const float u = p->u; const float u = p->u;
...@@ -146,7 +155,7 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force( ...@@ -146,7 +155,7 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
p->force.POrho2 = u * hydro_gamma_minus_one / (p->rho * xp->omega); p->force.POrho2 = u * hydro_gamma_minus_one / (p->rho * xp->omega);
/* Balsara switch */ /* Balsara switch */
p->force.balsara = normDiv_v / (normDiv_v + normCurl_v + 0.0001f * fc * ih); p->force.balsara = normDiv_v / (normDiv_v + normRot_v + 0.0001f * fc * ih);
/* Viscosity parameter decay time */ /* Viscosity parameter decay time */
const float tau = h / (2.f * const_viscosity_length * p->force.c); const float tau = h / (2.f * const_viscosity_length * p->force.c);
...@@ -171,7 +180,7 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force( ...@@ -171,7 +180,7 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
* @param p The particle to act upon * @param p The particle to act upon
*/ */
__attribute__((always_inline)) INLINE static void hydro_reset_acceleration( __attribute__((always_inline)) INLINE static void hydro_reset_acceleration(
struct part* p) { struct part *restrict p) {
/* Reset the acceleration. */ /* Reset the acceleration. */
p->a_hydro[0] = 0.0f; p->a_hydro[0] = 0.0f;
...@@ -194,7 +203,8 @@ __attribute__((always_inline)) INLINE static void hydro_reset_acceleration( ...@@ -194,7 +203,8 @@ __attribute__((always_inline)) INLINE static void hydro_reset_acceleration(
* @param timeBase The minimal time-step size * @param timeBase The minimal time-step size
*/ */