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
4 of 35 committers (11.4%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.9%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
:spider_web: Gmsh for Python
Basic Info
Statistics
- Stars: 921
- Watchers: 40
- Forks: 164
- Open Issues: 59
- Releases: 35
Topics
Metadata Files
README.md
Gmsh for Python.
pygmsh combines the power of Gmsh with the versatility of Python. It provides useful abstractions from Gmsh's own Python interface so you can create complex geometries more easily.
To use, install Gmsh itself and pygmsh from pypi:
[sudo] apt install python3-gmsh
pip install pygmsh
This document and the tests/
directory contain many small examples. See
here for the full documentation.
Flat shapes
| |
|
|
| :-------------------------------------------------------------------: | :------------------------------------------------------------------: | :-------------------------------------------------------------------: |
| Polygon | Circle | (B-)Splines |
Codes:
```python import pygmsh
with pygmsh.geo.Geometry() as geom: geom.addpolygon( [ [0.0, 0.0], [1.0, -0.2], [1.1, 1.2], [0.1, 0.7], ], meshsize=0.1, ) mesh = geom.generate_mesh()
mesh.points, mesh.cells, ...
mesh.write("out.vtk")
```
```python import pygmsh
with pygmsh.geo.Geometry() as geom: geom.addcircle([0.0, 0.0], 1.0, meshsize=0.2) mesh = geom.generate_mesh() ```
```python import pygmsh
with pygmsh.geo.Geometry() as geom: lcar = 0.1 p1 = geom.addpoint([0.0, 0.0], lcar) p2 = geom.addpoint([1.0, 0.0], lcar) p3 = geom.addpoint([1.0, 0.5], lcar) p4 = geom.addpoint([1.0, 1.0], lcar) s1 = geom.add_bspline([p1, p2, p3, p4])
p2 = geom.add_point([0.0, 1.0], lcar)
p3 = geom.add_point([0.5, 1.0], lcar)
s2 = geom.add_spline([p4, p3, p2, p1])
ll = geom.add_curve_loop([s1, s2])
pl = geom.add_plane_surface(ll)
mesh = geom.generate_mesh()
```
The return value is always a meshio mesh, so to store it to a file you can
python
mesh.write("test.vtk")
The output file can be visualized with various tools, e.g., ParaView.
With
python
pygmsh.write("test.msh")
you can access Gmsh's native file writer.
Extrusions
|
|
|
|
| :-------------------------------------------------------------------: | :-------------------------------------------------------------------: | :-----------------------------------------------------------------: |
| extrude | revolve | twist |
```python import pygmsh
with pygmsh.geo.Geometry() as geom: poly = geom.addpolygon( [ [0.0, 0.0], [1.0, -0.2], [1.1, 1.2], [0.1, 0.7], ], meshsize=0.1, ) geom.extrude(poly, [0.0, 0.3, 1.0], numlayers=5) mesh = geom.generatemesh() ```
```python from math import pi import pygmsh
with pygmsh.geo.Geometry() as geom: poly = geom.addpolygon( [ [0.0, 0.2, 0.0], [0.0, 1.2, 0.0], [0.0, 1.2, 1.0], ], meshsize=0.1, ) geom.revolve(poly, [0.0, 0.0, 1.0], [0.0, 0.0, 0.0], 0.8 * pi) mesh = geom.generate_mesh() ```
```python from math import pi import pygmsh
with pygmsh.geo.Geometry() as geom: poly = geom.addpolygon( [ [+0.0, +0.5], [-0.1, +0.1], [-0.5, +0.0], [-0.1, -0.1], [+0.0, -0.5], [+0.1, -0.1], [+0.5, +0.0], [+0.1, +0.1], ], meshsize=0.05, )
geom.twist(
poly,
translation_axis=[0, 0, 1],
rotation_axis=[0, 0, 1],
point_on_axis=[0, 0, 0],
angle=pi / 3,
)
mesh = geom.generate_mesh()
```
OpenCASCADE
|
|
|
|
| :------------------------------------------------------------------------: | :---------------------------------------------------------------------------: | :------------------------------------------------------------------: |
| | |
Gmsh also supports OpenCASCADE (occ), allowing for a CAD-style geometry specification.
```python from math import pi, cos import pygmsh
with pygmsh.occ.Geometry() as geom: geom.characteristiclengthmax = 0.1 r = 0.5 disks = [ geom.adddisk([-0.5 * cos(7 / 6 * pi), -0.25], 1.0), geom.adddisk([+0.5 * cos(7 / 6 * pi), -0.25], 1.0), geom.adddisk([0.0, 0.5], 1.0), ] geom.booleanintersection(disks)
mesh = geom.generate_mesh()
```
```python
ellpsoid with holes
import pygmsh
with pygmsh.occ.Geometry() as geom: geom.characteristiclengthmax = 0.1 ellipsoid = geom.add_ellipsoid([0.0, 0.0, 0.0], [1.0, 0.7, 0.5])
cylinders = [
geom.add_cylinder([-1.0, 0.0, 0.0], [2.0, 0.0, 0.0], 0.3),
geom.add_cylinder([0.0, -1.0, 0.0], [0.0, 2.0, 0.0], 0.3),
geom.add_cylinder([0.0, 0.0, -1.0], [0.0, 0.0, 2.0], 0.3),
]
geom.boolean_difference(ellipsoid, geom.boolean_union(cylinders))
mesh = geom.generate_mesh()
```
```python
puzzle piece
import pygmsh
with pygmsh.occ.Geometry() as geom: geom.characteristiclengthmin = 0.1 geom.characteristiclengthmax = 0.1
rectangle = geom.add_rectangle([-1.0, -1.0, 0.0], 2.0, 2.0)
disk1 = geom.add_disk([-1.2, 0.0, 0.0], 0.5)
disk2 = geom.add_disk([+1.2, 0.0, 0.0], 0.5)
disk3 = geom.add_disk([0.0, -0.9, 0.0], 0.5)
disk4 = geom.add_disk([0.0, +0.9, 0.0], 0.5)
flat = geom.boolean_difference(
geom.boolean_union([rectangle, disk1, disk2]),
geom.boolean_union([disk3, disk4]),
)
geom.extrude(flat, [0, 0, 0.3])
mesh = geom.generate_mesh()
```
Mesh refinement/boundary layers
| |
|
|
| :---------------------------------------------------------------------: | :------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: |
| | |
```python
boundary refinement
import pygmsh
with pygmsh.geo.Geometry() as geom: poly = geom.addpolygon( [ [0.0, 0.0], [2.0, 0.0], [3.0, 1.0], [1.0, 2.0], [0.0, 1.0], ], meshsize=0.3, )
field0 = geom.add_boundary_layer(
edges_list=[poly.curves[0]],
lcmin=0.05,
lcmax=0.2,
distmin=0.0,
distmax=0.2,
)
field1 = geom.add_boundary_layer(
nodes_list=[poly.points[2]],
lcmin=0.05,
lcmax=0.2,
distmin=0.1,
distmax=0.4,
)
geom.set_background_mesh([field0, field1], operator="Min")
mesh = geom.generate_mesh()
```
```python
mesh refinement with callback
import pygmsh
with pygmsh.geo.Geometry() as geom: geom.addpolygon( [ [-1.0, -1.0], [+1.0, -1.0], [+1.0, +1.0], [-1.0, +1.0], ] ) geom.setmeshsizecallback( lambda dim, tag, x, y, z: 6.0e-2 + 2.0e-1 * (x2 + y2) )
mesh = geom.generate_mesh()
```
```python
ball with mesh refinement
from math import sqrt import pygmsh
with pygmsh.occ.Geometry() as geom: geom.add_ball([0.0, 0.0, 0.0], 1.0)
geom.set_mesh_size_callback(
lambda dim, tag, x, y, z: abs(sqrt(x**2 + y**2 + z**2) - 0.5) + 0.1
)
mesh = geom.generate_mesh()
```
Optimization
pygmsh can optimize existing meshes, too.
```python import meshio
mesh = meshio.read("mymesh.vtk") optimized_mesh = pygmsh.optimize(mesh, method="") ```
You can also use the command-line utility
pygmsh-optimize input.vtk output.xdmf
where input and output can be any format supported by meshio.
Testing
To run the pygmsh unit tests, check out this repository and type
pytest
Building Documentation
Docs are built using Sphinx.
To build, run
sphinx-build -b html doc doc/_build
License
This software is published under the GPLv3 license.
Owner
- Name: Nico Schlömer
- Login: nschloe
- Kind: user
- Location: Berlin, Germany
- Company: Monday Tech
- Repositories: 97
- Profile: https://github.com/nschloe
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: "pygmsh: A Python frontend for Gmsh" doi: 10.5281/zenodo.1173105 url: https://github.com/nschloe/pygmsh license: GPL-3.0
GitHub Events
Total
- Issues event: 3
- Watch event: 68
- Issue comment event: 2
- Fork event: 7
Last Year
- Issues event: 3
- Watch event: 68
- Issue comment event: 2
- Fork event: 7
Committers
Last synced: 11 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Nico Schlömer | n****r@g****m | 881 |
| Antonio Cervone | a****e@g****m | 51 |
| G. D. McBain | g****n@p****m | 39 |
| Tryfon Antonakakis | t****n@m****h | 23 |
| G. D. McBain | g****n@m****m | 14 |
| Bin Wang | b****3@g****m | 13 |
| Carlos Baptista | c****o@g****m | 11 |
| Andreas Zilian | a****n@u****u | 9 |
| rubenvanstaden | r****n@g****m | 8 |
| Filip Gokstorp | f****p@g****e | 8 |
| nate-sime | n****e@c****u | 8 |
| toothstone | t****e@w****e | 7 |
| pre-commit-ci[bot] | 6****] | 6 |
| dokken | d****2@g****m | 5 |
| Andrew | a****f@l****u | 4 |
| Juan E. Sanchez | j****n@t****m | 3 |
| Dominic Kempf | d****f@i****e | 3 |
| Matthias Bussonnier | b****s@g****m | 2 |
| Léon van Velzen | l****n@p****m | 2 |
| Keurfon Luu | k****u@o****m | 2 |
| Fabian Preiss | f****e | 2 |
| Geordie Drummond McBain | g****e@l****l | 2 |
| ElCondemor | 5****r | 1 |
| Fred F | f****f | 1 |
| Ivan Voznyuk | i****n@m****r | 1 |
| daalgi | d****m@g****m | 1 |
| Simon Chabot | c****v@c****r | 1 |
| Nils Wagner | n****6@g****m | 1 |
| Rémi Delaporte-Mathurin | 4****n | 1 |
| Siwei Chen | me@c****e | 1 |
| and 5 more... | ||
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 80
- Total pull requests: 35
- Average time to close issues: about 2 months
- Average time to close pull requests: 6 days
- Total issue authors: 62
- Total pull request authors: 12
- Average comments per issue: 1.66
- Average comments per pull request: 1.09
- Merged pull requests: 25
- Bot issues: 0
- Bot pull requests: 5
Past Year
- Issues: 5
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 4
- Pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- lucascbarbosa (5)
- YongYahn (3)
- yurivict (3)
- jiangzhangze (3)
- leon-vv (2)
- zhang-qiang-github (2)
- ghost (2)
- bullgom (2)
- firstkingofrome (2)
- MrRicardoLuo (2)
- Zevrap-81 (2)
- asmithAE22 (2)
- connorivy (1)
- loumalouomega (1)
- JianqiangDing (1)
Pull Request Authors
- nschloe (17)
- pre-commit-ci[bot] (5)
- capitalaslash (3)
- arpit15 (2)
- OSliusarenko (1)
- luzpaz (1)
- keurfonluu (1)
- leon-vv (1)
- szabolcsdombi (1)
- sugatoray (1)
- hvasbath (1)
- RemDelaporteMathurin (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 3
-
Total downloads:
- pypi 20,745 last-month
-
Total dependent packages: 22
(may contain duplicates) -
Total dependent repositories: 50
(may contain duplicates) - Total versions: 211
- Total maintainers: 2
pypi.org: pygmsh
Python frontend for Gmsh
- Documentation: https://pygmsh.readthedocs.io/en/latest
- License: GNU General Public License v3 or later (GPLv3+)
-
Latest release: 7.1.17
published about 4 years ago
Rankings
Maintainers (1)
Funding
- https://github.com/sponsors/nschloe
proxy.golang.org: github.com/nschloe/pygmsh
- Documentation: https://pkg.go.dev/github.com/nschloe/pygmsh#section-documentation
- License: gpl-3.0
-
Latest release: v7.1.17+incompatible
published about 4 years ago
Rankings
spack.io: py-pygmsh
Easier Pythonic interface to GMSH.
- Homepage: https://github.com/nschloe/pygmsh
- License: []
-
Latest release: 7.1.17
published over 1 year ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v2 composite
- actions/setup-python v2 composite
- codecov/codecov-action v1 composite
- pre-commit/action v2.0.3 composite
- mock *
- numpy *
- sphinx-autodoc-typehints *
- sphinxcontrib-napoleon *
- gmsh *
- meshio >= 4.3.2, <6
- numpy >= 1.20.0