From e39ea546180026269531265180318ef7e148f920 Mon Sep 17 00:00:00 2001 From: tradke Date: Fri, 25 Jul 2003 12:33:59 +0000 Subject: Re-enabled the out-of-bounds check in the core interpolation routine which is also used now by local interpolators. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/LocalInterp/trunk@168 df1f8a13-aa1d-4dd4-9681-27ded5b42416 --- src/Interpolate.c | 70 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/Interpolate.c b/src/Interpolate.c index 4dd6067..ed05ae8 100644 --- a/src/Interpolate.c +++ b/src/Interpolate.c @@ -284,9 +284,7 @@ int LocalInterp_Interpolate (int order, { int retval; int i, a, n, shift; -#if 0 int out_of_bounds; -#endif CCTK_INT max_dims[MAXDIM], point[MAXDIM]; CCTK_REAL delta_inv[MAXDIM]; CCTK_REAL below[MAXDIM]; @@ -362,10 +360,8 @@ int LocalInterp_Interpolate (int order, /* loop over all points to interpolate at */ for (n = 0; n < num_points; n++) { -#if 0 /* reset the out-of-bounds flag */ out_of_bounds = 0; -#endif /* loop over all dimensions */ for (i = 0; i < num_dims; i++) @@ -374,10 +370,8 @@ int LocalInterp_Interpolate (int order, point[i] = floor ((coord[i][n] - origin[i]) * delta_inv[i] - 0.5 * (order - 1)); -#if 0 /* test bounds */ out_of_bounds |= point[i] < 0 || point[i]+order >= dims[i]; -#endif /* check that the stencil/molecule isn't bigger than the grid */ if (order+1 > dims[i]) /* stencil/molecule size = order+1 */ @@ -418,43 +412,55 @@ if (n == LocalInterp_verbose_debug_n) } #endif /* LOCALINTERP_VERBOSE_DEBUG */ -#if 0 /* check bounds */ if (out_of_bounds) { - char *msg; - - - /* put all information into a single message string for output */ - msg = malloc (100 + num_dims*(10 + 4*20)); - sprintf (msg, - "Interpolation stencil/molecule out of bounds at grid point [%d", - point[0]); - for (i = 1; i < num_dims; i++) + if (num_dims == 1) { - sprintf (msg, "%s, %d", msg, point[i]); + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Interpolation stencil/molecule out of bounds " + "at grid point [%d]\n" + "range would be min/max [%f / %f]\n" + "grid is min/max [%f / %f]", + point[0], + (double) below[0], (double) (below[0] + offset[0]), + (double) origin[0], (double) (origin[0] + (dims[0]-1)*delta[0])); } - sprintf (msg, "%s]\nrange would be min/max [%f / %f", msg, - (double) below[0], (double) (below[0] + offset[0])); - for (i = 1; i < num_dims; i++) + else if (num_dims == 2) { - sprintf (msg, "%s, %f / %f", msg, - (double) below[i], (double) (below[i] + offset[i])); + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Interpolation stencil/molecule out of bounds " + "at grid point [%d, %d]\n" + "range would be min/max [%f / %f, %f / %f]\n" + "grid is min/max [%f / %f, %f / %f]", + point[0], point[1], + (double) below[0], (double) (below[0] + offset[0]), + (double) below[1], (double) (below[1] + offset[1]), + (double) origin[0], (double) (origin[0] + (dims[0]-1)*delta[0]), + (double) origin[1], (double) (origin[1] + (dims[1]-1)*delta[1])); } - sprintf (msg, "%s]\ngrid is min/max [%f / %f", msg, - (double) origin[0], (double) (origin[0] + (dims[0]-1)*delta[0])); - for (i = 1; i < num_dims; i++) + else if (num_dims == 3) { - sprintf (msg, "%s, %f / %f", msg, - (double)origin[i], (double)(origin[i] + (dims[i]-1)*delta[i])); + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Interpolation stencil/molecule out of bounds " + "at grid point [%d, %d, %d]\n" + "range would be min/max [%f / %f, %f / %f, %f / %f]\n" + "grid is min/max [%f / %f, %f / %f, %f / %f]", + point[0], point[1], point[2], + (double) below[0], (double) (below[0] + offset[0]), + (double) below[1], (double) (below[1] + offset[1]), + (double) below[2], (double) (below[2] + offset[2]), + (double) origin[0], (double) (origin[0] + (dims[0]-1)*delta[0]), + (double) origin[1], (double) (origin[1] + (dims[1]-1)*delta[1]), + (double) origin[2], (double) (origin[2] + (dims[2]-1)*delta[2])); + } + else + { + CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, + "Internal error: %d dimensions aren't supported", num_dims); } - sprintf (msg, "%s]", msg); - CCTK_WARN (1, msg); - free (msg); - continue; } -#endif /* * *** compute the interpolation coefficients according to the order *** -- cgit v1.2.3