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.2.tar.gz (217.2 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.2-py3-none-any.whl (202.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for meshlane-5.4.2.tar.gz
Algorithm Hash digest
SHA256 2897bcea373ceaa18b2613cf3764af23f956a87bb8fe5ed82a69fcd62636d0aa
MD5 245c345a2dfb7dd86381416198872ad6
BLAKE2b-256 3db5565a42b675b76b3df5dbadde5439a45664d472e73df01d9e1f0bd3db97c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshlane-5.4.2.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.2-py3-none-any.whl.

File metadata

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

File hashes

Hashes for meshlane-5.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e37b1db41bf2e266a7d5b4f01e6e4410c02672614e4be46f8064103723f132ba
MD5 8f39cfb7647ad764e7903c1480fce267
BLAKE2b-256 7537253f5c93ef9c38b503985d8979b7b1f80602a74594ddd93aee0b75d8f8e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshlane-5.4.2-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