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

Print the cosmological model to the HDF5 snapshots.

parent 2df4bac8
No related branches found
No related tags found
1 merge request!509Cosmological time integration
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
/* Local headers */ /* Local headers */
#include "adiabatic_index.h" #include "adiabatic_index.h"
#include "common_io.h"
#include "inline.h" #include "inline.h"
#include "restart.h" #include "restart.h"
...@@ -627,6 +628,26 @@ void cosmology_clean(struct cosmology *c) { ...@@ -627,6 +628,26 @@ void cosmology_clean(struct cosmology *c) {
free(c->time_interp_table); free(c->time_interp_table);
} }
#ifdef HAVE_HDF5
void cosmology_write_model(hid_t h_grp, const struct cosmology *c) {
io_write_attribute_d(h_grp, "a_beg", c->a_begin);
io_write_attribute_d(h_grp, "a_end", c->a_end);
io_write_attribute_d(h_grp, "time_beg [internal units]", c->time_begin);
io_write_attribute_d(h_grp, "time_end [internal units]", c->time_end);
io_write_attribute_d(h_grp, "h", c->h);
io_write_attribute_d(h_grp, "H0 [internal units]", c->H0);
io_write_attribute_d(h_grp, "Hubble time [internal units]", c->Hubble_time);
io_write_attribute_d(h_grp, "Omega_m", c->Omega_m);
io_write_attribute_d(h_grp, "Omega_r", c->Omega_r);
io_write_attribute_d(h_grp, "Omega_b", c->Omega_b);
io_write_attribute_d(h_grp, "Omega_k", c->Omega_k);
io_write_attribute_d(h_grp, "Omega_lambda", c->Omega_lambda);
io_write_attribute_d(h_grp, "w_0", c->w_0);
io_write_attribute_d(h_grp, "w_a", c->w_a);
}
#endif
/** /**
* @brief Write a cosmology struct to the given FILE as a stream of bytes. * @brief Write a cosmology struct to the given FILE as a stream of bytes.
* *
......
...@@ -186,6 +186,10 @@ void cosmology_init_no_cosmo(struct cosmology *c); ...@@ -186,6 +186,10 @@ void cosmology_init_no_cosmo(struct cosmology *c);
void cosmology_print(const struct cosmology *c); void cosmology_print(const struct cosmology *c);
void cosmology_clean(struct cosmology *c); void cosmology_clean(struct cosmology *c);
#ifdef HAVE_HDF5
void cosmology_write_model(hid_t h_grp, const struct cosmology *c);
#endif
/* Dump/restore. */ /* Dump/restore. */
void cosmology_struct_dump(const struct cosmology *cosmology, FILE *stream); void cosmology_struct_dump(const struct cosmology *cosmology, FILE *stream);
void cosmology_struct_restore(struct cosmology *cosmology, FILE *stream); void cosmology_struct_restore(struct cosmology *cosmology, FILE *stream);
......
...@@ -929,6 +929,15 @@ void prepare_file(struct engine* e, const char* baseName, long long N_total[6], ...@@ -929,6 +929,15 @@ void prepare_file(struct engine* e, const char* baseName, long long N_total[6],
H5Gclose(h_grp); H5Gclose(h_grp);
} }
/* Print the gravity parameters */
if (e->policy & engine_policy_cosmology) {
h_grp = H5Gcreate(h_file, "/Cosmology", H5P_DEFAULT, H5P_DEFAULT,
H5P_DEFAULT) if (h_grp < 0)
error("Error while creating cosmology group");
cosmology_write_model(h_grp, e->cosmology);
H5Gclose(h_grp);
}
/* Print the runtime parameters */ /* Print the runtime parameters */
h_grp = h_grp =
H5Gcreate(h_file, "/Parameters", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Gcreate(h_file, "/Parameters", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
......
...@@ -837,6 +837,15 @@ void write_output_serial(struct engine* e, const char* baseName, ...@@ -837,6 +837,15 @@ void write_output_serial(struct engine* e, const char* baseName,
H5Gclose(h_grp); H5Gclose(h_grp);
} }
/* Print the cosmological model */
if (e->policy & engine_policy_cosmology) {
h_grp = H5Gcreate(h_file, "/Cosmology", H5P_DEFAULT, H5P_DEFAULT,
H5P_DEFAULT);
if (h_grp < 0) error("Error while creating cosmology group");
cosmology_write_model(h_grp, e->cosmology);
H5Gclose(h_grp);
}
/* Print the runtime parameters */ /* Print the runtime parameters */
h_grp = h_grp =
H5Gcreate(h_file, "/Parameters", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Gcreate(h_file, "/Parameters", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
......
...@@ -689,6 +689,15 @@ void write_output_single(struct engine* e, const char* baseName, ...@@ -689,6 +689,15 @@ void write_output_single(struct engine* e, const char* baseName,
H5Gclose(h_grp); H5Gclose(h_grp);
} }
/* Print the cosmological model */
if (e->policy & engine_policy_cosmology) {
h_grp =
H5Gcreate(h_file, "/Cosmology", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
if (h_grp < 0) error("Error while creating cosmology group");
cosmology_write_model(h_grp, e->cosmology);
H5Gclose(h_grp);
}
/* Print the runtime parameters */ /* Print the runtime parameters */
h_grp = h_grp =
H5Gcreate(h_file, "/Parameters", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Gcreate(h_file, "/Parameters", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment