Skip to content
Snippets Groups Projects

Improvements to GIZMO implementation

Merged Matthieu Schaller requested to merge gizmo_speedup into master
Files
20
+ 16
7
@@ -362,8 +362,9 @@ __attribute__((always_inline)) INLINE static void hydro_end_density(
#endif
/* sanity checks */
gizmo_check_physical_quantity("density", p->primitives.rho);
gizmo_check_physical_quantity("pressure", p->primitives.P);
gizmo_check_physical_quantities("density", "pressure", p->primitives.rho,
p->primitives.v[0], p->primitives.v[1],
p->primitives.v[2], p->primitives.P);
#ifdef GIZMO_LLOYD_ITERATION
/* overwrite primitive variables to make sure they still have safe values */
@@ -563,7 +564,6 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra(
p->primitives.v[2] +=
p->conserved.flux.momentum[2] * dt_drift / p->conserved.mass;
// MATTHIEU: Bert is this correct?
#if !defined(EOS_ISOTHERMAL_GAS)
const float u = p->conserved.energy + p->conserved.flux.energy * dt_therm;
p->primitives.P =
@@ -576,6 +576,10 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra(
error("Zero or negative smoothing length (%g)!", p->h);
}
#endif
gizmo_check_physical_quantities("density", "pressure", p->primitives.rho,
p->primitives.v[0], p->primitives.v[1],
p->primitives.v[2], p->primitives.P);
}
/**
@@ -632,13 +636,14 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra(
/* Apply the minimal energy limit */
const float min_energy =
hydro_props->minimal_internal_energy * cosmo->a_factor_internal_energy;
if (p->conserved.energy < min_energy) {
p->conserved.energy = min_energy;
if (p->conserved.energy < min_energy * p->conserved.mass) {
p->conserved.energy = min_energy * p->conserved.mass;
p->conserved.flux.energy = 0.f;
}
gizmo_check_physical_quantity("mass", p->conserved.mass);
gizmo_check_physical_quantity("energy", p->conserved.energy);
gizmo_check_physical_quantities(
"mass", "energy", p->conserved.mass, p->conserved.momentum[0],
p->conserved.momentum[1], p->conserved.momentum[2], p->conserved.energy);
#ifdef SWIFT_DEBUG_CHECKS
/* Note that this check will only have effect if no GIZMO_UNPHYSICAL option
@@ -675,6 +680,10 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra(
p->conserved.momentum[0] += dt * p->conserved.mass * a_grav[0];
p->conserved.momentum[1] += dt * p->conserved.mass * a_grav[1];
p->conserved.momentum[2] += dt * p->conserved.mass * a_grav[2];
p->conserved.energy += dt * (p->gravity.mflux[0] * a_grav[0] +
p->gravity.mflux[1] * a_grav[1] +
p->gravity.mflux[2] * a_grav[2]);
}
hydro_velocities_set(p, xp);
Loading