|
[Sponsors] |
February 14, 2006, 10:16 |
Hello!
I've been looking at
|
#1 |
Member
Fabian Peng Karrholm
Join Date: Mar 2009
Posts: 61
Rep Power: 17 |
Hello!
I've been looking at different parts of the source code to try to figure out how surfaceScalarFields are addressed. I'm not really sure how they work, because if we take phi as an example, it can be addressed by cell. However, which of the faces does this value belong to? phi[1] Is there any way to retrieve the other faces value belong to the same cell? /Fabian |
|
February 14, 2006, 10:33 |
surfaceScalarField is a face b
|
#2 |
Senior Member
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21 |
surfaceScalarField is a face based field. phi[1] belongs to face 1, it can not be addressed by cell. You must have misinterpreted something.
To figure out which cells share the face: label faceOwnerCell = mesh.owner()[1]; label faceNeighbourCell = mesh.neighbour()[1]; Examine fvMesh.H, polyMesh.H and primitiveMesh.H to figure out what kind of face owner/neighbour access is available. The functions above only address internal faces for example. |
|
February 14, 2006, 10:35 |
Nope, not like that. A surfac
|
#3 |
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33 |
Nope, not like that. A surfaceScalarField is defined on the faces of the mesh, so phi[1] gives you the flux in the second face in the mesh. Face ordering is defined by the faces file in polyMesh. For each of the faces, you can get the owner/neigbour cell info by asking the mesh.
In surfaceScalarFields, the internal faces belong to the internalField() and patch fields are done in the usual way. Note the limitations on the patch field types: you cannot have, say, a zeroGradient patch field on the surfaceScalarField. By doiung phi[1], you are really getting phi.internalField()[1] because the Geometric field is derived from the internal field. Enjoy, Hrv
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk |
|
March 2, 2006, 09:49 |
Thanks for your help. I want t
|
#4 |
Member
Fabian Peng Karrholm
Join Date: Mar 2009
Posts: 61
Rep Power: 17 |
Thanks for your help. I want to ask another thing before I make an ugly piece of code.
I want to evaluate the mass flow in a cut-section. So I need: 1. Evalute physical properties on faces, no problem 2. Evalute the area of the face in the flow direction. This is the part I'm not sure about how to do. I'm only considering cartesian meshes, and I know the mesh.Sf() funciton will aid me. I also know which cells I have cut out for my plane. What I don't know is: How to know which faces surrounds these cells, disregarding which cell the faces belongs to? I know mesh.owner() would give me the faces the cells own, but if the faces the cell owns is not in the flow direction, things get complicated because then I have to iterate around in the surrounding cells checking who owns the flow direction face. Is there any easier way to just find out which faces surround a cell? Something like findFaces()? /Fabian |
|
March 3, 2006, 10:54 |
Ok the problem was resolved af
|
#5 |
Member
Fabian Peng Karrholm
Join Date: Mar 2009
Posts: 61
Rep Power: 17 |
Ok the problem was resolved after some local collaborations. However, we noticed something peculiar. I want the face area normals, so I do:
const surfaceVectorField faceNormals = mesh.Sf(); then at a later stage when I have selected a particular face, I want this face's normal. So I do: faceNormals[facei] but this gives me the wrong answer sometimes, I think it gives the wrong when I'm on a boundary face. However, if I do: mesh.Sf()[facei] I get the correct boundary, no matter what type of face it is, internal or boundary. Why is this? /Fabian |
|
March 4, 2006, 15:40 |
Have you run it through valgri
|
#6 |
Senior Member
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26 |
Have you run it through valgrind? Could be a problem with 'slicedSurfaceVectorField' which is holds the surface areas.
Try and use the primitiveMesh::faceAreas() instead. |
|
March 6, 2006, 05:47 |
about your problem: slicedSurf
|
#7 |
Senior Member
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26 |
about your problem: slicedSurfaceVectorFields cannot be copied into a surfaceScalarField. Can't you hold a reference instead of copying it?
2) evaluate the area of the face in the flow direction: something like: fvc::interpolate(U) & mesh.Sf() or use phi (don't know if this works): phi * mesh.Sf() 3) faces surrounding a cell: mesh.cells()[cellI] Look in primitiveMesh for all the addressing available. Anything more complicated you'll have to iterate yourself |
|
August 10, 2016, 06:00 |
|
#8 |
Member
|
I know it is a quite old post, but I have a question here. Is it possible to get access to the value of certain face of patches in this way? Like phi[facei]. Here facei is the global face index in list mesh.faces().
__________________
Kai |
|
|
|