diff options
author | schnetter <schnetter@b61c5cb5-eaca-4651-9a7a-d64986f99364> | 2009-01-28 18:18:02 +0000 |
---|---|---|
committer | schnetter <schnetter@b61c5cb5-eaca-4651-9a7a-d64986f99364> | 2009-01-28 18:18:02 +0000 |
commit | 268936b8f93bec3a18681d2650cac01d4395dd76 (patch) | |
tree | c1194f11b67a57cfed11929a400574ce8915c1d6 | |
parent | a0dd488a203adea76ba28e6884dc1aec59436b58 (diff) |
Do not set up topologies for lower-dimensional grid functions if these
are not allowed, as indicated by the flesh parameter
Cactus::allow_mixeddim_gfs. This prevents problems if such topologies
do not exist, e.g. on small grids such as 3x3x200.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@493 b61c5cb5-eaca-4651-9a7a-d64986f99364
-rw-r--r-- | src/SetupPGH.c | 76 |
1 files changed, 55 insertions, 21 deletions
diff --git a/src/SetupPGH.c b/src/SetupPGH.c index ab71fb4..2a1198d 100644 --- a/src/SetupPGH.c +++ b/src/SetupPGH.c @@ -111,6 +111,9 @@ pGH *PUGH_SetupPGH (void *callerid, pGH *pughGH; int i, idim; int *nprocs; + int type; + const void *allow_mixeddim_gfs_ptr; + CCTK_INT allow_mixeddim_gfs; /* Allocate for myself */ @@ -125,35 +128,66 @@ pGH *PUGH_SetupPGH (void *callerid, /* Set the total number of processors */ Setup_nProcs (pughGH, dim); + /* Determine whether mixed-dimensional grid functions need to be + supported */ + allow_mixeddim_gfs_ptr = + CCTK_ParameterGet ("allow_mixeddim_gfs", "Cactus", &type); + if (! allow_mixeddim_gfs_ptr) + { + CCTK_WARN (CCTK_WARN_ABORT, "internal error -- flesh parameter Cactus::allow_mixeddim_gfs does not exist"); + } + if (type != PARAMETER_BOOLEAN) + { + CCTK_WARN (CCTK_WARN_ABORT, "internal error -- flesh parameter Cactus::allow_mixeddim_gfs has wrong type"); + } + allow_mixeddim_gfs = *(const CCTK_INT*)allow_mixeddim_gfs_ptr; + /* Set up connectivity and extras for each dimension */ for (idim = 1; idim <= dim; idim++) { - nprocs = malloc (idim * sizeof (int)); + /* Do not set up topologies for lower-dimensional grid functions + if these are not allowed. This prevents problems if such + topologies do not exist, e.g. on small grids. */ + if (allow_mixeddim_gfs || idim == dim) + { + CCTK_VInfo (CCTK_THORNSTRING, + "Setting up a topology for %d dimensions", idim); + nprocs = malloc (idim * sizeof (int)); - PUGH_SetupDefaultTopology (idim, nprocs); + PUGH_SetupDefaultTopology (idim, nprocs); - /* Check that there are enough grid points in this dimension - * to make parallelising it worthwhile - */ - for (i = 0; i < idim; i++) - { - if ((! nprocs[i]) && (abs (nsize[i]) <= 2 * nghostzones[i] + 1)) + /* Check that there are enough grid points in this dimension + * to make parallelising it worthwhile + */ + for (i = 0; i < idim; i++) { - nprocs[i] = 1; + if ((! nprocs[i]) && (abs (nsize[i]) <= 2 * nghostzones[i] + 1)) + { + nprocs[i] = 1; + } } - } - pughGH->Connectivity[idim-1] = PUGH_SetupConnectivity (idim, pughGH->nprocs, - nsize, nghostzones, - nprocs, perme); - free(nprocs); - - pughGH->GFExtras[idim-1] = PUGH_SetupPGExtras (1, idim, perme, staggertype, - nsize, nghostzones, - pughGH->nprocs, - pughGH->Connectivity[idim-1]->nprocs, - pughGH->Connectivity[idim-1]->neighbours, - pughGH->myproc); + pughGH->Connectivity[idim-1] = + PUGH_SetupConnectivity (idim, pughGH->nprocs, + nsize, nghostzones, + nprocs, perme); + free(nprocs); + + pughGH->GFExtras[idim-1] = + PUGH_SetupPGExtras (1, idim, perme, staggertype, + nsize, nghostzones, + pughGH->nprocs, + pughGH->Connectivity[idim-1]->nprocs, + pughGH->Connectivity[idim-1]->neighbours, + pughGH->myproc); + } + else + { + CCTK_VInfo (CCTK_THORNSTRING, + "Not setting up a topology for %d dimensions", idim); + pughGH->Connectivity[idim-1] = NULL; + pughGH->GFExtras[idim-1] = NULL; + } } /* create the timer for communication time */ |