|
[Sponsors] |
November 29, 2013, 09:54 |
automatic interpolation of field on call
|
#1 |
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 20 |
I have a question. Let's say I have a field
Code:
const volScalarField& k Code:
label faceI // surface between two cells label faceCellI // cell center Code:
k[faceCellI] Code:
k[faceI] Now the question, does OpenFOAM automatically interpolate in these cases? I wonder if the same also works for volVectorFields, when retrieving a value from the interface between two neighboring cells (through a label) that it then interpolates.
__________________
~roman |
|
November 29, 2013, 10:23 |
|
#2 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
Both faceI and faceCellI in your example are labels (this pretty much is equal to a integer). Suppose faceI = 1, and faceCelli = 1, how would the code you show know if it's supposed to return a interpolated or cell centre value? Keep in mind the code doesn't know the name of your variable, only the location in memory. Thus, from the very brief snippets you show, you should get the cell centre value in both cases.
- Anton
__________________
*On twitter @akidTwit *Spend as much time formulating your questions as you expect people to spend on their answer. |
|
November 29, 2013, 10:30 |
|
#3 | |
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 20 |
Quote:
I am using this method http://www.cfd-online.com/Forums/ope...tml#post254946 to find the global indices for the cell interface opposite to the patch on a boundary. With this label I then would like to retrieve the velocity and k. At first I thought this should work very easily by using the interpolated (onto the surface mesh) fields in combination with the label oppFaceI which I retrieve from the mentioned method
__________________
~roman |
||
November 29, 2013, 12:32 |
|
#4 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
Please post the code as you have implemented it.
__________________
*On twitter @akidTwit *Spend as much time formulating your questions as you expect people to spend on their answer. |
|
November 29, 2013, 12:44 |
|
#5 |
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 20 |
I think I have found my answer, however, here comes the code Code:
// get access to the mesh for opposite faces const fvMesh& mesh = patch().boundaryMesh().mesh(); // access to everything else const turbulenceModel& turbModel = db().lookupObject<turbulenceModel>("turbulenceModel"); const tmp<volScalarField> tk = turbModel.k(); const volScalarField& k = tk(); const surfaceScalarField kSurface = fvc::interpolate(k); forAll(mutw, faceI) { label faceCellI = patch().faceCells()[faceI]; label oppFaceI = mesh.cells()[faceCellI].opposingFaceLabel ( faceI+patch().patch().start(), mesh.faces() ); // calculate distance between wall and opposing face // get coordinates of centre of face opposite the patch boundary face vector faceCentre = mesh.faceCentres()[oppFaceI]; // get coordinates of centre of patch at the boundary face vector patchFaceCentre = mesh.faceCentres()[faceI+patch().patch().start()]; // distance to opposite face scalar yn = mag(patchFaceCentre - faceCentre); // dimensionless distance to opposite face, using k at the opposite // face scalar yStarn = yn*sqrt(kSurface[oppFaceI])*rhon/mun; } Code:
const surfaceScalarField& kSurface = fvc::interpolate(k)
__________________
~roman |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Setting an external B0_x field in MHD module | fferroni | FLUENT | 11 | August 1, 2022 08:20 |
[OpenFOAM] Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 | keepfit | ParaView | 60 | September 18, 2013 03:23 |
How to get the velocity field from the pressure field | Hermano | Main CFD Forum | 2 | November 29, 2011 08:32 |
automatic call a function in a program | gerado | OpenFOAM | 9 | June 29, 2009 02:30 |
2D CFD code using SIMPLE algorithm | bfan | Main CFD Forum | 3 | June 22, 2002 22:01 |