diff options
Diffstat (limited to 'src/Interpolate.c')
-rw-r--r-- | src/Interpolate.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Interpolate.c b/src/Interpolate.c index 146b61c..b46cb40 100644 --- a/src/Interpolate.c +++ b/src/Interpolate.c @@ -370,7 +370,7 @@ int PUGHInterp_Interpolate (int order, /* loop over all dimensions */ for (i = 0; i < num_dims; i++) { - /* closest grid point for stencil */ + /* closest grid point for stencil/molecule */ point[i] = floor ((coord[num_dims*n + i] - origin[i]) * delta_inv[i] - 0.5 * (order - 1)); @@ -379,6 +379,12 @@ int PUGHInterp_Interpolate (int order, 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 */ + { + return -1; + } + /* if beyond lower bound shift the grid point to the right */ shift = point[i]; if (shift < 0) @@ -429,7 +435,7 @@ if (n == PUGHInterp_verbose_debug_n) /* put all information into a single message string for output */ msg = (char *) malloc (100 + num_dims*(10 + 4*20)); - sprintf (msg, "Interpolation stencil out of bounds at grid point [%d", + sprintf (msg, "Interpolation stencil/molecule out of bounds at grid point [%d", point[0]); for (i = 1; i < num_dims; i++) { |