CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

question about mesh.sf[faceI]mesh.sf[faceI]

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By Jerryfan

Reply
 
LinkBack Thread Tools Display Modes
Old   March 12, 2015, 08:59
Default question about mesh.sf[faceI]mesh.sf[faceI]
  #1
New Member
 
Join Date: Nov 2010
Posts: 10
Rep Power: 8
Friederike is on a distinguished road
Hi FOAMers,
I need to loop over all faces of a cell and collect fluxes. I have a 2D case so i set the boundaries with face normal in y-direction to empty.

I use the following code:

PHP Code:
// loop over all cells:
forAll(mesh.C(), cellI
{
   
Info << "******* CellID: " << cellI << "*******"<< endl;

  
//Getting list of all faces of current cell
  
const labelListfaces mesh.cells()[cellI];

  
//loop over all faces of current cell
  
forAllfacesfaceI )
  {   
    if (
mesh.isInternalFace(faces[faceI]))
     {   
       
Info << "internal faceI: " << faceI << "    mesh.Sf()[faceI]: " << -mesh.Sf()[faceI] << "    mesh.magSf()[faceI]: " << mesh.magSf()[faceI] << endl;
     }   
     else
     {   
       
Info << "boundary faceI: " << faceI << "    mesh.Sf()[faceI]: " << -mesh.Sf()[faceI] << "    mesh.magSf()[faceI]: " << mesh.magSf()[faceI] << endl;
     }   

  } 
//move on to next face  
  
Info << " " << endl;
}
//move on to next cell 
The output of this is:
PHP Code:
******* CellID1*******
internal faceI0    mesh.Sf()[faceI]: (---0)    mesh.magSf()[faceI]: 1
internal faceI
1    mesh.Sf()[faceI]: (---1)    mesh.magSf()[faceI]: 1
boundary faceI
2    mesh.Sf()[faceI]: (---0)    mesh.magSf()[faceI]: 1
boundary faceI
3    mesh.Sf()[faceI]: (---1)    mesh.magSf()[faceI]: 1
boundary faceI
4    mesh.Sf()[faceI]: (---0)    mesh.magSf()[faceI]: 1
internal faceI
5    mesh.Sf()[faceI]: (---1)    mesh.magSf()[faceI]: 1

******* CellID2*******
internal faceI0    mesh.Sf()[faceI]: (---0)    mesh.magSf()[faceI]: 1
internal faceI
1    mesh.Sf()[faceI]: (---1)    mesh.magSf()[faceI]: 1
boundary faceI
2    mesh.Sf()[faceI]: (---0)    mesh.magSf()[faceI]: 1
boundary faceI
3    mesh.Sf()[faceI]: (---1)    mesh.magSf()[faceI]: 1
boundary faceI
4    mesh.Sf()[faceI]: (---0)    mesh.magSf()[faceI]: 1
internal faceI
5    mesh.Sf()[faceI]: (---1)    mesh.magSf()[faceI]: 1

******* CellID3*******
internal faceI0    mesh.Sf()[faceI]: (---0)    mesh.magSf()[faceI]: 1
internal faceI
1    mesh.Sf()[faceI]: (---1)    mesh.magSf()[faceI]: 1
boundary faceI
2    mesh.Sf()[faceI]: (---0)    mesh.magSf()[faceI]: 1
boundary faceI
3    mesh.Sf()[faceI]: (---1)    mesh.magSf()[faceI]: 1
boundary faceI
4    mesh.Sf()[faceI]: (---0)    mesh.magSf()[faceI]: 1
internal faceI
5    mesh.Sf()[faceI]: (---1)    mesh.magSf()[faceI]: 
My question now are:
Why are all vector components negative (it stays like that for the whole grid)?
Why are there no vectors with a y-Component? Is this because of the pseudo 2D grid?
I get the same output with a zeroGradient boundary condition for the third dimension.
I don't want to sum over the boundaries which are set to empty. I guess I could also use this as a condition but I still would like to know why mesh.Sf() behaves so wired.

I have looked for some time now but could not find an answer...

Thanks for any help and suggestions!!!
Cheers
friederike
Friederike is offline   Reply With Quote

Old   July 23, 2016, 14:47
Default
  #2
New Member
 
stater's Avatar
 
H. Omar
Join Date: Mar 2013
Posts: 19
Rep Power: 5
stater is on a distinguished road
Hi Friederike,
I know it is an old thread, but actually i am stuck on the same issues, so I am interested to know if you have already found the answers to your questions
Thank you
stater is offline   Reply With Quote

Old   July 25, 2016, 09:38
Default
  #3
Member
 
Jerry
Join Date: Oct 2013
Location: Salt Lake City, UT, USA
Posts: 52
Rep Power: 5
Jerryfan is on a distinguished road
Hi Friederike,


Are you still stuck with this problem? I found at least two problems with the above code:
First of all, The index of
Quote:
mesh.Sf()[faceI]
shouldn't be faceI. It should be faces[faceI] so that you can get the global face index.
Secondly, you cannot get the surface area vector for boundary faces as Sf() only contains area vectors for internal faces.

As for why all the vector components stay negative, it is because of the mesh (all the surface normal directions are positive). For example, face 0 seems to be negative for cell 1 in x direction, but because of the owner and neighbor rule, it's always pointing from cell 0 (owner) to cell 1 (neighbor) such that it's still (-1, 0, 0).

As for why y-component is always 0, the reason is that you will not be able to get the surface vector based on Sf() even if you correct the index as suggested above. You have to access the boundary faces through the fvBoundaryMesh variable boundary_.

I hope it can help you.
LogiDF likes this.
Jerryfan is offline   Reply With Quote

Old   July 27, 2016, 13:00
Default
  #4
New Member
 
stater's Avatar
 
H. Omar
Join Date: Mar 2013
Posts: 19
Rep Power: 5
stater is on a distinguished road
Hi,

For the first question. I think the negative value of vector components is due to the presence of the "-" character in the code just near the mesh.Sf()[faceI]

Best regards
stater is offline   Reply With Quote

Old   July 27, 2016, 14:40
Default
  #5
Member
 
Jerry
Join Date: Oct 2013
Location: Salt Lake City, UT, USA
Posts: 52
Rep Power: 5
Jerryfan is on a distinguished road
Hi stater,


You are right. As I mentioned above, all the surface normal directions are positive. After putting am "-" sign in front, all becomes negative. In addition to this, what I was trying to say above is that some surfaces "seem" to have negative direction, but because of the owner-neighbour convention, they are still positive.
Jerryfan is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
small question about the functionalities of topological changes in OpenFoam ngj OpenFOAM Running, Solving & CFD 2 February 28, 2013 11:02
Question Re Engineering Data Source imnull ANSYS 0 March 5, 2012 14:51
internal field question - PitzDaily Case atareen64 OpenFOAM Running, Solving & CFD 2 January 26, 2011 16:26
question on bounday layer modeling Wen Long Main CFD Forum 2 November 12, 2005 18:29
Poisson Solver question Suresh Main CFD Forum 3 August 12, 2005 04:37


All times are GMT -4. The time now is 06:44.