nschloe / meshio

:spider_web: input/output for many mesh formats
MIT License
1.96k stars 402 forks source link

Labels are not conserved when transforming from .mesh to .vtk format #1258

Open oarcelus opened 2 years ago

oarcelus commented 2 years ago

I am generating a .mesh file with CGAL. The .mesh file saves the labels of each of the mesh points that belong to different phases.

When running the command meshio convert input.mesh output.vtk

However, the resulting .vtk does not save this information. I am doing something wrong here?

reox commented 2 years ago

I think one problem is that vtk files do not contain any point or element label information but just the arrays of nodes and elements, indexed starting with 0. There is the same issue if you convert from abaqus meshes. You might even have meshes where you are missing a lot of labels, for example because your elements are labeled 1,2,3,1000 and in the VTK mesh you will just get elements 0,1,2,3.

I think conserving labels would be really nice, especially if you read label-agnostic meshes and want to select certain elements/nodes in the mesh. For abaqus meshes, for example, all labels are withdrawn when reading in the mesh.

nschloe commented 2 years ago

I could see if the problem still exists in the development version, but I'd need a sample input.mesh.

oarcelus commented 2 years ago

Hi, please find attached the liver.mesh example from CGAL documentation. liver.zip

I just realized that even the meshio.read function does not conserve the labels of mesh elements.