diff --git a/src/cooling/none/cooling_io.h b/src/cooling/none/cooling_io.h index 16b4b4ca29f8ebd325decc25420d7db617e1e4ef..9ee6208e9e78e4af39b40df87c998bf3b68cd4fe 100644 --- a/src/cooling/none/cooling_io.h +++ b/src/cooling/none/cooling_io.h @@ -62,9 +62,9 @@ __attribute__((always_inline)) INLINE static int cooling_write_particles( const struct part* parts, const struct xpart* xparts, struct io_props* list, const struct cooling_function_data* cooling) { - list[0] = io_make_output_field_convert_part("Temperature", FLOAT, 1, - UNIT_CONV_TEMPERATURE, parts, - xparts, convert_part_T); + list[0] = io_make_output_field_convert_part( + "Temperature", FLOAT, 1, UNIT_CONV_TEMPERATURE, 0.f, parts, xparts, + convert_part_T, "Temperature of the particles"); return 1; } diff --git a/src/gravity/Default/gravity_io.h b/src/gravity/Default/gravity_io.h index c4c41c8d9cbdc76895d65c2da0b41b7bf2f5b13d..47d3e4d2f37a9be9c284a8eb61310fd4084b9749 100644 --- a/src/gravity/Default/gravity_io.h +++ b/src/gravity/Default/gravity_io.h @@ -108,9 +108,11 @@ INLINE static void darkmatter_write_particles(const struct gpart* gparts, /* List what we want to write */ list[0] = io_make_output_field_convert_gpart( - "Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH, gparts, convert_gpart_pos); + "Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH, 1.f, gparts, + convert_gpart_pos, "Position of the particles"); list[1] = io_make_output_field_convert_gpart( - "Velocities", FLOAT, 3, UNIT_CONV_SPEED, gparts, convert_gpart_vel); + "Velocities", FLOAT, 3, UNIT_CONV_SPEED, 0.f, gparts, convert_gpart_vel, + "Peculiar velocites of the particles"); list[2] = io_make_output_field("Masses", FLOAT, 1, UNIT_CONV_MASS, 0.f, gparts, mass, ""); list[3] = diff --git a/src/hydro/Minimal/hydro_io.h b/src/hydro/Minimal/hydro_io.h index d3dcbaf1d4c8558da4c99fa8a2d5eadd1da31e20..8137a3e2c8912ed763c6b44267d1770107746eaa 100644 --- a/src/hydro/Minimal/hydro_io.h +++ b/src/hydro/Minimal/hydro_io.h @@ -160,11 +160,12 @@ INLINE static void hydro_write_particles(const struct part* parts, *num_fields = 10; /* List what we want to write */ - list[0] = io_make_output_field_convert_part("Coordinates", DOUBLE, 3, - UNIT_CONV_LENGTH, parts, xparts, - convert_part_pos); + list[0] = io_make_output_field_convert_part( + "Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH, 1.f, parts, xparts, + convert_part_pos, "Co-moving position of the particles"); list[1] = io_make_output_field_convert_part( - "Velocities", FLOAT, 3, UNIT_CONV_SPEED, parts, xparts, convert_part_vel); + "Velocities", FLOAT, 3, UNIT_CONV_SPEED, 0.f, parts, xparts, + convert_part_vel, "Peculiar velocites of the particles"); list[2] = io_make_output_field("Masses", FLOAT, 1, UNIT_CONV_MASS, 0.f, parts, mass, "Masses of the particles"); list[3] = io_make_output_field( @@ -179,15 +180,16 @@ INLINE static void hydro_write_particles(const struct part* parts, list[6] = io_make_output_field("Density", FLOAT, 1, UNIT_CONV_DENSITY, -3.f, parts, rho, "Physical mass density of the particles"); - list[7] = io_make_output_field_convert_part("Entropy", FLOAT, 1, - UNIT_CONV_ENTROPY_PER_UNIT_MASS, - parts, xparts, convert_S); + list[7] = io_make_output_field_convert_part( + "Entropy", FLOAT, 1, UNIT_CONV_ENTROPY_PER_UNIT_MASS, 0.f, parts, xparts, + convert_S, "Entropy per unit mass of the particles"); list[8] = io_make_output_field_convert_part( - "Pressure", FLOAT, 1, UNIT_CONV_PRESSURE, parts, xparts, convert_P); + "Pressure", FLOAT, 1, UNIT_CONV_PRESSURE, 3 * hydro_gamma, parts, xparts, + convert_P, "Pressure of the particles"); - list[9] = io_make_output_field_convert_part("Potential", FLOAT, 1, - UNIT_CONV_POTENTIAL, parts, - xparts, convert_part_potential); + list[9] = io_make_output_field_convert_part( + "Potential", FLOAT, 1, UNIT_CONV_POTENTIAL, 1.f, parts, xparts, + convert_part_potential, "Gravitational potential of the particles"); } /** diff --git a/src/io_properties.h b/src/io_properties.h index 739063059da449eada937138aa94fda5473e3c81..f34ce577fd92e3601fcd4a61f64583c9516193ef 100644 --- a/src/io_properties.h +++ b/src/io_properties.h @@ -214,8 +214,10 @@ INLINE static struct io_props io_make_input_field_( * @param type The type of the data * @param dimension Dataset dimension (1D, 3D, ...) * @param units The units of the dataset + * @param a_exponent Exponent of the scale-factor to convert to physical units. * @param field Pointer to the field of the first particle * @param partSize The size in byte of the particle + * @param description Description of the field added to the meta-data. * * Do not call this function directly. Use the macro defined above. */ @@ -262,10 +264,11 @@ INLINE static struct io_props io_make_output_field_( /** * @brief Constructs an #io_props (with conversion) from its parameters */ -#define io_make_output_field_convert_part(name, type, dim, units, part, xpart, \ - convert) \ - io_make_output_field_convert_part_##type( \ - name, type, dim, units, sizeof(part[0]), part, xpart, convert) +#define io_make_output_field_convert_part(name, type, dim, units, a_exponent, \ + part, xpart, convert, desc) \ + io_make_output_field_convert_part_##type(name, type, dim, units, a_exponent, \ + sizeof(part[0]), part, xpart, \ + convert, desc) /** * @brief Construct an #io_props from its parameters @@ -274,25 +277,34 @@ INLINE static struct io_props io_make_output_field_( * @param type The type of the data * @param dimension Dataset dimension (1D, 3D, ...) * @param units The units of the dataset + * @param a_exponent Exponent of the scale-factor to convert to physical units. * @param partSize The size in byte of the particle * @param parts The particle array * @param xparts The xparticle array * @param functionPtr The function used to convert a particle to an int + * @param description Description of the field added to the meta-data. * * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_part_INT( const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, - enum unit_conversion_factor units, size_t partSize, + enum unit_conversion_factor units, float a_exponent, size_t partSize, const struct part* parts, const struct xpart* xparts, - conversion_func_part_int functionPtr) { + conversion_func_part_int functionPtr, + const char description[DESCRIPTION_BUFFER_SIZE]) { struct io_props r; strcpy(r.name, name); + if (strlen(description) == 0) { + sprintf(r.description, "No description given"); + } else { + strcpy(r.description, description); + } r.type = type; r.dimension = dimension; r.importance = UNUSED; r.units = units; + r.scale_factor_exponent = a_exponent; r.field = NULL; r.partSize = partSize; r.parts = parts; @@ -320,25 +332,34 @@ INLINE static struct io_props io_make_output_field_convert_part_INT( * @param type The type of the data * @param dimension Dataset dimension (1D, 3D, ...) * @param units The units of the dataset + * @param a_exponent Exponent of the scale-factor to convert to physical units. * @param partSize The size in byte of the particle * @param parts The particle array * @param xparts The xparticle array * @param functionPtr The function used to convert a particle to a float + * @param description Description of the field added to the meta-data. * * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_part_FLOAT( const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, - enum unit_conversion_factor units, size_t partSize, + enum unit_conversion_factor units, float a_exponent, size_t partSize, const struct part* parts, const struct xpart* xparts, - conversion_func_part_float functionPtr) { + conversion_func_part_float functionPtr, + const char description[DESCRIPTION_BUFFER_SIZE]) { struct io_props r; strcpy(r.name, name); + if (strlen(description) == 0) { + sprintf(r.description, "No description given"); + } else { + strcpy(r.description, description); + } r.type = type; r.dimension = dimension; r.importance = UNUSED; r.units = units; + r.scale_factor_exponent = a_exponent; r.field = NULL; r.partSize = partSize; r.parts = parts; @@ -371,25 +392,34 @@ INLINE static struct io_props io_make_output_field_convert_part_FLOAT( * @param type The type of the data * @param dimension Dataset dimension (1D, 3D, ...) * @param units The units of the dataset + * @param a_exponent Exponent of the scale-factor to convert to physical units. * @param partSize The size in byte of the particle * @param parts The particle array * @param xparts The xparticle array * @param functionPtr The function used to convert a particle to a double + * @param description Description of the field added to the meta-data. * * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_part_DOUBLE( const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, - enum unit_conversion_factor units, size_t partSize, + enum unit_conversion_factor units, float a_exponent, size_t partSize, const struct part* parts, const struct xpart* xparts, - conversion_func_part_double functionPtr) { + conversion_func_part_double functionPtr, + const char description[DESCRIPTION_BUFFER_SIZE]) { struct io_props r; strcpy(r.name, name); + if (strlen(description) == 0) { + sprintf(r.description, "No description given"); + } else { + strcpy(r.description, description); + } r.type = type; r.dimension = dimension; r.importance = UNUSED; r.units = units; + r.scale_factor_exponent = a_exponent; r.field = NULL; r.partSize = partSize; r.parts = parts; @@ -422,25 +452,34 @@ INLINE static struct io_props io_make_output_field_convert_part_DOUBLE( * @param type The type of the data * @param dimension Dataset dimension (1D, 3D, ...) * @param units The units of the dataset + * @param a_exponent Exponent of the scale-factor to convert to physical units. * @param partSize The size in byte of the particle * @param parts The particle array * @param xparts The xparticle array * @param functionPtr The function used to convert a particle to a double + * @param description Description of the field added to the meta-data. * * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_part_LONGLONG( const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, - enum unit_conversion_factor units, size_t partSize, + enum unit_conversion_factor units, float a_exponent, size_t partSize, const struct part* parts, const struct xpart* xparts, - conversion_func_part_long_long functionPtr) { + conversion_func_part_long_long functionPtr, + const char description[DESCRIPTION_BUFFER_SIZE]) { struct io_props r; strcpy(r.name, name); + if (strlen(description) == 0) { + sprintf(r.description, "No description given"); + } else { + strcpy(r.description, description); + } r.type = type; r.dimension = dimension; r.importance = UNUSED; r.units = units; + r.scale_factor_exponent = a_exponent; r.field = NULL; r.partSize = partSize; r.parts = parts; @@ -469,10 +508,11 @@ INLINE static struct io_props io_make_output_field_convert_part_LONGLONG( /** * @brief Constructs an #io_props (with conversion) from its parameters */ -#define io_make_output_field_convert_gpart(name, type, dim, units, gpart, \ - convert) \ - io_make_output_field_convert_gpart_##type(name, type, dim, units, \ - sizeof(gpart[0]), gpart, convert) +#define io_make_output_field_convert_gpart(name, type, dim, units, a_exponent, \ + gpart, convert, desc) \ + io_make_output_field_convert_gpart_##type(name, type, dim, units, \ + a_exponent, sizeof(gpart[0]), \ + gpart, convert, desc) /** * @brief Construct an #io_props from its parameters @@ -481,23 +521,32 @@ INLINE static struct io_props io_make_output_field_convert_part_LONGLONG( * @param type The type of the data * @param dimension Dataset dimension (1D, 3D, ...) * @param units The units of the dataset + * @param a_exponent Exponent of the scale-factor to convert to physical units. * @param gpartSize The size in byte of the particle * @param gparts The particle array * @param functionPtr The function used to convert a g-particle to a float + * @param description Description of the field added to the meta-data. * * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_gpart_FLOAT( const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, - enum unit_conversion_factor units, size_t gpartSize, - const struct gpart* gparts, conversion_func_gpart_float functionPtr) { + enum unit_conversion_factor units, float a_exponent, size_t gpartSize, + const struct gpart* gparts, conversion_func_gpart_float functionPtr, + const char description[DESCRIPTION_BUFFER_SIZE]) { struct io_props r; strcpy(r.name, name); + if (strlen(description) == 0) { + sprintf(r.description, "No description given"); + } else { + strcpy(r.description, description); + } r.type = type; r.dimension = dimension; r.importance = UNUSED; r.units = units; + r.scale_factor_exponent = a_exponent; r.field = NULL; r.partSize = gpartSize; r.parts = NULL; @@ -530,23 +579,32 @@ INLINE static struct io_props io_make_output_field_convert_gpart_FLOAT( * @param type The type of the data * @param dimension Dataset dimension (1D, 3D, ...) * @param units The units of the dataset + * @param a_exponent Exponent of the scale-factor to convert to physical units. * @param gpartSize The size in byte of the particle * @param gparts The particle array * @param functionPtr The function used to convert a g-particle to a double + * @param description Description of the field added to the meta-data. * * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_gpart_DOUBLE( const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, - enum unit_conversion_factor units, size_t gpartSize, - const struct gpart* gparts, conversion_func_gpart_double functionPtr) { + enum unit_conversion_factor units, float a_exponent, size_t gpartSize, + const struct gpart* gparts, conversion_func_gpart_double functionPtr, + const char description[DESCRIPTION_BUFFER_SIZE]) { struct io_props r; strcpy(r.name, name); + if (strlen(description) == 0) { + sprintf(r.description, "No description given"); + } else { + strcpy(r.description, description); + } r.type = type; r.dimension = dimension; r.importance = UNUSED; r.units = units; + r.scale_factor_exponent = a_exponent; r.field = NULL; r.partSize = gpartSize; r.parts = NULL; @@ -579,23 +637,32 @@ INLINE static struct io_props io_make_output_field_convert_gpart_DOUBLE( * @param type The type of the data * @param dimension Dataset dimension (1D, 3D, ...) * @param units The units of the dataset + * @param a_exponent Exponent of the scale-factor to convert to physical units. * @param gpartSize The size in byte of the particle * @param gparts The particle array * @param functionPtr The function used to convert a g-particle to a double + * @param description Description of the field added to the meta-data. * * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_gpart_LONGLONG( const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, - enum unit_conversion_factor units, size_t gpartSize, - const struct gpart* gparts, conversion_func_gpart_long_long functionPtr) { + enum unit_conversion_factor units, float a_exponent, size_t gpartSize, + const struct gpart* gparts, conversion_func_gpart_long_long functionPtr, + const char description[DESCRIPTION_BUFFER_SIZE]) { struct io_props r; strcpy(r.name, name); + if (strlen(description) == 0) { + sprintf(r.description, "No description given"); + } else { + strcpy(r.description, description); + } r.type = type; r.dimension = dimension; r.importance = UNUSED; r.units = units; + r.scale_factor_exponent = a_exponent; r.field = NULL; r.partSize = gpartSize; r.parts = NULL; @@ -624,10 +691,11 @@ INLINE static struct io_props io_make_output_field_convert_gpart_LONGLONG( /** * @brief Constructs an #io_props (with conversion) from its parameters */ -#define io_make_output_field_convert_spart(name, type, dim, units, spart, \ - convert) \ - io_make_output_field_convert_spart_##type(name, type, dim, units, \ - sizeof(spart[0]), spart, convert) +#define io_make_output_field_convert_spart(name, type, dim, units, a_exponent, \ + spart, convert, desc) \ + io_make_output_field_convert_spart_##type(name, type, dim, units, \ + a_exponent, sizeof(spart[0]), \ + spart, convert, desc) /** * @brief Construct an #io_props from its parameters @@ -636,23 +704,32 @@ INLINE static struct io_props io_make_output_field_convert_gpart_LONGLONG( * @param type The type of the data * @param dimension Dataset dimension (1D, 3D, ...) * @param units The units of the dataset + * @param a_exponent Exponent of the scale-factor to convert to physical units. * @param spartSize The size in byte of the particle * @param sparts The particle array * @param functionPtr The function used to convert a g-particle to a float + * @param description Description of the field added to the meta-data. * * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_spart_FLOAT( const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, - enum unit_conversion_factor units, size_t spartSize, - const struct spart* sparts, conversion_func_spart_float functionPtr) { + enum unit_conversion_factor units, float a_exponent, size_t spartSize, + const struct spart* sparts, conversion_func_spart_float functionPtr, + const char description[DESCRIPTION_BUFFER_SIZE]) { struct io_props r; strcpy(r.name, name); + if (strlen(description) == 0) { + sprintf(r.description, "No description given"); + } else { + strcpy(r.description, description); + } r.type = type; r.dimension = dimension; r.importance = UNUSED; r.units = units; + r.scale_factor_exponent = a_exponent; r.field = NULL; r.partSize = spartSize; r.parts = NULL; @@ -685,23 +762,32 @@ INLINE static struct io_props io_make_output_field_convert_spart_FLOAT( * @param type The type of the data * @param dimension Dataset dimension (1D, 3D, ...) * @param units The units of the dataset + * @param a_exponent Exponent of the scale-factor to convert to physical units. * @param spartSize The size in byte of the particle * @param sparts The particle array * @param functionPtr The function used to convert a s-particle to a double + * @param description Description of the field added to the meta-data. * * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_spart_DOUBLE( const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, - enum unit_conversion_factor units, size_t spartSize, - const struct spart* sparts, conversion_func_spart_double functionPtr) { + enum unit_conversion_factor units, float a_exponent, size_t spartSize, + const struct spart* sparts, conversion_func_spart_double functionPtr, + const char description[DESCRIPTION_BUFFER_SIZE]) { struct io_props r; strcpy(r.name, name); + if (strlen(description) == 0) { + sprintf(r.description, "No description given"); + } else { + strcpy(r.description, description); + } r.type = type; r.dimension = dimension; r.importance = UNUSED; r.units = units; + r.scale_factor_exponent = a_exponent; r.field = NULL; r.partSize = spartSize; r.parts = NULL; @@ -734,23 +820,32 @@ INLINE static struct io_props io_make_output_field_convert_spart_DOUBLE( * @param type The type of the data * @param dimension Dataset dimension (1D, 3D, ...) * @param units The units of the dataset + * @param a_exponent Exponent of the scale-factor to convert to physical units. * @param spartSize The size in byte of the particle * @param sparts The particle array * @param functionPtr The function used to convert a s-particle to a double + * @param description Description of the field added to the meta-data. * * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_spart_LONGLONG( const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, - enum unit_conversion_factor units, size_t spartSize, - const struct spart* sparts, conversion_func_spart_long_long functionPtr) { + enum unit_conversion_factor units, float a_exponent, size_t spartSize, + const struct spart* sparts, conversion_func_spart_long_long functionPtr, + const char description[DESCRIPTION_BUFFER_SIZE]) { struct io_props r; strcpy(r.name, name); + if (strlen(description) == 0) { + sprintf(r.description, "No description given"); + } else { + strcpy(r.description, description); + } r.type = type; r.dimension = dimension; r.importance = UNUSED; r.units = units; + r.scale_factor_exponent = a_exponent; r.field = NULL; r.partSize = spartSize; r.parts = NULL; @@ -779,10 +874,11 @@ INLINE static struct io_props io_make_output_field_convert_spart_LONGLONG( /** * @brief Constructs an #io_props (with conversion) from its parameters */ -#define io_make_output_field_convert_bpart(name, type, dim, units, bpart, \ - convert) \ - io_make_output_field_convert_bpart_##type(name, type, dim, units, \ - sizeof(bpart[0]), bpart, convert) +#define io_make_output_field_convert_bpart(name, type, dim, units, a_exponent, \ + bpart, convert, desc) \ + io_make_output_field_convert_bpart_##type(name, type, dim, units, \ + a_exponent, sizeof(bpart[0]), \ + bpart, convert, desc) /** * @brief Construct an #io_props from its parameters @@ -791,23 +887,32 @@ INLINE static struct io_props io_make_output_field_convert_spart_LONGLONG( * @param type The type of the data * @param dimension Dataset dimension (1D, 3D, ...) * @param units The units of the dataset + * @param a_exponent Exponent of the scale-factor to convert to physical units. * @param bpartSize The size in byte of the particle * @param bparts The particle array * @param functionPtr The function used to convert a g-particle to a float + * @param description Description of the field added to the meta-data. * * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_bpart_FLOAT( const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, - enum unit_conversion_factor units, size_t bpartSize, - const struct bpart* bparts, conversion_func_bpart_float functionPtr) { + enum unit_conversion_factor units, float a_exponent, size_t bpartSize, + const struct bpart* bparts, conversion_func_bpart_float functionPtr, + const char description[DESCRIPTION_BUFFER_SIZE]) { struct io_props r; strcpy(r.name, name); + if (strlen(description) == 0) { + sprintf(r.description, "No description given"); + } else { + strcpy(r.description, description); + } r.type = type; r.dimension = dimension; r.importance = UNUSED; r.units = units; + r.scale_factor_exponent = a_exponent; r.field = NULL; r.partSize = bpartSize; r.parts = NULL; @@ -839,23 +944,32 @@ INLINE static struct io_props io_make_output_field_convert_bpart_FLOAT( * @param type The type of the data * @param dimension Dataset dimension (1D, 3D, ...) * @param units The units of the dataset + * @param a_exponent Exponent of the scale-factor to convert to physical units. * @param bpartSize The size in byte of the particle * @param bparts The particle array * @param functionPtr The function used to convert a s-particle to a double + * @param description Description of the field added to the meta-data. * * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_bpart_DOUBLE( const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, - enum unit_conversion_factor units, size_t bpartSize, - const struct bpart* bparts, conversion_func_bpart_double functionPtr) { + enum unit_conversion_factor units, float a_exponent, size_t bpartSize, + const struct bpart* bparts, conversion_func_bpart_double functionPtr, + const char description[DESCRIPTION_BUFFER_SIZE]) { struct io_props r; strcpy(r.name, name); + if (strlen(description) == 0) { + sprintf(r.description, "No description given"); + } else { + strcpy(r.description, description); + } r.type = type; r.dimension = dimension; r.importance = UNUSED; r.units = units; + r.scale_factor_exponent = a_exponent; r.field = NULL; r.partSize = bpartSize; r.parts = NULL; @@ -887,23 +1001,33 @@ INLINE static struct io_props io_make_output_field_convert_bpart_DOUBLE( * @param type The type of the data * @param dimension Dataset dimension (1D, 3D, ...) * @param units The units of the dataset + * @param a_exponent Exponent of the scale-factor to convert to physical units. * @param bpartSize The size in byte of the particle * @param bparts The particle array * @param functionPtr The function used to convert a s-particle to a double + * @param description Description of the field added to the meta-data. + * @param description Description of the field added to the meta-data. * * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_bpart_LONGLONG( const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, - enum unit_conversion_factor units, size_t bpartSize, - const struct bpart* bparts, conversion_func_bpart_long_long functionPtr) { + enum unit_conversion_factor units, float a_exponent, size_t bpartSize, + const struct bpart* bparts, conversion_func_bpart_long_long functionPtr, + const char description[DESCRIPTION_BUFFER_SIZE]) { struct io_props r; strcpy(r.name, name); + if (strlen(description) == 0) { + sprintf(r.description, "No description given"); + } else { + strcpy(r.description, description); + } r.type = type; r.dimension = dimension; r.importance = UNUSED; r.units = units; + r.scale_factor_exponent = a_exponent; r.field = NULL; r.partSize = bpartSize; r.parts = NULL; diff --git a/src/stars/Default/stars_io.h b/src/stars/Default/stars_io.h index 6bb0741ba67b366d6008a10b6b2d5e019365656e..c13f9c9bbe0673331d793f54f6e89be0ac64b129 100644 --- a/src/stars/Default/stars_io.h +++ b/src/stars/Default/stars_io.h @@ -66,7 +66,7 @@ INLINE static void stars_write_particles(const struct spart *sparts, /* List what we want to write */ list[0] = io_make_output_field("Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH, 1.f, sparts, x, ""); - list[1] = io_make_output_field("Velocities", FLOAT, 3, UNIT_CONV_SPEED, 1.f, + list[1] = io_make_output_field("Velocities", FLOAT, 3, UNIT_CONV_SPEED, 0.f, sparts, v, ""); list[2] = io_make_output_field("Masses", FLOAT, 1, UNIT_CONV_MASS, 0.f, sparts, mass, ""); diff --git a/src/velociraptor_io.h b/src/velociraptor_io.h index 366c9f501445c0586b5aca46ce66ffea816f3f68..4310c4288001b1983bd27187a56058b70f1e676d 100644 --- a/src/velociraptor_io.h +++ b/src/velociraptor_io.h @@ -61,8 +61,9 @@ __attribute__((always_inline)) INLINE static int velociraptor_write_parts( struct io_props* list) { list[0] = io_make_output_field_convert_part( - "GroupID", LONGLONG, 1, UNIT_CONV_NO_UNITS, parts, xparts, - velociraptor_convert_part_groupID); + "GroupID", LONGLONG, 1, UNIT_CONV_NO_UNITS, 0.f, parts, xparts, + velociraptor_convert_part_groupID, + "Group ID of the particle in the VELOCIraptor catalogue"); return 1; } @@ -70,8 +71,9 @@ __attribute__((always_inline)) INLINE static int velociraptor_write_parts( __attribute__((always_inline)) INLINE static int velociraptor_write_gparts( const struct velociraptor_gpart_data* group_data, struct io_props* list) { - list[0] = io_make_output_field("GroupID", LONGLONG, 1, UNIT_CONV_NO_UNITS, - 0.f, group_data, groupID, ""); + list[0] = io_make_output_field( + "GroupID", LONGLONG, 1, UNIT_CONV_NO_UNITS, 0.f, group_data, groupID, + "Group ID of the particle in the VELOCIraptor catalogue"); return 1; } @@ -80,8 +82,9 @@ __attribute__((always_inline)) INLINE static int velociraptor_write_sparts( const struct spart* sparts, struct io_props* list) { list[0] = io_make_output_field_convert_spart( - "GroupID", LONGLONG, 1, UNIT_CONV_NO_UNITS, sparts, - velociraptor_convert_spart_groupID); + "GroupID", LONGLONG, 1, UNIT_CONV_NO_UNITS, 0.f, sparts, + velociraptor_convert_spart_groupID, + "Group ID of the particle in the VELOCIraptor catalogue"); return 1; } @@ -90,8 +93,9 @@ __attribute__((always_inline)) INLINE static int velociraptor_write_bparts( const struct bpart* bparts, struct io_props* list) { list[0] = io_make_output_field_convert_bpart( - "GroupID", LONGLONG, 1, UNIT_CONV_NO_UNITS, bparts, - velociraptor_convert_bpart_groupID); + "GroupID", LONGLONG, 1, UNIT_CONV_NO_UNITS, 0.f, bparts, + velociraptor_convert_bpart_groupID, + "Group ID of the particle in the VELOCIraptor catalogue"); return 1; }