diff --git a/src/gravity/Default/gravity_io.h b/src/gravity/Default/gravity_io.h index 1ba3899e7ecc346227c10679bb8b704937c625b2..0c3c6431026e1e92cd96141d1d0603f0200ca4cb 100644 --- a/src/gravity/Default/gravity_io.h +++ b/src/gravity/Default/gravity_io.h @@ -92,6 +92,15 @@ INLINE static void darkmatter_read_particles(struct gpart* gparts, UNIT_CONV_NO_UNITS, gparts, id_or_neg_offset); } +INLINE static void test_time_bin_gpart(const struct engine* e, + const struct gpart* gp, float* ret) { + + if (gp->time_bin >= time_bin_inhibited) + error("Writing inhibited or extra particle time_bin=%d", gp->time_bin); + + *ret = gp->time_bin; +} + /** * @brief Specifies which g-particle fields to write to a dataset * @@ -104,7 +113,7 @@ INLINE static void darkmatter_write_particles(const struct gpart* gparts, int* num_fields) { /* Say how much we want to write */ - *num_fields = 4; + *num_fields = 5; /* List what we want to write */ list[0] = io_make_output_field_convert_gpart( @@ -115,6 +124,8 @@ INLINE static void darkmatter_write_particles(const struct gpart* gparts, io_make_output_field("Masses", FLOAT, 1, UNIT_CONV_MASS, gparts, mass); list[3] = io_make_output_field("ParticleIDs", ULONGLONG, 1, UNIT_CONV_NO_UNITS, gparts, id_or_neg_offset); + list[4] = io_make_output_field_convert_gpart( + "TimeBin", FLOAT, 1, UNIT_CONV_NO_UNITS, gparts, test_time_bin_gpart); } #endif /* SWIFT_DEFAULT_GRAVITY_IO_H */ diff --git a/src/hydro/Gadget2/hydro_io.h b/src/hydro/Gadget2/hydro_io.h index ec7d34f7ad8697f1d639ea4951011ddb06ec8833..d776951767559faa4ef47e19db566b7c20037516 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 test_time_bin_part(const struct engine* e, + const struct part* p, + const struct xpart* xp, float* ret) { + + if (p->time_bin >= time_bin_inhibited) + error("Writing inhibited or extra particle time_bin=%d", p->time_bin); + + *ret = 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 = 11; /* List what we want to write */ list[0] = io_make_output_field_convert_part("Coordinates", DOUBLE, 3, @@ -168,6 +178,9 @@ INLINE static void hydro_write_particles(const struct part* parts, list[9] = io_make_output_field_convert_part("Potential", FLOAT, 1, UNIT_CONV_POTENTIAL, parts, xparts, convert_part_potential); + list[10] = + io_make_output_field_convert_part("TimeBin", FLOAT, 1, UNIT_CONV_NO_UNITS, + parts, xparts, test_time_bin_part); #ifdef DEBUG_INTERACTIONS_SPH diff --git a/src/stars/Default/stars_io.h b/src/stars/Default/stars_io.h index a6c2768f715e3dc6e870ee92e7d8a5e9458a5d11..82d06d292fe3f427c963247f1324a7cd837d12b7 100644 --- a/src/stars/Default/stars_io.h +++ b/src/stars/Default/stars_io.h @@ -22,6 +22,15 @@ #include "io_properties.h" #include "stars_part.h" +INLINE static void test_time_bin_spart(const struct engine *e, + const struct spart *sp, float *ret) { + + if (sp->time_bin >= time_bin_inhibited) + error("Writing inhibited or extra particle time_bin=%d", sp->time_bin); + + *ret = sp->time_bin; +} + /** * @brief Specifies which s-particle fields to read from a dataset * @@ -60,8 +69,8 @@ INLINE static void stars_write_particles(const struct spart *sparts, struct io_props *list, int *num_fields) { - /* Say how much we want to read */ - *num_fields = 5; + /* Say how much we want to write */ + *num_fields = 6; /* List what we want to read */ list[0] = io_make_output_field("Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH, @@ -74,6 +83,9 @@ INLINE static void stars_write_particles(const struct spart *sparts, sparts, id); list[4] = io_make_output_field("SmoothingLength", FLOAT, 1, UNIT_CONV_LENGTH, sparts, h); + + list[5] = io_make_output_field_convert_spart( + "TimeBin", FLOAT, 1, UNIT_CONV_NO_UNITS, sparts, test_time_bin_spart); } /**