meshio

:spider_web: input/output for many mesh formats

https://github.com/nschloe/meshio

Science Score: 77.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    7 of 67 committers (10.4%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.8%) to scientific vocabulary

Keywords

engineering mathematics mesh meshing pypi python vtk

Keywords from Contributors

fem finite-elements finite-element-analysis closember mesh-processing meshviewer open-science gtk qt tk
Last synced: 6 months ago · JSON representation ·

Repository

:spider_web: input/output for many mesh formats

Basic Info
  • Host: GitHub
  • Owner: nschloe
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 12.5 MB
Statistics
  • Stars: 2,094
  • Watchers: 40
  • Forks: 421
  • Open Issues: 224
  • Releases: 81
Topics
engineering mathematics mesh meshing pypi python vtk
Created over 10 years ago · Last pushed over 1 year ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation

README.md

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

```sh 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

```python 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

```python 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. pointdata={"T": [0.3, -1.2, 0.5, 0.7, 0.0, -3.0]}, # Each item in cell data must match the cells array celldata={"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.writepointscells("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

python 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

python 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.

Owner

  • Name: Nico Schlömer
  • Login: nschloe
  • Kind: user
  • Location: Berlin, Germany
  • Company: Monday Tech

Mathematics, numerical analysis, scientific computing, Python. Always interested in new problems.

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Schlömer"
  given-names: "Nico"
  orcid: "https://orcid.org/0000-0001-5228-0946"
title: "meshio: Tools for mesh files"
doi: 10.5281/zenodo.1173115
url: https://github.com/nschloe/meshio
license: MIT

GitHub Events

Total
  • Issues event: 19
  • Watch event: 201
  • Issue comment event: 24
  • Pull request event: 14
  • Fork event: 34
Last Year
  • Issues event: 19
  • Watch event: 201
  • Issue comment event: 24
  • Pull request event: 14
  • Fork event: 34

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 2,730
  • Total Committers: 67
  • Avg Commits per committer: 40.746
  • Development Distribution Score (DDS): 0.337
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Nico Schlömer n****r@g****m 1,809
G. D. McBain g****n@p****m 200
Keurfon Luu k****u@o****m 159
Christos Tsolakis c****s@c****u 79
Tianyi Li t****a@g****m 52
Matthias Hochsteger m****r@c****m 32
Nils Wagner n****r@i****e 30
Vicente Mataix Ferrándiz v****x@c****u 29
Eirik Keilegavlen E****n@u****o 28
Vladimir Lukes v****s@k****z 27
Chris Barnes b****c@j****g 25
Lisandro Dalcin d****l@g****m 24
hillyuan h****p@g****m 19
eolianoe e****e 16
Claas Abert c****t@u****t 15
Miche Jansen m****n@g****m 14
MuellerSeb m****b@p****e 11
Matthias Rambausek m****k@g****m 11
Scott Barlow 3****5 10
bwoodsend b****d@g****m 10
Clement Moreau c****4@g****m 9
pre-commit-ci[bot] 6****] 9
Kristoffer k****n@o****m 8
Abhinav Gupta i****i@g****m 7
Leo Schwarz m****l@l****m 7
Jan Blechta b****a@k****z 7
G. D. McBain g****n@m****m 7
Jesusbill i****c@a****m 6
cbcoutinho c****o@g****m 6
Sebastian Bachmann b****n@i****t 5
and 37 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 142
  • Total pull requests: 78
  • Average time to close issues: 4 months
  • Average time to close pull requests: 6 months
  • Total issue authors: 127
  • Total pull request authors: 60
  • Average comments per issue: 2.06
  • Average comments per pull request: 1.35
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 21
  • Pull requests: 20
  • Average time to close issues: N/A
  • Average time to close pull requests: 2 months
  • Issue authors: 17
  • Pull request authors: 13
  • Average comments per issue: 0.38
  • Average comments per pull request: 0.25
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • Mayakruha (4)
  • reox (3)
  • gdmcbain (3)
  • user27182 (2)
  • sigvaldm (2)
  • martin-bernhard (2)
  • amit112amit (2)
  • shimwell (2)
  • matnoel (2)
  • tedtroxell (2)
  • gertjanvanzwieten (2)
  • aaguirreme (1)
  • frankeye (1)
  • NjJu1 (1)
  • jeffrey-cochran (1)
Pull Request Authors
  • kaiserls (10)
  • mgorny (4)
  • mwestphal (4)
  • matnoel (3)
  • YuanWenqing (3)
  • jord1e (2)
  • RemDelaporteMathurin (2)
  • ly16302 (2)
  • baxmittens (2)
  • tianyikillua (2)
  • sridhar-mani (2)
  • musicinmybrain (2)
  • nschloe (2)
  • davidcortesortuno (2)
  • mhochsteger (2)
Top Labels
Issue Labels
needs triage (13) new format (12) gmsh (10) needs info (3)
Pull Request Labels

Packages

  • Total packages: 4
  • Total downloads:
    • pypi 262,169 last-month
  • Total docker downloads: 148,504
  • Total dependent packages: 135
    (may contain duplicates)
  • Total dependent repositories: 310
    (may contain duplicates)
  • Total versions: 487
  • Total maintainers: 2
pypi.org: meshio

I/O for many mesh formats

  • Documentation: https://meshio.readthedocs.io/
  • License: The MIT License (MIT) Copyright (c) 2015-2021 Nico Schlömer et al. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  • Latest release: 5.3.5
    published about 2 years ago
  • Versions: 213
  • Dependent Packages: 113
  • Dependent Repositories: 283
  • Downloads: 262,169 Last month
  • Docker Downloads: 148,504
Rankings
Dependent packages count: 0.2%
Dependent repos count: 0.9%
Downloads: 1.3%
Average: 1.4%
Stargazers count: 1.7%
Docker downloads count: 1.8%
Forks count: 2.8%
Maintainers (1)
Last synced: 6 months ago
proxy.golang.org: github.com/nschloe/meshio
  • Versions: 213
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Forks count: 1.5%
Stargazers count: 1.6%
Average: 5.9%
Dependent packages count: 9.6%
Dependent repos count: 10.8%
Last synced: 6 months ago
conda-forge.org: meshio
  • Versions: 58
  • Dependent Packages: 20
  • Dependent Repositories: 27
Rankings
Dependent packages count: 3.2%
Dependent repos count: 7.1%
Average: 7.5%
Forks count: 9.4%
Stargazers count: 10.4%
Last synced: 6 months ago
spack.io: py-meshio

MeshIO is a Python library to read and write many mesh formats.

  • Versions: 3
  • Dependent Packages: 2
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Forks count: 5.3%
Stargazers count: 6.2%
Average: 7.6%
Dependent packages count: 19.0%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/ci.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • codecov/codecov-action v1 composite
  • nschloe/action-cached-lfs-checkout v1 composite
  • pre-commit/action v2.0.3 composite
pyproject.toml pypi
  • importlib_metadata python_version<'3.8'
  • numpy >=1.20.0