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
No related branches found
No related tags found
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,
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 */
......@@ -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
......
......@@ -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);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment