diff options
author | tradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364> | 2003-06-27 12:38:22 +0000 |
---|---|---|
committer | tradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364> | 2003-06-27 12:38:22 +0000 |
commit | a2dc34d362192030d603ecec1b49a714349f338b (patch) | |
tree | e25e6f976375073010d25307c438d765acc99ce6 | |
parent | a42151145cfedd1dbbf972533a9cc195dd69a2da (diff) |
Fixed PUGH_GFSize() and PUGH_GFPeriodic() to also initialize the sizes and
periodic flags resp. for dimensions larger than 3D.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@413 b61c5cb5-eaca-4651-9a7a-d64986f99364
-rw-r--r-- | src/GHExtension.c | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/src/GHExtension.c b/src/GHExtension.c index fe0fff3..aa7ec1b 100644 --- a/src/GHExtension.c +++ b/src/GHExtension.c @@ -27,7 +27,7 @@ CCTK_FILEVERSION(CactusPUGH_pugh_GHExtension_c) /* prototypes of routines defined in this source file */ -int PUGH_PrintTimingInfo (cGH *GH); +int PUGH_PrintTimingInfo (const cGH *GH); void PUGH_RegisterCallFunc (int (* func) (void *function, cFunctionData *fdata, void *data)); @@ -83,15 +83,15 @@ void *PUGH_SetupGH (tFleshConfig *config, /* avoid compiler warnings about unused parameters */ - config = config; - convergence_level = convergence_level; + (void *) (config + 0); + (void) (convergence_level + 0); /* Set up the GH */ maxdim = CCTK_MaxDim (); - nsize = (int *) malloc (5 * maxdim * sizeof (int)); - ghostsize = nsize + 1*maxdim; - perme = nsize + 2*maxdim; + nsize = malloc (5 * maxdim * sizeof (int)); + ghostsize = nsize + 1*maxdim; + perme = nsize + 2*maxdim; PUGH_GFSize (maxdim, nsize); PUGH_GFGhostsize (maxdim, ghostsize); @@ -106,19 +106,19 @@ void *PUGH_SetupGH (tFleshConfig *config, } /* Set the identity for this pGH. For now this is an empty string. */ - newGH->identity_string = (char *) calloc (1, sizeof (char)); + newGH->identity_string = calloc (1, sizeof (char)); /* Set up groups on the GH */ for (group = 0; group < CCTK_NumGroups (); group++) { CCTK_GroupData (group, &pgroup); - groupsize = nsize + 3*maxdim; - groupghostsize = nsize + 4*maxdim; /* Set the global size of the variables in the group */ size = CCTK_GroupSizesI (group); + groupsize = NULL; if (size) { + groupsize = nsize + 3*maxdim; for (i = 0; i < pgroup.dim; i++) { groupsize[i] = *size[i]; @@ -129,13 +129,10 @@ void *PUGH_SetupGH (tFleshConfig *config, } } } - else - { - groupsize = NULL; - } /* Set the ghostzone size of the variables in the group */ size = CCTK_GroupGhostsizesI (group); + groupghostsize = nsize + 4*maxdim; if (size) { for (i = 0; i < pgroup.dim; i++) @@ -186,14 +183,11 @@ static void PUGH_InitGHBasics (cGH *GH) mypGH = PUGH_pGH (GH); + GFExtras = NULL; if (GH->cctk_dim > 0) { GFExtras = mypGH->GFExtras[GH->cctk_dim - 1]; } - else - { - GFExtras = NULL; - } GH->identity = mypGH->identity_string; @@ -265,7 +259,7 @@ static void PUGH_InitGHVariables (cGH *GH) GH->data[var][level] = ((pGA *) mypGH->variables[var][level])->data; break; default: - CCTK_WARN (1, "PUGH_InitGHVariables: Unknown group type"); + CCTK_WARN (0, "PUGH_InitGHVariables: Unknown group type"); } } } @@ -381,7 +375,7 @@ void PUGH_RegisterCallFunc (int (* func) (void *function, FIXME: This cannot be made static' because it is used by thorn BAM_Elliptic. @enddesc - @var dim + @var maxdim @vdesc dimension of the grid function @vtype int @vio in @@ -392,23 +386,33 @@ void PUGH_RegisterCallFunc (int (* func) (void *function, @vio out @endvar @@*/ -/* static */ void PUGH_GFSize (int dim, int *nsize) +/* static */ void PUGH_GFSize (int maxdim, int *nsize) { - int dir, size; + int i, size; DECLARE_CCTK_PARAMETERS + /* set the default size to 1 if it wasn't specified by parameters + driver::global_nsize or driver::local_nsize */ + size = 1; if (global_nsize > 0 || local_nsize > 0) { size = global_nsize > 0 ? global_nsize : -local_nsize; - for (dir = 0; dir < dim; dir++) - { - nsize[dir] = size; - } } - else + for (i = 0; i < maxdim; i++) { - switch (dim) + nsize[i] = size; + } + + /* now set the sizes for x,y,z according to the driver::global_n[xyz] or + driver::local_n[xyz] parameters if these were set */ + if (! (global_nsize > 0 || local_nsize > 0)) + { + if (maxdim > 3) + { + maxdim = 3; + } + switch (maxdim) { case 3: nsize[2] = local_nz > 0 ? -local_nz : global_nz; case 2: nsize[1] = local_ny > 0 ? -local_ny : global_ny; @@ -427,7 +431,7 @@ void PUGH_RegisterCallFunc (int (* func) (void *function, FIXME: This cannot be made static' because it is used by thorn BAM_Elliptic. @enddesc - @var dim + @var maxdim @vdesc dimension of the grid function @vtype int @vio in @@ -438,23 +442,23 @@ void PUGH_RegisterCallFunc (int (* func) (void *function, @vio out @endvar @@*/ -/* static */ void PUGH_GFGhostsize (int dim, int *ghostsize) +/* static */ void PUGH_GFGhostsize (int maxdim, int *ghostsize) { - int dir; + int i; DECLARE_CCTK_PARAMETERS if (ghost_size >= 0) { - for (dir = 0; dir < dim; dir++) + for (i = 0; i < maxdim; i++) { - ghostsize[dir] = ghost_size; + ghostsize[i] = ghost_size; } } else { - memset (ghostsize, 0, dim); - switch (dim) + memset (ghostsize, 0, maxdim); + switch (maxdim) { case 3: ghostsize[2] = ghost_size_z; case 2: ghostsize[1] = ghost_size_y; @@ -473,7 +477,7 @@ void PUGH_RegisterCallFunc (int (* func) (void *function, FIXME: This cannot be made static' because it is used by thorn BAM_Elliptic. @enddesc - @var dim + @var maxdim @vdesc dimension of the grid function @vtype int @vio in @@ -484,24 +488,21 @@ void PUGH_RegisterCallFunc (int (* func) (void *function, @vio out @endvar @@*/ -/* static */ void PUGH_GFPeriodic (int dim, int *perme) +/* static */ void PUGH_GFPeriodic (int maxdim, int *perme) { DECLARE_CCTK_PARAMETERS + memset (perme, 0, maxdim * sizeof (int)); if (periodic) { - switch (dim) + switch (maxdim) { case 3: perme[2] = periodic_z; case 2: perme[1] = periodic_y; case 1: perme[0] = periodic_x; } } - else - { - memset (perme, 0, dim * sizeof (int)); - } } @@ -514,8 +515,8 @@ void PUGH_RegisterCallFunc (int (* func) (void *function, @enddesc @var GH @vdesc pointer to CCTK grid hierarchy - @vtype cGH * - @vio out + @vtype const cGH * + @vio in @endvar @returntype int @@ -523,11 +524,11 @@ void PUGH_RegisterCallFunc (int (* func) (void *function, always returns 0 @endreturndesc @@*/ -int PUGH_PrintTimingInfo (cGH *GH) +int PUGH_PrintTimingInfo (const cGH *GH) { int i; cTimerData *info; - pGH *pughGH = PUGH_pGH (GH); + const pGH *pughGH = PUGH_pGH (GH); if (pughGH->comm_time < 0) |