aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortradke <tradke@1c20744c-e24a-42ec-9533-f5004cb800e5>2001-08-02 16:37:18 +0000
committertradke <tradke@1c20744c-e24a-42ec-9533-f5004cb800e5>2001-08-02 16:37:18 +0000
commit835471642710f0c2d922823e448a62e7c831d332 (patch)
treed7540d02b1df01c1ba903c332fe3a62d32289b77 /src
parent5c06ee788482b032fc3c45e62dacd055c727d8b6 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/Interpolate.c13
1 files 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 <math.h>
#include <stdlib.h>
#include <string.h>
@@ -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);