CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   interpolationCellPoint not consistent? (

nikwin April 4, 2011 13:57

interpolationCellPoint not consistent?

I'm using the interpolationCellPoint class to interpolate cell values to points, which are not necessary located at the nodes of the field. I'm using the code below in OF 1.6. However, the problem is that I'm not getting consistent results, i.e at some points the interpolation routine gives me values that are not consistent with the field that I'm interpolating from.

Am I using the correct syntax for the interpolation? Is there a different way to perform an interpolation? What kind of interpolation routine is used in this case? And, is the interpolation routine changed in OF-1.7.1, since according to the doxygen manual for 1.7.1 there are several new member functions?

interpolationCellPoint<vector> UInt(U);
point p1(0.0550,0.0048,0.0001);
Info << "p1=" << UInt.interpolate(p1,meshPhys.findCell(p1)) << endl;


For testing I used 6 points closely located with the following results, (p3 deviates)
p1= (0.055 0.0048 0.0001) U(p1) = (49.32435609 -0.487422855 0.0005173166021)
p2= (0.0551 0.0048 0.0001) U(p2) = (49.27461082 -0.4875524205 0.0005564675199)
p3= (0.0552 0.0048 0.0001) U(p3) = (48.38065493 -0.4683060613 0.0005972628526)
p4= (0.0553 0.0048 0.0001) U(p4) = (49.13672163 -0.4864052464 0.001304037682)
p5= (0.0554 0.0048 0.0001) U(p5) = (49.08416 -0.4862573532 0.001257339119)
p6= (0.0555 0.0048 0.0001) U(p6) = (48.99065904 -0.485661105 0.0004215057358)

David* June 14, 2011 08:02

Hi Niklas,
did you figured something out regarding this issue? In my case, I observed a fluctuating behavior of Uint.interpolate at the cell edges. Is it possible that your position x = 0.0552 is such an edge?

nikwin June 17, 2011 07:47


Yes that's possible. Since it doesn't really work close to the boundary etc.where there are strong gradients I implemented an interpolation routine, which you can find at,

All the Best

David* June 17, 2011 10:34

Hi Niklas,
that is a very interesting information, as I experienced a somewhat strange behaviour of the interpolation at the boundary, too.
Thanks for the formulas you linked. But would you mind sharing your implemented code with us? I fully understand if you don't want/are not allowed to, but it would save me a lot of time and frustration ;)
Nice weekend,

deji January 4, 2012 11:17

Hello guys. Is it possible for you to share the code you implemented to interpolate cell values to points within a cell? I will need such values near the boundary as well, where there are high gradients.


All times are GMT -4. The time now is 18:46.