Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Determine cell and face centroids of HDF5 Fluent files in Python using h5py

TAGGED: ,

    • Kenneth.Fung
      Subscriber

      Hi,

      I have a bunch of data files which I would like to post-process in Python. To do this, I use the h5py library to import the data files.

      Does anyone know how to determine the centroids of the cells and boundary faces from the mesh, case, or data files?

      Using the HDF5 viewer, I found that the mesh and case files contains nodal coordinates under "/meshes/1/nodes/coords/3404", but I could not find any information which indicates which cell/face corresponds to which collection of nodes.

    • Rob
      Forum Moderator

      The best way to figure things like this out is to create a very simple model (10-20 cells) with a simple result (initialise to constant values) and then start working through what's written out. Some of the data structures are covered here https://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v231/en/flu_ug/flu_ug_chp_fileformat.html 

    • Kenneth.Fung
      Subscriber

      My issue is with the groups in the case data file. Under "/meshes/1/cells", there's "ctype" and "zoneTopology", neither of which seems to give information about the actual connectivity of the mesh. In the link you posted, it also seems that the case file under "/meshes/1/cells" in Figure 1 is different to that shown in Figure 3. My case file resembles Figure 3, where there the "/meshes/1/cells/nodes" group doesn't exist, so I'm rather confused by this.

    • Rob
      Forum Moderator

      Are you using 2d or 3d?  I know people who've been tinkering with the case and data files for "stuff" but no details, and nothing other than DOC that I can share. This assumes there's nothing in Minerva or Optislang documentation as those tools take Fluent data for various purposes. 

    • Kenneth.Fung
      Subscriber

      I'm using 3d. I'm using it to perform some calculations on the data, which would be easier to do with Python than a UDF.

    • Kenneth.Fung
      Subscriber

      I’ve figured out a workaround to get the cell and face centroids: I can just assign the x,y,z centroid locations to 3 UDM memory locations.

      However, I also need to get the node coordinates corresponding to each boundary face for some other calculations. Are you able to help me confirm whether my following 2 interpretations of the HDF5 case file groups are correct?

      1. I first need to determine whether or not a face is a boundary face. Boundary faces will have only have c0, but not c1. Based on analyzing a few faces on the boundary, I believe that the indexing in “/meshes/faces/c0/1” indexes boundary faces first, followed by interior faces. E.g. if there’s 10 faces and 3 of them are boundary faces, then index 0 to 2 corresponds to boundary faces, and index 3 to 9 correspond to interior faces). Is this correct?

      2. Once I know the boundary faces, I need to determine their corresponding node locations. The case file has 2 groups in “/meshes/1/faces/nodes/1/”: “nnodes” and “nodes”. “nnodes” seems to correspond to the number of nodes of each face. I’m not quite sure what the integers in “nodes” represents – however, the size of the array seems to match up if I sum up all the numbers in “nnodes”, so my guess is that these are the node numbers corresponding to each face. E.g. if there’s 4 nodes per face, then index 0 to 3 contains the node indices of face 1, index 4 to 7 contains the node indices of face 2, etc. Is this correct?

    • Rob
      Forum Moderator

      A boundary face will only have C0 (check the UDF manual as it's in there), but a boundary cell could have more than one external facet. 

      I don't know about the node index, some nodes will be shared but I don't know how they're defined. 

Viewing 6 reply threads
  • The topic ‘Determine cell and face centroids of HDF5 Fluent files in Python using h5py’ is closed to new replies.