# How to use "interpolation" utility in my own code

 Register Blogs Members List Search Today's Posts Mark Forums Read

 August 11, 2011, 14:57 How to use "interpolation" utility in my own code #1 New Member   Frank Yu Join Date: Jun 2011 Location: Toronto, ON Posts: 15 Rep Power: 7 Hello, I am trying to call the interpolation functions from "finiteVolume" folder in my own code. My purpose is, by knowing a GeometricField ( "vf" for example ) and it's corresponding mesh grid ( mesh().C(), a volVectorField? ), given a coordinate (x0,y0,z0), interpolate the function value vf(x0,y0,z0). I've read through the source code in " .../finiteVolume/interpolation/... " and " .../OpenFOAM/interpolations/... ", didn't find any function can fit my input format, which is a GeometricField, volVectorField, and a vector (x,y,z). Any similar situation have you been through before? Or any ideas? Thanks for your time. Frank

 September 7, 2011, 12:28 #2 New Member   Frank Yu Join Date: Jun 2011 Location: Toronto, ON Posts: 15 Rep Power: 7 Have tried some alternative ways but still doesn't work, anybody knows how to solve it? or any similar situations?

 September 7, 2011, 13:57 #3 Senior Member   Kathrin Kissling Join Date: Mar 2009 Location: Besigheim, Germany Posts: 134 Rep Power: 9 Hi Frank, what do you inted to do? Do you want to interpolate around a point? Or do you want the value in a specific point? For interpolation to the mesh faces just go surfaceVectorField sVF = vF.interpolate(); Then search for the face center closest to what you need. Grap its face id and do vector sV = sVF[faceI]; You definitely need to specify because interpolation is a very wide field... Then we can try to help you! Best Kathrin

 September 7, 2011, 14:06 #4 New Member   Frank Yu Join Date: Jun 2011 Location: Toronto, ON Posts: 15 Rep Power: 7 Hi Kathrin, Thanks for the reply. My purpose is, given a specific point 'vector X', find out what is the value of vf.oldTime() at that point. And since that point 'X' may not exactly on the meshgrid, i need to interpolate it by the known vf values. Frank

 September 8, 2011, 02:26 #5 Senior Member   Kathrin Kissling Join Date: Mar 2009 Location: Besigheim, Germany Posts: 134 Rep Power: 9 Hi Frank, so what you need to do: First find the cell where it is located: label myCellLabel = mesh.findNearestCell(yourPoint); labelList adjacentCells = mesh.cellCells()[myCellLabel]; Then find the centers of the adjacent cells calculte the distance to your point -> weighting factors and interpolate Hope this being of help! Kathrin

 September 9, 2011, 11:57 #6 New Member   Frank Yu Join Date: Jun 2011 Location: Toronto, ON Posts: 15 Rep Power: 7 Thanks a lot Kathrin, this is very helpful. I assume the default search method is 'octree' used in label myCellLabel = mesh().findNearestCell(yourPoint); it seems time consuming when doing the search. I also tried other method such as label myCellLabel = mesh().findNearestCellLinear(yourPoint); label myCellLabel = mesh().findNearestCellWalk(yourPoint, patchI); where 'patchI' is my reference index. When I make the file, is says finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.C: In member function ‘Foam::tmp > Foam::fv::EulerDdtScheme::fvmDdt(const Foam::GeometricField&) [with Type = Foam::Tensor]’: finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtSchemes.C:37: instantiated from here finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.C:520: error: ‘const class Foam::fvMesh’ has no member named ‘findNearestCellWalk’ Doesn't all search utilities come from the following directory, or I missed something again? /home/frank/OpenFOAM/OpenFOAM-2.0.0/src/meshTools/meshSearch/meshSearch.C

 September 10, 2011, 19:39 #7 New Member   Frank Yu Join Date: Jun 2011 Location: Toronto, ON Posts: 15 Rep Power: 7 Problem solved, should use following commends: meshSearch ms(mesh()); label myCellLabel = ms.findNearestCell(X,patchI); with a reference seedcell patchI, the search is much faster than before. (given a large number of cells). Again, many thanks Kathrin! -Frank

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post holger_marschall OpenFOAM 242 March 7, 2013 13:30 cwang5 OpenFOAM Programming & Development 1 May 30, 2011 04:47 MechE OpenFOAM 28 May 16, 2011 11:02 Zdravko Stojanovic Main CFD Forum 2 July 19, 2010 10:11 Heinz Wilkening Main CFD Forum 38 March 5, 1999 12:44

All times are GMT -4. The time now is 16:26.