Science Score: 67.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
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.4%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Basic Info
  • Host: GitHub
  • Owner: luclaurent
  • License: mit
  • Language: Python
  • Default Branch: main
  • Size: 35.2 MB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 15
Created over 4 years ago · Last pushed 12 months ago
Metadata Files
Readme License Citation Authors

README.md

meshRW

GitHub pypi release DOI CI-pytest code coverage

meshRW is a Python module that proposes basic readers and writers for msh (gmsh) and vtk/vtu/pvd (Paraview). It proposes:

  • to read basic legacy gmsh mesh files (version: 2.2)
  • to write mesh files including time series fields to any version of gmsh mesh files and legacy (.vtk) and XML (.vtu, with .pvd) VTK mesh file compatible with Paraview.

Installation

Installation via pip install meshRW

Usage

Examples of usage

Examples of usage could be found in tests files: test_msh.py and test_vtk.py.

Read mesh files

meshRW can read msh files only. Notice that no field can be read.

  • For msh format (only Legacy version 2):

    • Read the file

      from meshRW import msh
      dataMesh = msh.mshReader(filename=<name of the file>, dim=<2 or 3>)
      

      Argument dim (which is optional) could be switched to the value 2 in order to force to extract nodes coordinates in 2D (z-axis coordinate will be removed).

    • Get coordinates of the nodes

       nodes = dataMesh.getNodes()
      
    • Get the list of tags number

       tags = dataMesh.getTags() 
      
    • Get the list of types of elements

       tags = dataMesh.getTypes() 
      
    • Get the list of elements

       elements = dataMesh.getElements(type=<types of elements>, tag=<tags>, dictFormat=<True or False>)
      

      The getElements property

Write mesh files

meshRW can write msh and vtk files. Basic static and time dependent nodal and elemental fields can be written aswell.

The common syntax for writers is the following

    from meshRW import XXXX

        XXXX.zzzzWriter(
            filename = <name of the file>,
            nodes = <array of nodes coordinates>,
            title = <title of the file> (optional),
            elements = [
                {
                    'connectivity': <name of the file>,
                    'type': <type (string) of elements (TRI3, TET4...)>,
                    'physgrp': <list/array of physical groups>,
                },...
            ],
            fields = [
                {
                    'data': <array of data>,
                    'type': <type of data ('nodal' or 'elemental')>,
                    'dim': <ndimension of data's array>,
                    'name': <name of the field>,
                },            
                {
                    'data': <array of data>,
                    'type': <name of the file>,
                    'dim': <dimension of data's array>,
                    'name': <name of the field>,
                    'nbsteps': <number of steps (transient field for instance)>,
                    'steps': <list of steps (time steps for instance)>
                    },...
            ],  
            opts = {...} (dictionary of specific options)
        )
  • For msh format (based on Legacy format, version 2.2 only with class msh and all meshes format provided by gmsh using class msh2):

    • for classical legacy file (not use the gmsh's libAPI) could be accessed by choosing XXXX = msh and zzzz=msh (msh.mshWriter(...))
    • for any kind of legacy file (not use the gmsh's libAPI) could be accessed by choosing XXXX = msh2 and zzzz=msh (msh2.mshWriter(...))

NB: * filename must contain .msh extension * opts could be (for msh2 only) {'version': VV} (VV could be equal to 2, 2.2, 4, 4.1 that corresponds to gmsh mesh files version - MshFileVersion) * in the case of time series data, all the fields are given by default in the output file (to obtain one field per file, pass option append = True to the writer).

  • for vtk format (only non-binary legacy)

    • for classical legacy file (not use the VTK library) could be accessed by choosing XXXX = vtk and zzzz=vtk (vtk.vtkWriter(...))
    • for any kind of legacy file (not use the gmsh's libAPI) could be accessed by choosing XXXX = vtk2 and zzzz=vtk (vtk2.vtkWriter(...))

NB: * filename must contain .vtk, .vtu (recommanded) extension * opts could be (for vtk2 only) {'binary': True/False, 'ascii': True/False} (these options force data format in .vtu files) * in the case of time series fields, the fields are written separated series files with the following format : basename.NNN.vtu (NNN correspond the number of the step starting at 0). In this case, a Paraview .pvd file is also generated to declare all the steps and associated mesh files with the time step values.

References

Developments are based on GMSH API documentation, GMSH tutorials, VTK documentation, Kitware blog posts, VTK discourse.

Other similar tools

LICENSE

Copyright 2024 luc.laurent@lecnam.net

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.

Owner

  • Login: luclaurent
  • Kind: user

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: meshRW
type: software
authors:
  - given-names: Luc
    family-names: Laurent
    email: luc.laurent@lecnam.net
    affiliation: "Laboratoire de Mécanique des structures et des systèmes couplés, Conservatoire national des arts et métiers, Paris, France"
    orcid: "https://orcid.org/0000-0002-8935-5929"
identifiers:
  - type: doi
    value: 10.5281/zenodo.14514790
repository-code: "https://github.com/luclaurent/meshRW"
repository: "https://pypi.org/project/meshRW/"
abstract: >-
  meshRW is a Python module that proposes basic readers and
  writers for msh`(gmsh) and vtk/vtu/pvd (Paraview). It
  proposes: (1) to read basic legacy gmsh mesh files (version: 2.2)
  and (2) to write mesh files including time series fields to any
  version of gmsh mesh files and legacy (.vtk) and XML
  (.vtu, with .pvd) VTK mesh file compatible with Paraview.
keywords:
  - meshes
  - input-output
  - gmsh
  - paraview
  - vtk
  - time series
license: MIT
doi: 10.5281/zenodo.14514790

GitHub Events

Total
  • Release event: 18
  • Delete event: 1
  • Push event: 61
  • Create event: 28
Last Year
  • Release event: 18
  • Delete event: 1
  • Push event: 61
  • Create event: 28

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 327 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 13
  • Total maintainers: 1
pypi.org: meshrw

meshRW is a Python module that proposes basic readers and writers for msh (gmsh) and vtk (Paraview).

  • Homepage: https://github.com/luclaurent/meshRW
  • Documentation: https://meshrw.readthedocs.io/
  • 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.
  • Latest release: 1.5.1
    published 12 months ago
  • Versions: 13
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 327 Last month
Rankings
Dependent packages count: 9.9%
Average: 32.7%
Dependent repos count: 55.6%
Maintainers (1)
l2
Last synced: 11 months ago

Dependencies

.github/workflows/CI-publish.yml actions
  • actions-ecosystem/action-regex-match v2 composite
  • actions/checkout main composite
  • actions/download-artifact v4 composite
  • actions/download-artifact main composite
  • actions/setup-python main composite
  • actions/upload-artifact main composite
  • pypa/gh-action-pypi-publish release/v1 composite
  • sigstore/gh-action-sigstore-python v3.0.0 composite
.github/workflows/CI-pytest.yml actions
  • JamesIves/github-pages-deploy-action v4 composite
  • actions/checkout main composite
  • actions/setup-python main composite
  • tj-actions/coverage-badge-py v2 composite
pyproject.toml pypi
  • gmsh *
  • loguru *
  • lxml *
  • numpy *
  • pytest *
  • pytest-cov *
  • vtk ==9.4.0