meshio 5.3.5


pip install meshio

  Latest version

Released: Jan 31, 2024


Meta
Author: Nico Schlömer
Requires Python: >=3.8

Classifiers

Development Status
  • 5 - Production/Stable

Programming Language
  • Python
  • Python :: 3
  • Python :: 3.8
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12

Intended Audience
  • Science/Research

License
  • OSI Approved :: MIT License

Operating System
  • OS Independent

Topic
  • Scientific/Engineering
  • Utilities

meshio

I/O for mesh files.

PyPi Version Anaconda Cloud Packaging status PyPI pyversions DOI GitHub stars Downloads

Discord

gh-actions codecov LGTM Code style: black

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

Abaqus (.inp), ANSYS msh (.msh), AVS-UCD (.avs), CGNS (.cgns), DOLFIN XML (.xml), Exodus (.e, .exo), FLAC3D (.f3grid), H5M (.h5m), Kratos/MDPA (.mdpa), Medit (.mesh, .meshb), MED/Salome (.med), Nastran (bulk data, .bdf, .fem, .nas), Netgen (.vol, .vol.gz), Neuroglancer precomputed format, Gmsh (format versions 2.2, 4.0, and 4.1, .msh), OBJ (.obj), OFF (.off), PERMAS (.post, .post.gz, .dato, .dato.gz), PLY (.ply), STL (.stl), Tecplot .dat, TetGen .node/.ele, SVG (2D output only) (.svg), SU2 (.su2), UGRID (.ugrid), VTK (.vtk), VTU (.vtu), WKT (TIN) (.wkt), XDMF (.xdmf, .xmf).

(Here's a little survey on which formats are actually used.)

Install with one of

pip install meshio[all]
conda install -c conda-forge meshio

([all] pulls in all optional dependencies. By default, meshio only uses numpy.) You can then use the command-line tool

meshio convert    input.msh output.vtk   # convert between two formats

meshio info       input.xdmf             # show some info about the mesh

meshio compress   input.vtu              # compress the mesh file
meshio decompress input.vtu              # decompress the mesh file

meshio binary     input.msh              # convert to binary format
meshio ascii      input.msh              # convert to ASCII format

with any of the supported formats.

In Python, simply do

import meshio

mesh = meshio.read(
    filename,  # string, os.PathLike, or a buffer/open file
    # file_format="stl",  # optional if filename is a path; inferred from extension
    # see meshio-convert -h for all possible formats
)
# mesh.points, mesh.cells, mesh.cells_dict, ...

# mesh.vtk.read() is also possible

to read a mesh. To write, do

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)

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

Time series

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

with meshio.xdmf.TimeSeriesWriter(filename) as writer:
    writer.write_points_cells(points, cells)
    for t in [0.0, 0.1, 0.21]:
        writer.write_data(t, point_data={"phi": data})

and read it with

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

ParaView plugin

gmsh paraview *A Gmsh file opened with ParaView.*

If you have downloaded a binary version of ParaView, you may proceed as follows.

  • Install meshio for the Python major version that ParaView uses (check pvpython --version)
  • Open ParaView
  • Find the file paraview-meshio-plugin.py of your meshio installation (on Linux: ~/.local/share/paraview-5.9/plugins/) and load it under Tools / Manage Plugins / Load New
  • Optional: Activate Auto Load

You can now open all meshio-supported files in ParaView.

Performance comparison

The comparisons here are for a triangular mesh with about 900k points and 1.8M triangles. The red lines mark the size of the mesh in memory.

File sizes

file size

I/O speed

performance

Maximum memory usage

memory usage

Installation

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

pip install meshio

to install.

Additional dependencies (netcdf4, h5py) are required for some of the output formats and can be pulled in by

pip install meshio[all]

You can also install meshio from Anaconda:

conda install -c conda-forge meshio

Testing

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

tox

License

meshio is published under the MIT license.

5.3.5 Jan 31, 2024
5.3.4 Mar 11, 2022
5.3.3 Mar 10, 2022
5.3.2 Feb 24, 2022
5.3.1 Feb 24, 2022
5.3.0 Jan 24, 2022
5.2.6 Jan 22, 2022
5.2.5 Jan 20, 2022
5.2.4 Jan 20, 2022
5.2.3 Jan 19, 2022
5.2.2 Dec 20, 2021
5.2.0 Dec 18, 2021
5.1.2 Dec 17, 2021
5.1.1 Dec 12, 2021
5.1.0 Dec 11, 2021
5.0.6 Dec 10, 2021
5.0.5 Nov 30, 2021
5.0.4 Nov 22, 2021
5.0.3 Nov 17, 2021
5.0.2 Sep 30, 2021
5.0.1 Sep 23, 2021
5.0.0 Aug 06, 2021
4.4.6 Jun 04, 2021
4.4.5 May 27, 2021
4.4.4 May 27, 2021
4.4.3 May 06, 2021
4.4.2 May 04, 2021
4.4.1 Apr 29, 2021
4.4.0 Apr 29, 2021
4.3.13 Apr 21, 2021
4.3.12 Apr 08, 2021
4.3.11 Mar 09, 2021
4.3.10 Feb 22, 2021
4.3.9 Feb 15, 2021
4.3.8 Dec 22, 2020
4.3.7 Dec 21, 2020
4.3.6 Nov 26, 2020
4.3.5 Nov 12, 2020
4.3.4 Nov 05, 2020
4.3.3 Nov 02, 2020
4.3.2 Oct 27, 2020
4.3.1 Oct 15, 2020
4.3.0 Oct 07, 2020
4.2.2 Sep 30, 2020
4.2.1 Sep 25, 2020
4.2.0 Sep 10, 2020
4.1.1 Aug 24, 2020
4.1.0 Aug 08, 2020
4.0.16 Jun 29, 2020
4.0.15 Jun 10, 2020
4.0.13 May 13, 2020
4.0.12 Apr 28, 2020
4.0.11 Apr 22, 2020
4.0.10 Mar 17, 2020
4.0.9 Mar 11, 2020
4.0.8 Feb 28, 2020
4.0.7 Feb 25, 2020
4.0.6 Feb 24, 2020
4.0.5 Feb 24, 2020
4.0.4 Feb 21, 2020
4.0.3 Feb 21, 2020
4.0.2 Feb 19, 2020
4.0.1 Feb 18, 2020
4.0.0 Feb 18, 2020
3.3.1 Dec 19, 2019
3.3.0 Dec 10, 2019
3.2.15 Nov 24, 2019
3.2.14 Nov 20, 2019
3.2.13 Nov 20, 2019
3.2.12 Nov 17, 2019
3.2.11 Nov 15, 2019
3.2.10 Nov 13, 2019
3.2.9 Nov 13, 2019
3.2.8 Nov 08, 2019
3.2.7 Nov 04, 2019
3.2.6 Oct 25, 2019
3.2.5 Oct 23, 2019
3.2.4 Oct 21, 2019
3.2.3 Oct 21, 2019
3.2.2 Oct 20, 2019
3.2.1 Oct 19, 2019
3.2.0 Oct 08, 2019
3.1.6 Oct 01, 2019
3.1.5 Sep 08, 2019
3.1.4 Sep 03, 2019
3.1.3 Aug 31, 2019
3.1.1 Aug 08, 2019
3.0.7 Aug 05, 2019
3.0.6 Aug 04, 2019
3.0.5 Aug 01, 2019
3.0.4 Jul 30, 2019
3.0.3 Jul 30, 2019
3.0.2 Jul 19, 2019
3.0.1 Jul 18, 2019
3.0.0 Jul 17, 2019
2.3.10 Jun 19, 2019
2.3.9 May 30, 2019
2.3.8 May 15, 2019
2.3.7 Mar 25, 2019
2.3.6 Mar 21, 2019
2.3.5 Mar 07, 2019
2.3.4 Mar 04, 2019
2.3.3 Oct 10, 2018
2.3.2 Oct 09, 2018
2.3.1 Sep 22, 2018
2.3.0 Sep 17, 2018
2.2.5 Sep 04, 2018
2.2.4 Sep 03, 2018
2.2.3 Aug 30, 2018
2.2.2 Aug 29, 2018
2.2.1 Aug 28, 2018
2.2.0 Aug 27, 2018
2.1.0 Jul 31, 2018
2.0.4 Jul 01, 2018
2.0.3 Jun 25, 2018
2.0.2 Jun 19, 2018
2.0.1 Jun 15, 2018
2.0.0 Jun 11, 2018
1.11.20 Jun 10, 2018
1.11.19 May 20, 2018
1.11.18 May 18, 2018
1.11.17 May 14, 2018
1.11.16 May 14, 2018
1.11.15 May 09, 2018
1.11.14 May 03, 2018
1.11.13 Apr 13, 2018
1.11.12 Apr 06, 2018
1.11.11 Mar 30, 2018
1.11.10 Mar 28, 2018
1.11.9 Mar 11, 2018
1.11.8 Mar 07, 2018
1.11.7 Feb 02, 2018
1.11.6 Jan 25, 2018
1.11.5 Jan 21, 2018
1.11.4 Jan 19, 2018
1.11.3 Jan 18, 2018
1.11.2 Jan 11, 2018
1.11.1 Jan 10, 2018
1.11.0 Jan 05, 2018
1.10.8 Dec 21, 2017
1.10.7 Dec 20, 2017
1.10.6 Dec 20, 2017
1.10.5 Dec 19, 2017
1.10.4 Dec 19, 2017
1.10.3 Dec 11, 2017
1.10.2 Dec 06, 2017
1.10.1 Dec 06, 2017
1.10.0 Dec 06, 2017
1.9.4 Nov 23, 2017
1.9.3 Nov 15, 2017
1.9.2 Nov 09, 2017
1.9.1 Nov 08, 2017
1.9.0 Nov 07, 2017
1.8.17 Oct 26, 2017
1.8.16 Sep 12, 2017
1.8.15 Sep 06, 2017
1.8.14 Aug 16, 2017
1.8.13 Aug 15, 2017
1.8.12 Aug 01, 2017
1.8.11 Jul 19, 2017
1.8.10 Jun 21, 2017
1.8.9 Jun 14, 2017
1.8.8 Jun 07, 2017
1.8.7 Jun 06, 2017
1.8.6 Jun 03, 2017
1.8.5 Jun 02, 2017
1.8.4 May 18, 2017
1.8.3 May 17, 2017
1.8.2 May 15, 2017
1.8.1 May 12, 2017
1.8.0 May 12, 2017
1.7.11 May 10, 2017
1.7.10 May 09, 2017
1.7.9 May 09, 2017
1.7.8 May 08, 2017
1.7.7 Apr 14, 2017
1.7.6 Apr 06, 2017
1.7.5 Mar 24, 2017
1.7.4 Mar 14, 2017
1.7.3 Mar 10, 2017
1.7.2 Mar 09, 2017
1.7.1 Feb 08, 2017
1.7.0 Feb 01, 2017
1.6.1 Jan 31, 2017
1.6.0 Jan 22, 2017
1.5.0 Jan 16, 2017
1.4.2 Dec 06, 2016
1.4.1 Sep 06, 2016
1.4.0 Aug 19, 2016
1.3.3 Aug 18, 2016
1.3.2 Jul 12, 2016
1.3.1 Apr 27, 2016
1.3.0 Apr 27, 2016
1.2.1 Feb 01, 2016
1.2.0 Dec 23, 2015
1.1.1 Dec 22, 2015
1.1.0 Dec 18, 2015
1.0.4 Dec 10, 2015
1.0.3 Dec 08, 2015
1.0.2 Dec 03, 2015
1.0.1 Nov 26, 2015
1.0.0 Nov 26, 2015
0.4.3 Nov 23, 2015
0.4.2 Nov 23, 2015
0.4.1 Nov 17, 2015
0.4.0 Nov 17, 2015
0.3.0 Nov 13, 2015
0.2.0 Nov 13, 2015
0.1.4 Nov 12, 2015
0.1.3 Nov 12, 2015
0.1.2 Nov 10, 2015
0.1.1 Nov 10, 2015
0.1.0 Nov 10, 2015

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies:
numpy (>=1.20.0)
rich
importlib-metadata