CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

get number of faces

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By mprinkey

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 14, 2014, 09:24
Default get number of faces
  #1
Senior Member
 
Tom-Robin Teschner
Join Date: Dec 2011
Location: Cranfield, UK
Posts: 204
Rep Power: 16
t.teschner is on a distinguished road
is there an easy way to obtain the number of faces in an arbitrary (hybrid) unstructured mesh with different elements? i am using a CGNS file for my mesh reading but as far as i know the number of faces are not stored ?!

although for now i only have a 2d triangulated mesh, i want to have an algorithm that can deal with a 2d/3d mixed element mesh.

if possible i only want to loop once through my cells and count the faces but avoid duplicates from neighbor cells once i visit them in my loop. is there any good algorithm that can do that??
t.teschner is offline   Reply With Quote

Old   December 14, 2014, 22:11
Default
  #2
Senior Member
 
Michael Prinkey
Join Date: Mar 2009
Location: Pittsburgh PA
Posts: 363
Rep Power: 25
mprinkey will become famous soon enough
I am not familiar with the CGNS format in particular, but unstructured CFD mesh files often contains only vertex (aka node) locations and then lists of elements defined by the element type (HEX, TET, etc) and then an ordered list of vertices compromising each. A quick review of the format seems to indicate this is indeed the case for CGNS unstructured grids.

Of course, finite-volume CFD solvers don't generally care about the vertex locations as part of the calculation. (Since you are talking cells/faces, I'm assuming that you are doing FV and not FE.) The vertex data is primarily used to compute cell volumes and centroids and face area vectors and centroids, and, of course, lists of faces for each cell, the cell pair associated with each face, etc. The process of converting from vertex/element to face/cell data involves a lot of book keeping and geometry. The creation of all of those FV mesh centroids, areas, volumes, and connectivity are all essential before you can do any CFD calculations.

So if you are asking your question with a working code in hand, then you will need to look into the mesh parsing code where face areas, etc. are being computed. Those data all need to be stored somewhere, and a numberOfFaces variable is likely prominent in that code and you can reference it directly to answer your question.

If, however, you are asking your question because you are at the beginning of writing code to parse an input file for use in an FV code, I don't wish to discourage you, but recognize that counting the number of faces is only the tip of the iceberg.

EDIT. To more directly answer your question, you can compute the total number of faces by summing all of the faces on each element (for HEX, add 6; for TET, add 4, etc.). Then add to that the total number of boundary faces. Then divide that by 2.
t.teschner likes this.

Last edited by mprinkey; December 15, 2014 at 01:28.
mprinkey is offline   Reply With Quote

Old   December 15, 2014, 05:08
Default
  #3
Senior Member
 
Tom-Robin Teschner
Join Date: Dec 2011
Location: Cranfield, UK
Posts: 204
Rep Power: 16
t.teschner is on a distinguished road
indeed i am using FV and I am doing some small CFD codes mainly to familiarise myself with unstructured grids (I have only been doing structured grids with FD before).

does nfaces = (nfaces_fluid_zone + nfaces_on_boundaries)/2 hold in general (i mean for 2d/3d meshes with mixed elements (of course adding the number of faces appropriatly for the elements)?

EDIT: ah, i actually see how this formula works, thanks, exactly what i was looking for!
t.teschner 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Other] Mesh Importing Problem cuteapathy ANSYS Meshing & Geometry 2 June 24, 2017 05:29
[mesh manipulation] Mesh Refinement Luiz Eduardo Bittencourt Sampaio (Sampaio) OpenFOAM Meshing & Mesh Conversion 42 January 8, 2017 12:55
foam-extend_3.1 decompose and pyfoam warning shipman OpenFOAM 3 July 24, 2014 08:14
DecomposePar unequal number of shared faces maka OpenFOAM Pre-Processing 6 August 12, 2010 09:01
Unaligned accesses on IA64 andre OpenFOAM 5 June 23, 2008 10:37


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