Converts a mesh written with gmsh to the exodus II format, which is used in common simulations tools, like Peridigm
Are you using this code for research purposes? Please take the time to cite it using this DOI:
python convert.py -i input.msh -o output.g
Note that meshio supprts the same functionality with
meshio-convert input.msh output.e
- VTK Toolkit >= 5.8 (with python bindings)
If you are using Ubuntu, you must use the python-vtk package (sudo apt-get install python-vtk
). There is a bug with the python-vtk6 package which provokes a segmentation fault.
(More information about it here: https://gitlab.kitware.com/vtk/vtk/issues/16009)
The input.msh
file must be generated with Gmsh. Currently, only the following elements are supported:
2D
- 2 = 3-node triangle
- 3 = 4-node quadrangle
3D
- 4 = 4-node tetrahedron
Description of the gmsh format and how it works. An example can be found here. The [brackets] contain comments expanations about each line. More complex files can be found, refer to the gmsh documentation in that case.
$MeshFormat
2.2 0 8
$EndMeshFormat
$Nodes
[The start-tag $Nodes anounces that the nodes are going to be listed]
148
[Number of nodes]
1 2.5 9.5 49.6423745119
[Node number] [Element node point 1] [Elmnt node pt2] [Elmnt node #pt3]
2 2.5 6.5 28.5
3 -2.5 9.5 49.6423745119
4 -2.5 6.5 28.5
...
$EndNodes
[The end-tag $EndNodes anounces that the node list is over]
For detailed information, check this section of gmsh documentation
$Elements
[The start-tag $Elements anounces that the elements are going to be listed]
729
[Number of elements]
1 15 2 0 1 1
[Element number] [Elmnt type] [Elmnt physical entity tag] [Elmnt Geometry point] [Vertex tag]
2 15 2 0 2 2
3 15 2 0 3 3
4 15 2 0 4 4
5 15 2 0 5 5
...
$EndElements
[The end-tag $EndElements anounces that the Elements list is over]
- 1 = 2-node line
- 2 = 3-node line
- 3 = 4-node quadrangle
- 4 = 4-node tetrahedron
- 15 = 1-node point
2D
Mesh generated with gmesh | Exodus geometry visualized with paraview |
---|---|
3D
Mesh generated with gmesh | Exodus geometry visualized with paraview |
---|---|