# 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

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
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