Commit ff44be2c authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

The SPH description written in the HDF5 files is now in hydro/*/hydro_io.h

parent 2107b82a
......@@ -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
*
......
......@@ -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);
}
......@@ -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));
}
......@@ -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);
}
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment