Metadata-Version: 2.4
Name: meshRW
Version: 1.6.1
Summary: meshRW is a Python module that proposes basic readers and writers for msh (gmsh) and vtk (Paraview).
Project-URL: Homepage, https://github.com/luclaurent/meshRW
Project-URL: Repository, https://github.com/luclaurent/meshRW
Project-URL: Issues, https://github.com/luclaurent/meshRW/issues
Author-email: "L. Laurent" <luc.laurent@lecnam.net>
License: MIT License
        
        Copyright (c) 2021 luclaurent
        
        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.
License-File: AUTHORS
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Requires-Dist: gmsh
Requires-Dist: loguru
Requires-Dist: lxml
Requires-Dist: numpy
Requires-Dist: pytest
Requires-Dist: pytest-cov
Requires-Dist: vtk
Provides-Extra: dev
Requires-Dist: ruff>=0.8; extra == 'dev'
Provides-Extra: docs
Requires-Dist: furo>=2024.8.6; extra == 'docs'
Requires-Dist: myst-parser>=3.0; extra == 'docs'
Requires-Dist: sphinx>=7.4; extra == 'docs'
Description-Content-Type: text/markdown

# meshRW

![GitHub](https://img.shields.io/github/license/luclaurent/meshRW?style=flat-square)
[![PyPI release](https://img.shields.io/pypi/v/meshrw.svg)](https://pypi.org/project/meshrw/)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.14514789.svg)](https://doi.org/10.5281/zenodo.14514789)
![CI tests](https://github.com/luclaurent/meshRW/actions/workflows/CI-pytest.yml/badge.svg)
![code coverage](https://raw.githubusercontent.com/luclaurent/meshRW/refs/heads/coverage-badge/coverage.svg)
[![Documentation](https://app.readthedocs.org/projects/meshrw/badge/?version=latest)](https://meshrw.readthedocs.io/en/latest/)

meshRW is a lightweight Python library to read/write mesh files for Gmsh and VTK-based workflows.

## What it provides

- Read legacy Gmsh meshes (`.msh`, v2.2).
- Write Gmsh meshes (`.msh`) with static or transient fields.
- Write legacy VTK (`.vtk`) and XML VTK (`.vtu` + `.pvd`) outputs.
- Export nodal and elemental data, including time-series results.

## Installation

```bash
pip install meshRW
```

For contributors (lint + docs tooling):

```bash
pip install -e .[dev,docs]
```

## Quick start

### Read a Gmsh mesh

```python
from meshRW import msh

mesh = msh.mshReader(filename="input.msh", dim=3)
nodes = mesh.getNodes()
elements = mesh.getElements(dictFormat=True)
```

### Write a VTK/VTU result

```python
from meshRW import vtk2

vtk2.vtkWriter(
    filename="output.vtu",
    nodes=nodes,
    elements=elements,
    fields=[],
)
```

## Writer input model

Writers share the same core data model:

- `nodes`: array-like `(n_nodes, 2|3)`.
- `elements`: a dictionary or list of dictionaries with `connectivity`, `type`, and optional `physgrp`.
- `fields`: list of dictionaries with `name`, `type` (`nodal`/`elemental`), `dim`, `data`, and optional time metadata (`nbsteps`, `steps`).

## Format notes

- `.msh`: use `meshRW.msh` (legacy) or `meshRW.msh2` (Gmsh API-backed, version options).
- `.vtk`: use `meshRW.vtk` (legacy writer).
- `.vtu` / `.pvd`: use `meshRW.vtk2` for XML and transient outputs.

## Documentation

- Hosted documentation on Read the Docs: [meshrw.readthedocs.io](https://meshrw.readthedocs.io/en/latest/)
- Project docs index: [docs/index.md](docs/index.md)
- Getting started: [docs/getting-started.md](docs/getting-started.md)
- API overview: [docs/api-overview.md](docs/api-overview.md)
- Format support: [docs/format-support.md](docs/format-support.md)
- Development guide: [docs/development.md](docs/development.md)

## Development and quality

- Tests: `pytest meshRW/tests -q`
- Lint: `ruff check meshRW`
- Docs build: `sphinx-build -W --keep-going -b html docs docs/_build/html`

See [CONTRIBUTING.md](CONTRIBUTING.md) for the full workflow.

## Related projects

- [meshio](https://github.com/nschloe/meshio)

## License

This project is licensed under the MIT License. See [LICENSE](LICENSE).
