CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   coordinate based interpolation ?? (https://www.cfd-online.com/Forums/openfoam/68552-coordinate-based-interpolation.html)

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) )


thanks.

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?

Cheers!

nikwin November 24, 2009 08: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.

Anyone?

Thanks
/NW

kev4573 November 24, 2009 10: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 10: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....

Regards
/NW

nikwin November 25, 2009 03: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);

/NW


All times are GMT -4. The time now is 17:36.