diff --git a/src/common_io.c b/src/common_io.c index f375df85d2d749698938e3179a0bee239a8b94d8..7059f1e813d6cdaf6afd1e637a826292674a51fe 100644 --- a/src/common_io.c +++ b/src/common_io.c @@ -267,59 +267,6 @@ void writeAttribute_s(hid_t grp, char* name, const char* str) { writeStringAttribute(grp, name, str, strlen(str)); } -/* ------------------------------------------------------------------------------------------------ - * This part writes the XMF file descriptor enabling a visualisation through - * ParaView - * ------------------------------------------------------------------------------------------------ - */ -/** - * @brief Writes the current model of SPH to the file - * @param h_file The (opened) HDF5 file in which to write - */ -void writeSPHflavour(hid_t h_file) { - hid_t h_grpsph = 0; - - h_grpsph = H5Gcreate1(h_file, "/SPH", 0); - if (h_grpsph < 0) error("Error while creating SPH group"); - - writeAttribute_f(h_grpsph, "Kernel eta", const_eta_kernel); - writeAttribute_f(h_grpsph, "Weighted N_ngb", kernel_nwneigh); - writeAttribute_f(h_grpsph, "Delta N_ngb", const_delta_nwneigh); - writeAttribute_f(h_grpsph, "Hydro gamma", const_hydro_gamma); - -#ifdef GADGET2_SPH - writeAttribute_s(h_grpsph, "Thermal Conductivity Model", - "(No treatment) Legacy Gadget-2 as in Springel (2005)"); - writeAttribute_s(h_grpsph, "Viscosity Model", - "Legacy Gadget-2 as in Springel (2005)"); - writeAttribute_f(h_grpsph, "Viscosity alpha", const_viscosity_alpha); - writeAttribute_f(h_grpsph, "Viscosity beta", 3.f); -#else - writeAttribute_s(h_grpsph, "Thermal Conductivity Model", - "Price (2008) without switch"); - writeAttribute_f(h_grpsph, "Thermal Conductivity alpha", - const_conductivity_alpha); - writeAttribute_s(h_grpsph, "Viscosity Model", - "Morris & Monaghan (1997), Rosswog, Davies, Thielemann & " - "Piran (2000) with additional Balsara (1995) switch"); - writeAttribute_f(h_grpsph, "Viscosity alpha_min", const_viscosity_alpha_min); - writeAttribute_f(h_grpsph, "Viscosity alpha_max", const_viscosity_alpha_max); - writeAttribute_f(h_grpsph, "Viscosity beta", 2.f); - writeAttribute_f(h_grpsph, "Viscosity decay length", const_viscosity_length); -#endif - - writeAttribute_f(h_grpsph, "CFL parameter", const_cfl); - writeAttribute_f(h_grpsph, "Maximal ln(Delta h) change over dt", - const_ln_max_h_change); - writeAttribute_f(h_grpsph, "Maximal Delta h change over dt", - exp(const_ln_max_h_change)); - writeAttribute_f(h_grpsph, "Maximal Delta u change over dt", - const_max_u_change); - writeAttribute_s(h_grpsph, "Kernel", kernel_name); - - H5Gclose(h_grpsph); -} - /** * @brief Writes the current Unit System * @param h_file The (opened) HDF5 file in which to write @@ -372,6 +319,12 @@ void writeCodeDescription(hid_t h_file) { H5Gclose(h_grpcode); } +/* ------------------------------------------------------------------------------------------------ + * This part writes the XMF file descriptor enabling a visualisation through + * ParaView + * ------------------------------------------------------------------------------------------------ + */ + /** * @brief Prepares the XMF file for the new entry * diff --git a/src/hydro/Default/hydro_io.h b/src/hydro/Default/hydro_io.h index e0debaa0d10f5c78f087d636efc4363eaf24f8d8..958bf5a1869718b57678246ff3b1985e54145824 100644 --- a/src/hydro/Default/hydro_io.h +++ b/src/hydro/Default/hydro_io.h @@ -88,3 +88,39 @@ __attribute__((always_inline)) INLINE static void hydro_write_particles( writeArray(h_grp, fileName, xmfFile, "Density", FLOAT, N, 1, parts, N_total, mpi_rank, offset, rho, us, UNIT_CONV_DENSITY); } + +/** + * @brief Writes the current model of SPH to the file + * @param h_grpsph The HDF5 group in which to write + */ +void writeSPHflavour(hid_t h_grpsph) { + + /* Kernel function description */ + writeAttribute_s(h_grpsph, "Kernel", kernel_name); + writeAttribute_f(h_grpsph, "Kernel eta", const_eta_kernel); + writeAttribute_f(h_grpsph, "Weighted N_ngb", kernel_nwneigh); + writeAttribute_f(h_grpsph, "Delta N_ngb", const_delta_nwneigh); + writeAttribute_f(h_grpsph, "Hydro gamma", const_hydro_gamma); + + /* Viscosity and thermal conduction */ + writeAttribute_s(h_grpsph, "Thermal Conductivity Model", + "Price (2008) without switch"); + writeAttribute_f(h_grpsph, "Thermal Conductivity alpha", + const_conductivity_alpha); + writeAttribute_s(h_grpsph, "Viscosity Model", + "Morris & Monaghan (1997), Rosswog, Davies, Thielemann & " + "Piran (2000) with additional Balsara (1995) switch"); + writeAttribute_f(h_grpsph, "Viscosity alpha_min", const_viscosity_alpha_min); + writeAttribute_f(h_grpsph, "Viscosity alpha_max", const_viscosity_alpha_max); + writeAttribute_f(h_grpsph, "Viscosity beta", 2.f); + writeAttribute_f(h_grpsph, "Viscosity decay length", const_viscosity_length); + + /* Time integration properties */ + writeAttribute_f(h_grpsph, "CFL parameter", const_cfl); + writeAttribute_f(h_grpsph, "Maximal ln(Delta h) change over dt", + const_ln_max_h_change); + writeAttribute_f(h_grpsph, "Maximal Delta h change over dt", + exp(const_ln_max_h_change)); + writeAttribute_f(h_grpsph, "Maximal Delta u change over dt", + const_max_u_change); +} diff --git a/src/hydro/Gadget2/hydro_io.h b/src/hydro/Gadget2/hydro_io.h index ed450e77ad631ba14a14583fe17c8173652321c2..17c3d3013644c3572f3c26fc3e270b1c1bc465ed 100644 --- a/src/hydro/Gadget2/hydro_io.h +++ b/src/hydro/Gadget2/hydro_io.h @@ -89,3 +89,32 @@ __attribute__((always_inline)) INLINE static void hydro_write_particles( writeArray(h_grp, fileName, xmfFile, "Density", FLOAT, N, 1, parts, N_total, mpi_rank, offset, rho, us, UNIT_CONV_DENSITY); } + +/** + * @brief Writes the current model of SPH to the file + * @param h_grpsph The HDF5 group in which to write + */ +void writeSPHflavour(hid_t h_grpsph) { + + /* Kernel function description */ + writeAttribute_s(h_grpsph, "Kernel", kernel_name); + writeAttribute_f(h_grpsph, "Kernel eta", const_eta_kernel); + writeAttribute_f(h_grpsph, "Weighted N_ngb", kernel_nwneigh); + writeAttribute_f(h_grpsph, "Delta N_ngb", const_delta_nwneigh); + writeAttribute_f(h_grpsph, "Hydro gamma", const_hydro_gamma); + + /* Viscosity and thermal conduction */ + writeAttribute_s(h_grpsph, "Thermal Conductivity Model", + "(No treatment) Legacy Gadget-2 as in Springel (2005)"); + writeAttribute_s(h_grpsph, "Viscosity Model", + "Legacy Gadget-2 as in Springel (2005)"); + writeAttribute_f(h_grpsph, "Viscosity alpha", const_viscosity_alpha); + writeAttribute_f(h_grpsph, "Viscosity beta", 3.f); + + /* Time integration properties */ + writeAttribute_f(h_grpsph, "CFL parameter", const_cfl); + writeAttribute_f(h_grpsph, "Maximal ln(Delta h) change over dt", + const_ln_max_h_change); + writeAttribute_f(h_grpsph, "Maximal Delta h change over dt", + exp(const_ln_max_h_change)); +} diff --git a/src/hydro/Minimal/hydro_io.h b/src/hydro/Minimal/hydro_io.h index e0debaa0d10f5c78f087d636efc4363eaf24f8d8..2c56fb489ab84ca7c30426b54cf95e26e3821084 100644 --- a/src/hydro/Minimal/hydro_io.h +++ b/src/hydro/Minimal/hydro_io.h @@ -88,3 +88,31 @@ __attribute__((always_inline)) INLINE static void hydro_write_particles( writeArray(h_grp, fileName, xmfFile, "Density", FLOAT, N, 1, parts, N_total, mpi_rank, offset, rho, us, UNIT_CONV_DENSITY); } + +/** + * @brief Writes the current model of SPH to the file + * @param h_grpsph The HDF5 group in which to write + */ +void writeSPHflavour(hid_t h_grpsph) { + + /* Kernel function description */ + writeAttribute_s(h_grpsph, "Kernel", kernel_name); + writeAttribute_f(h_grpsph, "Kernel eta", const_eta_kernel); + writeAttribute_f(h_grpsph, "Weighted N_ngb", kernel_nwneigh); + writeAttribute_f(h_grpsph, "Delta N_ngb", const_delta_nwneigh); + writeAttribute_f(h_grpsph, "Hydro gamma", const_hydro_gamma); + + /* Viscosity and thermal conduction */ + /* Nothing in this minimal model... */ + writeAttribute_s(h_grpsph, "Thermal Conductivity Model", "No model"); + writeAttribute_s(h_grpsph, "Viscosity Model", "No model"); + + /* Time integration properties */ + writeAttribute_f(h_grpsph, "CFL parameter", const_cfl); + writeAttribute_f(h_grpsph, "Maximal ln(Delta h) change over dt", + const_ln_max_h_change); + writeAttribute_f(h_grpsph, "Maximal Delta h change over dt", + exp(const_ln_max_h_change)); + writeAttribute_f(h_grpsph, "Maximal Delta u change over dt", + const_max_u_change); +} diff --git a/src/parallel_io.c b/src/parallel_io.c index 1391322af1e1520cabc007eee354b669bc4219c6..5ac0d7122b17c135dca386f3e9c74123d15676cd 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -459,7 +459,7 @@ void write_output_parallel(struct engine* e, struct UnitSystem* us, int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info) { - hid_t h_file = 0, h_grp = 0; + hid_t h_file = 0, h_grp = 0, h_grpsph = 0; int N = e->s->nr_parts; int periodic = e->s->periodic; unsigned int numParticles[6] = {N, 0}; @@ -546,7 +546,10 @@ void write_output_parallel(struct engine* e, struct UnitSystem* us, writeCodeDescription(h_file); /* Print the SPH parameters */ - writeSPHflavour(h_file); + h_grpsph = H5Gcreate1(h_file, "/SPH", 0); + if (h_grpsph < 0) error("Error while creating SPH group"); + writeSPHflavour(h_grpsph); + H5Gclose(h_grpsph); /* Print the system of Units */ writeUnitSystem(h_file, us); diff --git a/src/serial_io.c b/src/serial_io.c index 481a82c4977310aa28b94bfc543f1acbf8b90f35..5402afba096bc62530ef04a5c717c2180d7a7c95 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -511,7 +511,7 @@ void read_ic_serial(char* fileName, double dim[3], struct part** parts, int* N, */ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info) { - hid_t h_file = 0, h_grp = 0; + hid_t h_file = 0, h_grp = 0, h_grpsph = 0; int N = e->s->nr_parts; int periodic = e->s->periodic; int numParticles[6] = {N, 0}; @@ -601,7 +601,10 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank, writeCodeDescription(h_file); /* Print the SPH parameters */ - writeSPHflavour(h_file); + h_grpsph = H5Gcreate1(h_file, "/SPH", 0); + if (h_grpsph < 0) error("Error while creating SPH group"); + writeSPHflavour(h_grpsph); + H5Gclose(h_grpsph); /* Print the system of Units */ writeUnitSystem(h_file, us); diff --git a/src/single_io.c b/src/single_io.c index 1a74f690f1a0658f74a58c55d3ab0ffcf2717463..b0e350ffe2e2f7ff077c29dd0b581c9c3c555822 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -383,7 +383,7 @@ void read_ic_single(char* fileName, double dim[3], struct part** parts, int* N, */ void write_output_single(struct engine* e, struct UnitSystem* us) { - hid_t h_file = 0, h_grp = 0; + hid_t h_file = 0, h_grp = 0, h_grpsph = 0; int N = e->s->nr_parts; int periodic = e->s->periodic; int numParticles[6] = {N, 0}; @@ -451,7 +451,10 @@ void write_output_single(struct engine* e, struct UnitSystem* us) { writeCodeDescription(h_file); /* Print the SPH parameters */ - writeSPHflavour(h_file); + h_grpsph = H5Gcreate1(h_file, "/SPH", 0); + if (h_grpsph < 0) error("Error while creating SPH group"); + writeSPHflavour(h_grpsph); + H5Gclose(h_grpsph); /* Print the system of Units */ writeUnitSystem(h_file, us);