From 133171b27718dfb68ed92a2af7f4b9c0547f05b8 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Tue, 26 Jul 2016 17:51:51 +0100 Subject: [PATCH] And OK for the MINIMAL_SPH --- src/const.h | 4 ++-- src/hydro/Minimal/hydro.h | 36 ++++++++++++++++++++++++++++++++++++ tests/test125cells.c | 11 ++++++++++- tests/testNonSymInt.c | 10 ++++++++-- tests/testSymInt.c | 10 ++++++++-- 5 files changed, 64 insertions(+), 7 deletions(-) diff --git a/src/const.h b/src/const.h index 270474d05e..50d72e3339 100644 --- a/src/const.h +++ b/src/const.h @@ -56,8 +56,8 @@ /* SPH variant to use */ //#define MINIMAL_SPH -//#define GADGET2_SPH -#define DEFAULT_SPH +#define GADGET2_SPH +//#define DEFAULT_SPH /* External potential properties */ #define EXTERNAL_POTENTIAL_POINTMASS diff --git a/src/hydro/Minimal/hydro.h b/src/hydro/Minimal/hydro.h index ee7001700c..f1f284d5d2 100644 --- a/src/hydro/Minimal/hydro.h +++ b/src/hydro/Minimal/hydro.h @@ -246,3 +246,39 @@ __attribute__((always_inline)) INLINE static float hydro_get_internal_energy( return p->u; } + +/** + * @brief Returns the pressure of a particle + * + * @param p The particle of interest + * @param dt Time since the last kick + */ +__attribute__((always_inline)) INLINE static float hydro_get_pressure( + const struct part *restrict p, float dt) { + + return p->u * p->rho * hydro_gamma_minus_one; +} + +/** + * @brief Returns the entropy of a particle + * + * @param p The particle of interest + * @param dt Time since the last kick + */ +__attribute__((always_inline)) INLINE static float hydro_get_entropy( + const struct part *restrict p, float dt) { + + return hydro_gamma_minus_one * p->u * pow_minus_gamma_minus_one(p->rho); +} + +/** + * @brief Returns the sound speed of a particle + * + * @param p The particle of interest + * @param dt Time since the last kick + */ +__attribute__((always_inline)) INLINE static float hydro_get_soundspeed( + const struct part *restrict p, float dt) { + + return sqrt(p->u * hydro_gamma * hydro_gamma_minus_one); +} diff --git a/tests/test125cells.c b/tests/test125cells.c index 19509db4ee..0aa14061a2 100644 --- a/tests/test125cells.c +++ b/tests/test125cells.c @@ -97,6 +97,8 @@ void set_energy_state(struct part *part, enum pressure_field press, float size, part->entropy = pressure / pow_gamma(density); #elif defined(DEFAULT_SPH) part->u = pressure / (hydro_gamma_minus_one * density); +#elif defined(MINIMAL_SPH) + part->u = pressure / (hydro_gamma_minus_one * density); #else error("Need to define pressure here !"); #endif @@ -298,7 +300,12 @@ void dump_particle_fields(char *fileName, struct cell *main_cell, main_cell->parts[pid].x[1], main_cell->parts[pid].x[2], main_cell->parts[pid].v[0], main_cell->parts[pid].v[1], main_cell->parts[pid].v[2], main_cell->parts[pid].h, - main_cell->parts[pid].rho, main_cell->parts[pid].density.div_v, + main_cell->parts[pid].rho, +#ifdef MINIMAL_SPH + 0.f, +#else + main_cell->parts[pid].density.div_v, +#endif hydro_get_entropy(&main_cell->parts[pid], 0.f), hydro_get_internal_energy(&main_cell->parts[pid], 0.f), hydro_get_pressure(&main_cell->parts[pid], 0.f), @@ -310,6 +317,8 @@ void dump_particle_fields(char *fileName, struct cell *main_cell, main_cell->parts[pid].entropy_dt, 0.f #elif defined(DEFAULT_SPH) 0.f, main_cell->parts[pid].force.u_dt +#elif defined(MINIMAL_SPH) + 0.f, main_cell->parts[pid].u_dt #else 0.f, 0.f #endif diff --git a/tests/testNonSymInt.c b/tests/testNonSymInt.c index 23242563bd..3388569018 100644 --- a/tests/testNonSymInt.c +++ b/tests/testNonSymInt.c @@ -78,8 +78,14 @@ void dump_indv_particle_fields(char *fileName, struct part *p) { "%6llu %10f %10f %10f %10f %10f %10f %13e %13e %13e %13e %13e " "%13e %13e %13e\n", p->id, p->x[0], p->x[1], p->x[2], p->v[0], p->v[1], p->v[2], p->rho, - p->rho_dh, p->density.wcount, p->density.wcount_dh, p->density.div_v, - p->density.rot_v[0], p->density.rot_v[1], p->density.rot_v[2]); + p->rho_dh, p->density.wcount, p->density.wcount_dh, +#ifdef MINIMAL_SPH + 0.f, 0.f, 0.f, 0.f +#else + p->density.div_v, + p->density.rot_v[0], p->density.rot_v[1], p->density.rot_v[2] +#endif + ); fclose(file); } diff --git a/tests/testSymInt.c b/tests/testSymInt.c index 9019821900..5158f2bae6 100644 --- a/tests/testSymInt.c +++ b/tests/testSymInt.c @@ -75,8 +75,14 @@ void dump_indv_particle_fields(char *fileName, struct part *p) { "%6llu %10f %10f %10f %10f %10f %10f %13e %13e %13e %13e %13e " "%13e %13e %13e\n", p->id, p->x[0], p->x[1], p->x[2], p->v[0], p->v[1], p->v[2], p->rho, - p->rho_dh, p->density.wcount, p->density.wcount_dh, p->density.div_v, - p->density.rot_v[0], p->density.rot_v[1], p->density.rot_v[2]); + p->rho_dh, p->density.wcount, p->density.wcount_dh, +#ifdef MINIMAL_SPH + 0.f, 0.f, 0.f, 0.f +#else + p->density.div_v, + p->density.rot_v[0], p->density.rot_v[1], p->density.rot_v[2] +#endif + ); fclose(file); } -- GitLab