|
[Sponsors] |
How to use "interpolation" utility in my own code |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
New Member
Frank Yu
Join Date: Jun 2011
Location: Toronto, ON
Posts: 15
Rep Power: 15 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#2 |
New Member
Frank Yu
Join Date: Jun 2011
Location: Toronto, ON
Posts: 15
Rep Power: 15 ![]() |
Have tried some alternative ways but still doesn't work, anybody knows how to solve it? or any similar situations?
|
|
![]() |
![]() |
![]() |
![]() |
#3 |
Senior Member
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 18 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#4 |
New Member
Frank Yu
Join Date: Jun 2011
Location: Toronto, ON
Posts: 15
Rep Power: 15 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#5 |
Senior Member
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 18 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#6 |
New Member
Frank Yu
Join Date: Jun 2011
Location: Toronto, ON
Posts: 15
Rep Power: 15 ![]() |
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::fvMatrix<Type> > Foam::fv::EulerDdtScheme<Type>::fvmDdt(const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&) [with Type = Foam::Tensor<double>]’: 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 |
|
![]() |
![]() |
![]() |
![]() |
#7 |
New Member
Frank Yu
Join Date: Jun 2011
Location: Toronto, ON
Posts: 15
Rep Power: 15 ![]() |
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 | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
The FOAM Documentation Project - SHUT-DOWN | holger_marschall | OpenFOAM | 242 | March 7, 2013 12:30 |
How to make code run in parallel? | cwang5 | OpenFOAM Programming & Development | 1 | May 30, 2011 04:47 |
Open Source Vs Commercial Software | MechE | OpenFOAM | 28 | May 16, 2011 11:02 |
Small 3-D code | Zdravko Stojanovic | Main CFD Forum | 2 | July 19, 2010 10:11 |
public CFD Code development | Heinz Wilkening | Main CFD Forum | 38 | March 5, 1999 11:44 |