|
[Sponsors] |
Trying to implement interpolation in openFOAM |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 10, 2012, 12:20 |
Trying to implement interpolation in openFOAM
|
#1 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
Can someone please give me some feedback? I am trying to figure this out and running out of ideas as to how to solve it: Please look at the attached jpg file. During run time, how can I acquire quantities at points V and N via interpolation, with P being the cell centered node?
|
|
January 11, 2012, 11:53 |
|
#2 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
It seems there is no one here on the forum that has a clue about this, and I do find that hard to believe.
For the interpolated quantities at point N, I thought of two things: 1)Is there a function available in OpenFOAM that would allow me to gain access to these faces OR 2) Perhaps I can calculate the normal wall distance from the wall to the face, and subsequently get hold of all the faces at this distance from the wall. I have being digging through the forum and haven't found anything on this. There has to be a way or maybe I might have to code this, and some feedback on this will be extremely helpful. |
|
January 13, 2012, 10:59 |
all faces or a specific one
|
#3 |
Senior Member
Fabian Roesler
Join Date: Mar 2009
Location: Germany
Posts: 213
Rep Power: 18 |
hi deji
do you have a specific point in your mesh where you want to know the temperature? Then you could use a probe. If you want the temperatures on each face of the cells you could interpolate your volScalarField onto the faces gaining a surfaceScalarField. Hope this is what you meant. Regards Fabian |
|
January 13, 2012, 11:19 |
|
#4 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
Hi Fabian. Well, if you look at the diagram, I would like to know quantities at point V, and it is at y*=10.8. So I suppose I could use a probe at run time, is that correct? So I can do this at this height for the entire 3D field?
Also, I know how to compute the surface quantities, I just do not know how to access those particular faces near the wall, point N in the picture attached. Thanks much Fabian for your feedback, I really appreciate it. Cheers, Deji Last edited by deji; January 26, 2012 at 13:57. |
|
January 13, 2012, 13:14 |
|
#5 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
It seems I ought to be able to use probe* to compute quantities at v, so I just have to figure out how to implement that for my entire domain.
|
|
January 13, 2012, 14:13 |
|
#6 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
After thinking about this, I do not think I can use probe to get the quantities at point V. I will have to interpolate for those quantities at run time. Still trying to figure it out!!!
|
|
January 14, 2012, 01:16 |
|
#7 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
Hello Foamers. Okay, so I think I've figured out how to get the interpolated surface quantities at point N. This is my thought and would greatly appreciate if someone can help comment or give me some feedback.
1) Acquire boundary faces 2) Get all internal faces 3) Perform dot product of unit face normals & axis direction of interest (say X), check magnitude, and select those magnitude is one. 4) Get cell height near wall using nearWallDist, and multiply value by 2 for cell height 5) Check the X location of the faces chosen from (3) and if it is the distance calculated from 4 away from the wall, it is the face whose quantities I pick to use..... Now I just have to code this, any feedback from the experts here on the forum?? |
|
January 16, 2012, 03:25 |
|
#8 |
Senior Member
Fabian Roesler
Join Date: Mar 2009
Location: Germany
Posts: 213
Rep Power: 18 |
Hi deji
I started into weekend after my last post and didn't check your replays. I think you’re on the right trip. I wanted to suggest the same thing: Identify the cells with boundary faces and select the face with a normal vector pointing away from the boundary face. This gets even simpler when using a hex mesh. Regards Fabian |
|
January 16, 2012, 14:09 |
|
#9 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
Thanks for the feedbacks. I am working on the coding and trying to find a decent way of getting a list of just the internal faces. I am get a list of all the faces, patch faces, but not the internal faces alone. How would I go about to get that list?
|
|
January 23, 2012, 13:24 |
|
#10 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
Hello to the OpenFOAM forum. Problem fixed, if anyone has a similar issue, I can post the section of the code that covers this topic!!!
|
|
January 24, 2012, 03:06 |
Would be nice
|
#11 |
Senior Member
Fabian Roesler
Join Date: Mar 2009
Location: Germany
Posts: 213
Rep Power: 18 |
Hi deji
Congratulations. Would be interesting to see your solution. Thanks for posting. Regards Fabian |
|
January 24, 2012, 03:53 |
|
#12 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
just discovered this thread
probe will do the trick if you know the position at start, but if you want a variable position, calculated at runtime, I dont know if probe can do this. Althought with the recent improvement with formulas it might be possible. Still, what you want is something like this Code:
dictionary interpolationDict = mesh.solutionDict().subDict("interpolationSchemes"); autoPtr<interpolation<vector> > Uinterp = interpolation<vector>::New(interpolationDict, U); vector pos(0,0,0); label cellI = mesh.findCell(pos); vector Ui = Uinterp->interpolate(pos, cellI); So you need to add the type of interpolation to fvSolution, like below. Code:
interpolationSchemes { U SCHEME; } N |
|
January 24, 2012, 09:49 |
|
#13 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
Hey Fabian. Sure, I will post the code that I implemented.
Hey Niklas. I do know the points that I would like to probe, and it is many that I would need for a wall function. Hence, in this code: dictionary interpolationDict = mesh.solutionDict().subDict("interpolationSchemes" ); autoPtr<interpolation<vector> > Uinterp = interpolation<vector>::New(interpolationDict, U); vector pos(0,0,0); label cellI = mesh.findCell(pos); vector Ui = Uinterp->interpolate(pos, cellI); So that means I would have multiple vector positions, perhaps I can loop through all the vectors, what do you think? |
|
January 24, 2012, 09:59 |
|
#14 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
you just change it to
Code:
vectorList positions = ..something; forAll(positions, i) { label cellI = mesh.findCell(positions[i]); vector Ui = Uinterp->interpolate(positions[i], cellI); } since the findCell operation is quite time-consuming, you'd want to do that as little as possible. Code:
// outside the loop in the beginning vectorList positions; labelList cellIndex(positions.size()); forAll(positions, i) { cellIndex[i] = mesh.findCell(positions[i]); } // inside the loop forAll(positions, i) { vector Ui = Uinterp->interpolate(positions[i], cellIndex[i]); } |
|
January 24, 2012, 10:04 |
|
#15 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
but if you have positions known at the start, why dont you just just probes.
Here's how it would look like for 2 probes. (Just stick it in the controlDict) Code:
functions { UProbes { type probes; functionObjectLibs ("libfieldFunctionObjects.so"); enabled true; outputControl timeStep; outputInterval 10; log false; valueOutput false; probeLocations ( ( 0.5 0.01 -0.01 ) (-1 0.0 0.0) ); fields ( U ); } } |
|
January 24, 2012, 10:11 |
|
#16 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
Thanks much Niklas. I actually know where I want to get the quantities, but not the exact points at runtime. Therefore, I will not be able to prescribe the points as probes in controlDict. Thanks again, I will try it...
Cheers, Deji |
|
January 24, 2012, 12:11 |
|
#17 |
Member
valerio
Join Date: Jun 2009
Location: Nancy
Posts: 30
Rep Power: 17 |
||
July 6, 2012, 07:24 |
|
#18 | |
Member
Björn Windén
Join Date: Feb 2012
Location: National Maritime Research Institute, Tokyo, Japan
Posts: 37
Rep Power: 14 |
Hi.
Any idea how you would achieve an interpolation like this Quote:
I tried something like: Before simulation start Code:
for ( int i=0 ; i <= npts ; i++) { cellsI[i]=-1; cellsI[i]=mesh.findCell(pointLists[i]); if (cellsI[i] != -1) { cellsI[i]= globalCells_.toGlobal(cellsI[i]); } } reduce(cellsI,maxOp<List<label> >()); Code:
autoPtr<interpolation<scalar> > alphaint =interpolation<scalar>::New(interpolationDict_,obr_.lookupObject<volScalarField>("alpha1")); for loop { if (cellsI[i] > 0) { alphai[i] = alphaint->interpolate(pointLists[i], cellsI[i]); } } reduce(alphai,maxOp<List<double> >()); Code:
cellsI[i] = globalCells_.toLocal(cellLists_[i]); PS. I want to use the interpolated values for some run-time calculations after I have retrieved them which is why I'm not simply using probes. |
||
July 6, 2012, 07:53 |
|
#19 |
Member
Björn Windén
Join Date: Feb 2012
Location: National Maritime Research Institute, Tokyo, Japan
Posts: 37
Rep Power: 14 |
As always, the minute after I posted, I figured out what was wrong. I got rid of the reduce(cellsI)-command and the toGlobal and then it works since everything is kept local without the masters interference : ) .
|
|
September 25, 2014, 09:54 |
|
#20 | ||
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 17 |
Quote:
Quote:
Solved: #include interpolation.H did the job Regards, Ilya Last edited by linch; September 25, 2014 at 11:40. |
|||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Possible bug in OpenFoam Interpolation class | MMC15 | OpenFOAM Bugs | 2 | March 23, 2014 13:55 |
[Gmsh] 2D Mesh Generation Tutorial for GMSH | aeroslacker | OpenFOAM Meshing & Mesh Conversion | 12 | January 19, 2012 04:52 |
Modified OpenFOAM Forum Structure and New Mailing-List | pete | Site News & Announcements | 0 | June 29, 2009 06:56 |
64bitrhel5 OF installation instructions | mirko | OpenFOAM Installation | 2 | August 12, 2008 19:07 |
OpenFOAM Training and Workshop Zagreb 2628Jan2006 | hjasak | OpenFOAM | 1 | February 2, 2006 22:07 |