Meshio to convert from Cubit

Hi all!

Does anyone have any experience with converting meshes (with subdomains) from Cubit to XDMF?

Thanks so much for the help!

Rem

For context it is worthwhile adding a link to:

I think it shouldn’t be too hard to convert the facet sets of cubit into something readable by xdmf/hdf5/dolfin.

However, as I do not have any examples of a cubit mesh, and it is using a license I cannot obtain, there isn’t much I can do about this atm.

The key would be to loop through each cell (the connectivity array), then extract the subset of vertices per facet (Depends on the node ordering), and attach the given tag value in an complimentary array.

Once all cells have been looked through, one can reduce the set of facets to a unique set

1 Like

Thank you for the reply. Yes I had stumbled upon this issue in meshio.

I have the educational license of Cubit so I can provide a very simple mesh as exodus if need be.

reading it with meshio, it only shows one cell block for the tets, no triangles…

If you could provide either: a unit square of two cells, or a UnitCubeMesh of 6 tetrahedra or 1 hexahedron with marked facets (preferrably with unique tags on all exterior facets) i can see what I can do.

1 Like

@dokken

Here’s a unit cube mesh with 6 tets.
I marked all 6 surfaces from 1 to 6 using “side sets”.

Executive Exodus summary:
  Number of dimensions     = 3
  Number of element blocks = 1
  Number of sidesets       = 6
  Number of nodesets       = 0
  Number of bc sets        = 1
  Number of elements       = 12
  Number of nodes          = 9

I must admit I’m not sure if the right strategy is to either use Side Sets, or Blocks with surfaces, or even Groups…

I’ll mull this over on my side too

Thanks for the help!
Rem

@RemDelaporteMathurin
I’ve made a small stand-alone repository for mesh conversion.
Currently it supports Exodus2->XDMF

It stores both the parent mesh and facet mesh in the same file:

MWE

from mesh_converter import read_exodus2_data, write_mesh
mesh = read_exodus2_data("test_mesh.e")
write_mesh(mesh, "out_mesh.xdmf")

As I currently do not have a mesh with element tags (as far as I am aware, I cannot really do anything further).
If you can provide further examples I can adapt the code for them

2 Likes

@dokken this looks fantastic! I’ll try it out now!

I’ve produced a mesh with 2 unit cubes with 6 tets each. Each cube is tagged with 1 and 2

In the meantime I’ll read your code to try and understand how things work!

Cheers for this!

Updated reader/writer supporting cell tags (element blocks) available at: GitHub - jorgensd/mesh_converter: A mesh converter from EXODUS 2 to XDMF
Also support for adios 2.10.

Another update
Had to drop sideset support, as it did not work for triangles.

After alot of back and forth with @RemDelaporteMathurin we found a work-around, which is to save the facet markers as element blocks in Cubit. This is now possible to read with the code above.

Hopefully final update
Side-sets now supported. Code tested for triangular and tetrahedral meshes provided by @RemDelaporteMathurin