diff --git a/src/engine.c b/src/engine.c index 330e626ae4e8bbbadf497475850db3feff806dad..74459541ec0d38c3f737bec728ac68eb7757f888 100644 --- a/src/engine.c +++ b/src/engine.c @@ -5644,9 +5644,8 @@ void engine_struct_dump(struct engine *e, FILE *stream) { units_struct_dump(e->internal_units, stream); units_struct_dump(e->snapshotUnits, stream); partition_struct_dump(e->reparttype, stream); + phys_const_struct_dump(e->physical_constants, stream); - /* repartition */ - /* physical constants */ /* hydro props */ /* gravity props */ /* external potential props */ @@ -5689,8 +5688,8 @@ void engine_struct_restore(struct engine *e, FILE *stream) { units_struct_restore(e->internal_units, stream); units_struct_restore(e->snapshotUnits, stream); partition_struct_restore(e->reparttype, stream); + phys_const_struct_restore(e->physical_constants, stream); - /* physical constants */ /* hydro props */ /* gravity props */ /* external potential props */ diff --git a/src/physical_constants.c b/src/physical_constants.c index c851578c96e146261e9512f6899c7b82a8d91097..8d1460b67a45dc8c50414079e4cbc522ecae0370 100644 --- a/src/physical_constants.c +++ b/src/physical_constants.c @@ -27,6 +27,7 @@ /* Local headers. */ #include "error.h" #include "physical_constants_cgs.h" +#include "restart.h" /** * @brief Converts physical constants to the internal unit system @@ -121,3 +122,31 @@ void phys_const_print(struct phys_const* internal_const) { message("%25s = %e", "Parsec", internal_const->const_parsec); message("%25s = %e", "Solar mass", internal_const->const_solar_mass); } + +/** + * @brief Write a phys_const struct to the given FILE as a stream of bytes. + * + * @param internal_const the struct + * @param stream the file stream + */ +void phys_const_struct_dump(const struct phys_const *internal_const, + FILE *stream) { + restart_write_blocks((void *) internal_const, sizeof(struct phys_const), + 1, stream, + "phys_const params"); +} + + +/** + * @brief Restore a phys_const struct from the given FILE as a stream of + * bytes. + * + * @param internal_const the struct + * @param stream the file stream + */ +void phys_const_struct_restore(const struct phys_const *internal_const, + FILE *stream) { + restart_read_blocks((void *)internal_const, sizeof(struct phys_const), + 1, stream, + "phys_const params"); +} diff --git a/src/physical_constants.h b/src/physical_constants.h index 3731c0ef565c6159592ad2de96a222efc6cf43f2..79f341a8b81b6bf85c5f7613abd081454e8b4995 100644 --- a/src/physical_constants.h +++ b/src/physical_constants.h @@ -82,4 +82,8 @@ void phys_const_init(struct unit_system* us, struct phys_const* internal_const); void phys_const_print(struct phys_const* internal_const); +/* Dump/restore. */ +void phys_const_struct_dump(const struct phys_const* internal_const, FILE *stream); +void phys_const_struct_restore(const struct phys_const* internal_const, FILE *stream); + #endif /* SWIFT_PHYSICAL_CONSTANTS_H */ diff --git a/src/restart.h b/src/restart.h index 579ca582c1fcb48156673633d8940df05cdd2abb..124c5f425f065d8d68a4781930cc5a4cbeab7247 100644 --- a/src/restart.h +++ b/src/restart.h @@ -19,6 +19,10 @@ #ifndef SWIFT_RESTART_H #define SWIFT_RESTART_H +#include <stdio.h> + +#include "engine.h" + void restart_write(struct engine *e, const char *filename); void restart_read(struct engine *e, const char *filename);