Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vtk to gmesh's .msh #1497

Open
WangYiKang0 opened this issue Nov 23, 2024 · 1 comment
Open

vtk to gmesh's .msh #1497

WangYiKang0 opened this issue Nov 23, 2024 · 1 comment

Comments

@WangYiKang0
Copy link

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

@10427788
Copy link

10427788 commented Dec 9, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants