CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How to sample (with interpolation) at runtime (https://www.cfd-online.com/Forums/openfoam-programming-development/73776-how-sample-interpolation-runtime.html)

ole March 16, 2010 14:06

How to sample (with interpolation) at runtime
 
I would like to sample my velocity field at evenly spaced points along a line. This is easily done with the sample utility for post-processing, however, I need to process the data in my application during run-time. I have looked at the source for the sample utility, but it is really hard to pick out which part to copy into my code. I have a feeling that this can be done in just a few lines of code. Does anyone know how to do this?

Thanks,
Ole

r08n March 27, 2010 08:18

http://openfoamwiki.net/index.php/Sn...value_at_point

If the field value in the cell is sufficient (without interpolation), it can be accessed as

U[mesh.findCell(point(x,y,z))], where x,y,z are the point coords.

sbarthmes March 29, 2010 06:33

I'm working on a similar problem and didn't come further yet. Sure I could try doing my own interpolation though this would be quite unefficient because I think there already are classes that do exactly what I want.
Unfortunatly I don't have enough knowledge about the application of openfoam-classes yet and don't know were to start solving this problem.
It's just that I wan't to get the interpolated values on a plane surface in the field during runtime to calculate the values for my boundary condition.
Any help or suggestions would be greatly appreciated!

I found some interesting classes but didn't understand them in detail:
src/sampling/meshToMeshInterpolation/meshToMesh/
Can these be used by a boundary condition?

How do you proceed if you are confronted with new code you don't know?
Sorry, I'm quite new to this level of programming... ;-)

doedmund November 3, 2010 13:47

Volume to point interpolation (just one point - not a pointMesh)
 
Hello,

I am also trying to sample the velocity at points in the field during runtime in order to update a boundary condition (in 1.6.x).

Basically, I want to define a point in the field, and give it to a function that will provide the interpolated value of the velocity at that point.

There seem to be a few unresolved posts about similar issues, so for the sake of putting them all in one place, here is a summary of what I have looked at or tried:

- Using U[mesh.findCell(pointCoordinates)] as suggested by r08n in this thread and listed on the wiki. This works, but just gives the cell value; I would like to implement interpolation (preferably using OpenFOAM, not writing my own interpolation scheme!).
- Using volPointInterpolation -- this looks like it should be able to do exactly what I need, but it needs a pointMesh where I just want to give it a point or list of points. (Any ideas on how to make it work on for a point?)
- fvc::interpolate -- This looks like it takes a scalar onto a surface, which is not exactly what I am going for... (http://www.cfd-online.com/Forums/ope...o-surface.html)
- using probes -- http://www.cfd-online.com/Forums/ope...ion-probe.html

I would really appreciate any thoughts on how one of the above could be made to work, or something else to try. (I am no expert at this, and could easily be missing something!)

Thank you,
Deborah

nlc December 14, 2010 12:57

Hi Foamers,

The interpolation class are in src/finitVolume/interpolation
and there we find interpolationCell, interpolationCellPoint and interpolationCellPointFace as sample utility interpolation choice are "Cell", "CellPoint" and "CellPointFace" I think it is the right place to look !

I have tried to use the class but I'm slit learning C++. :) Here is something that work but its nothing great its give as interpolation the value at the center of the cell !!!

Code:

const interpolationCell<vector> UInterp(U);
point point(y,x,z);
Info << UInterp.interpolate(point,mesh.findCell(point)) << endl;

I was hoping to be able to do the same thing with interpolationCellPoint or interpolationCellPointFace but the class are not build the same way and create an instance of interpolationCellPoint is not permitted !!


Ideally I'd like to be eable to read from the dictionary the type of interpolation and chose it for my application.

If any one know how to do this. I'll be happy to learn!

By the way I try to make a post process utility that will do some computing on values interpolated on different disk in the domain.

Regards


All times are GMT -4. The time now is 03:13.