mesh2vtk is a Python script that converts ANSYS Finite Element Model files (currently focused) into VTK Unstructured Grid (.vtu) files. This tool is designed for visualizing and analyzing FEM data in tools like ParaView.
- Converts FEM nodes and elements to VTK-compatible formats.
- Maps FEM node and element IDs to the
.vtufile (optional). .vtuoutputs in binary or ASCII format.
- Python 3.8 or higher
- Python libraries:
vtknumpy
Install the required libraries using:
pip install vtk numpyRun the script with the following options:
python mesh2vtk.py --inputfile INPUTFILE --outputfile OUTPUTFILE [options]| Option | Description |
|---|---|
--ascii |
Output the .vtu file in ASCII format (default is binary). |
--fem_node_string |
Map FEM node IDs to the .vtu file. |
--fem_element_string |
Map FEM element IDs to the .vtu file. |
python mesh2vtk.py --inputfile model.dat --outputfile model.vtu --ascii --fem_node_string --fem_element_stringThis command:
- Reads
model.dat. - Outputs
model.vtuin ASCII format. - Includes FEM node and element IDs in the output.
- Supports the following ANSYS element types:
| Element Type | Nodes | VTK Cell Type |
|---|---|---|
| Solid 187 | 10 | Quadtratic Tetra (=24) |
| Solid 186 | 20 | Quadratic Hexahedron (=25) |
| Solid 185 | 8 | Hexahedron (=12) |
| Solid 185 | 4 | Tetra (=10) |
| Shell 181 | 4 | Quad (=9) |
| Shell 181 | 3 | Triangle (=5) |
-
The
.vtufile contains (example):- Points
- Cells:
The script outputs key statistics about the generated .vtu file, including:
- Number of points (nodes).
- Number of cells (elements).
- Output file directory and file name
Execution time is displayed at the end of the run, providing insight into processing efficiency.
Built using:
For feedback or contributions, feel free to create an issue or submit a pull request.




