diff --git a/src/hydro/Gadget2/hydro_io.h b/src/hydro/Gadget2/hydro_io.h index 8cae2639fff7d396ef77e421fc23556a4f088724..15e2b9b9ba1a85b13094ab4c0d5da7bff950b0c6 100644 --- a/src/hydro/Gadget2/hydro_io.h +++ b/src/hydro/Gadget2/hydro_io.h @@ -52,7 +52,7 @@ void hydro_read_particles(struct part* parts, struct io_props* list, UNIT_CONV_DENSITY, parts, rho); } -float convert_u(struct part* p) { +float convert_u(struct engine* e, struct part* p) { return p->entropy * pow_gamma_minus_one(p->rho) * hydro_one_over_gamma_minus_one; diff --git a/src/io_properties.h b/src/io_properties.h index a6714b2d38a6c1fad0eaea1759ac51da3e1050c7..11c43b503f991ec298917a5a39fe3f47f85ffb2f 100644 --- a/src/io_properties.h +++ b/src/io_properties.h @@ -60,10 +60,10 @@ struct io_props { struct gpart* gparts; /* Conversion function for part */ - float (*convert_part)(struct part*); + float (*convert_part)(struct engine*, struct part*); /* Conversion function for part */ - float (*convert_gpart)(struct gpart*); + float (*convert_gpart)(struct engine*, struct gpart*); }; /** @@ -173,7 +173,7 @@ struct io_props io_make_output_field_(char name[FIELD_BUFFER_SIZE], struct io_props io_make_output_field_convert_part_( char name[FIELD_BUFFER_SIZE], enum DATA_TYPE type, int dimension, enum UnitConversionFactor units, char* field, size_t partSize, - struct part* parts, float (*functionPtr)(struct part*)) { + struct part* parts, float (*functionPtr)(struct engine*, struct part*)) { struct io_props r; strcpy(r.name, name); @@ -218,7 +218,7 @@ struct io_props io_make_output_field_convert_part_( struct io_props io_make_output_field_convert_gpart_( char name[FIELD_BUFFER_SIZE], enum DATA_TYPE type, int dimension, enum UnitConversionFactor units, char* field, size_t partSize, - struct gpart* gparts, float (*functionPtr)(struct gpart*)) { + struct gpart* gparts, float (*functionPtr)(struct engine*, struct gpart*)) { struct io_props r; strcpy(r.name, name); diff --git a/src/parallel_io.c b/src/parallel_io.c index cd9498612e204858af5da7f268d2c17eb7932083..73653259909f2921a321c5e2f046aa5d2bf1717c 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -181,6 +181,7 @@ void readArray(hid_t grp, const struct io_props prop, size_t N, /** * @brief Writes a data array in given HDF5 group. * + * @param e The #engine we are writing from. * @param grp The group in which to write. * @param fileName The name of the file in which the data is written * @param xmfFile The FILE used to write the XMF description @@ -194,7 +195,7 @@ void readArray(hid_t grp, const struct io_props prop, size_t N, * the part array will be written once the structures have been stabilized. * */ -void writeArray(hid_t grp, char* fileName, FILE* xmfFile, +void writeArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile, char* partTypeGroupName, const struct io_props props, size_t N, long long N_total, int mpi_rank, long long offset, const struct UnitSystem* internal_units, @@ -222,13 +223,13 @@ void writeArray(hid_t grp, char* fileName, FILE* xmfFile, float* temp_f = temp; for (size_t i = 0; i < N; ++i) - temp_f[i] = props.convert_part(&props.parts[i]); + temp_f[i] = props.convert_part(e, &props.parts[i]); } else if (props.convert_gpart != NULL) { /* conversion (for gparts)*/ float* temp_f = temp; for (size_t i = 0; i < N; ++i) - temp_f[i] = props.convert_gpart(&props.gparts[i]); + temp_f[i] = props.convert_gpart(e, &props.gparts[i]); } /* Unit conversion if necessary */ @@ -781,7 +782,7 @@ void write_output_parallel(struct engine* e, const char* baseName, /* Write everything */ for (int i = 0; i < num_fields; ++i) - writeArray(h_grp, fileName, xmfFile, partTypeGroupName, list[i], N, + writeArray(e, h_grp, fileName, xmfFile, partTypeGroupName, list[i], N, N_total[ptype], mpi_rank, offset[ptype], internal_units, snapshot_units); diff --git a/src/serial_io.c b/src/serial_io.c index 6e6a57f49b6daf653dc12486a5af0de035e924e5..aafb5ca9b58c58d308de13978019d5c3c4f15aaf 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -261,6 +261,7 @@ void prepareArray(hid_t grp, char* fileName, FILE* xmfFile, /** * @brief Writes a data array in given HDF5 group. * + * @param e The #engine we are writing from. * @param grp The group in which to write. * @param fileName The name of the file in which the data is written * @param xmfFile The FILE used to write the XMF description @@ -276,7 +277,7 @@ void prepareArray(hid_t grp, char* fileName, FILE* xmfFile, * @param us The UnitSystem currently in use * @param convFactor The UnitConversionFactor for this arrayo */ -void writeArray(hid_t grp, char* fileName, FILE* xmfFile, +void writeArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile, char* partTypeGroupName, const struct io_props props, size_t N, long long N_total, int mpi_rank, long long offset, const struct UnitSystem* internal_units, @@ -309,13 +310,13 @@ void writeArray(hid_t grp, char* fileName, FILE* xmfFile, float* temp_f = temp; for (size_t i = 0; i < N; ++i) - temp_f[i] = props.convert_part(&props.parts[i]); + temp_f[i] = props.convert_part(e, &props.parts[i]); } else if (props.convert_gpart != NULL) { /* conversion (for gparts)*/ float* temp_f = temp; for (size_t i = 0; i < N; ++i) - temp_f[i] = props.convert_gpart(&props.gparts[i]); + temp_f[i] = props.convert_gpart(e, &props.gparts[i]); } /* Unit conversion if necessary */ @@ -868,7 +869,7 @@ void write_output_serial(struct engine* e, const char* baseName, /* Write everything */ for (int i = 0; i < num_fields; ++i) - writeArray(h_grp, fileName, xmfFile, partTypeGroupName, list[i], N, + writeArray(e, h_grp, fileName, xmfFile, partTypeGroupName, list[i], N, N_total[ptype], mpi_rank, offset[ptype], internal_units, snapshot_units); diff --git a/src/single_io.c b/src/single_io.c index b3478912c9fdf2759995875f0b30a5f3acf8a9b5..26c7ecd48c001caa122bc08d87fa3416e770925c 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -152,6 +152,7 @@ void readArray(hid_t h_grp, const struct io_props prop, size_t N, /** * @brief Writes a data array in given HDF5 group. * + * @param e The #engine we are writing from. * @param grp The group in which to write. * @param fileName The name of the file in which the data is written * @param xmfFile The FILE used to write the XMF description @@ -165,7 +166,7 @@ void readArray(hid_t h_grp, const struct io_props prop, size_t N, * @todo A better version using HDF5 hyper-slabs to write the file directly from * the part array will be written once the structures have been stabilized. */ -void writeArray(hid_t grp, char* fileName, FILE* xmfFile, +void writeArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile, char* partTypeGroupName, const struct io_props props, size_t N, const struct UnitSystem* internal_units, const struct UnitSystem* snapshot_units) { @@ -192,13 +193,13 @@ void writeArray(hid_t grp, char* fileName, FILE* xmfFile, float* temp_f = temp; for (size_t i = 0; i < N; ++i) - temp_f[i] = props.convert_part(&props.parts[i]); + temp_f[i] = props.convert_part(e, &props.parts[i]); } else if (props.convert_gpart != NULL) { /* conversion (for gparts)*/ float* temp_f = temp; for (size_t i = 0; i < N; ++i) - temp_f[i] = props.convert_gpart(&props.gparts[i]); + temp_f[i] = props.convert_gpart(e, &props.gparts[i]); } /* Unit conversion if necessary */ @@ -678,7 +679,7 @@ void write_output_single(struct engine* e, const char* baseName, /* Write everything */ for (int i = 0; i < num_fields; ++i) - writeArray(h_grp, fileName, xmfFile, partTypeGroupName, list[i], N, + writeArray(e, h_grp, fileName, xmfFile, partTypeGroupName, list[i], N, internal_units, snapshot_units); /* Free temporary array */