Skip to main content

meshlane

I/O for mesh files: convert smoothly between many formats.

License: MIT PyPI version Code style: black

meshlane is an actively maintained descendant of meshio by Nico Schlömer. It builds directly on meshio's codebase and history, and extends it with new format support and fixes geared toward FEA/CFD interoperability (code_aster, Ansys, OpenFOAM, Salome/MED). See Relationship to meshio.

There are many mesh formats for representing unstructured meshes. meshlane reads and writes all of the following and converts smoothly between them:

Abaqus (.inp), ANSYS msh (.msh), Ansys/APDL input (.inp, .cdb), 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 (formats 2.2, 4.0, 4.1, .msh), OBJ (.obj), OFF (.off), OpenFOAM polyMesh (.foam, read only), 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).

What meshlane adds over meshio

  • OpenFOAM polyMesh reader: ASCII and binary, arbitrary cell types (tri / quad / polyhedra).
  • Ansys/APDL .inp / .cdb reader & writer for FEA interoperability.
  • MED/Salome improvements:
    • multi-mesh files (several meshes in one .med)
    • polygon cell support, including ragged/Voronoi meshes
    • multi-timestep result fields, with NDT/NOR/PDT preserved
    • round-trip of mesh metadata, field units and component names
    • MED 4.1 bitmask metadata and HDF5 link-creation-order, so files stay readable by Salome / medfile / mdump
    • extended field data types (float32/64, int32/64)
    • robust handling of missing FAS / NOEUD / GRO sections and merged cell blocks
  • Encoding and parsing robustness fixes (Latin-1 metadata, group name parsing).

Installation

meshlane is available on PyPI:

pip install meshlane[all]

([all] pulls in the optional dependencies netCDF4 and h5py, required for the CGNS, H5M, MED and XDMF formats. By default only numpy is needed.)

To install from source instead:

git clone https://github.com/simvia-tech/meshlane.git
cd meshlane
pip install -e .[all]

Usage

Command line:

meshlane convert    input.msh output.vtk   # convert between two formats
meshlane info       input.xdmf             # show some info about the mesh
meshlane compress   input.vtu              # compress the mesh file
meshlane decompress input.vtu              # decompress the mesh file
meshlane binary     input.msh              # convert to binary format
meshlane ascii      input.msh              # convert to ASCII format

In Python, read a mesh:

import meshlane

mesh = meshlane.read(
    filename,                # path, os.PathLike, or a buffer/open file
    # file_format="stl",     # optional; inferred from the extension
)
# mesh.points, mesh.cells, mesh.cells_dict, ...

Write a mesh:

import meshlane

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 = meshlane.Mesh(
    points,
    cells,
    point_data={"T": [0.3, -1.2, 0.5, 0.7, 0.0, -3.0]},
    cell_data={"a": [[0.1, 0.2], [0.4]]},
)
mesh.write("foo.vtk")

# Or, equivalently:
meshlane.write_points_cells("foo.vtk", points, cells)

For both reading and writing you may pass file_format= explicitly (e.g. to force ASCII over binary VTK).

Time series

The XDMF format supports time series sharing one mesh:

with meshlane.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})
with meshlane.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)

Testing

tox

(Some test meshes are stored with Git LFS; run git lfs pull after cloning.)

Relationship to meshio

meshlane is a fork of meshio. We kept the full git history and authorship so the original work remains properly attributed. We started a separate project, rather than only contributing upstream, to move faster on the FEA/CFD interoperability features we need (code_aster, Ansys, code_saturne, OpenFOAM, Salome, etc.) and to maintain them under active development.

meshio is no longer actively maintained. Simvia is a company willing to commit time and people to keep this project alive and moving forward.

Contributing

Everyone is welcome, individuals and companies alike. If you want to help us keep meshlane maintained, we would be glad to have you on board. We will do our best to triage issues quickly and to give timely, constructive feedback on pull requests.

Huge thanks to Nico Schlömer and all meshio contributors for the foundation this project is built on.

License

meshlane is published under the MIT license, the same as meshio. Copyright is retained by the original meshio authors and the meshlane contributors.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

meshlane-5.4.3.tar.gz (219.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

meshlane-5.4.3-py3-none-any.whl (203.5 kB view details)

Uploaded Python 3

File details

Details for the file meshlane-5.4.3.tar.gz.

File metadata

  • Download URL: meshlane-5.4.3.tar.gz
  • Upload date:
  • Size: 219.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for meshlane-5.4.3.tar.gz
Algorithm Hash digest
SHA256 1c151cf08c45ba85dc67485cc46442236c71346f43d0ee1a1cc56f2bec5f58a4
MD5 4736d79638b541c920c4873a76f5a059
BLAKE2b-256 3d15e805074996a994e4146819558e4c82c7c12fe06d2029bf99178510fc7337

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshlane-5.4.3.tar.gz:

Publisher: release.yml on simvia-tech/meshlane

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file meshlane-5.4.3-py3-none-any.whl.

File metadata

  • Download URL: meshlane-5.4.3-py3-none-any.whl
  • Upload date:
  • Size: 203.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for meshlane-5.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e51bb0560c93acfd7efb26b89b68447c680b53c6fa59a8cdf1cffa2c01431fac
MD5 ef54ba15d1ee8dfee8d43e8c9052e529
BLAKE2b-256 b976498df4eae1305482daebbe15736e05e6a717c4f31f4b564caa84a6dbae57

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshlane-5.4.3-py3-none-any.whl:

Publisher: release.yml on simvia-tech/meshlane

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page