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

Only attempt to allocate the gravity mesh on restart if we are running with periodic BCs.

parent e8ea7062
No related branches found
No related tags found
No related merge requests found
......@@ -686,15 +686,18 @@ 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");
#ifdef HAVE_FFTW
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.");
if (mesh->periodic) {
#ifdef HAVE_FFTW
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.");
#else
error("No FFTW library found. Cannot compute periodic long-range forces.");
error("No FFTW library found. Cannot compute periodic long-range forces.");
#endif
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment