vtk to gmesh's .msh
I am using meshio to read my vtk file, my vtk file contains 966 2D triangles 1544 3D tetrahedra, when I convert the vtk to gmesh's .msh file an error occurs, he lost the boundary labels that I defined in cell_data. When I try to assign the data from cell_data to gmsh:physical it reports an error that my array is inhomogeneous. I used the code as follows mesh = meshio.read('1.vtk') mesh.cell_data['gmsh:physical'] =mesh.cell_data.pop('CellEntityIds') meshio.write('test_mesh.msh', mesh, file_format='gmsh22')
Hi, While writing VTK for the given example problem in the Meshio script, it throws following error :
import meshio
two triangles and one quad
points = [ [0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0], [2.0, 0.0], [2.0, 1.0], ] cells = [ ("triangle", [[0, 1, 2], [1, 3, 2]]), ("quad", [[1, 4, 5, 3]]), ]
mesh = meshio.Mesh( points, cells, # Optionally provide extra data on points, cells, etc. point_data={"T": [0.3, -1.2, 0.5, 0.7, 0.0, -3.0]}, # Each item in cell data must match the cells array cell_data={"a": [[0.1, 0.2], [0.4]]}, ) mesh.write( "foo.vtk", # str, os.PathLike, or buffer/open file # file_format="vtk", # optional if first argument is a path; inferred from extension )
Alternative with the same options
meshio.write_points_cells("foo.vtk", points, cells)
AttributeError: 'Mesh' object has no attribute 'write'
Its is not writing VTK files and create attribute error