diff --git a/src/parallel_io.c b/src/parallel_io.c index 2cf4bc2586a7393e6dbeb81f0452ee32423c5d66..f337958077b3b700efb2271f13c495b7917ffecd 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -503,6 +503,47 @@ void writeAttribute_s(hid_t grp, char* name, char* str) writeStringAttribute(grp, name, str, strlen(str)); } +/** + * @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, "/Header/SPH", 0); + if(h_grpsph < 0) + error("Error while creating SPH header\n"); + + 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 LEGACY_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); + + /* Close headers */ + H5Gclose(h_grpsph); +} /** * @brief Writes a data array in given HDF5 group. @@ -657,7 +698,7 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name, enu void write_output_parallel (struct engine *e, int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info) { - hid_t h_file=0, h_grp=0, h_grpsph=0; + hid_t h_file=0, h_grp=0; int N = e->s->nr_parts; int periodic = e->s->periodic; unsigned int numParticles[6]={N,0}; @@ -741,38 +782,9 @@ void write_output_parallel (struct engine *e, int mpi_rank, int mpi_size, MPI_Co writeAttribute(h_grp, "NumFilesPerSnapshot", INT, &numFiles, 1); /* Print the SPH parameters */ - h_grpsph = H5Gcreate1(h_file, "/Header/SPH", 0); - if(h_grpsph < 0) - error("Error while creating SPH header\n"); - - 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); + writeSPHflavour(h_file); -#ifdef LEGACY_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); - - /* Close headers */ - H5Gclose(h_grpsph); + /* Close header */ H5Gclose(h_grp); /* Create SPH particles group */ @@ -808,7 +820,6 @@ void write_output_parallel (struct engine *e, int mpi_rank, int mpi_size, MPI_Co } - /* ------------------------------------------------------------------------------------------------ * This part writes the XMF file descriptor enabling a visualisation through ParaView * ------------------------------------------------------------------------------------------------ */