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

Make sure we have at least 8 cells on a side when using gravity

parent aa075f20
Branches
Tags
2 merge requests!212Gravity infrastructure,!172[WIP] Self gravity (Barnes-Hut version)
......@@ -375,8 +375,8 @@ int main(int argc, char *argv[]) {
/* Initialize the space with these data. */
if (myrank == 0) clocks_gettime(&tic);
struct space s;
space_init(&s, params, dim, parts, gparts, Ngas, Ngpart, periodic, talking,
dry_run);
space_init(&s, params, dim, parts, gparts, Ngas, Ngpart, periodic,
with_self_gravity, talking, dry_run);
if (myrank == 0) {
clocks_gettime(&toc);
message("space_init took %.3f %s.", clocks_diff(&tic, &toc),
......
......@@ -205,6 +205,12 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
"Must have at least 3 cells in each spatial dimension when periodicity "
"is switched on.");
/* Check if we have enough cells for gravity. */
if (s->gravity && (cdim[0] < 8 || cdim[1] < 8 || cdim[2] < 8))
error(
"Must have at least 8 cells in each spatial dimension when gravity "
"is switched on.");
/* In MPI-Land, changing the top-level cell size requires that the
* global partition is recomputed and the particles redistributed.
* Be prepared to do that. */
......@@ -1415,8 +1421,8 @@ struct cell *space_getcell(struct space *s) {
void space_init(struct space *s, const struct swift_params *params,
double dim[3], struct part *parts, struct gpart *gparts,
size_t Npart, size_t Ngpart, int periodic, int verbose,
int dry_run) {
size_t Npart, size_t Ngpart, int periodic, int gravity,
int verbose, int dry_run) {
/* Clean-up everything */
bzero(s, sizeof(struct space));
......@@ -1426,6 +1432,7 @@ void space_init(struct space *s, const struct swift_params *params,
s->dim[1] = dim[1];
s->dim[2] = dim[2];
s->periodic = periodic;
s->gravity = gravity;
s->nr_parts = Npart;
s->size_parts = Npart;
s->parts = parts;
......
......@@ -96,6 +96,9 @@ struct space {
/* Is the space periodic? */
int periodic;
/* Are we doing gravity? */
int gravity;
/* General-purpose lock for this space. */
swift_lock_type lock;
......@@ -139,8 +142,8 @@ int space_getsid(struct space *s, struct cell **ci, struct cell **cj,
double *shift);
void space_init(struct space *s, const struct swift_params *params,
double dim[3], struct part *parts, struct gpart *gparts,
size_t Npart, size_t Ngpart, int periodic, int verbose,
int dry_run);
size_t Npart, size_t Ngpart, int periodic, int gravity,
int verbose, int dry_run);
void space_map_cells_pre(struct space *s, int full,
void (*fun)(struct cell *c, void *data), void *data);
void space_map_parts(struct space *s,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment