Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
8532b39d
Commit
8532b39d
authored
Mar 01, 2018
by
Matthieu Schaller
Browse files
Print the cosmological model to the HDF5 snapshots.
parent
2df4bac8
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/cosmology.c
View file @
8532b39d
...
...
@@ -30,6 +30,7 @@
/* Local headers */
#include
"adiabatic_index.h"
#include
"common_io.h"
#include
"inline.h"
#include
"restart.h"
...
...
@@ -627,6 +628,26 @@ void cosmology_clean(struct cosmology *c) {
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.
*
...
...
src/cosmology.h
View file @
8532b39d
...
...
@@ -186,6 +186,10 @@ void cosmology_init_no_cosmo(struct cosmology *c);
void
cosmology_print
(
const
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. */
void
cosmology_struct_dump
(
const
struct
cosmology
*
cosmology
,
FILE
*
stream
);
void
cosmology_struct_restore
(
struct
cosmology
*
cosmology
,
FILE
*
stream
);
...
...
src/parallel_io.c
View file @
8532b39d
...
...
@@ -929,6 +929,15 @@ void prepare_file(struct engine* e, const char* baseName, long long N_total[6],
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 */
h_grp
=
H5Gcreate
(
h_file
,
"/Parameters"
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
...
...
src/serial_io.c
View file @
8532b39d
...
...
@@ -837,6 +837,15 @@ void write_output_serial(struct engine* e, const char* baseName,
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 */
h_grp
=
H5Gcreate
(
h_file
,
"/Parameters"
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
...
...
src/single_io.c
View file @
8532b39d
...
...
@@ -689,6 +689,15 @@ void write_output_single(struct engine* e, const char* baseName,
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 */
h_grp
=
H5Gcreate
(
h_file
,
"/Parameters"
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment