I/O for various mesh formats
Branch: master
Clone or download
nschloe Merge pull request #326 from gdmcbain/325-vector-2D
pad 2d vectors to 3d to write to VTK
Latest commit e18867b Feb 16, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci flake8, black fixes Jun 19, 2018
.github remove line breaks from issue template Jan 11, 2018
logo black logo Sep 4, 2018
meshio pad cell_data to 3D as well as point_data Feb 12, 2019
test black Feb 12, 2019
.bandit pylint fixes in setup.py Feb 14, 2018
.flake8 use flake8 for linting Jun 1, 2018
.gitignore more gitignore Mar 6, 2018
.travis.yml remove lxml Nov 30, 2017
LICENSE.txt version bump Jan 18, 2018
Makefile black format Jul 10, 2018
README.md more readme, black Sep 17, 2018
codecov.yml fix for codecov May 11, 2017
setup.py remove python2 tag Aug 2, 2018



CircleCI codecov Code style: black PyPi Version Debian CI DOI GitHub stars

There are various mesh formats available for representing unstructured meshes. meshio can read and write all of the following and smoothly converts between them:

Simply call

meshio-convert input.msh output.vtu

with any of the supported formats.

In Python, simply call

import meshio

mesh = meshio.read(filename)
# mesh.points, mesh.cells, ...

to read a mesh. To write, do

points = numpy.array([
    [0.0, 0.0, 0.0],
    [0.0, 1.0, 0.0],
    [0.0, 0.0, 1.0],
cells = {
    "triangle": numpy.array([
        [0, 1, 2]
    # Optionally provide extra data on points, cells, etc.
    # point_data=point_data,
    # cell_data=cell_data,
    # field_data=field_data

or explicitly create a mesh object for writing

mesh = meshio.Mesh(points, cells)
meshio.write("foo.vtk", mesh)

For both input and output, you can optionally specify the exact file_format (in case you would like to enforce binary over ASCII VTK, for example).

Time series

The XDMF format supports time series with a shared mesh. You can write times series data using meshio with

writer = meshio.XdmfTimeSeriesWriter(filename)
writer.write_points_cells(points, cells)
for t in [0.0, 0.1, 0.21]:
    writer.write_point_data({"phi": data}, t)

and read it with

reader = meshio.XdmfTimeSeriesReader(filename)
points, cells = reader.read_points_cells()
for k in range(reader.num_steps):
    t, point_data, cell_data = reader.read_data(k)


meshio is available from the Python Package Index, so simply type

pip install -U meshio

to install or upgrade.


To run the meshio unit tests, check out this repository and type



To create a new release

  1. bump the __version__ number,

  2. tag and upload to PyPi:

    make publish


meshio is published under the MIT license.