CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

SurfaceScalarFields

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By hjasak

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 14, 2006, 09:16
Default Hello! I've been looking at
  #1
Member
 
Fabian Peng Karrholm
Join Date: Mar 2009
Posts: 61
Rep Power: 17
fabianpk is on a distinguished road
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
fabianpk is offline   Reply With Quote

Old   February 14, 2006, 09:33
Default surfaceScalarField is a face b
  #2
Senior Member
 
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21
eugene is on a distinguished road
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.
eugene is offline   Reply With Quote

Old   February 14, 2006, 09:35
Default Nope, not like that. A surfac
  #3
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,905
Rep Power: 33
hjasak will become famous soon enough
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
kaifu and massive_turbulence like this.
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   March 2, 2006, 08:49
Default Thanks for your help. I want t
  #4
Member
 
Fabian Peng Karrholm
Join Date: Mar 2009
Posts: 61
Rep Power: 17
fabianpk is on a distinguished road
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 is offline   Reply With Quote

Old   March 3, 2006, 09:54
Default Ok the problem was resolved af
  #5
Member
 
Fabian Peng Karrholm
Join Date: Mar 2009
Posts: 61
Rep Power: 17
fabianpk is on a distinguished road
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
fabianpk is offline   Reply With Quote

Old   March 4, 2006, 14:40
Default Have you run it through valgri
  #6
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
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 is offline   Reply With Quote

Old   March 6, 2006, 04:47
Default about your problem: slicedSurf
  #7
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
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
mattijs is offline   Reply With Quote

Old   August 10, 2016, 05:00
Default
  #8
Member
 
Kai
Join Date: May 2010
Location: Shanghai
Posts: 61
Blog Entries: 1
Rep Power: 15
kaifu is on a distinguished road
Quote:
Originally Posted by hjasak View Post
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().
__________________
Kai
kaifu is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 23:21.