Skip to content
Snippets Groups Projects
Commit f26d1107 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Temporarily write the time-bins to the snapshots to make sure we only write real particles.

parent 17d568e2
Branches
Tags
2 merge requests!688Star formation (non-MPI),!684Add star particles on-the-fly
...@@ -92,6 +92,15 @@ INLINE static void darkmatter_read_particles(struct gpart* gparts, ...@@ -92,6 +92,15 @@ INLINE static void darkmatter_read_particles(struct gpart* gparts,
UNIT_CONV_NO_UNITS, gparts, id_or_neg_offset); 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 * @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, ...@@ -104,7 +113,7 @@ INLINE static void darkmatter_write_particles(const struct gpart* gparts,
int* num_fields) { int* num_fields) {
/* Say how much we want to write */ /* Say how much we want to write */
*num_fields = 4; *num_fields = 5;
/* List what we want to write */ /* List what we want to write */
list[0] = io_make_output_field_convert_gpart( list[0] = io_make_output_field_convert_gpart(
...@@ -115,6 +124,8 @@ INLINE static void darkmatter_write_particles(const struct gpart* gparts, ...@@ -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); io_make_output_field("Masses", FLOAT, 1, UNIT_CONV_MASS, gparts, mass);
list[3] = io_make_output_field("ParticleIDs", ULONGLONG, 1, list[3] = io_make_output_field("ParticleIDs", ULONGLONG, 1,
UNIT_CONV_NO_UNITS, gparts, id_or_neg_offset); 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 */ #endif /* SWIFT_DEFAULT_GRAVITY_IO_H */
...@@ -128,6 +128,16 @@ INLINE static void convert_part_potential(const struct engine* e, ...@@ -128,6 +128,16 @@ INLINE static void convert_part_potential(const struct engine* e,
ret[0] = 0.f; 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 * @brief Specifies which particle fields to write to a dataset
* *
...@@ -141,7 +151,7 @@ INLINE static void hydro_write_particles(const struct part* parts, ...@@ -141,7 +151,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
struct io_props* list, struct io_props* list,
int* num_fields) { int* num_fields) {
*num_fields = 10; *num_fields = 11;
/* List what we want to write */ /* List what we want to write */
list[0] = io_make_output_field_convert_part("Coordinates", DOUBLE, 3, 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, ...@@ -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, list[9] = io_make_output_field_convert_part("Potential", FLOAT, 1,
UNIT_CONV_POTENTIAL, parts, UNIT_CONV_POTENTIAL, parts,
xparts, convert_part_potential); 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 #ifdef DEBUG_INTERACTIONS_SPH
......
...@@ -22,6 +22,15 @@ ...@@ -22,6 +22,15 @@
#include "io_properties.h" #include "io_properties.h"
#include "stars_part.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 * @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, ...@@ -60,8 +69,8 @@ INLINE static void stars_write_particles(const struct spart *sparts,
struct io_props *list, struct io_props *list,
int *num_fields) { int *num_fields) {
/* Say how much we want to read */ /* Say how much we want to write */
*num_fields = 5; *num_fields = 6;
/* List what we want to read */ /* List what we want to read */
list[0] = io_make_output_field("Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH, 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, ...@@ -74,6 +83,9 @@ INLINE static void stars_write_particles(const struct spart *sparts,
sparts, id); sparts, id);
list[4] = io_make_output_field("SmoothingLength", FLOAT, 1, UNIT_CONV_LENGTH, list[4] = io_make_output_field("SmoothingLength", FLOAT, 1, UNIT_CONV_LENGTH,
sparts, h); sparts, h);
list[5] = io_make_output_field_convert_spart(
"TimeBin", FLOAT, 1, UNIT_CONV_NO_UNITS, sparts, test_time_bin_spart);
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment