CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   coordinate based interpolation ?? (

kdarc September 23, 2009 12:55

coordinate based interpolation ??
Can someone tell me if there is a straightforward way to return a value of a variable by simply specifying x,y,z coordinates??

Would this also work on boundaries??

in pseudo-code, I'm seeking to implement something in OpenFoam equivalent to:

q_interpolated = interpolate(q_field, at point(x,y,z) )


DanL September 28, 2009 06:25

I'd also like to know the answer to this question!

Also the inverse of defining a volVectorField from a field defined on an arbitrary set of Lagrangian points?


nikwin November 24, 2009 09:14

I'm having the same problem and found that perhaps the following could be used, (which should interpolate a value from the cell to a point within the cell)

interpolationCellPoint< Type > Class Template Reference

But, I don't have the programming skills to understand how to use it since it seems to not be implemented directly as a class.



kev4573 November 24, 2009 11:12

I know that in general RBF interpolation has the ability to do this and it seems the code does live in the OpenFOAM code base in the interpolations section. Once you figure out how to get the object constructed the interpolation should be straight-forward. The interpolate(Field ) function should return a field of your interpolated values to the field you specfied in the constructor (if I am reading this code correctly).

nikwin November 24, 2009 11:38

Thanks for your reply!

My problem is actually to construct an interpolationCellPoint. I've figured out that (basic programming) interpolationCellPoint<Type> expects me to define type for my class. So, I'm trying the following,

pointMesh pMesh(mesh);
volMesh vMesh(mesh);
volPointInterpolation interpMesh(mesh, pMesh);
interpolationCellPoint<vector> Uint(interpMesh,U,vMesh);

And getting the following error message since, I believe, I'm not defining a fvPatchField,

mySonicFoam.C: In function ‘int main(int, char**)’:
mySonicFoam.C:185: error: no matching function for call to ‘Foam::interpolationCellPoint<Foam::Vector<double> >::interpolationCellPoint(Foam::volPointInterpolat ion&, Foam::volVectorField&, Foam::volMesh&)’
/scratch/nwinkler/ProgramFiles/OF-1.5dev/OpenFOAM-1.5-dev/src/finiteVolume/lnInclude/interpolationCellPoint.C:37: note: candidates are: Foam::interpolationCellPoint<Type>::interpolationC ellPoint(const Foam::volPointInterpolation&, const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&) [with Type = Foam::Vector<double>]
/scratch/nwinkler/ProgramFiles/OF-1.5dev/OpenFOAM-1.5-dev/src/finiteVolume/lnInclude/interpolationCellPoint.H:52: note: Foam::interpolationCellPoint<Foam::Vector<double> >::interpolationCellPoint(const Foam::interpolationCellPoint<Foam::Vector<double> >&)
make: *** [Make/linux64GccDPOpt/mySonicFoam.o] Error 1

How can I construct/give a fvPatchField? Don't understand doxygen enough....


nikwin November 25, 2009 04:21

Programming skills....

interpolationCellPoint (const GeometricField< Type, fvPatchField, volMesh > &psi)

Says that it wants an argument not several. However, it works with 2 arguments as follows, (U interpolated to point xp)

pointMesh pMesh(mesh);
volPointInterpolation interpMesh(mesh, pMesh);
interpolationCellPoint<vector> Uint(interpMesh,U);
cell = mesh.findCell(xp);
vector Up = Uint.interpolate(xp,cell);


All times are GMT -4. The time now is 01:13.