From 835471642710f0c2d922823e448a62e7c831d332 Mon Sep 17 00:00:00 2001 From: tradke Date: Thu, 2 Aug 2001 16:37:18 +0000 Subject: Fixed location of stencils for interpolation. This closes PR CactusPUGH/745. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHInterp/trunk@16 1c20744c-e24a-42ec-9533-f5004cb800e5 --- src/Interpolate.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Interpolate.c b/src/Interpolate.c index b387b19..65e797a 100644 --- a/src/Interpolate.c +++ b/src/Interpolate.c @@ -17,6 +17,7 @@ @version $Id$ @@*/ +#include #include #include @@ -250,8 +251,16 @@ int PUGHInterp_Interpolate (int order, /* loop over all dimensions */ for (i = 0; i < num_dims; i++) { - /* nearest grid point for stencil */ - point[i] = (coord[num_dims*n + i] - origin[i]) / delta[i]; + /* closest grid point for stencil */ + point[i] = floor ((coord[num_dims*n + i] - origin[i]) / delta[i] + - 0.5 * (order - 1)); + + /* if beyond lower bound shift the grid point to the right */ + shift = point[i]; + if (shift < 0) + { + point[i] -= shift; + } /* if beyond upper bound shift the grid point to the left */ shift = point[i] + order - (dims[i] - 1); -- cgit v1.2.3