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

Also add the new meta-data to the output when using the conversio functions.

parent f1a71a73
No related branches found
No related tags found
1 merge request!824Add a description and a scale-factor exponent to each individual array written to the snapshots.
...@@ -62,9 +62,9 @@ __attribute__((always_inline)) INLINE static int cooling_write_particles( ...@@ -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 part* parts, const struct xpart* xparts, struct io_props* list,
const struct cooling_function_data* cooling) { const struct cooling_function_data* cooling) {
list[0] = io_make_output_field_convert_part("Temperature", FLOAT, 1, list[0] = io_make_output_field_convert_part(
UNIT_CONV_TEMPERATURE, parts, "Temperature", FLOAT, 1, UNIT_CONV_TEMPERATURE, 0.f, parts, xparts,
xparts, convert_part_T); convert_part_T, "Temperature of the particles");
return 1; return 1;
} }
......
...@@ -108,9 +108,11 @@ INLINE static void darkmatter_write_particles(const struct gpart* gparts, ...@@ -108,9 +108,11 @@ INLINE static void darkmatter_write_particles(const struct gpart* gparts,
/* 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(
"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( 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, list[2] = io_make_output_field("Masses", FLOAT, 1, UNIT_CONV_MASS, 0.f,
gparts, mass, ""); gparts, mass, "");
list[3] = list[3] =
......
...@@ -160,11 +160,12 @@ INLINE static void hydro_write_particles(const struct part* parts, ...@@ -160,11 +160,12 @@ INLINE static void hydro_write_particles(const struct part* parts,
*num_fields = 10; *num_fields = 10;
/* 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(
UNIT_CONV_LENGTH, parts, xparts, "Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH, 1.f, parts, xparts,
convert_part_pos); convert_part_pos, "Co-moving position of the particles");
list[1] = io_make_output_field_convert_part( 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, list[2] = io_make_output_field("Masses", FLOAT, 1, UNIT_CONV_MASS, 0.f, parts,
mass, "Masses of the particles"); mass, "Masses of the particles");
list[3] = io_make_output_field( list[3] = io_make_output_field(
...@@ -179,15 +180,16 @@ INLINE static void hydro_write_particles(const struct part* parts, ...@@ -179,15 +180,16 @@ INLINE static void hydro_write_particles(const struct part* parts,
list[6] = list[6] =
io_make_output_field("Density", FLOAT, 1, UNIT_CONV_DENSITY, -3.f, parts, io_make_output_field("Density", FLOAT, 1, UNIT_CONV_DENSITY, -3.f, parts,
rho, "Physical mass density of the particles"); rho, "Physical mass density of the particles");
list[7] = io_make_output_field_convert_part("Entropy", FLOAT, 1, list[7] = io_make_output_field_convert_part(
UNIT_CONV_ENTROPY_PER_UNIT_MASS, "Entropy", FLOAT, 1, UNIT_CONV_ENTROPY_PER_UNIT_MASS, 0.f, parts, xparts,
parts, xparts, convert_S); convert_S, "Entropy per unit mass of the particles");
list[8] = io_make_output_field_convert_part( 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, list[9] = io_make_output_field_convert_part(
UNIT_CONV_POTENTIAL, parts, "Potential", FLOAT, 1, UNIT_CONV_POTENTIAL, 1.f, parts, xparts,
xparts, convert_part_potential); convert_part_potential, "Gravitational potential of the particles");
} }
/** /**
......
...@@ -214,8 +214,10 @@ INLINE static struct io_props io_make_input_field_( ...@@ -214,8 +214,10 @@ INLINE static struct io_props io_make_input_field_(
* @param type The type of the data * @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...) * @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset * @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 field Pointer to the field of the first particle
* @param partSize The size in byte of the 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. * Do not call this function directly. Use the macro defined above.
*/ */
...@@ -262,10 +264,11 @@ INLINE static struct io_props io_make_output_field_( ...@@ -262,10 +264,11 @@ INLINE static struct io_props io_make_output_field_(
/** /**
* @brief Constructs an #io_props (with conversion) from its parameters * @brief Constructs an #io_props (with conversion) from its parameters
*/ */
#define io_make_output_field_convert_part(name, type, dim, units, part, xpart, \ #define io_make_output_field_convert_part(name, type, dim, units, a_exponent, \
convert) \ part, xpart, convert, desc) \
io_make_output_field_convert_part_##type( \ io_make_output_field_convert_part_##type(name, type, dim, units, a_exponent, \
name, type, dim, units, sizeof(part[0]), part, xpart, convert) sizeof(part[0]), part, xpart, \
convert, desc)
/** /**
* @brief Construct an #io_props from its parameters * @brief Construct an #io_props from its parameters
...@@ -274,25 +277,34 @@ INLINE static struct io_props io_make_output_field_( ...@@ -274,25 +277,34 @@ INLINE static struct io_props io_make_output_field_(
* @param type The type of the data * @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...) * @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset * @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 partSize The size in byte of the particle
* @param parts The particle array * @param parts The particle array
* @param xparts The xparticle array * @param xparts The xparticle array
* @param functionPtr The function used to convert a particle to an int * @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. * Do not call this function directly. Use the macro defined above.
*/ */
INLINE static struct io_props io_make_output_field_convert_part_INT( 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, 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, 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; struct io_props r;
strcpy(r.name, name); strcpy(r.name, name);
if (strlen(description) == 0) {
sprintf(r.description, "No description given");
} else {
strcpy(r.description, description);
}
r.type = type; r.type = type;
r.dimension = dimension; r.dimension = dimension;
r.importance = UNUSED; r.importance = UNUSED;
r.units = units; r.units = units;
r.scale_factor_exponent = a_exponent;
r.field = NULL; r.field = NULL;
r.partSize = partSize; r.partSize = partSize;
r.parts = parts; r.parts = parts;
...@@ -320,25 +332,34 @@ INLINE static struct io_props io_make_output_field_convert_part_INT( ...@@ -320,25 +332,34 @@ INLINE static struct io_props io_make_output_field_convert_part_INT(
* @param type The type of the data * @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...) * @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset * @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 partSize The size in byte of the particle
* @param parts The particle array * @param parts The particle array
* @param xparts The xparticle array * @param xparts The xparticle array
* @param functionPtr The function used to convert a particle to a float * @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. * Do not call this function directly. Use the macro defined above.
*/ */
INLINE static struct io_props io_make_output_field_convert_part_FLOAT( 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, 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, 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; struct io_props r;
strcpy(r.name, name); strcpy(r.name, name);
if (strlen(description) == 0) {
sprintf(r.description, "No description given");
} else {
strcpy(r.description, description);
}
r.type = type; r.type = type;
r.dimension = dimension; r.dimension = dimension;
r.importance = UNUSED; r.importance = UNUSED;
r.units = units; r.units = units;
r.scale_factor_exponent = a_exponent;
r.field = NULL; r.field = NULL;
r.partSize = partSize; r.partSize = partSize;
r.parts = parts; r.parts = parts;
...@@ -371,25 +392,34 @@ INLINE static struct io_props io_make_output_field_convert_part_FLOAT( ...@@ -371,25 +392,34 @@ INLINE static struct io_props io_make_output_field_convert_part_FLOAT(
* @param type The type of the data * @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...) * @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset * @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 partSize The size in byte of the particle
* @param parts The particle array * @param parts The particle array
* @param xparts The xparticle array * @param xparts The xparticle array
* @param functionPtr The function used to convert a particle to a double * @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. * Do not call this function directly. Use the macro defined above.
*/ */
INLINE static struct io_props io_make_output_field_convert_part_DOUBLE( 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, 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, 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; struct io_props r;
strcpy(r.name, name); strcpy(r.name, name);
if (strlen(description) == 0) {
sprintf(r.description, "No description given");
} else {
strcpy(r.description, description);
}
r.type = type; r.type = type;
r.dimension = dimension; r.dimension = dimension;
r.importance = UNUSED; r.importance = UNUSED;
r.units = units; r.units = units;
r.scale_factor_exponent = a_exponent;
r.field = NULL; r.field = NULL;
r.partSize = partSize; r.partSize = partSize;
r.parts = parts; r.parts = parts;
...@@ -422,25 +452,34 @@ INLINE static struct io_props io_make_output_field_convert_part_DOUBLE( ...@@ -422,25 +452,34 @@ INLINE static struct io_props io_make_output_field_convert_part_DOUBLE(
* @param type The type of the data * @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...) * @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset * @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 partSize The size in byte of the particle
* @param parts The particle array * @param parts The particle array
* @param xparts The xparticle array * @param xparts The xparticle array
* @param functionPtr The function used to convert a particle to a double * @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. * Do not call this function directly. Use the macro defined above.
*/ */
INLINE static struct io_props io_make_output_field_convert_part_LONGLONG( 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, 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, 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; struct io_props r;
strcpy(r.name, name); strcpy(r.name, name);
if (strlen(description) == 0) {
sprintf(r.description, "No description given");
} else {
strcpy(r.description, description);
}
r.type = type; r.type = type;
r.dimension = dimension; r.dimension = dimension;
r.importance = UNUSED; r.importance = UNUSED;
r.units = units; r.units = units;
r.scale_factor_exponent = a_exponent;
r.field = NULL; r.field = NULL;
r.partSize = partSize; r.partSize = partSize;
r.parts = parts; r.parts = parts;
...@@ -469,10 +508,11 @@ INLINE static struct io_props io_make_output_field_convert_part_LONGLONG( ...@@ -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 * @brief Constructs an #io_props (with conversion) from its parameters
*/ */
#define io_make_output_field_convert_gpart(name, type, dim, units, gpart, \ #define io_make_output_field_convert_gpart(name, type, dim, units, a_exponent, \
convert) \ gpart, convert, desc) \
io_make_output_field_convert_gpart_##type(name, type, dim, units, \ io_make_output_field_convert_gpart_##type(name, type, dim, units, \
sizeof(gpart[0]), gpart, convert) a_exponent, sizeof(gpart[0]), \
gpart, convert, desc)
/** /**
* @brief Construct an #io_props from its parameters * @brief Construct an #io_props from its parameters
...@@ -481,23 +521,32 @@ INLINE static struct io_props io_make_output_field_convert_part_LONGLONG( ...@@ -481,23 +521,32 @@ INLINE static struct io_props io_make_output_field_convert_part_LONGLONG(
* @param type The type of the data * @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...) * @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset * @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 gpartSize The size in byte of the particle
* @param gparts The particle array * @param gparts The particle array
* @param functionPtr The function used to convert a g-particle to a float * @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. * Do not call this function directly. Use the macro defined above.
*/ */
INLINE static struct io_props io_make_output_field_convert_gpart_FLOAT( 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, const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
enum unit_conversion_factor units, size_t gpartSize, enum unit_conversion_factor units, float a_exponent, size_t gpartSize,
const struct gpart* gparts, conversion_func_gpart_float functionPtr) { const struct gpart* gparts, conversion_func_gpart_float functionPtr,
const char description[DESCRIPTION_BUFFER_SIZE]) {
struct io_props r; struct io_props r;
strcpy(r.name, name); strcpy(r.name, name);
if (strlen(description) == 0) {
sprintf(r.description, "No description given");
} else {
strcpy(r.description, description);
}
r.type = type; r.type = type;
r.dimension = dimension; r.dimension = dimension;
r.importance = UNUSED; r.importance = UNUSED;
r.units = units; r.units = units;
r.scale_factor_exponent = a_exponent;
r.field = NULL; r.field = NULL;
r.partSize = gpartSize; r.partSize = gpartSize;
r.parts = NULL; r.parts = NULL;
...@@ -530,23 +579,32 @@ INLINE static struct io_props io_make_output_field_convert_gpart_FLOAT( ...@@ -530,23 +579,32 @@ INLINE static struct io_props io_make_output_field_convert_gpart_FLOAT(
* @param type The type of the data * @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...) * @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset * @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 gpartSize The size in byte of the particle
* @param gparts The particle array * @param gparts The particle array
* @param functionPtr The function used to convert a g-particle to a double * @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. * Do not call this function directly. Use the macro defined above.
*/ */
INLINE static struct io_props io_make_output_field_convert_gpart_DOUBLE( 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, const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
enum unit_conversion_factor units, size_t gpartSize, enum unit_conversion_factor units, float a_exponent, size_t gpartSize,
const struct gpart* gparts, conversion_func_gpart_double functionPtr) { const struct gpart* gparts, conversion_func_gpart_double functionPtr,
const char description[DESCRIPTION_BUFFER_SIZE]) {
struct io_props r; struct io_props r;
strcpy(r.name, name); strcpy(r.name, name);
if (strlen(description) == 0) {
sprintf(r.description, "No description given");
} else {
strcpy(r.description, description);
}
r.type = type; r.type = type;
r.dimension = dimension; r.dimension = dimension;
r.importance = UNUSED; r.importance = UNUSED;
r.units = units; r.units = units;
r.scale_factor_exponent = a_exponent;
r.field = NULL; r.field = NULL;
r.partSize = gpartSize; r.partSize = gpartSize;
r.parts = NULL; r.parts = NULL;
...@@ -579,23 +637,32 @@ INLINE static struct io_props io_make_output_field_convert_gpart_DOUBLE( ...@@ -579,23 +637,32 @@ INLINE static struct io_props io_make_output_field_convert_gpart_DOUBLE(
* @param type The type of the data * @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...) * @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset * @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 gpartSize The size in byte of the particle
* @param gparts The particle array * @param gparts The particle array
* @param functionPtr The function used to convert a g-particle to a double * @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. * Do not call this function directly. Use the macro defined above.
*/ */
INLINE static struct io_props io_make_output_field_convert_gpart_LONGLONG( 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, const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
enum unit_conversion_factor units, size_t gpartSize, enum unit_conversion_factor units, float a_exponent, size_t gpartSize,
const struct gpart* gparts, conversion_func_gpart_long_long functionPtr) { const struct gpart* gparts, conversion_func_gpart_long_long functionPtr,
const char description[DESCRIPTION_BUFFER_SIZE]) {
struct io_props r; struct io_props r;
strcpy(r.name, name); strcpy(r.name, name);
if (strlen(description) == 0) {
sprintf(r.description, "No description given");
} else {
strcpy(r.description, description);
}
r.type = type; r.type = type;
r.dimension = dimension; r.dimension = dimension;
r.importance = UNUSED; r.importance = UNUSED;
r.units = units; r.units = units;
r.scale_factor_exponent = a_exponent;
r.field = NULL; r.field = NULL;
r.partSize = gpartSize; r.partSize = gpartSize;
r.parts = NULL; r.parts = NULL;
...@@ -624,10 +691,11 @@ INLINE static struct io_props io_make_output_field_convert_gpart_LONGLONG( ...@@ -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 * @brief Constructs an #io_props (with conversion) from its parameters
*/ */
#define io_make_output_field_convert_spart(name, type, dim, units, spart, \ #define io_make_output_field_convert_spart(name, type, dim, units, a_exponent, \
convert) \ spart, convert, desc) \
io_make_output_field_convert_spart_##type(name, type, dim, units, \ io_make_output_field_convert_spart_##type(name, type, dim, units, \
sizeof(spart[0]), spart, convert) a_exponent, sizeof(spart[0]), \
spart, convert, desc)
/** /**
* @brief Construct an #io_props from its parameters * @brief Construct an #io_props from its parameters
...@@ -636,23 +704,32 @@ INLINE static struct io_props io_make_output_field_convert_gpart_LONGLONG( ...@@ -636,23 +704,32 @@ INLINE static struct io_props io_make_output_field_convert_gpart_LONGLONG(
* @param type The type of the data * @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...) * @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset * @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 spartSize The size in byte of the particle
* @param sparts The particle array * @param sparts The particle array
* @param functionPtr The function used to convert a g-particle to a float * @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. * Do not call this function directly. Use the macro defined above.
*/ */
INLINE static struct io_props io_make_output_field_convert_spart_FLOAT( 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, const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
enum unit_conversion_factor units, size_t spartSize, enum unit_conversion_factor units, float a_exponent, size_t spartSize,
const struct spart* sparts, conversion_func_spart_float functionPtr) { const struct spart* sparts, conversion_func_spart_float functionPtr,
const char description[DESCRIPTION_BUFFER_SIZE]) {
struct io_props r; struct io_props r;
strcpy(r.name, name); strcpy(r.name, name);
if (strlen(description) == 0) {
sprintf(r.description, "No description given");
} else {
strcpy(r.description, description);
}
r.type = type; r.type = type;
r.dimension = dimension; r.dimension = dimension;
r.importance = UNUSED; r.importance = UNUSED;
r.units = units; r.units = units;
r.scale_factor_exponent = a_exponent;
r.field = NULL; r.field = NULL;
r.partSize = spartSize; r.partSize = spartSize;
r.parts = NULL; r.parts = NULL;
...@@ -685,23 +762,32 @@ INLINE static struct io_props io_make_output_field_convert_spart_FLOAT( ...@@ -685,23 +762,32 @@ INLINE static struct io_props io_make_output_field_convert_spart_FLOAT(
* @param type The type of the data * @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...) * @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset * @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 spartSize The size in byte of the particle
* @param sparts The particle array * @param sparts The particle array
* @param functionPtr The function used to convert a s-particle to a double * @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. * Do not call this function directly. Use the macro defined above.
*/ */
INLINE static struct io_props io_make_output_field_convert_spart_DOUBLE( 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, const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
enum unit_conversion_factor units, size_t spartSize, enum unit_conversion_factor units, float a_exponent, size_t spartSize,
const struct spart* sparts, conversion_func_spart_double functionPtr) { const struct spart* sparts, conversion_func_spart_double functionPtr,
const char description[DESCRIPTION_BUFFER_SIZE]) {
struct io_props r; struct io_props r;
strcpy(r.name, name); strcpy(r.name, name);
if (strlen(description) == 0) {
sprintf(r.description, "No description given");
} else {
strcpy(r.description, description);
}
r.type = type; r.type = type;
r.dimension = dimension; r.dimension = dimension;
r.importance = UNUSED; r.importance = UNUSED;
r.units = units; r.units = units;
r.scale_factor_exponent = a_exponent;
r.field = NULL; r.field = NULL;
r.partSize = spartSize; r.partSize = spartSize;
r.parts = NULL; r.parts = NULL;
...@@ -734,23 +820,32 @@ INLINE static struct io_props io_make_output_field_convert_spart_DOUBLE( ...@@ -734,23 +820,32 @@ INLINE static struct io_props io_make_output_field_convert_spart_DOUBLE(
* @param type The type of the data * @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...) * @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset * @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 spartSize The size in byte of the particle
* @param sparts The particle array * @param sparts The particle array
* @param functionPtr The function used to convert a s-particle to a double * @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. * Do not call this function directly. Use the macro defined above.
*/ */
INLINE static struct io_props io_make_output_field_convert_spart_LONGLONG( 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, const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
enum unit_conversion_factor units, size_t spartSize, enum unit_conversion_factor units, float a_exponent, size_t spartSize,
const struct spart* sparts, conversion_func_spart_long_long functionPtr) { const struct spart* sparts, conversion_func_spart_long_long functionPtr,
const char description[DESCRIPTION_BUFFER_SIZE]) {
struct io_props r; struct io_props r;
strcpy(r.name, name); strcpy(r.name, name);
if (strlen(description) == 0) {
sprintf(r.description, "No description given");
} else {
strcpy(r.description, description);
}
r.type = type; r.type = type;
r.dimension = dimension; r.dimension = dimension;
r.importance = UNUSED; r.importance = UNUSED;
r.units = units; r.units = units;
r.scale_factor_exponent = a_exponent;
r.field = NULL; r.field = NULL;
r.partSize = spartSize; r.partSize = spartSize;
r.parts = NULL; r.parts = NULL;
...@@ -779,10 +874,11 @@ INLINE static struct io_props io_make_output_field_convert_spart_LONGLONG( ...@@ -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 * @brief Constructs an #io_props (with conversion) from its parameters
*/ */
#define io_make_output_field_convert_bpart(name, type, dim, units, bpart, \ #define io_make_output_field_convert_bpart(name, type, dim, units, a_exponent, \
convert) \ bpart, convert, desc) \
io_make_output_field_convert_bpart_##type(name, type, dim, units, \ io_make_output_field_convert_bpart_##type(name, type, dim, units, \
sizeof(bpart[0]), bpart, convert) a_exponent, sizeof(bpart[0]), \
bpart, convert, desc)
/** /**
* @brief Construct an #io_props from its parameters * @brief Construct an #io_props from its parameters
...@@ -791,23 +887,32 @@ INLINE static struct io_props io_make_output_field_convert_spart_LONGLONG( ...@@ -791,23 +887,32 @@ INLINE static struct io_props io_make_output_field_convert_spart_LONGLONG(
* @param type The type of the data * @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...) * @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset * @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 bpartSize The size in byte of the particle
* @param bparts The particle array * @param bparts The particle array
* @param functionPtr The function used to convert a g-particle to a float * @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. * Do not call this function directly. Use the macro defined above.
*/ */
INLINE static struct io_props io_make_output_field_convert_bpart_FLOAT( 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, const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
enum unit_conversion_factor units, size_t bpartSize, enum unit_conversion_factor units, float a_exponent, size_t bpartSize,
const struct bpart* bparts, conversion_func_bpart_float functionPtr) { const struct bpart* bparts, conversion_func_bpart_float functionPtr,
const char description[DESCRIPTION_BUFFER_SIZE]) {
struct io_props r; struct io_props r;
strcpy(r.name, name); strcpy(r.name, name);
if (strlen(description) == 0) {
sprintf(r.description, "No description given");
} else {
strcpy(r.description, description);
}
r.type = type; r.type = type;
r.dimension = dimension; r.dimension = dimension;
r.importance = UNUSED; r.importance = UNUSED;
r.units = units; r.units = units;
r.scale_factor_exponent = a_exponent;
r.field = NULL; r.field = NULL;
r.partSize = bpartSize; r.partSize = bpartSize;
r.parts = NULL; r.parts = NULL;
...@@ -839,23 +944,32 @@ INLINE static struct io_props io_make_output_field_convert_bpart_FLOAT( ...@@ -839,23 +944,32 @@ INLINE static struct io_props io_make_output_field_convert_bpart_FLOAT(
* @param type The type of the data * @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...) * @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset * @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 bpartSize The size in byte of the particle
* @param bparts The particle array * @param bparts The particle array
* @param functionPtr The function used to convert a s-particle to a double * @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. * Do not call this function directly. Use the macro defined above.
*/ */
INLINE static struct io_props io_make_output_field_convert_bpart_DOUBLE( 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, const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
enum unit_conversion_factor units, size_t bpartSize, enum unit_conversion_factor units, float a_exponent, size_t bpartSize,
const struct bpart* bparts, conversion_func_bpart_double functionPtr) { const struct bpart* bparts, conversion_func_bpart_double functionPtr,
const char description[DESCRIPTION_BUFFER_SIZE]) {
struct io_props r; struct io_props r;
strcpy(r.name, name); strcpy(r.name, name);
if (strlen(description) == 0) {
sprintf(r.description, "No description given");
} else {
strcpy(r.description, description);
}
r.type = type; r.type = type;
r.dimension = dimension; r.dimension = dimension;
r.importance = UNUSED; r.importance = UNUSED;
r.units = units; r.units = units;
r.scale_factor_exponent = a_exponent;
r.field = NULL; r.field = NULL;
r.partSize = bpartSize; r.partSize = bpartSize;
r.parts = NULL; r.parts = NULL;
...@@ -887,23 +1001,33 @@ INLINE static struct io_props io_make_output_field_convert_bpart_DOUBLE( ...@@ -887,23 +1001,33 @@ INLINE static struct io_props io_make_output_field_convert_bpart_DOUBLE(
* @param type The type of the data * @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...) * @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset * @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 bpartSize The size in byte of the particle
* @param bparts The particle array * @param bparts The particle array
* @param functionPtr The function used to convert a s-particle to a double * @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. * Do not call this function directly. Use the macro defined above.
*/ */
INLINE static struct io_props io_make_output_field_convert_bpart_LONGLONG( 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, const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
enum unit_conversion_factor units, size_t bpartSize, enum unit_conversion_factor units, float a_exponent, size_t bpartSize,
const struct bpart* bparts, conversion_func_bpart_long_long functionPtr) { const struct bpart* bparts, conversion_func_bpart_long_long functionPtr,
const char description[DESCRIPTION_BUFFER_SIZE]) {
struct io_props r; struct io_props r;
strcpy(r.name, name); strcpy(r.name, name);
if (strlen(description) == 0) {
sprintf(r.description, "No description given");
} else {
strcpy(r.description, description);
}
r.type = type; r.type = type;
r.dimension = dimension; r.dimension = dimension;
r.importance = UNUSED; r.importance = UNUSED;
r.units = units; r.units = units;
r.scale_factor_exponent = a_exponent;
r.field = NULL; r.field = NULL;
r.partSize = bpartSize; r.partSize = bpartSize;
r.parts = NULL; r.parts = NULL;
......
...@@ -66,7 +66,7 @@ INLINE static void stars_write_particles(const struct spart *sparts, ...@@ -66,7 +66,7 @@ INLINE static void stars_write_particles(const struct spart *sparts,
/* List what we want to write */ /* List what we want to write */
list[0] = io_make_output_field("Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH, list[0] = io_make_output_field("Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH,
1.f, sparts, x, ""); 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, ""); sparts, v, "");
list[2] = io_make_output_field("Masses", FLOAT, 1, UNIT_CONV_MASS, 0.f, list[2] = io_make_output_field("Masses", FLOAT, 1, UNIT_CONV_MASS, 0.f,
sparts, mass, ""); sparts, mass, "");
......
...@@ -61,8 +61,9 @@ __attribute__((always_inline)) INLINE static int velociraptor_write_parts( ...@@ -61,8 +61,9 @@ __attribute__((always_inline)) INLINE static int velociraptor_write_parts(
struct io_props* list) { struct io_props* list) {
list[0] = io_make_output_field_convert_part( list[0] = io_make_output_field_convert_part(
"GroupID", LONGLONG, 1, UNIT_CONV_NO_UNITS, parts, xparts, "GroupID", LONGLONG, 1, UNIT_CONV_NO_UNITS, 0.f, parts, xparts,
velociraptor_convert_part_groupID); velociraptor_convert_part_groupID,
"Group ID of the particle in the VELOCIraptor catalogue");
return 1; return 1;
} }
...@@ -70,8 +71,9 @@ __attribute__((always_inline)) INLINE static int velociraptor_write_parts( ...@@ -70,8 +71,9 @@ __attribute__((always_inline)) INLINE static int velociraptor_write_parts(
__attribute__((always_inline)) INLINE static int velociraptor_write_gparts( __attribute__((always_inline)) INLINE static int velociraptor_write_gparts(
const struct velociraptor_gpart_data* group_data, struct io_props* list) { const struct velociraptor_gpart_data* group_data, struct io_props* list) {
list[0] = io_make_output_field("GroupID", LONGLONG, 1, UNIT_CONV_NO_UNITS, list[0] = io_make_output_field(
0.f, group_data, groupID, ""); "GroupID", LONGLONG, 1, UNIT_CONV_NO_UNITS, 0.f, group_data, groupID,
"Group ID of the particle in the VELOCIraptor catalogue");
return 1; return 1;
} }
...@@ -80,8 +82,9 @@ __attribute__((always_inline)) INLINE static int velociraptor_write_sparts( ...@@ -80,8 +82,9 @@ __attribute__((always_inline)) INLINE static int velociraptor_write_sparts(
const struct spart* sparts, struct io_props* list) { const struct spart* sparts, struct io_props* list) {
list[0] = io_make_output_field_convert_spart( list[0] = io_make_output_field_convert_spart(
"GroupID", LONGLONG, 1, UNIT_CONV_NO_UNITS, sparts, "GroupID", LONGLONG, 1, UNIT_CONV_NO_UNITS, 0.f, sparts,
velociraptor_convert_spart_groupID); velociraptor_convert_spart_groupID,
"Group ID of the particle in the VELOCIraptor catalogue");
return 1; return 1;
} }
...@@ -90,8 +93,9 @@ __attribute__((always_inline)) INLINE static int velociraptor_write_bparts( ...@@ -90,8 +93,9 @@ __attribute__((always_inline)) INLINE static int velociraptor_write_bparts(
const struct bpart* bparts, struct io_props* list) { const struct bpart* bparts, struct io_props* list) {
list[0] = io_make_output_field_convert_bpart( list[0] = io_make_output_field_convert_bpart(
"GroupID", LONGLONG, 1, UNIT_CONV_NO_UNITS, bparts, "GroupID", LONGLONG, 1, UNIT_CONV_NO_UNITS, 0.f, bparts,
velociraptor_convert_bpart_groupID); velociraptor_convert_bpart_groupID,
"Group ID of the particle in the VELOCIraptor catalogue");
return 1; return 1;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment