├── docs ├── _static │ ├── delaunay_3d_01.png │ ├── delaunay_3d_02.png │ ├── csg_tree │ │ ├── csg_tree.png │ │ ├── CREDITS │ │ └── LICENSE │ ├── frontal_delaunay_2d_01.png │ ├── frontal_delaunay_2d_02.png │ ├── logo.svg │ └── small_logo.svg ├── index.md ├── Makefile ├── make.bat └── conf.py ├── packages.txt ├── examples ├── README.rst ├── icosahedron.py ├── capsule.py ├── cylinder.py ├── polygon_with_hole.py └── better_cell_size.py ├── .github ├── ISSUE_TEMPLATE │ ├── config.yml │ ├── maintenance-request.yml │ ├── feature-request.yml │ └── bug-report.yml ├── PULL_REQUEST_TEMPLATE.md ├── release.yml ├── workflows │ ├── update-pr-branch.yml │ ├── auto-approve.yml │ ├── labeler.yml │ ├── testing-and-deployment.yml │ └── publish-to-pypi.yml ├── dependabot.yml ├── config.yml ├── labeler.yml └── DISCUSSION_TEMPLATE │ ├── show-and-tell.yml │ ├── ideas.yml │ └── q-a.yml ├── setup.py ├── SECURITY.md ├── noxfile.py ├── .readthedocs.yaml ├── pyproject.toml ├── .all-contributorsrc ├── tests └── test_skgmsh.py ├── .pre-commit-config.yaml ├── .gitignore ├── CONTRIBUTORS.md ├── README.md ├── CODE_OF_CONDUCT.md ├── CREDITS ├── src └── skgmsh │ └── __init__.py ├── CONTRIBUTING.md └── LICENSE /docs/_static/delaunay_3d_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pyvista/scikit-gmsh/HEAD/docs/_static/delaunay_3d_01.png -------------------------------------------------------------------------------- /docs/_static/delaunay_3d_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pyvista/scikit-gmsh/HEAD/docs/_static/delaunay_3d_02.png -------------------------------------------------------------------------------- /docs/_static/csg_tree/csg_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pyvista/scikit-gmsh/HEAD/docs/_static/csg_tree/csg_tree.png -------------------------------------------------------------------------------- /docs/_static/frontal_delaunay_2d_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pyvista/scikit-gmsh/HEAD/docs/_static/frontal_delaunay_2d_01.png -------------------------------------------------------------------------------- /docs/_static/frontal_delaunay_2d_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pyvista/scikit-gmsh/HEAD/docs/_static/frontal_delaunay_2d_02.png -------------------------------------------------------------------------------- /docs/_static/csg_tree/CREDITS: -------------------------------------------------------------------------------- 1 | https://commons.wikimedia.org/wiki/File:Csg_tree.png 2 | https://commons.wikimedia.org/wiki/User:Zottie 3 | -------------------------------------------------------------------------------- /packages.txt: -------------------------------------------------------------------------------- 1 | libfltk1.3-dev 2 | libfreetype6-dev 3 | libgeos-dev 4 | libglu1 5 | libocct-data-exchange-dev 6 | libocct-foundation-dev 7 | libxcursor-dev 8 | libxft2 9 | libxinerama1 10 | xvfb 11 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # scikit-gmsh documentation 2 | 3 | :::{include} ../README.md 4 | :parser: myst_parser.sphinx 5 | 6 | ## Contributors 7 | 8 | :::{include} ../CONTRIBUTORS.md 9 | :parser: myst_parser.sphinx 10 | -------------------------------------------------------------------------------- /examples/README.rst: -------------------------------------------------------------------------------- 1 | .. _examples: 2 | 3 | Examples 4 | ======== 5 | 6 | A gallery of examples. Coarse meshes are used whenever possible to make the examples run 7 | fast. Some examples require external packages to be installed. 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Questions and Discussions 4 | url: https://github.com/pyvista/scikit-gmsh/discussions 5 | about: For general questions and discussions 6 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | """scikit-gmsh setuptools packaging.""" 2 | 3 | from __future__ import annotations 4 | 5 | from pathlib import Path 6 | 7 | from setuptools import setup 8 | 9 | this_directory = Path(__file__).parent 10 | long_description = (this_directory / "README.md").read_text() 11 | 12 | setup( 13 | name="scikit-gmsh", 14 | long_description=long_description, 15 | long_description_content_type="text/markdown", 16 | ) 17 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Overview 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ### Details 10 | 11 | - < feature1 or bug1 description > 12 | - < feature2 or bug2 description > 13 | -------------------------------------------------------------------------------- /.github/release.yml: -------------------------------------------------------------------------------- 1 | changelog: 2 | exclude: 3 | labels: 4 | - ignore-for-release 5 | categories: 6 | - title: Breaking Changes 7 | labels: 8 | - breaking-change 9 | - title: New Features 10 | labels: 11 | - enhancement 12 | - title: Bug fixes or behavior changes 13 | labels: 14 | - bug 15 | - title: Documentation 16 | labels: 17 | - documentation 18 | - title: Maintenance 19 | labels: 20 | - maintenance 21 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Security vulnerability reports will be accepted and acted upon for all released versions. 6 | 7 | ## Reporting a Vulnerability 8 | 9 | Allow the community to report potential security vulnerabilities to maintainers and repository owners privately. 10 | [Learn more about private vulnerability reporting](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability). 11 | -------------------------------------------------------------------------------- /noxfile.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S uv run --script 2 | # /// script 3 | # dependencies = ["nox"] 4 | # /// 5 | """Automation using nox.""" 6 | 7 | from __future__ import annotations 8 | 9 | import nox 10 | 11 | nox.needs_version = "2024.10.9" 12 | nox.options.default_venv_backend = "uv|virtualenv" 13 | 14 | 15 | @nox.session(python=["3.11", "3.12", "3.13"]) 16 | def tests(session: nox.Session) -> None: 17 | """Run the unit and regular tests.""" 18 | session.install(".[test]") 19 | session.run("pytest", *session.posargs) 20 | 21 | 22 | if __name__ == "__main__": 23 | nox.main() 24 | -------------------------------------------------------------------------------- /examples/icosahedron.py: -------------------------------------------------------------------------------- 1 | r""" 2 | Icosahedron geometry example 3 | ---------------------------- 4 | 5 | Icosahedron geometry example. 6 | 7 | """ 8 | 9 | # sphinx_gallery_thumbnail_number = 2 # noqa:ERA001 10 | 11 | from __future__ import annotations 12 | 13 | import pyvista as pv 14 | 15 | import skgmsh as sg 16 | 17 | edge_source = pv.Icosahedron() 18 | edge_source.merge(pv.PolyData(edge_source.points), merge_points=True, inplace=True) 19 | edge_source.plot(show_edges=True, color="white") 20 | 21 | # %% 22 | # Generate the mesh. 23 | 24 | delaunay_3d = sg.Delaunay3D(edge_source) 25 | delaunay_3d.mesh.shrink(0.9).plot(show_edges=True, color="white") 26 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # Read the Docs configuration file 2 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 3 | 4 | version: 2 5 | 6 | build: 7 | os: ubuntu-24.04 8 | tools: 9 | python: "3.12" 10 | apt_packages: 11 | - libfltk1.3-dev 12 | - libfreetype6-dev 13 | - libgl1-mesa-dev 14 | - libglu1 15 | - libocct-data-exchange-dev 16 | - libocct-foundation-dev 17 | - libxcursor-dev 18 | - libxft2 19 | - libxinerama1 20 | - xvfb 21 | 22 | sphinx: 23 | configuration: docs/conf.py 24 | 25 | python: 26 | install: 27 | - method: pip 28 | path: . 29 | extra_requirements: 30 | - docs 31 | -------------------------------------------------------------------------------- /.github/workflows/update-pr-branch.yml: -------------------------------------------------------------------------------- 1 | name: PR update 2 | 3 | on: 4 | push: 5 | branches: 6 | - "main" 7 | jobs: 8 | autoupdate: 9 | runs-on: ubuntu-latest 10 | permissions: 11 | contents: write 12 | pull-requests: write 13 | steps: 14 | - name: Automatically update PR 15 | uses: adRise/update-pr-branch@a51c014567e5be98445551cce9b8f5ad42dd8acf 16 | with: 17 | token: ${{ secrets.GITHUB_TOKEN }} 18 | base: "main" 19 | required_approval_count: 1 20 | require_passed_checks: false 21 | sort: "created" 22 | direction: "desc" 23 | require_auto_merge_enabled: true 24 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /examples/capsule.py: -------------------------------------------------------------------------------- 1 | r""" 2 | Capsule geometry example 3 | ------------------------- 4 | 5 | Capsule geometry example. 6 | 7 | """ 8 | 9 | # sphinx_gallery_thumbnail_number = 3 # noqa:ERA001 10 | 11 | from __future__ import annotations 12 | 13 | import pyvista as pv 14 | 15 | import skgmsh as sg 16 | 17 | edge_source = pv.Capsule(resolution=10) 18 | edge_source.merge(pv.PolyData(edge_source.points), merge_points=True, inplace=True) 19 | edge_source.plot(show_edges=True, color="white") 20 | 21 | # %% 22 | # Create a 3D mesh from the edge source. 23 | 24 | alg = sg.Delaunay3D(edge_source) 25 | alg.mesh.shrink(0.9).plot(show_edges=True, color="white") 26 | 27 | # %% 28 | # Change the cell size of the mesh. 29 | 30 | alg.cell_size = 0.25 31 | alg.mesh.plot(show_edges=True, color="white") 32 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "pip" 4 | directory: "/" 5 | schedule: 6 | interval: "monthly" 7 | time: "09:00" 8 | open-pull-requests-limit: 100 9 | labels: 10 | - "maintenance" 11 | - "dependencies" 12 | groups: 13 | pip: 14 | patterns: 15 | - "*" 16 | ignore: 17 | - dependency-name: "pydata-sphinx-theme" 18 | cooldown: 19 | default-days: 7 20 | - package-ecosystem: "github-actions" 21 | directory: "/" 22 | schedule: 23 | interval: "monthly" 24 | time: "09:00" 25 | open-pull-requests-limit: 100 26 | labels: 27 | - "maintenance" 28 | - "dependencies" 29 | groups: 30 | actions: 31 | patterns: 32 | - "*" 33 | cooldown: 34 | default-days: 7 35 | -------------------------------------------------------------------------------- /examples/cylinder.py: -------------------------------------------------------------------------------- 1 | r""" 2 | Cylinder geometry example 3 | ------------------------- 4 | 5 | Cylinder geometry example. 6 | 7 | """ 8 | 9 | # sphinx_gallery_thumbnail_number = 3 # noqa:ERA001 10 | 11 | from __future__ import annotations 12 | 13 | import pyvista as pv 14 | 15 | import skgmsh as sg 16 | 17 | edge_source = pv.Cylinder(resolution=16) 18 | edge_source.merge(pv.PolyData(edge_source.points), merge_points=True, inplace=True) 19 | edge_source.plot(show_edges=True, color="white", line_width=2) 20 | 21 | # %% 22 | # Generate the mesh. 23 | 24 | alg = sg.Delaunay3D(edge_source) 25 | mesh = alg.mesh 26 | mesh.plot(show_edges=True) 27 | 28 | # %% 29 | # Output the information of the mesh. 30 | 31 | print(mesh) 32 | 33 | # %% 34 | # Change the cell size of the mesh. 35 | 36 | alg.cell_size = 0.2 37 | alg.mesh.plot(show_edges=True, color="white", line_width=2) 38 | -------------------------------------------------------------------------------- /examples/polygon_with_hole.py: -------------------------------------------------------------------------------- 1 | r""" 2 | Polygon with hole geometry example 3 | ---------------------------------- 4 | 5 | Polygon with hole geometry example. 6 | 7 | """ 8 | 9 | # sphinx_gallery_thumbnail_number = 2 # noqa:ERA001 10 | 11 | from __future__ import annotations 12 | 13 | import skgmsh as sg 14 | 15 | shell = [(0, 0, 0), (0, 10, 0), (10, 10, 0), (10, 0, 0), (0, 0, 0)] 16 | holes = [[(2, 2, 0), (2, 4, 0), (4, 4, 0), (4, 2, 0), (2, 2, 0)]] 17 | alg = sg.Delaunay2D(shell=shell, holes=holes) 18 | 19 | # %% 20 | # Generate the mesh. 21 | 22 | alg.mesh.plot(show_edges=True, cpos="xy", color="white", line_width=2) 23 | 24 | # %% 25 | # Change the cell size of the mesh. 26 | 27 | alg.cell_size = 2.0 28 | alg.mesh.plot(show_edges=True, cpos="xy", color="white", line_width=2) 29 | 30 | # %% 31 | # Enable recombine. 32 | 33 | alg.enable_recombine() 34 | alg.mesh.plot(show_edges=True, cpos="xy", color="white", line_width=2) 35 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | %SPHINXBUILD% >NUL 2>NUL 14 | if errorlevel 9009 ( 15 | echo. 16 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 17 | echo.installed, then set the SPHINXBUILD environment variable to point 18 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 19 | echo.may add the Sphinx directory to PATH. 20 | echo. 21 | echo.If you don't have Sphinx installed, grab it from 22 | echo.https://www.sphinx-doc.org/ 23 | exit /b 1 24 | ) 25 | 26 | if "%1" == "" goto help 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /.github/workflows/auto-approve.yml: -------------------------------------------------------------------------------- 1 | name: Approve PRs 2 | on: 3 | workflow_dispatch: 4 | issue_comment: 5 | types: [created] 6 | 7 | jobs: 8 | autoapprove: 9 | # This job only runs for pull request comments by approved users on creation 10 | name: PR comment 11 | if: github.event.issue.pull_request && 12 | contains(github.event.comment.body, 'LGTM') && ( 13 | github.event.comment.user.login == 'tkoyama010' 14 | ) 15 | permissions: 16 | pull-requests: write 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: hmarr/auto-approve-action@8f929096a962e83ccdfa8afcf855f39f12d4dac7 20 | with: 21 | review-message: ":white_check_mark: Approving this PR because [${{ github.event.comment.user.login }}](https://github.com/${{ github.event.comment.user.login }}) said so in [here](${{ github.event.comment.html_url }}) :shipit:" 22 | pull-request-number: ${{ github.event.issue.number }} 23 | github-token: ${{ secrets.GITHUB_TOKEN }} 24 | -------------------------------------------------------------------------------- /.github/config.yml: -------------------------------------------------------------------------------- 1 | # Configuration for welcome - https://github.com/behaviorbot/welcome 2 | 3 | # Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome 4 | 5 | # Comment to be posted to on first time issues 6 | newIssueWelcomeComment: > 7 | Thanks for opening your first issue here! Be sure to follow the issue template! 8 | 9 | # Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome 10 | 11 | # Comment to be posted to on PRs from first time contributors in your repository 12 | newPRWelcomeComment: > 13 | Thanks for opening this pull request! Please check out our contributing guidelines. 14 | 15 | # Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge 16 | 17 | # Comment to be posted to on pull requests merged by a first time user 18 | firstPRMergeComment: > 19 | Congrats on merging your first pull request! We here at behaviorbot are proud of you! 20 | 21 | # It is recommended to include as many gifs and emojis as possible! 22 | -------------------------------------------------------------------------------- /.github/labeler.yml: -------------------------------------------------------------------------------- 1 | documentation: 2 | - any: 3 | - changed-files: 4 | - any-glob-to-any-file: "*.md" 5 | - any-glob-to-any-file: "*.rst" 6 | - any-glob-to-any-file: "docs/**/*" 7 | - any-glob-to-any-file: "examples/**/*" 8 | - any-glob-to-any-file: "examples_trame/**/*" 9 | maintenance: 10 | - any: 11 | - changed-files: 12 | - any-glob-to-any-file: ".flake8" 13 | - any-glob-to-any-file: ".github/**/*" 14 | - any-glob-to-any-file: ".pre-commit-config.yaml" 15 | - any-glob-to-any-file: "Makefile" 16 | - any-glob-to-any-file: "codecov.yml" 17 | - any-glob-to-any-file: "pyproject.toml" 18 | dependencies: 19 | - any: 20 | - changed-files: 21 | - any-glob-to-any-file: ".pre-commit-config.yaml" 22 | - any-glob-to-any-file: "environment.yml" 23 | - any-glob-to-any-file: "requirements*" 24 | docker: 25 | - any: 26 | - changed-files: 27 | - any-glob-to-any-file: ".dockerignore" 28 | - any-glob-to-any-file: "docker/**/*" 29 | -------------------------------------------------------------------------------- /.github/DISCUSSION_TEMPLATE/show-and-tell.yml: -------------------------------------------------------------------------------- 1 | body: 2 | - type: markdown 3 | attributes: 4 | value: | 5 | Thanks for taking the time to open this discussion to help improve scikit-gmsh! 6 | - type: textarea 7 | id: feature-details 8 | attributes: 9 | label: Describe something you've made 10 | description: | 11 | Provide a clear and concise description of something you've made. 12 | placeholder: Tell us what you see! 13 | value: "I have something made!" 14 | validations: 15 | required: true 16 | - type: textarea 17 | id: Links 18 | attributes: 19 | label: Links to Documentation, Examples, or Class Definitions. 20 | description: Please include the relevant links below. 21 | - type: textarea 22 | id: pseudocode-and-screenshots 23 | attributes: 24 | label: Pseudocode or Screenshots 25 | description: Feel free to include pseudocode or screenshots you've made. 26 | placeholder: Provide some code for us to reproduce you've made! 27 | value: "```python\nInsert code here\n```\nOr drag your screenshot here!" 28 | -------------------------------------------------------------------------------- /.github/workflows/labeler.yml: -------------------------------------------------------------------------------- 1 | name: "Pull Request Labeler" 2 | on: 3 | pull_request: 4 | types: [opened, reopened] 5 | 6 | jobs: 7 | labeler: 8 | permissions: 9 | contents: read 10 | pull-requests: write 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 14 | with: 15 | persist-credentials: false 16 | - uses: actions/labeler@25abb3cad4f14b7ac27968a495c37798860a5a1a 17 | with: 18 | repo-token: "${{ secrets.GITHUB_TOKEN }}" 19 | sync-labels: true 20 | configuration-path: .github/labeler.yml 21 | dot: true 22 | - uses: actions-ecosystem/action-add-labels@1a9c3715c0037e96b97bb38cb4c4b56a1f1d4871 23 | if: github.event.pull_request.user.type == 'Bot' && (github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'github-actions[bot]' || github.event.pull_request.user.login == 'pre-commit-ci[bot]') 24 | with: 25 | github_token: "${{ secrets.GITHUB_TOKEN }}" 26 | labels: ignore-for-release 27 | -------------------------------------------------------------------------------- /examples/better_cell_size.py: -------------------------------------------------------------------------------- 1 | r""" 2 | Constrain edge size for Delaunay2D 3 | ----------------------------------- 4 | 5 | Constrain edge size for Delaunay2D. 6 | 7 | """ 8 | 9 | from __future__ import annotations 10 | 11 | import pyvista as pv 12 | 13 | import skgmsh as sg 14 | 15 | edge_source = pv.Polygon(n_sides=16, radius=16) 16 | mesh = sg.Delaunay2D(shell=edge_source.points).mesh 17 | 18 | p = pv.Plotter() 19 | p.add_mesh(mesh, show_edges=True) 20 | p.add_mesh(pv.PolyData(edge_source.points), render_points_as_spheres=True, color="red", point_size=10) 21 | p.view_xy() 22 | p.show() 23 | 24 | # %% 25 | # With option `constrain_edge_size=True`, the edge size is constrained. 26 | 27 | mesh = sg.Delaunay2D(shell=edge_source.points, constrain_edge_size=True).mesh 28 | mesh.plot(show_edges=True, color="white", cpos="xy") 29 | 30 | # %% 31 | # Works with holes too! 32 | 33 | hole1 = pv.Polygon(n_sides=6, radius=4).translate([-4.0, -4.0, 0.0]) 34 | hole2 = pv.Polygon(n_sides=8, radius=2).translate([4.0, 4.0, 0.0]) 35 | mesh = sg.Delaunay2D(shell=edge_source.points, holes=[hole1.points, hole2.points], constrain_edge_size=True).mesh 36 | mesh.plot(show_edges=True, color="white", cpos="xy") 37 | -------------------------------------------------------------------------------- /.github/DISCUSSION_TEMPLATE/ideas.yml: -------------------------------------------------------------------------------- 1 | body: 2 | - type: markdown 3 | attributes: 4 | value: | 5 | Thanks for taking the time to open this discussion to help improve scikit-gmsh! 6 | - type: textarea 7 | id: feature-details 8 | attributes: 9 | label: Describe the feature you would like to be added. 10 | description: | 11 | Provide a clear and concise description of what you would like added. 12 | placeholder: Tell us what you see! 13 | value: "I have an idea for a new feature!" 14 | validations: 15 | required: true 16 | - type: textarea 17 | id: Gmsh-Links 18 | attributes: 19 | label: Links to Gmsh Documentation, Examples, or Class Definitions. 20 | description: If you are requesting that a feature from Gmsh be wrapped or exposed, please include the relevant links below. 21 | - type: textarea 22 | id: pseudocode-and-screenshots 23 | attributes: 24 | label: Pseudocode or Screenshots 25 | description: Feel free to include pseudocode or screenshots of the requested outcome. 26 | placeholder: Provide some code for us to reproduce the bug! 27 | value: "```python\nInsert code here\n```\nOr drag your screenshot here!" 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/maintenance-request.yml: -------------------------------------------------------------------------------- 1 | name: Maintenance Request 2 | description: Request general maintenance to code, CI, deployment, or otherwise 3 | labels: ["maintenance"] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Thanks for taking the time to open this issue to help improve scikit-gmsh! 9 | - type: textarea 10 | id: maintenance-request 11 | attributes: 12 | label: Describe what maintenance you would like added. 13 | description: | 14 | Provide a clear and concise description of the maintenance problem. 15 | placeholder: Tell us what you see! 16 | value: "I have a maintenance suggestion!" 17 | validations: 18 | required: true 19 | - type: textarea 20 | id: code-links 21 | attributes: 22 | label: Links to source code. 23 | description: If you are requesting maintenance for a specific line of source code, please include the permanent link for that line. 24 | - type: textarea 25 | id: pseudocode-and-screenshots 26 | attributes: 27 | label: Pseudocode or Screenshots 28 | description: Feel free to include pseudocode or screenshots of the requested outcome. 29 | placeholder: Provide some code for us to reproduce the bug! 30 | value: "```python\nInsert code here\n```\nOr drag your screenshot here!" 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.yml: -------------------------------------------------------------------------------- 1 | name: Feature Request 2 | description: Request that a feature be added to scikit-gmsh 3 | labels: ["feature-request"] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Thanks for taking the time to open this issue to help improve scikit-gmsh! 9 | - type: textarea 10 | id: feature-details 11 | attributes: 12 | label: Describe the feature you would like to be added. 13 | description: | 14 | Provide a clear and concise description of what you would like added. 15 | placeholder: Tell us what you see! 16 | value: "I have an idea for a new feature!" 17 | validations: 18 | required: true 19 | - type: textarea 20 | id: Gmsh-Links 21 | attributes: 22 | label: Links to Gmsh Documentation, Examples, or Class Definitions. 23 | description: If you are requesting that a feature from Gmsh be wrapped or exposed, please include the relevant links below. 24 | - type: textarea 25 | id: pseudocode-and-screenshots 26 | attributes: 27 | label: Pseudocode or Screenshots 28 | description: Feel free to include pseudocode or screenshots of the requested outcome. 29 | placeholder: Provide some code for us to reproduce the bug! 30 | value: "```python\nInsert code here\n```\nOr drag your screenshot here!" 31 | -------------------------------------------------------------------------------- /.github/workflows/testing-and-deployment.yml: -------------------------------------------------------------------------------- 1 | name: Unit Testing and Deployment 2 | 3 | on: 4 | pull_request: 5 | workflow_dispatch: 6 | schedule: 7 | - cron: "0 4 * * *" 8 | push: 9 | tags: 10 | - "*" 11 | branches: 12 | - main 13 | 14 | concurrency: 15 | group: ${{ github.workflow }}-${{ github.ref }} 16 | cancel-in-progress: true 17 | 18 | env: 19 | ALLOW_PLOTTING: true 20 | SHELLOPTS: "errexit:pipefail" 21 | 22 | jobs: 23 | Linux: 24 | name: Linux Unit Testing 25 | permissions: 26 | contents: read 27 | actions: write 28 | runs-on: ubuntu-latest 29 | strategy: 30 | fail-fast: false 31 | matrix: 32 | python-version: ["3.11", "3.12", "3.13"] 33 | steps: 34 | - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 35 | with: 36 | fetch-depth: 2 37 | persist-credentials: false 38 | 39 | - name: Set up Python ${{ matrix.python-version }} 40 | uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c 41 | with: 42 | python-version: ${{ matrix.python-version }} 43 | 44 | - name: Install packages 45 | run: | 46 | for i in $(cat packages.txt); do sudo apt-get install $i; done 47 | 48 | - name: Install Testing Requirements 49 | run: | 50 | pip install -e .[test] 51 | 52 | - name: Unit Testing 53 | run: | 54 | export PYTHONPATH=. && xvfb-run python -m pytest -v 55 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.yml: -------------------------------------------------------------------------------- 1 | name: Bug Report 2 | description: Create a report to help us fix broken features 3 | labels: ["bug"] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Thanks for taking the time to open this issue to help improve scikit-gmsh! 9 | - type: textarea 10 | id: what-happened 11 | attributes: 12 | label: Describe the bug, what's wrong, and what you expected. 13 | description: | 14 | Provide a clear and concise description of what the bug is. 15 | Provide a clear and concise description of what you expected to happen. 16 | placeholder: Tell us what you see! 17 | value: "I found a bug!" 18 | validations: 19 | required: true 20 | - type: textarea 21 | id: reproduce 22 | attributes: 23 | label: Steps to reproduce the bug. 24 | description: | 25 | Please provide a list of steps to reproduce the bug. 26 | Please include a code snippet to reproduce the bug in the text box below. 27 | placeholder: Provide some code for us to reproduce the bug! 28 | value: "```python\nInsert code here\n```" 29 | validations: 30 | required: true 31 | - type: textarea 32 | id: system-information 33 | attributes: 34 | label: System Information 35 | placeholder: The log will automatically be formatted! No need to type backticks. 36 | description: | 37 | Please run the following code wherever you are experiencing the bug, and paste the output below. 38 | This report helps us track down bugs and will be critical to addressing your bug. 39 | ```python 40 | # Get system info 41 | import skgmsh as sg 42 | print(sg.Report()) 43 | ``` 44 | render: shell 45 | validations: 46 | required: true 47 | - type: textarea 48 | id: screenshots 49 | attributes: 50 | label: Screenshots 51 | description: If applicable, please add screenshots to the text box below 52 | -------------------------------------------------------------------------------- /.github/workflows/publish-to-pypi.yml: -------------------------------------------------------------------------------- 1 | name: Build and publish Python distributions to PyPI and TestPyPI 2 | on: 3 | release: 4 | types: [published] 5 | push: 6 | tags: 7 | - "*" 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | environment: pypi 12 | permissions: 13 | id-token: write 14 | steps: 15 | - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 16 | with: 17 | persist-credentials: false 18 | - name: Set up Python 19 | uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c 20 | with: 21 | python-version: "3.x" 22 | - name: Install packages 23 | run: | 24 | for i in $(cat packages.txt); do sudo apt-get install $i; done 25 | - name: Install pypa/build 26 | run: >- 27 | python3 -m 28 | pip install 29 | build 30 | --user 31 | - name: Build a binary wheel and a source tarball 32 | run: >- 33 | python3 -m 34 | build 35 | --sdist 36 | --wheel 37 | --outdir dist/ 38 | - name: Store the distribution packages 39 | uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 40 | with: 41 | name: python-package-distributions 42 | path: dist/ 43 | publish: 44 | name: >- 45 | Publish Python distribution to PyPI 46 | if: github.repository_owner == 'pyvista' 47 | needs: 48 | - build 49 | runs-on: ubuntu-latest 50 | environment: 51 | name: pypi 52 | url: https://pypi.org/p/scikit-gmsh 53 | permissions: 54 | id-token: write 55 | steps: 56 | - name: Download all the dists 57 | uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 58 | with: 59 | name: python-package-distributions 60 | path: dist/ 61 | - name: Publish package to PyPI 62 | if: github.event_name == 'release' 63 | uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e 64 | -------------------------------------------------------------------------------- /docs/_static/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SciPy 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | skgmsh 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/_static/small_logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SciPy 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | skgmsh 19 | 20 | 21 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | build-backend = 'setuptools.build_meta' 3 | requires = [ 4 | 'gmsh<4.15.1', 5 | 'meshio<5.3.6', 6 | 'pyvista[all]<0.46.5', 7 | 'scooby<0.11.1', 8 | 'setuptools<80.9.1', 9 | 'shapely<2.1.3', 10 | ] 11 | 12 | [project] 13 | dependencies = [ 14 | 'gmsh<4.15.1', 15 | 'meshio<5.3.6', 16 | 'pyvista[all]<0.46.5', 17 | 'scooby<0.11.1', 18 | 'shapely<2.1.3', 19 | ] 20 | dynamic = ["readme", "version"] 21 | name = "scikit-gmsh" 22 | requires-python = '>=3.11' 23 | 24 | [project.optional-dependencies] 25 | docs = [ 26 | 'myst-parser==4.0.1', 27 | 'pydata-sphinx-theme==0.15.4', # Do not upgrade, see https://github.com/pyvista/scikit-gmsh/pull/446 28 | 'sphinx-book-theme==1.1.4', 29 | 'sphinx-copybutton==0.5.2', 30 | 'sphinx-design==0.6.1', 31 | 'sphinx-gallery==0.19.0', 32 | 'sphinx-toolbox==4.0.0', 33 | 'sphinx==8.2.3', 34 | ] 35 | test = ['pytest==9.0.1'] 36 | 37 | [dependency-groups] 38 | dev = [{ include-group = "docs" }, { include-group = "test" }] 39 | docs = [ 40 | "myst-parser==4.0.1", 41 | "pydata-sphinx-theme==0.15.4", 42 | "sphinx-book-theme==1.1.4", 43 | "sphinx-copybutton==0.5.2", 44 | "sphinx-design==0.6.1", 45 | "sphinx-gallery==0.19.0", 46 | "sphinx-toolbox==4.0.0", 47 | "sphinx==8.2.3", 48 | ] 49 | test = ["pytest==9.0.1"] 50 | 51 | [tool.mypy] 52 | enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] 53 | ignore_missing_imports = true 54 | strict = true 55 | warn_unreachable = true 56 | 57 | [tool.pytest.ini_options] 58 | addopts = ["--showlocals", "--strict-config", "--strict-markers", "-ra"] 59 | filterwarnings = ["error", 'ignore::DeprecationWarning'] 60 | log_cli_level = "info" 61 | log_level = "INFO" 62 | minversion = "6.0" 63 | testpaths = ["tests"] 64 | xfail_strict = true 65 | 66 | [tool.ruff] 67 | line-length = 150 68 | 69 | [tool.ruff.format] 70 | docstring-code-format = true 71 | 72 | [tool.ruff.lint] 73 | ignore = ["COM812", "D203", "D212", "ISC001"] 74 | select = ["ALL"] 75 | 76 | [tool.ruff.lint.isort] 77 | combine-as-imports = true 78 | force-single-line = true 79 | force-sort-within-sections = true 80 | required-imports = ["from __future__ import annotations"] 81 | 82 | [tool.ruff.lint.per-file-ignores] 83 | "docs/**" = ["INP001"] 84 | "examples/**" = ["D205", "D400", "D415", "INP001", "T201"] 85 | "tests/**" = ["INP001", "S101"] 86 | 87 | [tool.ruff.lint.pyupgrade] 88 | keep-runtime-typing = true 89 | 90 | [tool.setuptools.dynamic] 91 | readme = { file = "README.md", content-type = "text/markdown" } 92 | version = { attr = 'skgmsh.__version__' } 93 | -------------------------------------------------------------------------------- /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "CONTRIBUTORS.md" 4 | ], 5 | "imageSize": 100, 6 | "commit": false, 7 | "commitType": "docs", 8 | "commitConvention": "angular", 9 | "contributorsSortAlphabetically": true, 10 | "contributors": [ 11 | { 12 | "login": "tkoyama010", 13 | "name": "Tetsuo Koyama", 14 | "avatar_url": "https://avatars.githubusercontent.com/u/7513610?v=4", 15 | "profile": "https://github.com/tkoyama010", 16 | "contributions": [ 17 | "infra", 18 | "test", 19 | "code", 20 | "ideas", 21 | "maintenance", 22 | "bug", 23 | "doc", 24 | "design", 25 | "review", 26 | "example", 27 | "promotion", 28 | "security", 29 | "question", 30 | "talk", 31 | "business" 32 | ] 33 | }, 34 | { 35 | "login": "all-contributors", 36 | "name": "All Contributors", 37 | "avatar_url": "https://avatars.githubusercontent.com/u/46410174?v=4", 38 | "profile": "https://allcontributors.org", 39 | "contributions": [ 40 | "doc" 41 | ] 42 | }, 43 | { 44 | "login": "pre-commit-ci", 45 | "name": "pre-commit.ci", 46 | "avatar_url": "https://avatars.githubusercontent.com/u/64617429?v=4", 47 | "profile": "https://pre-commit.ci", 48 | "contributions": [ 49 | "maintenance" 50 | ] 51 | }, 52 | { 53 | "login": "dependabot", 54 | "name": "Dependabot", 55 | "avatar_url": "https://avatars.githubusercontent.com/u/27347476?v=4", 56 | "profile": "https://github.com/features/security", 57 | "contributions": [ 58 | "maintenance" 59 | ] 60 | }, 61 | { 62 | "login": "adtzlr", 63 | "name": "Andreas Dutzler", 64 | "avatar_url": "https://avatars.githubusercontent.com/u/5793153?v=4", 65 | "profile": "https://github.com/adtzlr", 66 | "contributions": [ 67 | "example" 68 | ] 69 | }, 70 | { 71 | "login": "bjlittle", 72 | "name": "Bill Little", 73 | "avatar_url": "https://avatars.githubusercontent.com/u/2051656?v=4", 74 | "profile": "https://github.com/bjlittle", 75 | "contributions": [ 76 | "ideas", 77 | "review", 78 | "maintenance" 79 | ] 80 | }, 81 | { 82 | "login": "keurfonluu", 83 | "name": "Keurfon Luu", 84 | "avatar_url": "https://avatars.githubusercontent.com/u/16566206?v=4", 85 | "profile": "https://github.com/keurfonluu", 86 | "contributions": [ 87 | "code", 88 | "ideas" 89 | ] 90 | }, 91 | { 92 | "login": "claude", 93 | "name": "Claude", 94 | "avatar_url": "https://avatars.githubusercontent.com/u/81847?v=4", 95 | "profile": "https://anthropic.com/claude-code", 96 | "contributions": [ 97 | "code" 98 | ] 99 | } 100 | ], 101 | "contributorsPerLine": 7, 102 | "skipCi": false, 103 | "repoType": "github", 104 | "repoHost": "https://github.com", 105 | "projectName": "scikit-gmsh", 106 | "projectOwner": "pyvista" 107 | } 108 | -------------------------------------------------------------------------------- /.github/DISCUSSION_TEMPLATE/q-a.yml: -------------------------------------------------------------------------------- 1 | body: 2 | - type: markdown 3 | attributes: 4 | value: | 5 | Thanks for taking the time to open this discussion to help improve scikit-gmsh! 6 | - type: checkboxes 7 | id: checks 8 | attributes: 9 | label: First check 10 | options: 11 | - label: I added a very descriptive title here. 12 | required: true 13 | - label: I used the GitHub search to find a similar question and didn't find it. 14 | required: true 15 | - label: I searched the scikit-gmsh documentation, with the integrated search. 16 | required: true 17 | - label: I already searched in Google "How to X in scikit-gmsh" and didn't find any information. 18 | required: true 19 | - label: I already read and followed all the tutorial in the docs and didn't find an answer. 20 | required: true 21 | - label: I will NOT make duplicate discussions or issues in the future. 22 | required: true 23 | - type: checkboxes 24 | id: help 25 | attributes: 26 | label: Commit to Help 27 | description: | 28 | After submitting this, I commit to one of: 29 | * Read open questions until I find 2 where I can help someone and add a comment to help there. 30 | * I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future. 31 | options: 32 | - label: I commit to help with one of those options. 33 | required: true 34 | - type: textarea 35 | id: sample 36 | attributes: 37 | label: Sample Code 38 | What is the problem, question, or error? 39 | 40 | Write a short description telling me what you are doing, what you expect to happen, and what is currently happening. 41 | placeholder: Provide some code for us to reproduce your question 42 | render: python 43 | validations: 44 | required: true 45 | - type: textarea 46 | id: description 47 | attributes: 48 | label: Description 49 | description: | 50 | What is the problem, question, or error? 51 | 52 | Write a short description telling me what you are doing, what you expect to happen, and what is currently happening. 53 | placeholder: | 54 | * It returns ... 55 | * But I expected it to ... 56 | validations: 57 | required: true 58 | - type: textarea 59 | id: system-information 60 | attributes: 61 | label: System Information 62 | placeholder: The log will automatically be formatted! No need to type backticks. 63 | description: | 64 | Please run the following code wherever you are experiencing the bug, and paste the output below. 65 | This report helps us track down bugs and will be critical to addressing your bug. 66 | ```python 67 | # Get system info 68 | import skgmsh as sg 69 | print(sg.Report()) 70 | ``` 71 | render: shell 72 | validations: 73 | required: true 74 | - type: textarea 75 | id: screenshots 76 | attributes: 77 | label: Screenshots 78 | description: If applicable, please add screenshots to the text box below 79 | -------------------------------------------------------------------------------- /tests/test_skgmsh.py: -------------------------------------------------------------------------------- 1 | """scikit-gmsh package for 3D mesh generation test.""" 2 | 3 | from __future__ import annotations 4 | 5 | from typing import TYPE_CHECKING 6 | 7 | if TYPE_CHECKING: 8 | from collections.abc import Sequence 9 | 10 | import numpy as np 11 | import pytest 12 | import pyvista as pv 13 | 14 | import skgmsh as sg 15 | 16 | EDGE_SOURCES = [ 17 | pv.Polygon(n_sides=4, radius=8), 18 | ] 19 | 20 | 21 | def test_frontal_delaunay_2d_default() -> None: 22 | """Frontal-Delaunay 2D mesh algorithm test code.""" 23 | edge_source = pv.Polygon(n_sides=4, radius=8) 24 | mesh = sg.frontal_delaunay_2d(edge_source) 25 | assert mesh.number_of_points == edge_source.number_of_points 26 | assert np.allclose(mesh.volume, edge_source.volume) 27 | # TODO @tkoyama010: Compare cell type. # noqa: FIX002 28 | # https://github.com/pyvista/scikit-gmsh/pull/125 29 | frontal_delaunay_2d = sg.Delaunay2D(edge_source=edge_source) 30 | mesh = frontal_delaunay_2d.mesh 31 | assert mesh.number_of_points == edge_source.number_of_points 32 | assert np.allclose(mesh.volume, edge_source.volume) 33 | 34 | 35 | def test_frontal_delaunay_2d_recombine() -> None: 36 | """Frontal-Delaunay 2D mesh algorithm test code.""" 37 | edge_source = pv.Polygon(n_sides=4, radius=8) 38 | mesh = sg.frontal_delaunay_2d(edge_source, recombine=True) 39 | assert mesh.number_of_points == edge_source.number_of_points 40 | assert mesh.number_of_cells == 1 41 | assert np.allclose(mesh.volume, edge_source.volume) 42 | for cell in mesh.cell: 43 | assert cell.type == pv.CellType.QUAD 44 | 45 | 46 | @pytest.mark.parametrize("edge_source", EDGE_SOURCES) 47 | @pytest.mark.parametrize("target_sizes", [2.0, [1.0, 2.0, 3.0, 4.0]]) 48 | def test_frontal_delaunay_2d(edge_source: pv.Polygon, target_sizes: float | Sequence[float]) -> None: 49 | """Frontal-Delaunay 2D mesh algorithm test code.""" 50 | mesh = sg.frontal_delaunay_2d(edge_source, target_sizes=target_sizes) 51 | assert mesh.number_of_points > edge_source.number_of_points 52 | assert mesh.number_of_cells > edge_source.number_of_cells 53 | assert np.allclose(mesh.volume, edge_source.volume) 54 | # TODO @tkoyama010: Compare cell type. # noqa: FIX002 55 | # https://github.com/pyvista/scikit-gmsh/pull/125 56 | 57 | 58 | @pytest.mark.parametrize("target_sizes", [0.5, [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]]) 59 | def test_delaunay_3d(target_sizes: float | Sequence[float]) -> None: 60 | """Delaunay 3D mesh algorithm test code.""" 61 | edge_source = pv.Cube() 62 | mesh = sg.delaunay_3d(edge_source, target_sizes=target_sizes) 63 | assert mesh.number_of_points > edge_source.number_of_points 64 | assert mesh.number_of_cells > edge_source.number_of_cells 65 | assert np.allclose(mesh.volume, edge_source.volume) 66 | # TODO @tkoyama010: Compare cell type. # noqa: FIX002 67 | # https://github.com/pyvista/scikit-gmsh/pull/125 68 | 69 | 70 | @pytest.mark.parametrize("edge_source", [pv.Cube(), pv.Cylinder()]) 71 | def test_delaunay_3d_default(edge_source: pv.PolyData) -> None: 72 | """Delaunay 3D mesh algorithm test code.""" 73 | edge_source.merge(pv.PolyData(edge_source.points), merge_points=True, inplace=True) 74 | delaunay_3d = sg.Delaunay3D(edge_source) 75 | mesh = delaunay_3d.mesh 76 | assert np.allclose(mesh.volume, edge_source.volume) 77 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | ci: 2 | autofix_commit_msg: "style: pre-commit fixes" 3 | autoupdate_commit_msg: "chore: update pre-commit hooks" 4 | autofix_prs: true 5 | autoupdate_schedule: weekly 6 | repos: 7 | - repo: https://github.com/adamchainz/blacken-docs 8 | rev: 1.20.0 9 | hooks: 10 | - id: blacken-docs 11 | additional_dependencies: [black==23.*] 12 | - repo: https://github.com/python-jsonschema/check-jsonschema 13 | rev: 0.36.0 14 | hooks: 15 | - id: check-github-workflows 16 | - id: check-dependabot 17 | - id: check-github-actions 18 | - id: check-readthedocs 19 | - repo: https://github.com/codespell-project/codespell 20 | rev: v2.4.1 21 | hooks: 22 | - id: codespell 23 | args: ["-L", "socio-economic"] 24 | - repo: https://github.com/pre-commit/mirrors-mypy 25 | rev: v1.19.1 26 | hooks: 27 | - id: mypy 28 | files: src 29 | additional_dependencies: 30 | [ 31 | "mypy-extensions==1.0.0", 32 | "toml==0.10.2", 33 | "typing-extensions==4.11.0", 34 | ] 35 | args: 36 | [ 37 | "--disallow-untyped-calls", 38 | "--disallow-untyped-defs", 39 | "--disallow-incomplete-defs", 40 | "--check-untyped-defs", 41 | "--disallow-untyped-decorators", 42 | "--no-implicit-optional", 43 | "--no-strict-optional", 44 | ] 45 | - repo: https://github.com/rbubley/mirrors-prettier 46 | rev: v3.7.4 47 | hooks: 48 | - id: prettier 49 | types_or: [yaml, markdown, html, css, scss, javascript, json, toml] 50 | - repo: https://github.com/DanielNoord/pydocstringformatter 51 | rev: v0.7.5 52 | hooks: 53 | - id: pydocstringformatter 54 | args: 55 | [ 56 | "--style {numpydoc,pep257}", 57 | "--no-strip-whitespace", 58 | "--no-capitalize-first-letter", 59 | ] 60 | - repo: https://github.com/pre-commit/pygrep-hooks 61 | rev: v1.10.0 62 | hooks: 63 | - id: rst-backticks 64 | - id: rst-directive-colons 65 | - id: rst-inline-touching-normal 66 | - repo: https://github.com/astral-sh/ruff-pre-commit 67 | rev: v0.14.9 68 | hooks: 69 | - id: ruff-check 70 | args: ["--fix", "--show-fixes"] 71 | - id: ruff-format 72 | - repo: https://github.com/scientific-python/cookie 73 | rev: 2025.11.21 74 | hooks: 75 | - id: sp-repo-review 76 | - repo: https://github.com/ComPWA/taplo-pre-commit 77 | rev: v0.9.3 78 | hooks: 79 | - id: taplo-format 80 | # See options: https://taplo.tamasfe.dev/configuration/formatter-options.html 81 | args: [--option, "reorder_arrays=true", --option, "reorder_keys=true"] 82 | - repo: https://github.com/pre-commit/pre-commit-hooks 83 | rev: v6.0.0 84 | hooks: 85 | - id: check-added-large-files 86 | - id: check-case-conflict 87 | - id: check-merge-conflict 88 | - id: check-symlinks 89 | - id: check-yaml 90 | - id: debug-statements 91 | - id: end-of-file-fixer 92 | - id: mixed-line-ending 93 | - id: name-tests-test 94 | args: ["--pytest-test-first"] 95 | - id: no-commit-to-branch 96 | args: [--branch, main] 97 | - id: requirements-txt-fixer 98 | - id: trailing-whitespace 99 | 100 | - repo: https://github.com/woodruffw/zizmor-pre-commit 101 | rev: v1.18.0 102 | hooks: 103 | - id: zizmor 104 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | #.idea/ 161 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
All Contributors
All Contributors

📖
Andreas Dutzler
Andreas Dutzler

💡
Bill Little
Bill Little

🤔 👀 🚧
Claude
Claude

💻
Dependabot
Dependabot

🚧
Keurfon Luu
Keurfon Luu

💻 🤔
Tetsuo Koyama
Tetsuo Koyama

🚇 ⚠️ 💻 🤔 🚧 🐛 📖 🎨 👀 💡 📣 🛡️ 💬 📢 💼
pre-commit.ci
pre-commit.ci

🚧
22 | 23 | 24 | 25 | 26 | 27 | 28 | This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | scikit-gmsh 6 |

7 | 8 | > Scikit for Gmsh to generate 3D finite element mesh. 9 | 10 | [![Status](https://badgen.net/badge/status/alpha/d8624d)](https://badgen.net/badge/status/alpha/d8624d) 11 | [![All Contributors](https://img.shields.io/github/all-contributors/pyvista/scikit-gmsh?color=ee8449)](https://scikit-gmsh.readthedocs.io/en/latest/reference/about.html#contributors) 12 | [![Contributing](https://img.shields.io/badge/PR-Welcome-%23FF8300.svg)](https://github.com/pyvista/scikit-gmsh/issues) 13 | [![Documentation Status](https://readthedocs.org/projects/scikit-gmsh/badge/?version=latest)](https://scikit-gmsh.readthedocs.io/en/latest/?badge=latest) 14 | [![GitHub Repo stars](https://img.shields.io/github/stars/pyvista/scikit-gmsh)](https://github.com/pyvista/scikit-gmsh/stargazers) 15 | [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) 16 | [![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md) 17 | [![Scientific Python](https://img.shields.io/badge/SPEC-0-blue.svg)](https://scientific-python.org/specs/spec-0000/) 18 | 19 | The `scikit-gmsh` package provides a simple interface to: 20 | 21 | - Christophe Geuzaine and Jean-François Remacle's [Gmsh](https://pypi.org/project/gmsh/) 22 | 23 | The library has following main objectives: 24 | 25 | 1. Provide an intuitive, object-oriented API for mesh creation like [scipy.spatial.Delaunay class](https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.Delaunay.html). 26 | 1. Integrate seamlessly with other libraries in the [Scientific Python ecosystem](https://scientific-python.org/). 27 | 28 | ## Installation 29 | 30 | [![pypi](https://img.shields.io/pypi/v/scikit-gmsh?label=pypi&logo=python&logoColor=white)](https://pypi.org/project/scikit-gmsh/) 31 | 32 | ```shell 33 | pip install scikit-gmsh 34 | ``` 35 | 36 | ## Gallery 37 | 38 | Check out the example galleries organized by subject here: 39 | 40 |

41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |

51 | 52 | ## Other Resources 53 | 54 | This library may not meet your needs and if this is this case, consider checking out these other resources: 55 | 56 | - [meshwell](https://github.com/simbilod/meshwell) - GMSH wrapper, with integrated photonics focus. 57 | - [objectgmsh](https://github.com/nemocrys/objectgmsh) - Object oriented Gmsh modeling. 58 | - [optimesh](https://github.com/meshpro/optimesh) - Mesh optimization, mesh smoothing. 59 | - [pandamesh](https://github.com/Deltares/pandamesh) - From geodataframe to mesh. 60 | - [pygalmesh](https://github.com/meshpro/pygalmesh) - A Python interface to CGAL's meshing tools. 61 | - [pygmsh](https://github.com/nschloe/pygmsh) - Gmsh for Python. 62 | - [pyvista-gridder](https://github.com/INTERA-Inc/pyvista-gridder) - Mesh generation using PyVista. 63 | 64 | ## License 65 | 66 | [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) 67 | 68 | This software is published under the [GPLv3 license](https://www.gnu.org/licenses/gpl-3.0.en.html). 69 | 70 | ## Contributions 71 | 72 | Contributions are _very welcome_ . 73 | This project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). 74 | By participating in this project, We want you to know that you agree to follow its terms. 75 | 76 | ## Star History 77 | 78 | Enjoying scikit-gmsh? Show your support with a [GitHub star](https://github.com/pyvista/scikit-gmsh) — it’s a simple click that means the world to us and helps others discover it, too! 79 | 80 | [![Star History Chart](https://api.star-history.com/svg?repos=pyvista/scikit-gmsh&type=Date)](https://star-history.com/#pyvista/scikit-gmsh&Date) 81 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | """ 2 | Configuration file for the Sphinx documentation builder. 3 | 4 | For the full list of built-in configuration values, see the documentation: 5 | https://www.sphinx-doc.org/en/master/usage/configuration.html 6 | """ 7 | 8 | from __future__ import annotations 9 | 10 | import datetime 11 | from importlib.metadata import version as get_version 12 | import os 13 | from pathlib import Path 14 | 15 | import pyvista 16 | from pyvista.plotting.utilities.sphinx_gallery import DynamicScraper 17 | 18 | pyvista.set_error_output_file("errors.txt") 19 | pyvista.OFF_SCREEN = True # Not necessary - simply an insurance policy 20 | pyvista.set_plot_theme("document") 21 | pyvista.BUILDING_GALLERY = True 22 | os.environ["PYVISTA_BUILDING_GALLERY"] = "true" 23 | 24 | if os.environ.get("READTHEDOCS") or os.environ.get("CI"): 25 | pyvista.start_xvfb() 26 | 27 | # -- Project information ----------------------------------------------------- 28 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information 29 | 30 | project = "scikit-gmsh" 31 | copyright_years = f"2024 - {datetime.datetime.now(datetime.UTC).year}" 32 | copyright = "2024, Tetsuo Koyama" # noqa: A001 33 | author = f"{project} Contributors" 34 | on_rtd = os.environ.get("READTHEDOCS") 35 | 36 | if on_rtd: 37 | # https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#including-content-based-on-tags 38 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#conf-tags 39 | tags.add("on_rtd") # noqa: F821 40 | 41 | # The full version, including alpha/beta/rc tags 42 | release = get_version("scikit-gmsh") 43 | release = release.removesuffix("+dirty") 44 | 45 | # docs src directory 46 | src_dir = Path(__file__).absolute().parent 47 | root_dir = src_dir.parents[1] 48 | package_dir = root_dir / "src" 49 | 50 | # -- General configuration --------------------------------------------------- 51 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration 52 | 53 | extensions = ["myst_parser", "pyvista.ext.plot_directive", "pyvista.ext.viewer_directive", "sphinx_design", "sphinx_gallery.gen_gallery"] 54 | templates_path = ["_templates"] 55 | exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] 56 | 57 | 58 | # -- Options for HTML output ------------------------------------------------- 59 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output 60 | 61 | html_theme = "sphinx_book_theme" 62 | html_logo = "_static/small_logo.svg" 63 | 64 | html_context = { 65 | "github_url": "https://github.com", 66 | "github_user": "pyvista", 67 | "github_repo": "scikit-gmsh", 68 | "github_version": "main", 69 | "doc_path": "docs/src", 70 | } 71 | 72 | html_theme_options = { 73 | "home_page_in_toc": True, 74 | "icon_links": [ 75 | { 76 | "name": "GitHub Discussions", 77 | "url": "https://github.com/pyvista/scikit-gmsh/discussions", 78 | "icon": "fa fa-comments fa-fw", 79 | }, 80 | { 81 | "name": "GitHub Issues", 82 | "url": "https://github.com/pyvista/scikit-gmsh/issues", 83 | "icon": "fa-brands fa-square-github fa-fw", 84 | }, 85 | { 86 | "name": "GitHub Pulls", 87 | "url": "https://github.com/pyvista/scikit-gmsh/pulls", 88 | "icon": "fa-brands fa-github-alt fa-fw", 89 | }, 90 | ], 91 | "navigation_with_keys": False, 92 | "path_to_docs": "docs/src", 93 | "repository_branch": "main", 94 | "repository_url": "https://github.com/pyvista/scikit-gmsh", 95 | "show_prev_next": True, 96 | "show_toc_level": 4, 97 | "toc_title": "On this page", 98 | "use_download_button": True, 99 | "use_edit_page_button": False, 100 | "use_fullscreen_button": True, 101 | "use_issues_button": False, 102 | "use_repository_button": True, 103 | "use_sidenotes": True, 104 | "use_source_button": False, 105 | } 106 | 107 | # Add any paths that contain custom static files (such as style sheets) here, 108 | # relative to this directory. They are copied after the builtin static files, 109 | # so a file named "default.css" will overwrite the builtin "default.css". 110 | html_static_path = [ 111 | "_static", 112 | ] 113 | html_css_files = [ 114 | "style.css", 115 | "theme_overrides.css", 116 | ] 117 | 118 | # -- MyST settings ----------------------------------------------------------- 119 | 120 | myst_enable_extensions = [ 121 | "amsmath", 122 | "attrs_block", 123 | "attrs_inline", 124 | "colon_fence", 125 | "deflist", 126 | "dollarmath", 127 | "fieldlist", 128 | "html_admonition", 129 | "html_image", 130 | "replacements", 131 | "smartquotes", 132 | "strikethrough", 133 | "substitution", 134 | "tasklist", 135 | ] 136 | 137 | # -- sphinx_gallery settings ------------------------------------------------- 138 | 139 | sphinx_gallery_conf = { 140 | "backreferences_dir": None, 141 | "doc_module": "pyvista", 142 | "download_all_examples": False, 143 | "examples_dirs": ["../examples/"], 144 | "filename_pattern": r"\.py", 145 | "first_notebook_cell": ("%matplotlib inline\nfrom pyvista import set_plot_theme\nset_plot_theme('document')\n"), 146 | "gallery_dirs": ["./examples"], 147 | "image_scrapers": (DynamicScraper(), "matplotlib"), 148 | "pypandoc": True, 149 | "remove_config_comments": True, 150 | "reset_modules_order": "both", 151 | } 152 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, caste, color, religion, or sexual 10 | identity and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | - Demonstrating empathy and kindness toward other people 21 | - Being respectful of differing opinions, viewpoints, and experiences 22 | - Giving and gracefully accepting constructive feedback 23 | - Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | - Focusing on what is best not just for us as individuals, but for the overall 26 | community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | - The use of sexualized language or imagery, and sexual attention or advances of 31 | any kind 32 | - Trolling, insulting or derogatory comments, and personal or political attacks 33 | - Public or private harassment 34 | - Publishing others' private information, such as a physical or email address, 35 | without their explicit permission 36 | - Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official email address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | tkoyama010@gmail.com. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series of 86 | actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or permanent 93 | ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within the 113 | community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.1, available at 119 | [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. 120 | 121 | Community Impact Guidelines were inspired by 122 | [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. 123 | 124 | For answers to common questions about this code of conduct, see the FAQ at 125 | [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at 126 | [https://www.contributor-covenant.org/translations][translations]. 127 | 128 | [homepage]: https://www.contributor-covenant.org 129 | [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html 130 | [Mozilla CoC]: https://github.com/mozilla/diversity 131 | [FAQ]: https://www.contributor-covenant.org/faq 132 | [translations]: https://www.contributor-covenant.org/translations 133 | -------------------------------------------------------------------------------- /CREDITS: -------------------------------------------------------------------------------- 1 | Gmsh is copyright (C) 1997-2022 2 | 3 | Christophe Geuzaine 4 | 5 | 6 | and 7 | 8 | Jean-Francois Remacle 9 | 10 | 11 | Code contributions to Gmsh have been provided by David Colignon (colormaps), 12 | Emilie Marchandise (old compound geometrical entities), Gaetan Bricteux (Gauss 13 | integration and levelsets), Jacques Lechelle (DIFFPACK export), Jonathan 14 | Lambrechts (mesh size fields, solver, Python wrappers), Jozef Vesely (old Tetgen 15 | integration), Koen Hillewaert (high order elements, generalized periodic 16 | meshes), Laurent Stainier (eigenvalue solvers, tensor display and help with 17 | macOS port), Marc Ume (original list and tree code), Mark van Doesburg (old 18 | OpenCASCADE face connection), Matt Gundry (Plot3d export), Matti Pellikka (cell 19 | complex and homology solver), Nicolas Tardieu (help with Netgen integration), 20 | Pascale Noyret (MED mesh IO), Pierre Badel (root finding and minimization), Ruth 21 | Sabariego (pyramids), Stephen Guzik (old CGNS IO, old partitioning code), 22 | Bastien Gorissen (parallel remote post-processing), Eric Bechet (solver), Gilles 23 | Marckmann (camera and stero mode, X3D export), Ashish Negi (Netgen CAD healing), 24 | Trevor Strickler (hybrid structured mesh coupling with pyramids), Amaury Johnen 25 | (Bezier code, high-order element validity), Benjamin Ruard (old Java wrappers), 26 | Maxime Graulich (iOS/Android port), Francois Henrotte (ONELAB metamodels), 27 | Sebastian Eiser (PGF export), Alexis Salzman (compressed IO), Hang Si (TetGen/BR 28 | boundary recovery code), Fernando Lorenzo (Tochnog export), Larry Price (Gambit 29 | export), Anthony Royer (new partitioning code, MSH4 IO), Darcy Beurle (code 30 | cleanup and performance improvements), Celestin Marot (HXT/tetMesh), 31 | Pierre-Alexandre Beaufort (HXT/reparam), Zhidong Han (LSDYNA export), Ismail 32 | Badia (hierarchical basis functions), Jeremy Theler (X3D export), Thomas 33 | Toulorge (high order mesh optimizer, new CGNS IO), Max Orok (binary PLY), Marek 34 | Wojciechowski (PyPi packaging), Maxence Reberol (automatic transfinite, quad 35 | meshing tools), Michael Ermakov (Gambit export, Fortran API, TransfiniteTri), 36 | Alex Krasner (X3D export), Giannis Nikiteas (Fortran API), Paul Sharp (Radioss 37 | export). See comments in the sources for more information. If we forgot to list 38 | your contributions please send us an email! 39 | 40 | Thanks to the following folks who have contributed by providing fresh ideas on 41 | theoretical or programming topics, who have sent patches, requests for changes 42 | or improvements, or who gave us access to exotic machines for testing Gmsh: Juan 43 | Abanto, Olivier Adam, Guillaume Alleon, Laurent Champaney, Pascal Dupuis, 44 | Patrick Dular, Philippe Geuzaine, Johan Gyselinck, Francois Henrotte, Benoit 45 | Meys, Nicolas Moes, Osamu Nakamura, Chad Schmutzer, Jean-Luc Fl'ejou, Xavier 46 | Dardenne, Christophe Prud'homme, Sebastien Clerc, Jose Miguel Pasini, Philippe 47 | Lussou, Jacques Kools, Bayram Yenikaya, Peter Hornby, Krishna Mohan Gundu, 48 | Christopher Stott, Timmy Schumacher, Carl Osterwisch, Bruno Frackowiak, Philip 49 | Kelleners, Romuald Conty, Renaud Sizaire, Michel Benhamou, Tom De Vuyst, Kris 50 | Van den Abeele, Simon Vun, Simon Corbin, Thomas De-Soza, Marcus Drosson, Antoine 51 | Dechaume, Jose Paulo Moitinho de Almeida, Thomas Pinchard, Corrado Chisari, Axel 52 | Hackbarth, Peter Wainwright, Jiri Hnidek, Thierry Thomas, Konstantinos Poulios, 53 | Laurent Van Miegroet, Shahrokh Ghavamian, Geordie McBain, Jose Paulo Moitinho de 54 | Almeida, Guillaume Demesy, Wendy Merks-Swolfs, Cosmin Stefan Deaconu, Nigel 55 | Nunn, Serban Georgescu, Julien Troufflard, Michele Mocciola, Matthijs Sypkens 56 | Smit, Sauli Ruuska, Romain Boman, Fredrik Ekre, Mark Burton, Max Orok, Paul 57 | Cristini, Isuru Fernando, Jose Paulo Moitinho de Almeida, Sophie Le Bras, 58 | Alberto Escrig, Samy Mukadi, Peter Johnston, Bruno de Sousa Alves, Stefan 59 | Bruens, Luca Verzeroli, Tristan Seidlhofer, Ding Jiaming, Joost Gevaert, Marcus 60 | Calhoun-Lopez, Michel Zou, Sir Sunsheep, Mariano Forti, Walter Steffe, Nico 61 | Schloemer, Simon Tournier, Alexandru Dadalau, Thomas Ulrich, Matthias Diener, 62 | Jamie Border; Kenneth Jansen. 63 | 64 | Special thanks to Bill Spitzak, Michael Sweet, Matthias Melcher, Greg Ercolano 65 | and others for the Fast Light Tool Kit on which Gmsh's GUI is based. See 66 | http://www.fltk.org for more info on this excellent object-oriented, 67 | cross-platform toolkit. Special thanks also to EDF for funding the original 68 | OpenCASCADE and MED integration in 2006-2007. Gmsh development was also 69 | financially supported by the PRACE project funded in part by the EU's Horizon 70 | 2020 Research and Innovation programme (2014-2020) under grant agreement 823767. 71 | 72 | The TetGen/BR code (src/mesh/tetgenBR.{cpp,h}) is copyright (c) 2016 Hang Si, 73 | Weierstrass Institute for Applied Analysis and Stochatics. It is relicensed 74 | under the terms of LICENSE.txt for use in Gmsh thanks to a Software License 75 | Agreement between Weierstrass Institute for Applied Analysis and Stochastics and 76 | GMESH SPRL. 77 | 78 | The AVL tree code (src/common/avl.{cpp,h}) and the YUV image code 79 | (src/graphics/gl2yuv.{cpp,h}) are copyright (C) 1988-1993, 1995 The Regents of 80 | the University of California. Permission to use, copy, modify, and distribute 81 | this software and its documentation for any purpose and without fee is hereby 82 | granted, provided that the above copyright notice appear in all copies and that 83 | both that copyright notice and this permission notice appear in supporting 84 | documentation, and that the name of the University of California not be used in 85 | advertising or publicity pertaining to distribution of the software without 86 | specific, written prior permission. The University of California makes no 87 | representations about the suitability of this software for any purpose. It is 88 | provided "as is" without express or implied warranty. 89 | 90 | The picojson code (src/common/picojson.h) is Copyright 2009-2010 Cybozu Labs, 91 | Inc., Copyright 2011-2014 Kazuho Oku, All rights reserved. Redistribution and 92 | use in source and binary forms, with or without modification, are permitted 93 | provided that the following conditions are met: 1. Redistributions of source 94 | code must retain the above copyright notice, this list of conditions and the 95 | following disclaimer. 2. Redistributions in binary form must reproduce the above 96 | copyright notice, this list of conditions and the following disclaimer in the 97 | documentation and/or other materials provided with the distribution. THIS 98 | SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 99 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 100 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 101 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 102 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 103 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 104 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 105 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 106 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 107 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 108 | 109 | The nanoflann code (src/numeric/nanoflann.hpp) is Copyright 2008-2009 Marius 110 | Muja, 2008-2009 David G. Lowe, 2011-2016 Jose Luis Blanco. Redistribution and 111 | use in source and binary forms, with or without modification, are permitted 112 | provided that the following conditions are met: 1. Redistributions of source 113 | code must retain the above copyright notice, this list of conditions and the 114 | following disclaimer. 2. Redistributions in binary form must reproduce the 115 | above copyright notice, this list of conditions and the following disclaimer in 116 | the documentation and/or other materials provided with the distribution. THIS 117 | SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 118 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 119 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 120 | SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 121 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 122 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 123 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 124 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 125 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 126 | OF SUCH DAMAGE. 127 | 128 | The trackball code (src/graphics/Trackball.{cpp.h}) is copyright (C) 1993, 1994, 129 | Silicon Graphics, Inc. ALL RIGHTS RESERVED. Permission to use, copy, modify, and 130 | distribute this software for any purpose and without fee is hereby granted, 131 | provided that the above copyright notice appear in all copies and that both the 132 | copyright notice and this permission notice appear in supporting documentation, 133 | and that the name of Silicon Graphics, Inc. not be used in advertising or 134 | publicity pertaining to distribution of the software without specific, written 135 | prior permission. 136 | 137 | The GIF and PPM routines (src/graphics/gl2gif.cpp) are based on code copyright 138 | (C) 1989, 1991, Jef Poskanzer. Permission to use, copy, modify, and distribute 139 | this software and its documentation for any purpose and without fee is hereby 140 | granted, provided that the above copyright notice appear in all copies and that 141 | both that copyright notice and this permission notice appear in supporting 142 | documentation. This software is provided "as is" without express or implied 143 | warranty. 144 | 145 | The colorbar widget (src/fltk/colorbarWindow.cpp) was inspired by code from the 146 | Vis5d program for visualizing five dimensional gridded data sets, copyright (C) 147 | 1990-1995, Bill Hibbard, Brian Paul, Dave Santek, and Andre Battaiola. 148 | 149 | The libOL code (src/common/libol1.{c,h}) is Copyright 2012-2018 - by Loïc 150 | Maréchal / INRIA. This program is a free software. You can redistribute it 151 | and/or modify it under the terms of the MIT License as published by the Open 152 | Source Initiative. 153 | 154 | The Fast & memory efficient hashtable based on robin hood hashing 155 | (src/common/robin_hood.h) is Copyright (c) 2018-2020 Martin Ankerl and is 156 | licensed under the MIT License. 157 | 158 | In addition, this version of Gmsh may contain the following contributed, 159 | optional codes in the contrib/ directory, each governed by their own license: 160 | 161 | * contrib/ANN copyright (C) 1997-2005 University of Maryland and Sunil Arya and 162 | David Mount; 163 | 164 | * contrib/gmm copyright (C) 2002-2008 Yves Renard; 165 | 166 | * contrib/hxt - Copyright (C) 2017-2020 - Universite catholique de Louvain; 167 | 168 | * contrib/kbipack copyright (C) 2005 Saku Suuriniemi; 169 | 170 | * contrib/MathEx based in part on the work of the SSCILIB Library, copyright (C) 171 | 2000-2003 Sadao Massago; 172 | 173 | * contrib/metis written by George Karypis (karypis at cs.umn.edu), copyright (C) 174 | 1995-2013 Regents of the University of Minnesota; 175 | 176 | * contrib/mpeg_encode copyright (c) 1995 The Regents of the University of 177 | California; 178 | 179 | * contrib/Netgen copyright (C) 1994-2004 Joachim Sch"oberl; 180 | 181 | * contrib/bamg from Freefem++ copyright (C) Frederic Hecht; 182 | 183 | * contrib/ALGLIB (C) Sergey Bochkanov (ALGLIB project); 184 | 185 | * contrib/blossom copyright (C) 1995-1997 Bill Cook et al.; 186 | 187 | * contrib/bamg from Freefem++ copyright (C) Frederic Hecht; 188 | 189 | * contrib/voro++ from Voro++ Copyright (c) 2008, The Regents of the University 190 | of California, through Lawrence Berkeley National Laboratory (subject to 191 | receipt of any required approvals from the U.S. Dept. of Energy). All rights 192 | reserved; 193 | 194 | * contrib/zipper from MiniZip - Copyright (c) 1998-2010 - by Gilles Vollant - 195 | version 1.1 64 bits from Mathias Svensson. 196 | 197 | Check the configuration options to see which have been enabled. 198 | -------------------------------------------------------------------------------- /src/skgmsh/__init__.py: -------------------------------------------------------------------------------- 1 | """scikit-gmsh package for 3D mesh generation.""" 2 | 3 | from __future__ import annotations 4 | 5 | import datetime 6 | from typing import TYPE_CHECKING 7 | 8 | import gmsh 9 | import numpy as np 10 | import pyvista as pv 11 | import scooby 12 | import shapely 13 | 14 | if TYPE_CHECKING: 15 | from collections.abc import Sequence 16 | 17 | from numpy.typing import ArrayLike 18 | 19 | INITIAL_MESH_ONLY_2D = 3 20 | FRONTAL_DELAUNAY_2D = 6 21 | DELAUNAY_3D = 1 22 | INITIAL_MESH_ONLY_3D = 3 23 | 24 | SILENT = 0 25 | SIMPLE = 0 26 | 27 | TRUE = 1 28 | FALSE = 0 29 | 30 | now = datetime.datetime.now(tz=datetime.UTC) 31 | 32 | # major, minor, patch 33 | version_info = 0, 4, "dev0" 34 | 35 | # Nice string for the version 36 | __version__ = ".".join(map(str, version_info)) 37 | 38 | 39 | class Report(scooby.Report): # type: ignore[misc] 40 | """ 41 | Generate an environment package and hardware report. 42 | 43 | Parameters 44 | ---------- 45 | ncol : int, default: 3 46 | Number of package-columns in html table; only has effect if 47 | ``mode='HTML'`` or ``mode='html'``. 48 | 49 | text_width : int, default: 80 50 | The text width for non-HTML display modes. 51 | 52 | """ 53 | 54 | def __init__(self: Report, ncol: int = 3, text_width: int = 80) -> None: # numpydoc ignore=PR01 55 | """Generate a :class:`scooby.Report` instance.""" 56 | # mandatory packages 57 | core: list[str] = [ 58 | "matplotlib", 59 | "numpy", 60 | "pooch", 61 | "pyvista", 62 | "scooby", 63 | "vtk", 64 | "gmsh", 65 | "meshio", 66 | "pygmsh", 67 | "pyvista", 68 | ] 69 | 70 | # optional packages 71 | optional: list[str] = [ 72 | "imageio", 73 | "pyvistaqt", 74 | "PyQt5", 75 | "IPython", 76 | "colorcet", 77 | "cmocean", 78 | "ipywidgets", 79 | "scipy", 80 | "tqdm", 81 | "jupyterlab", 82 | "pytest_pyvista", 83 | "trame", 84 | "trame_client", 85 | "trame_server", 86 | "trame_vtk", 87 | "trame_vuetify", 88 | "jupyter_server_proxy", 89 | "nest_asyncio", 90 | ] 91 | 92 | extra_meta = [ 93 | ("GPU Details", "None"), 94 | ] 95 | 96 | super().__init__( 97 | core=core, 98 | optional=optional, 99 | ncol=ncol, 100 | text_width=text_width, 101 | extra_meta=extra_meta, 102 | ) 103 | 104 | 105 | def delaunay_3d( 106 | edge_source: pv.PolyData, 107 | target_sizes: float | Sequence[float] | None = None, 108 | ) -> pv.UnstructuredGrid | None: 109 | """ 110 | Delaunay 3D mesh algorithm. 111 | 112 | Parameters 113 | ---------- 114 | edge_source : pyvista.PolyData 115 | Specify the source object used to specify constrained 116 | edges and loops. If set, and lines/polygons are defined, a 117 | constrained triangulation is created. The lines/polygons 118 | are assumed to reference points in the input point set 119 | (i.e. point ids are identical in the input and 120 | source). 121 | 122 | target_sizes : float | Sequence[float] 123 | Target mesh size close to the points. 124 | 125 | Returns 126 | ------- 127 | pyvista.UnstructuredGrid 128 | Mesh from the 3D delaunay generation. 129 | 130 | Notes 131 | ----- 132 | .. versionadded:: 0.2.0 133 | 134 | """ 135 | points = edge_source.points 136 | faces = edge_source.irregular_faces 137 | 138 | gmsh.initialize() 139 | if target_sizes is None: 140 | gmsh.option.set_number("Mesh.Algorithm", INITIAL_MESH_ONLY_3D) 141 | gmsh.option.set_number("Mesh.MeshSizeExtendFromBoundary", 0) 142 | gmsh.option.set_number("Mesh.MeshSizeFromPoints", 0) 143 | gmsh.option.set_number("Mesh.MeshSizeFromCurvature", 0) 144 | else: 145 | gmsh.option.set_number("Mesh.Algorithm3D", DELAUNAY_3D) 146 | gmsh.option.set_number("General.Verbosity", SILENT) 147 | gmsh.option.set_number("Mesh.AlgorithmSwitchOnFailure", FALSE) 148 | gmsh.option.set_number("Mesh.RecombinationAlgorithm", SIMPLE) 149 | gmsh.option.set_number("Mesh.RecombineNodeRepositioning", FALSE) 150 | 151 | if target_sizes is None: 152 | target_sizes = 0.0 153 | 154 | if isinstance(target_sizes, float): 155 | target_sizes = [target_sizes] * edge_source.number_of_points 156 | 157 | for i, (point, target_size) in enumerate(zip(points, target_sizes, strict=False)): 158 | id_ = i + 1 159 | gmsh.model.geo.add_point(point[0], point[1], point[2], target_size, id_) 160 | 161 | surface_loop = [] 162 | for i, face in enumerate(faces): 163 | curve_tags = [] 164 | for j, _ in enumerate(face): 165 | start_tag = face[j - 1] + 1 166 | end_tag = face[j] + 1 167 | curve_tag = gmsh.model.geo.add_line(start_tag, end_tag) 168 | curve_tags.append(curve_tag) 169 | gmsh.model.geo.add_curve_loop(curve_tags, i + 1) 170 | gmsh.model.geo.add_plane_surface([i + 1], i + 1) 171 | surface_loop.append(i + 1) 172 | 173 | gmsh.model.geo.remove_all_duplicates() 174 | gmsh.model.geo.synchronize() 175 | 176 | gmsh.model.geo.add_surface_loop(surface_loop, 1) 177 | gmsh.model.geo.add_volume([1], 1) 178 | 179 | gmsh.model.geo.synchronize() 180 | mesh = generate_mesh(3) 181 | 182 | ind = [] 183 | for i, cell in enumerate(mesh.cell): 184 | if cell.type != pv.CellType.TETRA: 185 | ind.append(i) 186 | mesh = mesh.remove_cells(ind) 187 | mesh.clear_data() 188 | 189 | return mesh 190 | 191 | 192 | def frontal_delaunay_2d( # noqa: C901, PLR0912 193 | edge_source: pv.PolyData | shapely.geometry.Polygon, 194 | target_sizes: float | ArrayLike | None = None, 195 | recombine: bool = False, # noqa: FBT001, FBT002 196 | ) -> pv.UnstructuredGrid | None: 197 | """ 198 | Frontal-Delaunay 2D mesh algorithm. 199 | 200 | Parameters 201 | ---------- 202 | edge_source : pyvista.PolyData | shapely.geometry.Polygon 203 | Specify the source object used to specify constrained 204 | edges and loops. If set, and lines/polygons are defined, a 205 | constrained triangulation is created. The lines/polygons 206 | are assumed to reference points in the input point set 207 | (i.e. point ids are identical in the input and 208 | source). 209 | 210 | target_sizes : float | ArrayLike 211 | Target mesh size close to the points. 212 | Default max size of edge_source in each direction. 213 | 214 | recombine : bool 215 | Recombine the generated mesh into quadrangles. 216 | 217 | Returns 218 | ------- 219 | pyvista.UnstructuredGrid 220 | Mesh from the 2D delaunay generation. 221 | 222 | Notes 223 | ----- 224 | .. versionadded:: 0.2.0 225 | 226 | """ 227 | gmsh.initialize() 228 | if target_sizes is None: 229 | gmsh.option.set_number("Mesh.Algorithm", INITIAL_MESH_ONLY_2D) 230 | gmsh.option.set_number("Mesh.MeshSizeExtendFromBoundary", 0) 231 | gmsh.option.set_number("Mesh.MeshSizeFromPoints", 0) 232 | gmsh.option.set_number("Mesh.MeshSizeFromCurvature", 0) 233 | else: 234 | gmsh.option.set_number("Mesh.Algorithm", FRONTAL_DELAUNAY_2D) 235 | gmsh.option.set_number("General.Verbosity", SILENT) 236 | 237 | if target_sizes is None: 238 | target_sizes = 0.0 239 | 240 | if isinstance(edge_source, shapely.geometry.Polygon): 241 | wire_tags = [] 242 | 243 | if isinstance(target_sizes, float): 244 | target_sizes = [target_sizes] * (len(edge_source.interiors) + 1) 245 | 246 | for target_size, linearring in zip(target_sizes, [edge_source.exterior, *list(edge_source.interiors)], strict=False): 247 | sizes = [target_size] * (len(linearring.coords) - 1) if isinstance(target_size, float) else target_size 248 | coords = linearring.coords[:-1].copy() 249 | tags = [] 250 | for size, coord in zip(sizes, coords, strict=False): 251 | x, y, z = coord 252 | tags.append(gmsh.model.geo.add_point(x, y, z, size)) 253 | curve_tags = [] 254 | for i, _ in enumerate(tags): 255 | start_tag = tags[i - 1] 256 | end_tag = tags[i] 257 | curve_tags.append(gmsh.model.geo.add_line(start_tag, end_tag)) 258 | wire_tags.append(gmsh.model.geo.add_curve_loop(curve_tags)) 259 | gmsh.model.geo.add_plane_surface(wire_tags) 260 | gmsh.model.geo.synchronize() 261 | else: 262 | points = edge_source.points 263 | lines = edge_source.lines 264 | 265 | if isinstance(target_sizes, float): 266 | target_sizes = [target_sizes] * edge_source.number_of_points 267 | 268 | embedded_points = [] 269 | for target_size, point in zip(target_sizes, points, strict=False): 270 | embedded_points.append(gmsh.model.geo.add_point(point[0], point[1], point[2], target_size)) 271 | 272 | for i in range(lines[0] - 1): 273 | id_ = i + 1 274 | gmsh.model.geo.add_line(lines[i + 1] + 1, lines[i + 2] + 1, id_) 275 | 276 | gmsh.model.geo.add_curve_loop(range(1, lines[0]), 1) 277 | gmsh.model.geo.add_plane_surface([1], 1) 278 | gmsh.model.geo.synchronize() 279 | gmsh.model.mesh.embed(0, embedded_points, 2, 1) 280 | 281 | if recombine: 282 | gmsh.model.mesh.set_recombine(2, 1) 283 | 284 | mesh = generate_mesh(2) 285 | 286 | ind = [] 287 | for index, cell in enumerate(mesh.cell): 288 | if cell.type in [pv.CellType.VERTEX, pv.CellType.LINE]: 289 | ind.append(index) 290 | 291 | return mesh.remove_cells(ind) 292 | 293 | 294 | def generate_mesh(dim: int) -> pv.UnstructuredGrid: 295 | """ 296 | Generate a mesh of the current model. 297 | 298 | Parameters 299 | ---------- 300 | dim : int 301 | Mesh dimension. 302 | 303 | Returns 304 | ------- 305 | pyvista.UnstructuredGrid 306 | Generated mesh. 307 | 308 | """ 309 | gmsh_to_pyvista_type = { 310 | 1: pv.CellType.LINE, 311 | 2: pv.CellType.TRIANGLE, 312 | 3: pv.CellType.QUAD, 313 | 4: pv.CellType.TETRA, 314 | 5: pv.CellType.HEXAHEDRON, 315 | 6: pv.CellType.WEDGE, 316 | 7: pv.CellType.PYRAMID, 317 | 15: pv.CellType.VERTEX, 318 | } 319 | 320 | try: 321 | gmsh.model.mesh.generate(dim) 322 | node_tags, coord, _ = gmsh.model.mesh.getNodes() 323 | element_types, element_tags, element_node_tags = gmsh.model.mesh.getElements() 324 | 325 | # Points 326 | assert (np.diff(node_tags) > 0).all() # noqa: S101 327 | points = np.reshape(coord, (-1, 3)) 328 | 329 | # Cells 330 | cells = {} 331 | 332 | for type_, tags, node_tags in zip(element_types, element_tags, element_node_tags, strict=False): 333 | assert (np.diff(tags) > 0).all() # noqa: S101 334 | 335 | celltype = gmsh_to_pyvista_type[type_] 336 | num_nodes = gmsh.model.mesh.getElementProperties(type_)[3] 337 | cells[celltype] = np.reshape(node_tags, (-1, num_nodes)) - 1 338 | 339 | mesh = pv.UnstructuredGrid(cells, points) 340 | 341 | finally: 342 | gmsh.clear() 343 | gmsh.finalize() 344 | 345 | return mesh 346 | 347 | 348 | class Delaunay2D: 349 | """ 350 | Delaunay 2D mesh algorithm. 351 | 352 | Parameters 353 | ---------- 354 | edge_source : pyvista.PolyData | shapely.Polygon 355 | Specify the source object used to specify constrained 356 | edges and loops. If set, and lines/polygons are defined, a 357 | constrained triangulation is created. The lines/polygons 358 | are assumed to reference points in the input point set 359 | (i.e. point ids are identical in the input and 360 | source). 361 | 362 | shell : sequence 363 | A sequence of (x, y [,z]) numeric coordinate pairs or triples, or 364 | an array-like with shape (N, 2) or (N, 3). 365 | Also can be a sequence of Point objects. 366 | 367 | holes : sequence 368 | A sequence of objects which satisfy the same requirements as the 369 | shell parameters above. 370 | 371 | cell_size : float | ArrayLike 372 | Meshing constraint at point. 373 | 374 | constrain_edge_size : bool 375 | If True, cell size at points are set to their maximum edge length. 376 | 377 | Notes 378 | ----- 379 | .. versionadded:: 0.2.0 380 | 381 | """ 382 | 383 | def __init__( 384 | self: Delaunay2D, 385 | *, 386 | edge_source: pv.PolyData | shapely.Polygon | None = None, 387 | shell: Sequence[tuple[int]] | None = None, 388 | holes: Sequence[tuple[int]] | None = None, 389 | cell_size: float | ArrayLike | None = None, 390 | constrain_edge_size: bool = False, 391 | ) -> None: 392 | """Initialize the Delaunay2D class.""" 393 | if edge_source is not None: 394 | self._edge_source = edge_source 395 | else: 396 | self._edge_source = shapely.Polygon(shell, holes) 397 | 398 | if constrain_edge_size: 399 | if isinstance(self.edge_source, shapely.Polygon): 400 | cell_size = [self._compute_cell_size_from_points(self.edge_source.exterior.coords)] 401 | cell_size += [self._compute_cell_size_from_points(hole.coords) for hole in self.edge_source.interiors] 402 | 403 | else: 404 | # Only the first line is processed 405 | lines = edge_source.lines 406 | line = lines[1 : lines[0] + 1] 407 | edge_points = edge_source.points[line] 408 | cell_size = self._compute_cell_size_from_points(edge_points) 409 | 410 | self._cell_size = cell_size 411 | self._recombine = False 412 | 413 | @staticmethod 414 | def _compute_cell_size_from_points(points: ArrayLike) -> ArrayLike: 415 | """Compute cell size from points array.""" 416 | lengths = np.linalg.norm(np.diff(points, axis=0), axis=-1) 417 | lengths = np.insert(lengths, 0, lengths[-1]) 418 | 419 | return np.maximum(lengths[:-1], lengths[1:]) 420 | 421 | @property 422 | def edge_source(self: Delaunay2D) -> pv.PolyData | shapely.geometry.Polygon: 423 | """Get the edge source.""" 424 | return self._edge_source 425 | 426 | @property 427 | def mesh(self: Delaunay2D) -> pv.PolyData: 428 | """Get the mesh.""" 429 | mesh = frontal_delaunay_2d(self._edge_source, target_sizes=self._cell_size, recombine=self._recombine) 430 | return pv.PolyData(mesh.points, mesh.cells) 431 | 432 | @property 433 | def cell_size(self: Delaunay2D) -> float | ArrayLike | None: 434 | """Get the cell_size of the mesh.""" 435 | return self._cell_size 436 | 437 | @cell_size.setter 438 | def cell_size(self: Delaunay2D, size: float | ArrayLike | None) -> None: 439 | """Set the cell_size of the mesh.""" 440 | self._cell_size = size 441 | 442 | def enable_recombine(self: Delaunay2D) -> None: 443 | """Enable recombination of the mesh.""" 444 | self._recombine = True 445 | 446 | def disable_recombine(self: Delaunay2D) -> None: 447 | """Disable recombination of the mesh.""" 448 | self._recombine = False 449 | 450 | 451 | class Delaunay3D: 452 | """ 453 | Delaunay 3D mesh algorithm. 454 | 455 | Parameters 456 | ---------- 457 | edge_source : pyvista.PolyData 458 | Specify the source object used to specify constrained 459 | edges and loops. If set, and lines/polygons are defined, a 460 | constrained triangulation is created. The lines/polygons 461 | are assumed to reference points in the input point set 462 | (i.e. point ids are identical in the input and 463 | source). 464 | 465 | Notes 466 | ----- 467 | .. versionadded:: 0.2.0 468 | 469 | """ 470 | 471 | def __init__( 472 | self: Delaunay3D, 473 | edge_source: pv.PolyData, 474 | cell_size: float | None = None, 475 | ) -> None: 476 | """Initialize the Delaunay3D class.""" 477 | self._edge_source = edge_source 478 | self._cell_size = cell_size 479 | 480 | @property 481 | def edge_source(self: Delaunay3D) -> pv.PolyData: 482 | """Get the edge source.""" 483 | return self._edge_source 484 | 485 | @property 486 | def mesh(self: Delaunay3D) -> pv.UnstructuredGrid: 487 | """Get the mesh.""" 488 | self._mesh = delaunay_3d(self.edge_source, target_sizes=self.cell_size) 489 | return self._mesh 490 | 491 | @property 492 | def cell_size(self: Delaunay3D) -> float | None: 493 | """Get the cell_size of the mesh.""" 494 | return self._cell_size 495 | 496 | @cell_size.setter 497 | def cell_size(self: Delaunay3D, size: int) -> None: 498 | """Set the cell_size of the mesh.""" 499 | self._cell_size = size 500 | -------------------------------------------------------------------------------- /docs/_static/csg_tree/LICENSE: -------------------------------------------------------------------------------- 1 | Attribution-NonCommercial-ShareAlike 4.0 International 2 | 3 | ======================================================================= 4 | 5 | Creative Commons Corporation ("Creative Commons") is not a law firm and 6 | does not provide legal services or legal advice. Distribution of 7 | Creative Commons public licenses does not create a lawyer-client or 8 | other relationship. Creative Commons makes its licenses and related 9 | information available on an "as-is" basis. Creative Commons gives no 10 | warranties regarding its licenses, any material licensed under their 11 | terms and conditions, or any related information. Creative Commons 12 | disclaims all liability for damages resulting from their use to the 13 | fullest extent possible. 14 | 15 | Using Creative Commons Public Licenses 16 | 17 | Creative Commons public licenses provide a standard set of terms and 18 | conditions that creators and other rights holders may use to share 19 | original works of authorship and other material subject to copyright 20 | and certain other rights specified in the public license below. The 21 | following considerations are for informational purposes only, are not 22 | exhaustive, and do not form part of our licenses. 23 | 24 | Considerations for licensors: Our public licenses are 25 | intended for use by those authorized to give the public 26 | permission to use material in ways otherwise restricted by 27 | copyright and certain other rights. Our licenses are 28 | irrevocable. Licensors should read and understand the terms 29 | and conditions of the license they choose before applying it. 30 | Licensors should also secure all rights necessary before 31 | applying our licenses so that the public can reuse the 32 | material as expected. Licensors should clearly mark any 33 | material not subject to the license. This includes other CC- 34 | licensed material, or material used under an exception or 35 | limitation to copyright. More considerations for licensors: 36 | wiki.creativecommons.org/Considerations_for_licensors 37 | 38 | Considerations for the public: By using one of our public 39 | licenses, a licensor grants the public permission to use the 40 | licensed material under specified terms and conditions. If 41 | the licensor's permission is not necessary for any reason--for 42 | example, because of any applicable exception or limitation to 43 | copyright--then that use is not regulated by the license. Our 44 | licenses grant only permissions under copyright and certain 45 | other rights that a licensor has authority to grant. Use of 46 | the licensed material may still be restricted for other 47 | reasons, including because others have copyright or other 48 | rights in the material. A licensor may make special requests, 49 | such as asking that all changes be marked or described. 50 | Although not required by our licenses, you are encouraged to 51 | respect those requests where reasonable. More considerations 52 | for the public: 53 | wiki.creativecommons.org/Considerations_for_licensees 54 | 55 | ======================================================================= 56 | 57 | Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International 58 | Public License 59 | 60 | By exercising the Licensed Rights (defined below), You accept and agree 61 | to be bound by the terms and conditions of this Creative Commons 62 | Attribution-NonCommercial-ShareAlike 4.0 International Public License 63 | ("Public License"). To the extent this Public License may be 64 | interpreted as a contract, You are granted the Licensed Rights in 65 | consideration of Your acceptance of these terms and conditions, and the 66 | Licensor grants You such rights in consideration of benefits the 67 | Licensor receives from making the Licensed Material available under 68 | these terms and conditions. 69 | 70 | 71 | Section 1 -- Definitions. 72 | 73 | a. Adapted Material means material subject to Copyright and Similar 74 | Rights that is derived from or based upon the Licensed Material 75 | and in which the Licensed Material is translated, altered, 76 | arranged, transformed, or otherwise modified in a manner requiring 77 | permission under the Copyright and Similar Rights held by the 78 | Licensor. For purposes of this Public License, where the Licensed 79 | Material is a musical work, performance, or sound recording, 80 | Adapted Material is always produced where the Licensed Material is 81 | synched in timed relation with a moving image. 82 | 83 | b. Adapter's License means the license You apply to Your Copyright 84 | and Similar Rights in Your contributions to Adapted Material in 85 | accordance with the terms and conditions of this Public License. 86 | 87 | c. BY-NC-SA Compatible License means a license listed at 88 | creativecommons.org/compatiblelicenses, approved by Creative 89 | Commons as essentially the equivalent of this Public License. 90 | 91 | d. Copyright and Similar Rights means copyright and/or similar rights 92 | closely related to copyright including, without limitation, 93 | performance, broadcast, sound recording, and Sui Generis Database 94 | Rights, without regard to how the rights are labeled or 95 | categorized. For purposes of this Public License, the rights 96 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 97 | Rights. 98 | 99 | e. Effective Technological Measures means those measures that, in the 100 | absence of proper authority, may not be circumvented under laws 101 | fulfilling obligations under Article 11 of the WIPO Copyright 102 | Treaty adopted on December 20, 1996, and/or similar international 103 | agreements. 104 | 105 | f. Exceptions and Limitations means fair use, fair dealing, and/or 106 | any other exception or limitation to Copyright and Similar Rights 107 | that applies to Your use of the Licensed Material. 108 | 109 | g. License Elements means the license attributes listed in the name 110 | of a Creative Commons Public License. The License Elements of this 111 | Public License are Attribution, NonCommercial, and ShareAlike. 112 | 113 | h. Licensed Material means the artistic or literary work, database, 114 | or other material to which the Licensor applied this Public 115 | License. 116 | 117 | i. Licensed Rights means the rights granted to You subject to the 118 | terms and conditions of this Public License, which are limited to 119 | all Copyright and Similar Rights that apply to Your use of the 120 | Licensed Material and that the Licensor has authority to license. 121 | 122 | j. Licensor means the individual(s) or entity(ies) granting rights 123 | under this Public License. 124 | 125 | k. NonCommercial means not primarily intended for or directed towards 126 | commercial advantage or monetary compensation. For purposes of 127 | this Public License, the exchange of the Licensed Material for 128 | other material subject to Copyright and Similar Rights by digital 129 | file-sharing or similar means is NonCommercial provided there is 130 | no payment of monetary compensation in connection with the 131 | exchange. 132 | 133 | l. Share means to provide material to the public by any means or 134 | process that requires permission under the Licensed Rights, such 135 | as reproduction, public display, public performance, distribution, 136 | dissemination, communication, or importation, and to make material 137 | available to the public including in ways that members of the 138 | public may access the material from a place and at a time 139 | individually chosen by them. 140 | 141 | m. Sui Generis Database Rights means rights other than copyright 142 | resulting from Directive 96/9/EC of the European Parliament and of 143 | the Council of 11 March 1996 on the legal protection of databases, 144 | as amended and/or succeeded, as well as other essentially 145 | equivalent rights anywhere in the world. 146 | 147 | n. You means the individual or entity exercising the Licensed Rights 148 | under this Public License. Your has a corresponding meaning. 149 | 150 | 151 | Section 2 -- Scope. 152 | 153 | a. License grant. 154 | 155 | 1. Subject to the terms and conditions of this Public License, 156 | the Licensor hereby grants You a worldwide, royalty-free, 157 | non-sublicensable, non-exclusive, irrevocable license to 158 | exercise the Licensed Rights in the Licensed Material to: 159 | 160 | a. reproduce and Share the Licensed Material, in whole or 161 | in part, for NonCommercial purposes only; and 162 | 163 | b. produce, reproduce, and Share Adapted Material for 164 | NonCommercial purposes only. 165 | 166 | 2. Exceptions and Limitations. For the avoidance of doubt, where 167 | Exceptions and Limitations apply to Your use, this Public 168 | License does not apply, and You do not need to comply with 169 | its terms and conditions. 170 | 171 | 3. Term. The term of this Public License is specified in Section 172 | 6(a). 173 | 174 | 4. Media and formats; technical modifications allowed. The 175 | Licensor authorizes You to exercise the Licensed Rights in 176 | all media and formats whether now known or hereafter created, 177 | and to make technical modifications necessary to do so. The 178 | Licensor waives and/or agrees not to assert any right or 179 | authority to forbid You from making technical modifications 180 | necessary to exercise the Licensed Rights, including 181 | technical modifications necessary to circumvent Effective 182 | Technological Measures. For purposes of this Public License, 183 | simply making modifications authorized by this Section 2(a) 184 | (4) never produces Adapted Material. 185 | 186 | 5. Downstream recipients. 187 | 188 | a. Offer from the Licensor -- Licensed Material. Every 189 | recipient of the Licensed Material automatically 190 | receives an offer from the Licensor to exercise the 191 | Licensed Rights under the terms and conditions of this 192 | Public License. 193 | 194 | b. Additional offer from the Licensor -- Adapted Material. 195 | Every recipient of Adapted Material from You 196 | automatically receives an offer from the Licensor to 197 | exercise the Licensed Rights in the Adapted Material 198 | under the conditions of the Adapter's License You apply. 199 | 200 | c. No downstream restrictions. You may not offer or impose 201 | any additional or different terms or conditions on, or 202 | apply any Effective Technological Measures to, the 203 | Licensed Material if doing so restricts exercise of the 204 | Licensed Rights by any recipient of the Licensed 205 | Material. 206 | 207 | 6. No endorsement. Nothing in this Public License constitutes or 208 | may be construed as permission to assert or imply that You 209 | are, or that Your use of the Licensed Material is, connected 210 | with, or sponsored, endorsed, or granted official status by, 211 | the Licensor or others designated to receive attribution as 212 | provided in Section 3(a)(1)(A)(i). 213 | 214 | b. Other rights. 215 | 216 | 1. Moral rights, such as the right of integrity, are not 217 | licensed under this Public License, nor are publicity, 218 | privacy, and/or other similar personality rights; however, to 219 | the extent possible, the Licensor waives and/or agrees not to 220 | assert any such rights held by the Licensor to the limited 221 | extent necessary to allow You to exercise the Licensed 222 | Rights, but not otherwise. 223 | 224 | 2. Patent and trademark rights are not licensed under this 225 | Public License. 226 | 227 | 3. To the extent possible, the Licensor waives any right to 228 | collect royalties from You for the exercise of the Licensed 229 | Rights, whether directly or through a collecting society 230 | under any voluntary or waivable statutory or compulsory 231 | licensing scheme. In all other cases the Licensor expressly 232 | reserves any right to collect such royalties, including when 233 | the Licensed Material is used other than for NonCommercial 234 | purposes. 235 | 236 | 237 | Section 3 -- License Conditions. 238 | 239 | Your exercise of the Licensed Rights is expressly made subject to the 240 | following conditions. 241 | 242 | a. Attribution. 243 | 244 | 1. If You Share the Licensed Material (including in modified 245 | form), You must: 246 | 247 | a. retain the following if it is supplied by the Licensor 248 | with the Licensed Material: 249 | 250 | i. identification of the creator(s) of the Licensed 251 | Material and any others designated to receive 252 | attribution, in any reasonable manner requested by 253 | the Licensor (including by pseudonym if 254 | designated); 255 | 256 | ii. a copyright notice; 257 | 258 | iii. a notice that refers to this Public License; 259 | 260 | iv. a notice that refers to the disclaimer of 261 | warranties; 262 | 263 | v. a URI or hyperlink to the Licensed Material to the 264 | extent reasonably practicable; 265 | 266 | b. indicate if You modified the Licensed Material and 267 | retain an indication of any previous modifications; and 268 | 269 | c. indicate the Licensed Material is licensed under this 270 | Public License, and include the text of, or the URI or 271 | hyperlink to, this Public License. 272 | 273 | 2. You may satisfy the conditions in Section 3(a)(1) in any 274 | reasonable manner based on the medium, means, and context in 275 | which You Share the Licensed Material. For example, it may be 276 | reasonable to satisfy the conditions by providing a URI or 277 | hyperlink to a resource that includes the required 278 | information. 279 | 3. If requested by the Licensor, You must remove any of the 280 | information required by Section 3(a)(1)(A) to the extent 281 | reasonably practicable. 282 | 283 | b. ShareAlike. 284 | 285 | In addition to the conditions in Section 3(a), if You Share 286 | Adapted Material You produce, the following conditions also apply. 287 | 288 | 1. The Adapter's License You apply must be a Creative Commons 289 | license with the same License Elements, this version or 290 | later, or a BY-NC-SA Compatible License. 291 | 292 | 2. You must include the text of, or the URI or hyperlink to, the 293 | Adapter's License You apply. You may satisfy this condition 294 | in any reasonable manner based on the medium, means, and 295 | context in which You Share Adapted Material. 296 | 297 | 3. You may not offer or impose any additional or different terms 298 | or conditions on, or apply any Effective Technological 299 | Measures to, Adapted Material that restrict exercise of the 300 | rights granted under the Adapter's License You apply. 301 | 302 | 303 | Section 4 -- Sui Generis Database Rights. 304 | 305 | Where the Licensed Rights include Sui Generis Database Rights that 306 | apply to Your use of the Licensed Material: 307 | 308 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 309 | to extract, reuse, reproduce, and Share all or a substantial 310 | portion of the contents of the database for NonCommercial purposes 311 | only; 312 | 313 | b. if You include all or a substantial portion of the database 314 | contents in a database in which You have Sui Generis Database 315 | Rights, then the database in which You have Sui Generis Database 316 | Rights (but not its individual contents) is Adapted Material, 317 | including for purposes of Section 3(b); and 318 | 319 | c. You must comply with the conditions in Section 3(a) if You Share 320 | all or a substantial portion of the contents of the database. 321 | 322 | For the avoidance of doubt, this Section 4 supplements and does not 323 | replace Your obligations under this Public License where the Licensed 324 | Rights include other Copyright and Similar Rights. 325 | 326 | 327 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 328 | 329 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 330 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 331 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 332 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 333 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 334 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 335 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 336 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 337 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 338 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 339 | 340 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 341 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 342 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 343 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 344 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 345 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 346 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 347 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 348 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 349 | 350 | c. The disclaimer of warranties and limitation of liability provided 351 | above shall be interpreted in a manner that, to the extent 352 | possible, most closely approximates an absolute disclaimer and 353 | waiver of all liability. 354 | 355 | 356 | Section 6 -- Term and Termination. 357 | 358 | a. This Public License applies for the term of the Copyright and 359 | Similar Rights licensed here. However, if You fail to comply with 360 | this Public License, then Your rights under this Public License 361 | terminate automatically. 362 | 363 | b. Where Your right to use the Licensed Material has terminated under 364 | Section 6(a), it reinstates: 365 | 366 | 1. automatically as of the date the violation is cured, provided 367 | it is cured within 30 days of Your discovery of the 368 | violation; or 369 | 370 | 2. upon express reinstatement by the Licensor. 371 | 372 | For the avoidance of doubt, this Section 6(b) does not affect any 373 | right the Licensor may have to seek remedies for Your violations 374 | of this Public License. 375 | 376 | c. For the avoidance of doubt, the Licensor may also offer the 377 | Licensed Material under separate terms or conditions or stop 378 | distributing the Licensed Material at any time; however, doing so 379 | will not terminate this Public License. 380 | 381 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 382 | License. 383 | 384 | 385 | Section 7 -- Other Terms and Conditions. 386 | 387 | a. The Licensor shall not be bound by any additional or different 388 | terms or conditions communicated by You unless expressly agreed. 389 | 390 | b. Any arrangements, understandings, or agreements regarding the 391 | Licensed Material not stated herein are separate from and 392 | independent of the terms and conditions of this Public License. 393 | 394 | 395 | Section 8 -- Interpretation. 396 | 397 | a. For the avoidance of doubt, this Public License does not, and 398 | shall not be interpreted to, reduce, limit, restrict, or impose 399 | conditions on any use of the Licensed Material that could lawfully 400 | be made without permission under this Public License. 401 | 402 | b. To the extent possible, if any provision of this Public License is 403 | deemed unenforceable, it shall be automatically reformed to the 404 | minimum extent necessary to make it enforceable. If the provision 405 | cannot be reformed, it shall be severed from this Public License 406 | without affecting the enforceability of the remaining terms and 407 | conditions. 408 | 409 | c. No term or condition of this Public License will be waived and no 410 | failure to comply consented to unless expressly agreed to by the 411 | Licensor. 412 | 413 | d. Nothing in this Public License constitutes or may be interpreted 414 | as a limitation upon, or waiver of, any privileges and immunities 415 | that apply to the Licensor or You, including from the legal 416 | processes of any jurisdiction or authority. 417 | 418 | ======================================================================= 419 | 420 | Creative Commons is not a party to its public 421 | licenses. Notwithstanding, Creative Commons may elect to apply one of 422 | its public licenses to material it publishes and in those instances 423 | will be considered the “Licensor.” The text of the Creative Commons 424 | public licenses is dedicated to the public domain under the CC0 Public 425 | Domain Dedication. Except for the limited purpose of indicating that 426 | material is shared under a Creative Commons public license or as 427 | otherwise permitted by the Creative Commons policies published at 428 | creativecommons.org/policies, Creative Commons does not authorize the 429 | use of the trademark "Creative Commons" or any other trademark or logo 430 | of Creative Commons without its prior written consent including, 431 | without limitation, in connection with any unauthorized modifications 432 | to any of its public licenses or any other arrangements, 433 | understandings, or agreements concerning use of licensed material. For 434 | the avoidance of doubt, this paragraph does not form part of the 435 | public licenses. 436 | 437 | Creative Commons may be contacted at creativecommons.org. 438 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We absolutely welcome contributions and we hope that this guide will 4 | facilitate an understanding of the scikit-gmsh code repository. It is 5 | important to note that the scikit-gmsh software package is maintained on 6 | a volunteer basis and thus we need to foster a community that can 7 | support user questions and develop new features to make this software a 8 | useful tool for all users. 9 | 10 | This page is dedicated to outline where you should start with your 11 | question, concern, feature request, or desire to contribute. 12 | 13 | ## Being Respectful 14 | 15 | [![Contributor 16 | Covenant](https://img.shields.io/badge/contributor%20covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md) 17 | 18 | Please demonstrate empathy and kindness toward other people, other 19 | software, and the communities who have worked diligently to build 20 | (un)related tools. 21 | 22 | Please do not talk down in Pull Requests, Issues, or otherwise in a way 23 | that portrays other people or their works in a negative light. 24 | 25 | ## Cloning the Source Repository 26 | 27 | You can clone the source repository from 28 | and install the latest version 29 | by running: 30 | 31 | ```bash 32 | git clone https://github.com/pyvista/scikit-gmsh.git 33 | cd scikit-gmsh 34 | python -m pip install -e . 35 | ``` 36 | 37 | ## Quick Start Development with Codespaces 38 | 39 | [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/pyvista/scikit-gmsh) 40 | 41 | A dev container is provided to quickly get started. The default 42 | container comes with the repository code checked out on a branch of your 43 | choice and all scikit-gmsh dependencies including test dependencies 44 | pre-installed. In addition, it uses the [desktop-lite 45 | feature](https://github.com/devcontainers/features/tree/main/src/desktop-lite) 46 | to provide live interaction windows. Follow directions [Connecting to 47 | the 48 | desktop](https://github.com/devcontainers/features/tree/main/src/desktop-lite#connecting-to-the-desktop) 49 | to use the live interaction. 50 | 51 | Alternatively, an offscreen version using OSMesa libraries and 52 | `vtk-osmesa` is available. 53 | 54 | ## Questions 55 | 56 | For general questions about the project, its applications, or about 57 | software usage, please create a discussion in the 58 | [Discussions](https://github.com/pyvista/scikit-gmsh/discussions) 59 | repository where the community can collectively address your questions. 60 | 61 | For critical, high-level project support and engagement, please email 62 | - but please do not use this email for technical 63 | support. 64 | 65 | For all technical conversations, you are welcome to create an issue on 66 | the [Discussions 67 | page](https://github.com/pyvista/scikit-gmsh/discussions) which we will 68 | address promptly. Through posting on the Discussions page, your question 69 | can be addressed by community members with the needed expertise and the 70 | information gained will remain available for other users to find. 71 | 72 | ## Reporting Bugs 73 | 74 | If you stumble across any bugs, crashes, or concerning quirks while 75 | using code distributed here, please report it on the [issues 76 | page](https://github.com/pyvista/scikit-gmsh/issues) with an appropriate 77 | label so we can promptly address it. When reporting an issue, please be 78 | overly descriptive so that we may reproduce it. Whenever possible, 79 | please provide tracebacks, screenshots, and sample files to help us 80 | address the issue. 81 | 82 | ## Feature Requests 83 | 84 | We encourage users to submit ideas for improvements to scikit-gmsh code 85 | base. Please create an issue on the [issues 86 | page](https://github.com/pyvista/scikit-gmsh/issues) with a _Feature 87 | Request_ label to suggest an improvement. Please use a descriptive title 88 | and provide ample background information to help the community implement 89 | that functionality. For example, if you would like a reader for a 90 | specific file format, please provide a link to documentation of that 91 | file format and possibly provide some sample files with screenshots to 92 | work with. We will use the issue thread as a place to discuss and 93 | provide feedback. 94 | 95 | ## Contributing New Code 96 | 97 | If you have an idea for how to improve scikit-gmsh, please first create 98 | an issue as a feature request which we can use as a discussion thread to 99 | work through how to implement the contribution. 100 | 101 | Once you are ready to start coding and develop for scikit-gmsh, please 102 | see the [Development Practices](#development-practices) section for more 103 | details. 104 | 105 | ## Licensing 106 | 107 | All contributed code will be licensed under The GPL-3.0 license found in the 108 | repository. If you did not write the code yourself, it is your 109 | responsibility to ensure that the existing license is compatible and 110 | included in the contributed files or you can obtain permission from the 111 | original author to relicense the code. 112 | 113 | --- 114 | 115 | ## Development Practices 116 | 117 | [![Nox](https://img.shields.io/badge/%F0%9F%A6%8A-Nox-D85E00.svg)](https://github.com/wntrblm/nox) 118 | 119 | This section provides a guide to how we conduct development in the 120 | scikit-gmsh repository. Please follow the practices outlined here when 121 | contributing directly to this repository. 122 | 123 | ### Guidelines 124 | 125 | Through direct access to the Visualization Toolkit (VTK) via direct 126 | array access and intuitive Python properties, we hope to make the entire 127 | VTK library easily accessible to researchers of all disciplines. To 128 | further scikit-gmsh towards being a valuable Python interface to VTK, we 129 | need your help to make it even better. 130 | 131 | If you want to add one or two interesting analysis algorithms as 132 | filters, implement a new plotting routine, or just fix 1-2 typos - your 133 | efforts are welcome. 134 | 135 | There are three general coding paradigms that we believe in: 136 | 137 | 1. **Make it intuitive**. scikit-gmsh's goal is to create an intuitive 138 | and easy to use interface back to the VTK library. Any new features 139 | should have intuitive naming conventions and explicit keyword 140 | arguments for users to make the bulk of the library accessible to 141 | novice users. 142 | 1. **Document everything**. At the least, include a docstring for any 143 | method or class added. Do not describe what you are doing but why 144 | you are doing it and provide a simple example for the new features. 145 | 1. **Keep it tested**. We aim for a high test coverage. See testing for 146 | more details. 147 | 148 | There are two important copyright guidelines: 149 | 150 | 1. Please do not include any data sets for which a license is not 151 | available or commercial use is prohibited. Those can undermine the 152 | license of the whole projects. 153 | 1. Do not use code snippets for which a license is not available (for 154 | example from Stack Overflow) or commercial use is prohibited. Those 155 | can undermine the license of the whole projects. 156 | 157 | Please also take a look at our [Code of 158 | Conduct](https://github.com/pyvista/scikit-gmsh/blob/main/CODE_OF_CONDUCT.md). 159 | 160 | ### Contributing to scikit-gmsh through GitHub 161 | 162 | To submit new code to scikit-gmsh, first fork the [scikit-gmsh GitHub 163 | Repository](https://github.com/pyvista/scikit-gmsh) and then clone the 164 | forked repository to your computer. Then, create a new branch based on 165 | the [Branch Naming Conventions Section](#branch-naming-conventions) in 166 | your local repository. 167 | 168 | Next, add your new feature and commit it locally. Be sure to commit 169 | frequently as it is often helpful to revert to past commits, especially 170 | if your change is complex. Also, be sure to test often. See the [Testing 171 | Section](#testing) below for automating testing. 172 | 173 | When you are ready to submit your code, create a pull request by 174 | following the steps in the [Creating a New Pull Request 175 | section](#creating-a-new-pull-request). 176 | 177 | #### Coding Style 178 | 179 | [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) 180 | [![code style: 181 | prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier) 182 | 183 | We adhere to [PEP 8](https://www.python.org/dev/peps/pep-0008/) wherever 184 | possible, except that line widths are permitted to go beyond 79 185 | characters to a max of 99 characters for code. This should tend to be 186 | the exception rather than the norm. A uniform code style is enforced by 187 | [Ruff](https://github.com/astral-sh/ruff) to prevent energy wasted on style 188 | disagreements. 189 | 190 | As for docstrings, scikit-gmsh follows the `numpydoc` style for its 191 | docstrings. Please also take a look at [Docstrings](#docstrings). 192 | 193 | Outside of PEP 8, when coding please consider [PEP 20 - The Zen of 194 | Python](https://www.python.org/dev/peps/pep-0020/). When in doubt: 195 | 196 | ```python 197 | import this 198 | ``` 199 | 200 | scikit-gmsh uses [pre-commit](https://pre-commit.com/) to enforce PEP8 201 | and other styles automatically. Please see the [Style Checking 202 | section](#style-checking) for further details. 203 | 204 | #### Documentation Style 205 | 206 | scikit-gmsh follows the [Google Developer Documentation 207 | Style](https://developers.google.com/style) with the following 208 | exceptions: 209 | 210 | - Allow first person pronouns. These pronouns (for example, \"We\") 211 | refer to \"scikit-gmsh Developers\", which can be anyone who 212 | contributes to scikit-gmsh. 213 | - Future tense is permitted. 214 | 215 | These rules are enforced for all text files (for example, `*.md`, 216 | `*.rst`) and partially enforced for Python source files. 217 | 218 | These rules are enforced through the use of [Vale](https://vale.sh/) via 219 | our GitHub Actions, and you can run Vale locally with: 220 | 221 | ``` 222 | pip install vale 223 | vale --config doc/.vale.ini doc scikit-gmsh examples ./*.rst --glob='!*{_build,AUTHORS.rst}*' 224 | ``` 225 | 226 | If you are on Linux or macOS, you can run: 227 | 228 | ``` 229 | make docstyle 230 | ``` 231 | 232 | #### Docstrings 233 | 234 | scikit-gmsh uses Python docstrings to create reference documentation for 235 | our Python APIs. Docstrings are read by developers, interactive Python 236 | users, and readers of our online documentation. This section describes 237 | how to write these docstrings for scikit-gmsh. 238 | 239 | scikit-gmsh follows the `numpydoc` style for its docstrings. Please 240 | follow the [numpydoc Style 241 | Guide](https://numpydoc.readthedocs.io/en/latest/format.html) in all 242 | ways except for the following: 243 | 244 | - Be sure to describe all `Parameters` and `Returns` for all public 245 | methods. 246 | - We strongly encourage you to add an example section. scikit-gmsh is 247 | a visual library, so adding examples that show a plot will really 248 | help users figure out what individual methods do. 249 | - With optional parameters, use `default: ` instead of 250 | `optional` when the parameter has a default value instead of `None`. 251 | 252 | Sample docstring follows: 253 | 254 | ```python 255 | def slice_x(self, x=None, generate_triangles=False): 256 | """Create an orthogonal slice through the dataset in the X direction. 257 | 258 | Parameters 259 | ---------- 260 | x : float, optional 261 | The X location of the YZ slice. By default this will be the X center 262 | of the dataset. 263 | 264 | generate_triangles : bool, default: False 265 | If this is enabled, the output will be all triangles. Otherwise the 266 | output will consist of the intersection polygons. 267 | 268 | Returns 269 | ------- 270 | skgmsh.PolyData 271 | Sliced dataset. 272 | 273 | Examples 274 | -------- 275 | Slice the random hills dataset with one orthogonal plane. 276 | 277 | >>> from skgmsh import examples 278 | >>> hills = examples.load_random_hills() 279 | >>> slices = hills.slice_x(5, generate_triangles=False) 280 | >>> slices.plot(line_width=5) 281 | 282 | See :ref:`slice_example` for more examples using this filter. 283 | 284 | """ 285 | 286 | pass # implementation goes here 287 | ``` 288 | 289 | Note the following: 290 | 291 | - The parameter definition of `generate_triangles` uses 292 | `default: False`, and does not include the default in the 293 | docstring\'s \"description\" section. 294 | - There is a newline between each parameter. This is different than 295 | `numpydoc`\'s documentation where there are no empty lines between 296 | parameter docstrings. 297 | - This docstring also contains a returns section and an examples 298 | section. 299 | - The returns section does not include the parameter name if the 300 | function has a single return value. Multiple return values (not 301 | shown) should have descriptive parameter names for each returned 302 | value, in the same format as the input parameters. 303 | - The examples section references the \"full example\" in the gallery 304 | if it exists. 305 | 306 | These standards will be enforced using `pre-commit` using 307 | `numpydoc-validate`, with errors being reported as: 308 | 309 | ```text 310 | +-----------------+--------------------------+---------+-------------------------------------------------+ 311 | | file | item | check | description | 312 | +=================+==========================+=========+=================================================+ 313 | | cells.py:85 | cells.create_mixed_cells | RT05 | Return value description should finish with "." | 314 | +-----------------+--------------------------+---------+-------------------------------------------------+ 315 | | cells.py:85 | cells.create_mixed_cells | RT05 | Return value description should finish with "." | 316 | +-----------------+--------------------------+---------+-------------------------------------------------+ 317 | | features.py:250 | features.merge | PR09 | Parameter "datasets" description should finish | 318 | | | | | with "." | 319 | +-----------------+--------------------------+---------+-------------------------------------------------+ 320 | ``` 321 | 322 | If for whatever reason you feel that your function should have an 323 | exception to any of the rules, add an exception to the function either 324 | in the `[tool.numpydoc_validation]` section in `pyproject.toml` or add 325 | an inline comment to exclude a certain check. For example, we do not 326 | enforce documentation strings for setters and skip the GL08 check. 327 | 328 | ```python 329 | @strips.setter 330 | def strips(self, strips): # numpydoc ignore=GL08 331 | if isinstance(strips, CellArray): 332 | self.SetStrips(strips) 333 | else: 334 | self.SetStrips(CellArray(strips)) 335 | ``` 336 | 337 | See the available validation checks in [numpydoc 338 | Validation](https://numpydoc.readthedocs.io/en/latest/validation.html). 339 | 340 | #### Deprecating Features or other Backwards-Breaking Changes 341 | 342 | When implementing backwards-breaking changes within scikit-gmsh, care 343 | must be taken to give users the chance to adjust to any new changes. Any 344 | non-backwards compatible modifications should proceed through the 345 | following steps: 346 | 347 | 1. Retain the old behavior and issue a `skgmshDeprecationWarning` 348 | indicating the new interface you should use. 349 | 1. Retain the old behavior but raise a 350 | `skgmsh.core.errors.DeprecationError` indicating the new interface 351 | you must use. 352 | 1. Remove the old behavior. 353 | 354 | Whenever possible, scikit-gmsh developers should seek to have at least 355 | three minor versions of backwards compatibility to give users the 356 | ability to update their software and scripts. 357 | 358 | Here\'s an example of a soft deprecation of a function. Note the usage 359 | of both the `skgmshDeprecationWarning` warning and the `.. deprecated` 360 | Sphinx directive. 361 | 362 | ```python 363 | import warnings 364 | from skgmsh.core.errors import skgmshDeprecationWarning 365 | 366 | 367 | def addition(a, b): 368 | """Add two numbers. 369 | 370 | .. deprecated:: 0.37.0 371 | Since scikit-gmsh 0.37.0, you can use :func:`skgmsh.add` instead. 372 | 373 | Parameters 374 | ---------- 375 | a : float 376 | First term to add. 377 | 378 | b : float 379 | Second term to add. 380 | 381 | Returns 382 | ------- 383 | float 384 | Sum of the two inputs. 385 | 386 | """ 387 | # deprecated 0.37.0, convert to error in 0.40.0, remove 0.41.0 388 | warnings.warn( 389 | "`addition` has been deprecated. Use skgmsh.add instead", 390 | skgmshDeprecationWarning, 391 | ) 392 | add(a, b) 393 | 394 | 395 | def add(a, b): 396 | """Add two numbers.""" 397 | 398 | pass # implementation goes here 399 | ``` 400 | 401 | In the above code example, note how a comment is made to convert to an 402 | error in three minor releases and completely remove in the following 403 | minor release. For significant changes, this can be made longer, and for 404 | trivial ones this can be kept short. 405 | 406 | Here\'s an example of adding error test codes that raise deprecation 407 | warning messages. 408 | 409 | ```python 410 | with pytest.warns(skgmshDeprecationWarning): 411 | addition(a, b) 412 | if sg._version.version_info >= (0, 40): 413 | raise RuntimeError("Convert error this function") 414 | if sg._version.version_info >= (0, 41): 415 | raise RuntimeError("Remove this function") 416 | ``` 417 | 418 | In the above code example, the old test code raises an error in v0.40 419 | and v0.41. This will prevent us from forgetting to remove deprecations 420 | on version upgrades. 421 | 422 | When adding an additional parameter to an existing method or function, 423 | you are encouraged to use the `.. versionadded` sphinx directive. For 424 | example: 425 | 426 | ```python 427 | def Cube(clean=True): 428 | """Create a cube. 429 | 430 | Parameters 431 | ---------- 432 | clean : bool, default: True 433 | Whether to clean the raw points of the mesh. 434 | 435 | .. versionadded:: 0.33.0 436 | """ 437 | ``` 438 | 439 | #### Branch Naming Conventions 440 | 441 | To streamline development, we have the following requirements for naming 442 | branches. These requirements help the core developers know what kind of 443 | changes any given branch is introducing before looking at the code. 444 | 445 | - `fix/`, `patch/` and `bug/`: any bug fixes, patches, or experimental 446 | changes that are minor 447 | - `feat/`: any changes that introduce a new feature or significant 448 | addition 449 | - `junk/`: for any experimental changes that can be deleted if gone 450 | stale 451 | - `maint/`: for general maintenance of the repository or CI routines 452 | - `doc/`: for any changes only pertaining to documentation 453 | - `no-ci/`: for low impact activity that should NOT trigger the CI 454 | routines 455 | - `testing/`: improvements or changes to testing 456 | - `release/`: releases (see below) 457 | - `breaking-change/`: Changes that break backward compatibility 458 | 459 | #### Testing 460 | 461 | After making changes, please test changes locally before creating a pull 462 | request. The following tests will be executed after any commit or pull 463 | request, so we ask that you perform the following sequence locally to 464 | track down any new issues from your changes. 465 | 466 | To run our comprehensive suite of unit tests, install all the 467 | dependencies listed in `requirements_test.txt` and 468 | `requirements_docs.txt`: 469 | 470 | ```bash 471 | pip install -r requirements_test.txt 472 | pip install -r requirements_docs.txt 473 | ``` 474 | 475 | Then, if you have everything installed, you can run the various test 476 | suites. 477 | 478 | ### Unit Testing 479 | 480 | Run the primary test suite and generate coverage report: 481 | 482 | ```bash 483 | python -m pytest -v --cov scikit-gmsh 484 | ``` 485 | 486 | Unit testing can take some time, if you wish to speed it up, set the 487 | number of processors with the `-n` flag. This uses `pytest-xdist` to 488 | leverage multiple processes. Example usage: 489 | 490 | ```bash 491 | python -m pytest -n --cov scikit-gmsh 492 | ``` 493 | 494 | ### Documentation Testing 495 | 496 | Run all code examples in the docstrings with: 497 | 498 | ```bash 499 | python -m pytest -v --doctest-modules scikit-gmsh 500 | ``` 501 | 502 | ### Style Checking 503 | 504 | scikit-gmsh follows PEP8 standard as outlined in the [Coding Style 505 | section](#coding-style) and implements style checking using 506 | [pre-commit](https://pre-commit.com/). 507 | 508 | To ensure your code meets minimum code styling standards, run: 509 | 510 | pip install pre-commit 511 | pre-commit run --all-files 512 | 513 | If you have issues related to `setuptools` when installing `pre-commit`, 514 | see [pre-commit Issue #2178 515 | comment](https://github.com/pre-commit/pre-commit/issues/2178#issuecomment-1002163763) 516 | for a potential resolution. 517 | 518 | You can also install this as a pre-commit hook by running: 519 | 520 | pre-commit install 521 | 522 | This way, it\'s not possible for you to push code that fails the style 523 | checks. For example, each commit automatically checks that you meet the 524 | style requirements: 525 | 526 | $ pre-commit install 527 | $ git commit -m "added my cool feature" 528 | ruff.....................................................................Passed 529 | codespell................................................................Passed 530 | 531 | The actual installation of the environment happens before the first 532 | commit following `pre-commit install`. This will take a bit longer, but 533 | subsequent commits will only trigger the actual style checks. 534 | 535 | Even if you are not in a situation where you are not performing or able 536 | to perform the above tasks, you can comment `pre-commit.ci autofix` on a 537 | pull request to manually trigger auto-fixing. 538 | 539 | ### Notes Regarding Image Regression Testing 540 | 541 | Since scikit-gmsh is primarily a plotting module, it's imperative we 542 | actually check the images that we generate in some sort of regression 543 | testing. In practice, this ends up being quite a bit of work because: 544 | 545 | - OpenGL software vs. hardware rending causes slightly different 546 | images to be rendered. 547 | - We want our CI (which uses a virtual frame buffer) to match our 548 | desktop images (uses hardware acceleration). 549 | - Different OSes render different images. 550 | 551 | As each platform and environment renders different slightly images 552 | relative to Linux (which these images were built from), so running these 553 | tests across all OSes isn't optimal. We need to know if something 554 | fundamental changed with our plotting without actually looking at the 555 | plots (like the docs at dev.scikit-gmsh.com) 556 | 557 | Based on these points, image regression testing only occurs on Linux CI, 558 | and multi-sampling is disabled as that seems to be one of the biggest 559 | difference between software and hardware based rendering. 560 | 561 | Image cache is stored here as `./tests/plotting/image_cache`. 562 | 563 | Image resolution is kept low at 400x400 as we don't want to pollute git 564 | with large images. Small variations between versions and environments 565 | are to be expected, so error \< `IMAGE_REGRESSION_ERROR` is allowable 566 | (and will be logged as a warning) while values over that amount will 567 | trigger an error. 568 | 569 | There are two mechanisms within `pytest` to control image regression 570 | testing, `--reset_image_cache` and `--ignore_image_cache`. For example: 571 | 572 | ```bash 573 | pytest tests/plotting --reset_image_cache 574 | ``` 575 | 576 | Running `--reset_image_cache` creates a new image for each test in 577 | `tests/plotting/test_plotting.py` and is not recommended except for 578 | testing or for potentially a major or minor release. You can use 579 | `--ignore_image_cache` if you're running on Linux and want to 580 | temporarily ignore regression testing. Realize that regression testing 581 | will still occur on our CI testing. 582 | 583 | Images are currently only cached from tests in 584 | `tests/plotting/test_plotting.py`. By default, any test that uses 585 | `Plotter.show` will cache images automatically. To skip image caching, 586 | the `verify_image_cache` fixture can be utilized: 587 | 588 | ```python 589 | def test_add_background_image_not_global(verify_image_cache): 590 | verify_image_cache.skip = True # Turn off caching 591 | plotter = skgmsh.Plotter() 592 | plotter.add_mesh(sphere) 593 | plotter.show() 594 | # Turn on caching for further plotting 595 | verify_image_cache.skip = False 596 | ... 597 | ``` 598 | 599 | This ensures that immediately before the plotter is closed, the current 600 | render window will be verified against the image in CI. If no image 601 | exists, be sure to add the resulting image with 602 | 603 | ```bash 604 | git add tests/plotting/image_cache/* 605 | ``` 606 | 607 | During unit testing, if you get image regression failures and would like 608 | to compare the images generated locally to the regression test suite, 609 | allow [pytest-pyvista](https://pytest.pyvista.org/) to write all new 610 | generated images to a local directory using the `--generated_image_dir` 611 | flag. 612 | 613 | For example, the following writes all images generated by `pytest` to 614 | `debug_images/` for any tests in `tests/plotting` whose function name 615 | has `volume` in it. 616 | 617 | ```bash 618 | pytest tests/plotting/ -k volume --generated_image_dir debug_images 619 | ``` 620 | 621 | See [pytest-pyvista](https://pytest.pyvista.org/) for more details. 622 | 623 | ### Building the Documentation 624 | 625 | Build the documentation on Linux or Mac OS with: 626 | 627 | ```bash 628 | make -C doc html 629 | ``` 630 | 631 | Build the documentation on Windows with: 632 | 633 | ```winbatch 634 | cd doc 635 | python -msphinx -M html source _build 636 | python -msphinx -M html . _build 637 | ``` 638 | 639 | The generated documentation can be found in the `doc/_build/html` 640 | directory. 641 | 642 | The first time you build the documentation locally will take a while as 643 | all the examples need to be built. After the first build, the 644 | documentation should take a fraction of the time. 645 | 646 | To test this locally you need to run a http server in the html directory 647 | with: 648 | 649 | ```bash 650 | make serve-html 651 | ``` 652 | 653 | #### Clearing the Local Build 654 | 655 | If you need to clear the locally built documentation, run: 656 | 657 | ```bash 658 | make -C doc clean 659 | ``` 660 | 661 | This will clear out everything, including the examples gallery. If you 662 | only want to clear everything except the gallery examples, run: 663 | 664 | ```bash 665 | make -C doc clean-except-examples 666 | ``` 667 | 668 | This will clear out the cache without forcing you to rebuild all the 669 | examples. 670 | 671 | #### Parallel Documentation Build 672 | 673 | You can improve your documentation build time on Linux and Mac OS with: 674 | 675 | ```bash 676 | make -C doc phtml 677 | ``` 678 | 679 | This effectively invokes `SPHINXOPTS=-j` and can be especially useful 680 | for multi-core computers. 681 | 682 | ### Contributing to the Documentation 683 | 684 | Documentation for scikit-gmsh is generated from three sources: 685 | 686 | - Docstrings from the classes, functions, and modules of `scikit-gmsh` 687 | using 688 | [sphinx.ext.autodoc](https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html). 689 | - Restructured test from `doc/` 690 | - Gallery examples from `examples/` 691 | 692 | General usage and API descriptions should be placed within `doc/api` and 693 | the docstrings. Full gallery examples should be placed in `examples`. 694 | 695 | #### Adding a New Example 696 | 697 | scikit-gmsh\'s examples come in two formats: basic code snippets 698 | demonstrating the functionality of an individual method or a full 699 | gallery example displaying one or more concepts. Small code samples and 700 | snippets are contained in the `doc/api` directory or within our 701 | documentation strings, while the full gallery examples, meant to be run 702 | as individual downloadable scripts, are contained in the `examples` 703 | directory at the root of this repository. 704 | 705 | To add a fully fledged, standalone example, add your example to the 706 | `examples` directory in the root directory of the [scikit-gmsh 707 | Repository](https://github.com/pyvista/scikit-gmsh/) within one of the 708 | applicable subdirectories. Should none of the existing directories match 709 | the category of your example, create a new directory with a `README.txt` 710 | describing the new category. Additionally, as these examples are built 711 | using the sphinx gallery extension, follow coding guidelines as 712 | established by 713 | [Sphinx-Gallery](https://sphinx-gallery.github.io/stable/index.html). 714 | 715 | For more details see `add_example_example`{.interpreted-text 716 | role="ref"}. 717 | 718 | #### Add a New Example File 719 | 720 | If you have a dataset that you need for your gallery example, add it to 721 | [scikit-gmsh/vtk-data](https://github.com/pyvista/vtk-data/) and follow 722 | the directions there. You will then need to add a new function to 723 | download the dataset `scikit-gmsh/examples/downloads.py`. This might be 724 | as easy as: 725 | 726 | ```python 727 | def download_my_dataset(load=True): 728 | """Download my new dataset.""" 729 | return _download_and_read("mydata/my_new_dataset.vtk", load=load) 730 | ``` 731 | 732 | Which enables: 733 | 734 | ``` 735 | >>> from scikit-gmsh import examples 736 | >>> dataset = examples.download_my_dataset() 737 | ``` 738 | 739 | ### Creating a New Pull Request 740 | 741 | Once you have tested your branch locally, create a pull request on 742 | [scikit-gmsh GitHub](https://github.com/pyvista/scikit-gmsh) while 743 | merging to main. This will automatically run continuous integration (CI) 744 | testing and verify your changes will work across several platforms. 745 | 746 | To ensure someone else reviews your code, at least one other member of 747 | the scikit-gmsh contributors group must review and verify your code 748 | meets our community's standards. Once approved, if you have write 749 | permission you may merge the branch. If you don't have write permission, 750 | the reviewer or someone else with write permission will merge the branch 751 | and delete the PR branch. 752 | 753 | Since it may be necessary to merge your branch with the current release 754 | branch (see below), please do not delete your branch if it is a `fix/` 755 | branch. 756 | 757 | ### Branching Model 758 | 759 | This project has a branching model that enables rapid development of 760 | features without sacrificing stability, and closely follows the [Trunk 761 | Based Development](https://trunkbaseddevelopment.com/) approach. 762 | 763 | The main features of our branching model are: 764 | 765 | - The `main` branch is the main development branch. All features, 766 | patches, and other branches should be merged here. While all PRs 767 | should pass all applicable CI checks, this branch may be 768 | functionally unstable as changes might have introduced unintended 769 | side-effects or bugs that were not caught through unit testing. 770 | - There will be one or many `release/` branches based on minor 771 | releases (for example `release/0.24`) which contain a stable version 772 | of the code base that is also reflected on PyPI/. Hotfixes from 773 | `fix/` branches should be merged both to main and to these branches. 774 | When necessary to create a new patch release these release branches 775 | will have their `scikit-gmsh/_version.py` updated and be tagged with 776 | a semantic version (for example `v0.24.1`). This triggers CI to push 777 | to PyPI, and allow us to rapidly push hotfixes for past versions of 778 | `scikit-gmsh` without having to worry about untested features. 779 | - When a minor release candidate is ready, a new `release` branch will 780 | be created from `main` with the next incremented minor version (for 781 | example `release/0.25`), which will be thoroughly tested. When 782 | deemed stable, the release branch will be tagged with the version 783 | (`v0.25.0` in this case), and if necessary merged with main if any 784 | changes were pushed to it. Feature development then continues on 785 | `main` and any hotfixes will now be merged with this release. Older 786 | release branches should not be deleted so they can be patched as 787 | needed. 788 | 789 | #### Minor Release Steps 790 | 791 | Minor releases are feature and bug releases that improve the 792 | functionality and stability of `scikit-gmsh`. Before a minor release is 793 | created the following will occur: 794 | 795 | 1. Create a new branch from the `main` branch with name 796 | `release/MAJOR.MINOR` (for example `release/0.25`). 797 | 798 | 1. Update the development version numbers in `scikit-gmsh/_version.py` 799 | and commit it (for example `0, 26, 'dev0'`). Push the branch to 800 | GitHub and create a new PR for this release that merges it to main. 801 | Development to main should be limited at this point while effort is 802 | focused on the release. 803 | 804 | 1. Locally run all tests as outlined in the [Testing Section](#testing) 805 | and ensure all are passing. 806 | 807 | 1. Locally test and build the documentation with link checking to make 808 | sure no links are outdated. Be sure to run `make clean` to ensure no 809 | results are cached. 810 | 811 | ```bash 812 | cd doc 813 | make clean # deletes the sphinx-gallery cache 814 | make doctest-modules 815 | make html -b linkcheck 816 | ``` 817 | 818 | 1. After building the documentation, open the local build and examine 819 | the examples gallery for any obvious issues. 820 | 821 | 1. It is now the responsibility of the `scikit-gmsh` community to 822 | functionally test the new release. It is best to locally install 823 | this branch and use it in production. Any bugs identified should 824 | have their hotfixes pushed to this release branch. 825 | 826 | 1. When the branch is deemed as stable for public release, the PR will 827 | be merged to main. After update the version number in 828 | `release/MAJOR.MINOR` branch, the `release/MAJOR.MINOR` branch will 829 | be tagged with a `vMAJOR.MINOR.0` release. The release branch will 830 | not be deleted. Tag the release with: 831 | 832 | ```bash 833 | git tag v$(python -c "import skgmsh as skg; print(skg.__version__)") 834 | ``` 835 | 836 | 1. Please check again that the tag has been created correctly and push 837 | the branch and tag. 838 | 839 | ```bash 840 | git push origin HEAD 841 | git push origin v$(python -c "import skgmsh as skg; print(skg.__version__)") 842 | ``` 843 | 844 | 1. Create a list of all changes for the release. It is often helpful to 845 | leverage [GitHub's compare 846 | feature](https://github.com/pyvista/scikit-gmsh/compare) to see the 847 | differences from the last tag and the `main` branch. Be sure to 848 | acknowledge new contributors by their GitHub username and place 849 | mentions where appropriate if a specific contributor is to thank for 850 | a new feature. 851 | 852 | 1. Place your release notes from previous step in the description for 853 | [the new release on 854 | GitHub](https://github.com/pyvista/scikit-gmsh/releases/new). 855 | 856 | 1. Go grab a beer/coffee/water and wait for 857 | [\@regro-cf-autotick-bot](https://github.com/regro/cf-scripts) to 858 | open a pull request on the conda-forge [scikit-gmsh 859 | feedstock](https://github.com/conda-forge/scikit-gmsh-feedstock). 860 | Merge that pull request. 861 | 862 | 1. Announce the new release in the Discussions page and celebrate. 863 | 864 | #### Patch Release Steps 865 | 866 | Patch releases are for critical and important bugfixes that can not or 867 | should not wait until a minor release. The steps for a patch release 868 | 869 | 1. Push the necessary bugfix(es) to the applicable release branch. This 870 | will generally be the latest release branch (for example 871 | `release/0.25`). 872 | 1. Update `scikit-gmsh/_version.py` with the next patch increment (for 873 | example `v0.25.1`), commit it, and open a PR that merge with the 874 | release branch. This gives the `scikit-gmsh` community a chance to 875 | validate and approve the bugfix release. Any additional hotfixes 876 | should be outside of this PR. 877 | 1. When approved, merge with the release branch, but not `main` as 878 | there is no reason to increment the version of the `main` branch. 879 | Then create a tag from the release branch with the applicable 880 | version number (see above for the correct steps). 881 | 1. If deemed necessary, create a release notes page. Also, open the PR 882 | from conda and follow the directions in step 10 in the minor release 883 | section. 884 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------