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
c4f17f91
Commit
c4f17f91
authored
Jun 28, 2018
by
Matthieu Schaller
Browse files
Create the infrastructure to stop and restart with the pm_mesh switched on.
parent
009a24cf
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/engine.c
View file @
c4f17f91
...
...
@@ -6295,6 +6295,7 @@ void engine_struct_dump(struct engine *e, FILE *stream) {
phys_const_struct_dump
(
e
->
physical_constants
,
stream
);
hydro_props_struct_dump
(
e
->
hydro_properties
,
stream
);
gravity_props_struct_dump
(
e
->
gravity_properties
,
stream
);
pm_mesh_struct_dump
(
e
->
mesh
,
stream
);
potential_struct_dump
(
e
->
external_potential
,
stream
);
cooling_struct_dump
(
e
->
cooling_func
,
stream
);
chemistry_struct_dump
(
e
->
chemistry
,
stream
);
...
...
@@ -6364,6 +6365,10 @@ void engine_struct_restore(struct engine *e, FILE *stream) {
gravity_props_struct_restore
(
gravity_properties
,
stream
);
e
->
gravity_properties
=
gravity_properties
;
struct
pm_mesh
*
mesh
=
(
struct
pm_mesh
*
)
malloc
(
sizeof
(
struct
pm_mesh
));
pm_mesh_struct_restore
(
mesh
,
stream
);
e
->
mesh
=
mesh
;
struct
external_potential
*
external_potential
=
(
struct
external_potential
*
)
malloc
(
sizeof
(
struct
external_potential
));
potential_struct_restore
(
external_potential
,
stream
);
...
...
src/gravity_properties.c
View file @
c4f17f91
...
...
@@ -190,7 +190,7 @@ void gravity_props_struct_dump(const struct gravity_props *p, FILE *stream) {
* @param p the struct
* @param stream the file stream
*/
void
gravity_props_struct_restore
(
const
struct
gravity_props
*
p
,
FILE
*
stream
)
{
void
gravity_props_struct_restore
(
struct
gravity_props
*
p
,
FILE
*
stream
)
{
restart_read_blocks
((
void
*
)
p
,
sizeof
(
struct
gravity_props
),
1
,
stream
,
NULL
,
"gravity props"
);
}
src/gravity_properties.h
View file @
c4f17f91
...
...
@@ -27,10 +27,12 @@
#endif
/* Local includes. */
#include
"cosmology.h"
#include
"parser.h"
#include
"restart.h"
/* Forward declarations */
struct
cosmology
;
struct
swift_params
;
/**
* @brief Contains all the constants and parameters of the self-gravity scheme
*/
...
...
@@ -96,6 +98,6 @@ void gravity_props_print_snapshot(hid_t h_grpsph,
/* Dump/restore. */
void
gravity_props_struct_dump
(
const
struct
gravity_props
*
p
,
FILE
*
stream
);
void
gravity_props_struct_restore
(
const
struct
gravity_props
*
p
,
FILE
*
stream
);
void
gravity_props_struct_restore
(
struct
gravity_props
*
p
,
FILE
*
stream
);
#endif
/* SWIFT_GRAVITY_PROPERTIES */
src/mesh_gravity.c
View file @
c4f17f91
...
...
@@ -509,3 +509,39 @@ void pm_mesh_clean(struct pm_mesh* mesh) {
if
(
mesh
->
potential
)
free
(
mesh
->
potential
);
mesh
->
potential
=
0
;
}
/**
* @brief Write a #pm_mesh struct to the given FILE as a stream of bytes.
*
* @param p the struct
* @param stream the file stream
*/
void
pm_mesh_struct_dump
(
const
struct
pm_mesh
*
mesh
,
FILE
*
stream
)
{
restart_write_blocks
((
void
*
)
mesh
,
sizeof
(
struct
pm_mesh
),
1
,
stream
,
"gravity"
,
"gravity props"
);
}
/**
* @brief Restore a #pm_mesh struct from the given FILE as a stream of
* bytes.
*
* @param p the struct
* @param stream the file stream
*/
void
pm_mesh_struct_restore
(
struct
pm_mesh
*
mesh
,
FILE
*
stream
)
{
restart_read_blocks
((
void
*
)
mesh
,
sizeof
(
struct
pm_mesh
),
1
,
stream
,
NULL
,
"gravity props"
);
const
int
N
=
mesh
->
N
;
/* Allocate the memory for the combined density and potential array */
mesh
->
potential
=
(
double
*
)
fftw_malloc
(
sizeof
(
double
)
*
N
*
N
*
N
);
if
(
mesh
->
potential
==
NULL
)
error
(
"Error allocating memory for the long-range gravity mesh."
);
#ifdef HAVE_FFTW
#else
error
(
"No FFTW library found. Cannot compute periodic long-range forces."
);
#endif
}
src/mesh_gravity.h
View file @
c4f17f91
...
...
@@ -24,6 +24,7 @@
/* Local headers */
#include
"gravity_properties.h"
#include
"restart.h"
/* Forward declarations */
struct
engine
;
...
...
@@ -71,4 +72,8 @@ void pm_mesh_interpolate_forces(const struct pm_mesh *mesh,
int
gcount
);
void
pm_mesh_clean
(
struct
pm_mesh
*
mesh
);
/* Dump/restore. */
void
pm_mesh_struct_dump
(
const
struct
pm_mesh
*
p
,
FILE
*
stream
);
void
pm_mesh_struct_restore
(
struct
pm_mesh
*
p
,
FILE
*
stream
);
#endif
/* SWIFT_MESH_GRAVITY_H */
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