PyGmsh
Gmsh is a powerful mesh generation tool with a scripting language that is notoriously hard to write.
The goal of PyGmsh is to combine the power of Gmsh with the versatility of Python and to provide useful abstractions from the Gmsh scripting language so you can create complex geometries more easily.
To create the above mesh, simply do
import pygmsh as pg
import numpy as np
geom = pg.Geometry()
# Draw a cross.
poly = geom.add_polygon([
[0.0, 0.5, 0.0],
[-0.1, 0.1, 0.0],
[-0.5, 0.0, 0.0],
[-0.1, -0.1, 0.0],
[0.0, -0.5, 0.0],
[0.1, -0.1, 0.0],
[0.5, 0.0, 0.0],
[0.1, 0.1, 0.0]
],
lcar=0.05
)
axis = [0, 0, 1]
geom.extrude(
'Surface{%s}' % poly,
translation_axis=axis,
rotation_axis=axis,
point_on_axis=[0, 0, 0],
angle=2.0 / 6.0 * np.pi
)
print(geom.get_code())
and write the output to a file, e.g., screw.geo. Then use Gmsh to generate the mesh screw.msh,
gmsh -3 screw.geo
You will find this case in the directory test/examples/ along with other small examples.
To convert from Gmsh’s mesh format to other, more common formats (VTK, VTU, Exodus), you can use MeshIO’s meshio-convert. Converting is as easy as
meshio-convert screw.msh screw.vtu
The output file can be visualized with various tools, e.g., ParaView.
Installation
Python Package Index
PyGmsh is available from the Python Package Index, so simply type
pip install pygmsh
to install or
pip install pygmsh -U
to upgrade.
Manual installation
Download PyGmsh from PyPi or GitHub and install it with
python setup.py install
Requirements
PyGmsh depends on
and, obviously, Gmsh.
Usage
Just
import pygmsh as pg
and make use of all the goodies the module provides. The documentation and the examples under test/examples/ might inspire you.
Testing
To run the PyGmsh unit tests, check out this repository and type
nosetests
or
nose2 -s test
Distribution
To create a new release
bump the __version__ number,
create a Git tag,
git tag v0.3.1 git push --tags
and
upload to PyPi:
make upload
License
PyGmsh is published under the MIT license.
Metadata
Release files for pygmsh 2.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pygmsh-2.1.3.tar.gz | 8.3 kB | Without provenance | Details for pygmsh-2.1.3.tar.gz |
Release files / pygmsh-2.1.3.tar.gz
| Download URL | pygmsh-2.1.3.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
837eec3255b6ac698d56bdf1022c431d1f9fcf3f2555ea95fdb489454ec0d657
|
|
BLAKE2b-256 checksum How to use checksums |
ff2310fa6fd12fc97ffe3863e252fa4ca678dd4e2eebbb75f0ec6bc7d9608345
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pygmsh 2.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.