From c2ca6b3881cd00f7023720816b671c85c46337e6 Mon Sep 17 00:00:00 2001 From: tradke Date: Wed, 17 Nov 2004 16:44:22 +0000 Subject: Allow negative extents in a definition for a global hyperslab mapping as a shortcut for the maximum extent. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHSlab/trunk@131 10716dce-81a3-4424-a2c8-48026a0d3035 --- src/Mapping.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Mapping.c b/src/Mapping.c index 9bc0c33..548db56 100644 --- a/src/Mapping.c +++ b/src/Mapping.c @@ -144,6 +144,7 @@ static CCTK_INT DefineMapping (const cGH *GH, cGroup vinfo; char key[128]; CCTK_INT type, nelems, with_ghostzones; + CCTK_INT *real_extent; /* prevent compiler warnings */ @@ -232,7 +233,7 @@ static CCTK_INT DefineMapping (const cGH *GH, retval |= origin[vdim] < 0; if (vdim < hdim) { - retval |= extent[vdim] < 0; + retval |= extent[vdim] == 0; if (downsample) { retval |= downsample[vdim] <= 0; @@ -363,13 +364,20 @@ static CCTK_INT DefineMapping (const cGH *GH, extras = GA->extras; /* check extent */ + real_extent = malloc (vinfo.dim * sizeof (CCTK_INT)); for (vdim = dim = 0; vdim < vinfo.dim; vdim++) { + real_extent[vdim] = extent[vdim]; + if (real_extent[vdim] < 0) + { + real_extent[vdim] = extras->nsize[vdim]; + } if (mapping->do_dir[vdim] && dim < mapping->hdim) { - if (origin[vdim] + extent[dim] > extras->nsize[vdim]) + if (origin[vdim] + real_extent[dim] > extras->nsize[vdim]) { free (mapping->do_dir); free (mapping->global_hsize); free (mapping); + free (real_extent); CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "PUGHlab_GlobalMappingByIndex: extent in " "%d-direction exceeds grid size", dim); @@ -378,9 +386,10 @@ static CCTK_INT DefineMapping (const cGH *GH, dim++; } else if (mapping->is_diagonal_in_3D && - origin[vdim] + extent[0] > extras->nsize[vdim]) + origin[vdim] + real_extent[0] > extras->nsize[vdim]) { free (mapping->do_dir); free (mapping->global_hsize); free (mapping); + free (real_extent); CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "PUGHlab_GlobalMappingByIndex: extent in " "%d-direction exceeds grid size", vdim); @@ -400,7 +409,7 @@ static CCTK_INT DefineMapping (const cGH *GH, mapping->downsample[vdim] = downsample[dim]; } mapping->global_hsize[dim] = - (extent[dim] + mapping->downsample[vdim]-1) / mapping->downsample[vdim]; + (real_extent[dim] + mapping->downsample[vdim]-1) / mapping->downsample[vdim]; /* subtract ghostzones for periodic BC */ if (! with_ghostzones && GA->connectivity->perme[vdim]) @@ -412,7 +421,7 @@ static CCTK_INT DefineMapping (const cGH *GH, else if (mapping->is_diagonal_in_3D) { mapping->totals = - (extent[0] + mapping->downsample[0]-1) / mapping->downsample[0]; + (real_extent[0] + mapping->downsample[0]-1) / mapping->downsample[0]; /* subtract ghostzones for periodic BC */ if (! with_ghostzones && GA->connectivity->perme[vdim]) @@ -427,7 +436,7 @@ static CCTK_INT DefineMapping (const cGH *GH, } /* check whether the full local data patch was requested as hyperslab */ - mapping->is_full_hyperslab = IsFullHyperslab (GA, origin, extent, mapping); + mapping->is_full_hyperslab = IsFullHyperslab (GA, origin, real_extent, mapping); if (mapping->is_full_hyperslab) { memset (mapping->local_startpoint, 0, vinfo.dim * sizeof (int)); @@ -468,8 +477,8 @@ static CCTK_INT DefineMapping (const cGH *GH, /* compute the global endpoint */ for (vdim = dim = 0; vdim < vinfo.dim; vdim++) { - mapping->global_endpoint[vdim] = origin[vdim] + - (mapping->do_dir[vdim] ? extent[dim++] : 1); + mapping->global_endpoint[vdim] = + origin[vdim] + (mapping->do_dir[vdim] ? real_extent[dim++] : 1); } /* compute this processor's global startpoint from the global ranges */ @@ -566,6 +575,8 @@ static CCTK_INT DefineMapping (const cGH *GH, } } /* end of else branch for 'if (mapping->is_full_hyperslab)' */ + free (real_extent); + #ifdef DEBUG fprintf (stderr, "total number of hyperslab data points: %d\n", mapping->totals); -- cgit v1.2.3