diff --git a/src/hydro/Gizmo/hydro.h b/src/hydro/Gizmo/hydro.h index 2c2f54699bb380a491edf61a83ad8a031572c86c..6273f5009a051e17d2a2954ac994c3f189110464 100644 --- a/src/hydro/Gizmo/hydro.h +++ b/src/hydro/Gizmo/hydro.h @@ -24,6 +24,7 @@ #include "approx_math.h" #include "equation_of_state.h" #include "hydro_gradients.h" +#include "hydro_properties.h" #include "hydro_space.h" #include "hydro_unphysical.h" #include "hydro_velocities.h" @@ -130,8 +131,9 @@ __attribute__((always_inline)) INLINE static void hydro_first_init_part( /* remember that we store the total thermal energy, not the specific thermal energy (as in Gadget) */ #if defined(EOS_ISOTHERMAL_GAS) - /* this overwrites the internal energy from the initial condition file */ - p->conserved.energy = mass * const_isothermal_internal_energy; + /* this overwrites the internal energy from the initial condition file + * Note that we call the EoS function just to get the constant u here. */ + p->conserved.energy = mass * gas_internal_energy_from_entropy(0.f, 0.f); #else p->conserved.energy *= mass; #endif @@ -608,7 +610,9 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra( p->conserved.momentum[1] += p->conserved.flux.momentum[1]; p->conserved.momentum[2] += p->conserved.flux.momentum[2]; #if defined(EOS_ISOTHERMAL_GAS) - p->conserved.energy = p->conserved.mass * const_isothermal_internal_energy; + /* We use the EoS equation in a sneaky way here just to get the constant u */ + p->conserved.energy = + p->conserved.mass * gas_internal_energy_from_entropy(0.f, 0.f); #else p->conserved.energy += p->conserved.flux.energy; #endif @@ -707,15 +711,11 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra( __attribute__((always_inline)) INLINE static float hydro_get_internal_energy( const struct part* restrict p) { - if (p->primitives.rho > 0.) { -#ifdef EOS_ISOTHERMAL_GAS - return p->primitives.P / hydro_gamma_minus_one / p->primitives.rho; -#else - return const_isothermal_internal_energy; -#endif - } else { + if (p->primitives.rho > 0.) + return gas_internal_energy_from_pressure(p->primitives.rho, + p->primitives.P); + else return 0.; - } } /** @@ -727,7 +727,7 @@ __attribute__((always_inline)) INLINE static float hydro_get_entropy( const struct part* restrict p) { if (p->primitives.rho > 0.) { - return p->primitives.P / pow_gamma(p->primitives.rho); + return gas_entropy_from_pressure(p->primitives.rho, p->primitives.P); } else { return 0.; } @@ -741,16 +741,10 @@ __attribute__((always_inline)) INLINE static float hydro_get_entropy( __attribute__((always_inline)) INLINE static float hydro_get_soundspeed( const struct part* restrict p) { - if (p->primitives.rho > 0.) { -#ifdef EOS_ISOTHERMAL_GAS - return sqrtf(const_isothermal_internal_energy * hydro_gamma * - hydro_gamma_minus_one); -#else - return sqrtf(hydro_gamma * p->primitives.P / p->primitives.rho); -#endif - } else { + if (p->primitives.rho > 0.) + return gas_soundspeed_from_pressure(p->primitives.rho, p->primitives.P); + else return 0.; - } } /** diff --git a/src/hydro/Gizmo/hydro_io.h b/src/hydro/Gizmo/hydro_io.h index d20f7e2eb1cf50be7690e15a9569d8e9c4605af5..ea0a083f37078859b236ca0799268066f6fa0385 100644 --- a/src/hydro/Gizmo/hydro_io.h +++ b/src/hydro/Gizmo/hydro_io.h @@ -18,6 +18,7 @@ ******************************************************************************/ #include "adiabatic_index.h" +#include "hydro.h" #include "hydro_flux_limiters.h" #include "hydro_gradients.h" #include "hydro_slope_limiters.h" @@ -71,15 +72,7 @@ void hydro_read_particles(struct part* parts, struct io_props* list, * @return Internal energy of the particle */ float convert_u(struct engine* e, struct part* p) { - if (p->primitives.rho > 0.) { -#ifdef EOS_ISOTHERMAL_GAS - return const_isothermal_internal_energy; -#else - return p->primitives.P / hydro_gamma_minus_one / p->primitives.rho; -#endif - } else { - return 0.; - } + return hydro_get_internal_energy(p); } /** @@ -90,11 +83,7 @@ float convert_u(struct engine* e, struct part* p) { * @return Entropic function of the particle */ float convert_A(struct engine* e, struct part* p) { - if (p->primitives.rho > 0.) { - return p->primitives.P / pow_gamma(p->primitives.rho); - } else { - return 0.; - } + return hydro_get_entropy(p); } /** diff --git a/src/parallel_io.c b/src/parallel_io.c index a542a5ff6f7f18d4e616abf355120844652075f2..b31d3b6351b00af4a042e4b28bf492258b17b073 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -146,7 +146,7 @@ void readArray_chunk(hid_t h_data, hid_t h_plist_id, * @brief Reads a data array from a given HDF5 group. * * @param grp The group from which to read. - * @param prop The #io_props of the field to read. + * @param props The #io_props of the field to read. * @param N The number of particles on that rank. * @param N_total The total number of particles. * @param mpi_rank The MPI rank of this node. diff --git a/src/space.c b/src/space.c index 4dab9346fa8a0af0d04984d2f3c43437eaa877e5..5e3c1a51711104530c27337abd82349802c5623a 100644 --- a/src/space.c +++ b/src/space.c @@ -2703,7 +2703,7 @@ void space_init_gparts(struct space *s, int verbose) { if (s->nr_gparts > 0) threadpool_map(&s->e->threadpool, space_init_gparts_mapper, s->gparts, - s->nr_gparts, sizeof(struct part), 0, NULL); + s->nr_gparts, sizeof(struct gpart), 0, NULL); if (verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), clocks_getunit()); diff --git a/tests/testFFT.c b/tests/testFFT.c index 970678c9a503517599737bfe41766913dde2a2d7..ba737935afc4568a1509d2c43a3534b60a6ef867 100644 --- a/tests/testFFT.c +++ b/tests/testFFT.c @@ -78,7 +78,7 @@ int main() { engine.nr_threads = 1; engine.nodeID = 0; engine_rank = 0; - + struct runner runner; runner.e = &engine;