CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

How to use "interpolation" utility in my own code

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 11, 2011, 15:57
Default 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: 14
frankyux is on a distinguished road
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
frankyux is offline   Reply With Quote

Old   September 7, 2011, 13:28
Default
  #2
New Member
 
Frank Yu
Join Date: Jun 2011
Location: Toronto, ON
Posts: 15
Rep Power: 14
frankyux is on a distinguished road
Have tried some alternative ways but still doesn't work, anybody knows how to solve it? or any similar situations?
frankyux is offline   Reply With Quote

Old   September 7, 2011, 14:57
Default
  #3
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
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
kathrin_kissling is offline   Reply With Quote

Old   September 7, 2011, 15:06
Default
  #4
New Member
 
Frank Yu
Join Date: Jun 2011
Location: Toronto, ON
Posts: 15
Rep Power: 14
frankyux is on a distinguished road
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
frankyux is offline   Reply With Quote

Old   September 8, 2011, 03:26
Default
  #5
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
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
kathrin_kissling is offline   Reply With Quote

Old   September 9, 2011, 12:57
Default
  #6
New Member
 
Frank Yu
Join Date: Jun 2011
Location: Toronto, ON
Posts: 15
Rep Power: 14
frankyux is on a distinguished road
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
frankyux is offline   Reply With Quote

Old   September 10, 2011, 20:39
Default
  #7
New Member
 
Frank Yu
Join Date: Jun 2011
Location: Toronto, ON
Posts: 15
Rep Power: 14
frankyux is on a distinguished road
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
frankyux is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
The FOAM Documentation Project - SHUT-DOWN holger_marschall OpenFOAM 242 March 7, 2013 13:30
How to make code run in parallel? cwang5 OpenFOAM Programming & Development 1 May 30, 2011 05:47
Open Source Vs Commercial Software MechE OpenFOAM 28 May 16, 2011 12:02
Small 3-D code Zdravko Stojanovic Main CFD Forum 2 July 19, 2010 11:11
public CFD Code development Heinz Wilkening Main CFD Forum 38 March 5, 1999 12:44


All times are GMT -4. The time now is 20:22.