From f4daa0f37a8f27776c35a266ea9ad596418bdc25 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Mon, 22 Oct 2018 11:29:57 +0200 Subject: [PATCH] Added debugging function to crash if trying to write an inhibited particle to a snapshot. --- src/hydro/Gadget2/hydro_io.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/hydro/Gadget2/hydro_io.h b/src/hydro/Gadget2/hydro_io.h index ec7d34f7ad..9b4a5940e6 100644 --- a/src/hydro/Gadget2/hydro_io.h +++ b/src/hydro/Gadget2/hydro_io.h @@ -128,6 +128,16 @@ INLINE static void convert_part_potential(const struct engine* e, ret[0] = 0.f; } +INLINE static void convert_part_inhibited(const struct engine* e, + const struct part* p, + const struct xpart* xp, float* ret) { + + if (p->time_bin == time_bin_inhibited) + error("Writing inhibited particle to the snapshot!"); + + ret[0] = p->time_bin; +} + /** * @brief Specifies which particle fields to write to a dataset * @@ -141,7 +151,7 @@ INLINE static void hydro_write_particles(const struct part* parts, struct io_props* list, int* num_fields) { - *num_fields = 10; + *num_fields = 12; /* List what we want to write */ list[0] = io_make_output_field_convert_part("Coordinates", DOUBLE, 3, @@ -169,6 +179,13 @@ INLINE static void hydro_write_particles(const struct part* parts, UNIT_CONV_POTENTIAL, parts, xparts, convert_part_potential); + list[10] = io_make_output_field("Timebin", CHAR, 1, UNIT_CONV_NO_UNITS, parts, + time_bin); + + list[11] = io_make_output_field_convert_part("Inhibited", FLOAT, 1, + UNIT_CONV_NO_UNITS, parts, + xparts, convert_part_inhibited); + #ifdef DEBUG_INTERACTIONS_SPH list += *num_fields; -- GitLab