CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   SurfaceScalarFields (https://www.cfd-online.com/Forums/openfoam/61005-surfacescalarfields.html)

fabianpk February 14, 2006 09:16

Hello! I've been looking at
 
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

eugene February 14, 2006 09:33

surfaceScalarField is a face b
 
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.

hjasak February 14, 2006 09:35

Nope, not like that. A surfac
 
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

fabianpk March 2, 2006 08:49

Thanks for your help. I want t
 
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

fabianpk March 3, 2006 09:54

Ok the problem was resolved af
 
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

mattijs March 4, 2006 14:40

Have you run it through valgri
 
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.

mattijs March 6, 2006 04:47

about your problem: slicedSurf
 
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

kaifu August 10, 2016 05:00

Quote:

Originally Posted by hjasak (Post 193251)
By doiung phi[1], you are really getting phi.internalField()[1] because the Geometric field is derived from the internal field.

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().


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