How to use "interpolation" utility in my own code
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.
Have tried some alternative ways but still doesn't work, anybody knows how to solve it? or any similar situations?
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!
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.
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!
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?
Problem solved, should use following commends:
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!
|All times are GMT -4. The time now is 22:04.|