Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
8532b39d
Commit
8532b39d
authored
7 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Print the cosmological model to the HDF5 snapshots.
parent
2df4bac8
No related branches found
No related tags found
1 merge request
!509
Cosmological time integration
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/cosmology.c
+21
-0
21 additions, 0 deletions
src/cosmology.c
src/cosmology.h
+4
-0
4 additions, 0 deletions
src/cosmology.h
src/parallel_io.c
+9
-0
9 additions, 0 deletions
src/parallel_io.c
src/serial_io.c
+9
-0
9 additions, 0 deletions
src/serial_io.c
src/single_io.c
+9
-0
9 additions, 0 deletions
src/single_io.c
with
52 additions
and
0 deletions
src/cosmology.c
+
21
−
0
View file @
8532b39d
...
@@ -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.
*
*
...
...
This diff is collapsed.
Click to expand it.
src/cosmology.h
+
4
−
0
View file @
8532b39d
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
src/parallel_io.c
+
9
−
0
View file @
8532b39d
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
src/serial_io.c
+
9
−
0
View file @
8532b39d
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
src/single_io.c
+
9
−
0
View file @
8532b39d
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment