From 7518f69b2ba75c8094ac40f1cca20f64aecc0a97 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Mon, 25 Jul 2022 19:41:20 +0900 Subject: [PATCH 01/45] Add Gmsh Python tutorial 1 --- tests/test_gmsh.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/test_gmsh.py diff --git a/tests/test_gmsh.py b/tests/test_gmsh.py new file mode 100644 index 00000000..45f93022 --- /dev/null +++ b/tests/test_gmsh.py @@ -0,0 +1,22 @@ +import pvgmsh + + +def test_tutorial1(): + # Gmsh Python tutorial 1 + # https://gitlab.onelab.info/gmsh/gmsh/blob/gmsh_4_10_5/tutorials/python/t1.py + + vertices = np.array([[0, 0, 0], [0.1, 0, 0], [0.1, 0.3, 0], [0.3, 0, 0]]) + + faces = np.hstack([[4, 0, 1, 2, 3]]) + + surf = pvgmsh.PolyData(vertices, faces, lc=1e-2) + + surf["points group number"] = np.array([1, 1, 1]) + surf["surface group number"] = np.array([2]) + + surf.add_physical_group(["points group number", "surface group number"]) + surf.generate(2) + + surf.save("t1.msh") + + surf.plot() From f3639ae6fef2a7612686248282aff66faecc3b8c Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Wed, 27 Jul 2022 16:20:02 +0900 Subject: [PATCH 02/45] Apply suggestions from code review --- tests/test_gmsh.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_gmsh.py b/tests/test_gmsh.py index 45f93022..8a87a37e 100644 --- a/tests/test_gmsh.py +++ b/tests/test_gmsh.py @@ -9,14 +9,15 @@ def test_tutorial1(): faces = np.hstack([[4, 0, 1, 2, 3]]) - surf = pvgmsh.PolyData(vertices, faces, lc=1e-2) + surf = pvgmsh.PolyData(vertices, faces) surf["points group number"] = np.array([1, 1, 1]) surf["surface group number"] = np.array([2]) +surf["lc"] = np.array([1e-2, 1e-2, 1e-2]) surf.add_physical_group(["points group number", "surface group number"]) - surf.generate(2) + mesh = surf.generate_mesh() - surf.save("t1.msh") + mesh.save("t1.msh") - surf.plot() + mesh.plot() From bf517311720860b679e3f836e378474facb0b393 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Wed, 27 Jul 2022 16:20:29 +0900 Subject: [PATCH 03/45] Apply suggestions from code review --- tests/test_gmsh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_gmsh.py b/tests/test_gmsh.py index 8a87a37e..e08950f0 100644 --- a/tests/test_gmsh.py +++ b/tests/test_gmsh.py @@ -13,7 +13,7 @@ def test_tutorial1(): surf["points group number"] = np.array([1, 1, 1]) surf["surface group number"] = np.array([2]) -surf["lc"] = np.array([1e-2, 1e-2, 1e-2]) + surf["lc"] = np.array([1e-2, 1e-2, 1e-2]) surf.add_physical_group(["points group number", "surface group number"]) mesh = surf.generate_mesh() From 69e747f4442a85e2c696af042f50147b9d5f03ba Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Wed, 27 Jul 2022 16:45:35 +0900 Subject: [PATCH 04/45] Update test_gmsh.py --- tests/test_gmsh.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/test_gmsh.py b/tests/test_gmsh.py index e08950f0..48a37643 100644 --- a/tests/test_gmsh.py +++ b/tests/test_gmsh.py @@ -6,18 +6,13 @@ def test_tutorial1(): # https://gitlab.onelab.info/gmsh/gmsh/blob/gmsh_4_10_5/tutorials/python/t1.py vertices = np.array([[0, 0, 0], [0.1, 0, 0], [0.1, 0.3, 0], [0.3, 0, 0]]) - faces = np.hstack([[4, 0, 1, 2, 3]]) - surf = pvgmsh.PolyData(vertices, faces) - surf["points group number"] = np.array([1, 1, 1]) - surf["surface group number"] = np.array([2]) - surf["lc"] = np.array([1e-2, 1e-2, 1e-2]) + surf.set_characteristic_length([1e-2, 1e-2, 1e-2, 1e-2]) - surf.add_physical_group(["points group number", "surface group number"]) - mesh = surf.generate_mesh() + # pvgmsh does not support PhysicalGroup; group configuration can be easily done with PyVista. + mesh = surf.generate_mesh() mesh.save("t1.msh") - mesh.plot() From 78705f40b9826a91f4a911beb4f4f20391acd85b Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Wed, 27 Jul 2022 16:50:01 +0900 Subject: [PATCH 05/45] Update test_gmsh.py --- tests/test_gmsh.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_gmsh.py b/tests/test_gmsh.py index 48a37643..63d831da 100644 --- a/tests/test_gmsh.py +++ b/tests/test_gmsh.py @@ -9,8 +9,6 @@ def test_tutorial1(): faces = np.hstack([[4, 0, 1, 2, 3]]) surf = pvgmsh.PolyData(vertices, faces) - surf.set_characteristic_length([1e-2, 1e-2, 1e-2, 1e-2]) - # pvgmsh does not support PhysicalGroup; group configuration can be easily done with PyVista. mesh = surf.generate_mesh() From c3109425df0bc8f792d140cc1b366bbf950e1755 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Wed, 27 Jul 2022 16:52:13 +0900 Subject: [PATCH 06/45] Update test_gmsh.py --- tests/test_gmsh.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_gmsh.py b/tests/test_gmsh.py index 63d831da..99da59fa 100644 --- a/tests/test_gmsh.py +++ b/tests/test_gmsh.py @@ -1,4 +1,5 @@ import pvgmsh +import pyvista def test_tutorial1(): @@ -7,10 +8,10 @@ def test_tutorial1(): vertices = np.array([[0, 0, 0], [0.1, 0, 0], [0.1, 0.3, 0], [0.3, 0, 0]]) faces = np.hstack([[4, 0, 1, 2, 3]]) - surf = pvgmsh.PolyData(vertices, faces) + surf = pyvista.PolyData(vertices, faces) # pvgmsh does not support PhysicalGroup; group configuration can be easily done with PyVista. - mesh = surf.generate_mesh() + mesh = pvgmsh.generate_mesh(surf) mesh.save("t1.msh") mesh.plot() From a4f3a436d9c097743d1006b65c1887b99ad6c208 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Wed, 27 Jul 2022 17:19:32 +0900 Subject: [PATCH 07/45] Update test_gmsh.py --- tests/test_gmsh.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_gmsh.py b/tests/test_gmsh.py index 99da59fa..cf999da3 100644 --- a/tests/test_gmsh.py +++ b/tests/test_gmsh.py @@ -13,5 +13,8 @@ def test_tutorial1(): # pvgmsh does not support PhysicalGroup; group configuration can be easily done with PyVista. mesh = pvgmsh.generate_mesh(surf) + assert mesh.n_pts > surf.n_pts + assert mesh.n_cells > surf.n_cells + mesh.save("t1.msh") mesh.plot() From 7d6d2075e25477d2f0185243c142d18aa2d58cf8 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Wed, 27 Jul 2022 17:33:39 +0900 Subject: [PATCH 08/45] Update test_gmsh.py --- tests/test_gmsh.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/test_gmsh.py b/tests/test_gmsh.py index cf999da3..066aca41 100644 --- a/tests/test_gmsh.py +++ b/tests/test_gmsh.py @@ -5,16 +5,10 @@ def test_tutorial1(): # Gmsh Python tutorial 1 # https://gitlab.onelab.info/gmsh/gmsh/blob/gmsh_4_10_5/tutorials/python/t1.py - vertices = np.array([[0, 0, 0], [0.1, 0, 0], [0.1, 0.3, 0], [0.3, 0, 0]]) faces = np.hstack([[4, 0, 1, 2, 3]]) surf = pyvista.PolyData(vertices, faces) - # pvgmsh does not support PhysicalGroup; group configuration can be easily done with PyVista. - mesh = pvgmsh.generate_mesh(surf) assert mesh.n_pts > surf.n_pts assert mesh.n_cells > surf.n_cells - - mesh.save("t1.msh") - mesh.plot() From 191f40c3a00b349759ee2e1c4ce2f71ad6131796 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 29 Jul 2022 03:19:04 +0900 Subject: [PATCH 09/45] Create testing-and-deployment.yml --- .github/workflows/testing-and-deployment.yml | 95 ++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 .github/workflows/testing-and-deployment.yml diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml new file mode 100644 index 00000000..ae7c9291 --- /dev/null +++ b/.github/workflows/testing-and-deployment.yml @@ -0,0 +1,95 @@ +name: Unit Testing and Deployment + +on: + pull_request: + workflow_dispatch: + schedule: + - cron: "0 4 * * *" + push: + tags: + - "*" + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + ALLOW_PLOTTING: true + SHELLOPTS: 'errexit:pipefail' + +jobs: + Linux: + name: Linux Unit Testing + runs-on: ubuntu-latest + strategy: + fail-fast: false + + # see discussion at https://github.com/pyvista/pyvista/issues/2867 + matrix: + include: + - python-version: '3.7' + vtk-version: '8.1.2' + - python-version: '3.8' + vtk-version: '9.0.3' + - python-version: '3.9' + vtk-version: '9.1' + - python-version: '3.10' + vtk-version: 'latest' + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: Python-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.vtk-version }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements_test.txt') }} + restore-keys: | + Python-${{ runner.os }}-${{ matrix.python-version }} + + - uses: actions/cache@v3 + with: + path: ~/.local/share/pyvista/examples + key: Examples-1-${{ hashFiles('*') }} + restore-keys: | + Examples-1- + + - name: Build wheel and install pyvista + run: | + pip install wheel + python setup.py bdist_wheel + pip install dist/pyvista*.whl + + - name: Set up vtk + if: ${{ matrix.vtk-version != 'latest' }} + run: pip install vtk==${{ matrix.vtk-version }} + + - uses: awalsh128/cache-apt-pkgs-action@v1.0.3 + with: + packages: libgl1-mesa-glx xvfb python-tk + version: 1.0 + + - name: Install Testing Requirements + run: pip install -r requirements_test.txt + + - name: Software Report + run: | + xvfb-run python -c "import pyvista; print(pyvista.Report())" + xvfb-run python -c "import pyvista; print(pyvista.EXAMPLES_PATH)" + which python + pip list + + - name: Unit Testing + run: | + xvfb-run pytest -v --cov pyvista --cov-report xml --fail_extra_image_cache + + - uses: codecov/codecov-action@v3 + if: matrix.python-version == '3.9' + name: 'Upload coverage to CodeCov' From fc3dc0400db311bf17357ad5cae1983fc28a07e3 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 29 Jul 2022 03:23:54 +0900 Subject: [PATCH 10/45] Update testing-and-deployment.yml --- .github/workflows/testing-and-deployment.yml | 24 -------------------- 1 file changed, 24 deletions(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index ae7c9291..0482d20c 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -54,19 +54,6 @@ jobs: restore-keys: | Python-${{ runner.os }}-${{ matrix.python-version }} - - uses: actions/cache@v3 - with: - path: ~/.local/share/pyvista/examples - key: Examples-1-${{ hashFiles('*') }} - restore-keys: | - Examples-1- - - - name: Build wheel and install pyvista - run: | - pip install wheel - python setup.py bdist_wheel - pip install dist/pyvista*.whl - - name: Set up vtk if: ${{ matrix.vtk-version != 'latest' }} run: pip install vtk==${{ matrix.vtk-version }} @@ -79,17 +66,6 @@ jobs: - name: Install Testing Requirements run: pip install -r requirements_test.txt - - name: Software Report - run: | - xvfb-run python -c "import pyvista; print(pyvista.Report())" - xvfb-run python -c "import pyvista; print(pyvista.EXAMPLES_PATH)" - which python - pip list - - name: Unit Testing run: | xvfb-run pytest -v --cov pyvista --cov-report xml --fail_extra_image_cache - - - uses: codecov/codecov-action@v3 - if: matrix.python-version == '3.9' - name: 'Upload coverage to CodeCov' From f392c53a6e5960b2d73df665b64add5b6b337704 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 29 Jul 2022 03:25:58 +0900 Subject: [PATCH 11/45] Update testing-and-deployment.yml --- .github/workflows/testing-and-deployment.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index 0482d20c..b1be6af1 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -29,12 +29,6 @@ jobs: # see discussion at https://github.com/pyvista/pyvista/issues/2867 matrix: include: - - python-version: '3.7' - vtk-version: '8.1.2' - - python-version: '3.8' - vtk-version: '9.0.3' - - python-version: '3.9' - vtk-version: '9.1' - python-version: '3.10' vtk-version: 'latest' steps: From 32825559161dd330f1a91732823235f90233928a Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 29 Jul 2022 03:28:07 +0900 Subject: [PATCH 12/45] Create requirements_test.txt --- requirements_test.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 requirements_test.txt diff --git a/requirements_test.txt b/requirements_test.txt new file mode 100644 index 00000000..67937340 --- /dev/null +++ b/requirements_test.txt @@ -0,0 +1,2 @@ +pyvista==0.35.2 +gmsh==4.10.5 From dafe7d6a30261192ed4db6a961c86c34dc3d9a7b Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 29 Jul 2022 03:30:40 +0900 Subject: [PATCH 13/45] Update requirements_test.txt --- requirements_test.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements_test.txt b/requirements_test.txt index 67937340..7c517f90 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,2 +1,3 @@ pyvista==0.35.2 gmsh==4.10.5 +pytest==7.1.2 From 22d03222b37dc17e0089ab2f9a2776faa9b03449 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 29 Jul 2022 03:32:36 +0900 Subject: [PATCH 14/45] Update testing-and-deployment.yml --- .github/workflows/testing-and-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index b1be6af1..800a30a4 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -62,4 +62,4 @@ jobs: - name: Unit Testing run: | - xvfb-run pytest -v --cov pyvista --cov-report xml --fail_extra_image_cache + xvfb-run pytest From 4fb7e691b63f7876aad8fda4aa223b25bb43cd40 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 29 Jul 2022 03:36:52 +0900 Subject: [PATCH 15/45] Create __init__.py --- pvgmsh/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 pvgmsh/__init__.py diff --git a/pvgmsh/__init__.py b/pvgmsh/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/pvgmsh/__init__.py @@ -0,0 +1 @@ + From c98ae8e535abe00c7db65fd14aa9a7b626636443 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 29 Jul 2022 03:40:25 +0900 Subject: [PATCH 16/45] Update test_gmsh.py --- tests/test_gmsh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_gmsh.py b/tests/test_gmsh.py index 066aca41..5b508a10 100644 --- a/tests/test_gmsh.py +++ b/tests/test_gmsh.py @@ -1,4 +1,4 @@ -import pvgmsh +import ..pvgmsh import pyvista From f8e2d7dcae8bb63c67ec48c983149a67e774ee15 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 29 Jul 2022 03:43:20 +0900 Subject: [PATCH 17/45] Update test_gmsh.py --- tests/test_gmsh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_gmsh.py b/tests/test_gmsh.py index 5b508a10..a3938783 100644 --- a/tests/test_gmsh.py +++ b/tests/test_gmsh.py @@ -1,4 +1,4 @@ -import ..pvgmsh +from .. import pvgmsh import pyvista From 36b4a09d212d961acfe2f417cc354bccc9115145 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 29 Jul 2022 03:51:56 +0900 Subject: [PATCH 18/45] Update testing-and-deployment.yml --- .github/workflows/testing-and-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index 800a30a4..2e363d04 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -62,4 +62,4 @@ jobs: - name: Unit Testing run: | - xvfb-run pytest + export PYTHONPATH=. && xvfb-run pytest From 5b13c23fa97710d3520dda3684b335f11f55188e Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 29 Jul 2022 03:53:25 +0900 Subject: [PATCH 19/45] Update test_gmsh.py --- tests/test_gmsh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_gmsh.py b/tests/test_gmsh.py index a3938783..066aca41 100644 --- a/tests/test_gmsh.py +++ b/tests/test_gmsh.py @@ -1,4 +1,4 @@ -from .. import pvgmsh +import pvgmsh import pyvista From de2da97a412d6bb72ae03d9878f2c41c5590736d Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 29 Jul 2022 04:33:32 +0900 Subject: [PATCH 20/45] Update test_gmsh.py --- tests/test_gmsh.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_gmsh.py b/tests/test_gmsh.py index 066aca41..1dd90a38 100644 --- a/tests/test_gmsh.py +++ b/tests/test_gmsh.py @@ -1,5 +1,6 @@ import pvgmsh import pyvista +import numpy as np def test_tutorial1(): From 7bd9c574f98dcfe2f3a7598f501b0767ef081bdc Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 29 Jul 2022 12:49:48 +0900 Subject: [PATCH 21/45] Update __init__.py --- pvgmsh/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pvgmsh/__init__.py b/pvgmsh/__init__.py index 8b137891..34f1ba20 100644 --- a/pvgmsh/__init__.py +++ b/pvgmsh/__init__.py @@ -1 +1,2 @@ - +def generate_mesh(surf): + return surf From 1cfb1d91d1d2e9cee12a5e8b0445efcdbcadb46e Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 29 Jul 2022 12:52:27 +0900 Subject: [PATCH 22/45] Update __init__.py --- pvgmsh/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pvgmsh/__init__.py b/pvgmsh/__init__.py index 34f1ba20..1e5f0f34 100644 --- a/pvgmsh/__init__.py +++ b/pvgmsh/__init__.py @@ -1,2 +1,7 @@ +import gmsh + + def generate_mesh(surf): + gmsh.initialize() + gmsh.clear() return surf From b49b7c2b76494e1585c3532fdcc4422a6e8fce53 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 29 Jul 2022 12:53:23 +0900 Subject: [PATCH 23/45] Update __init__.py --- pvgmsh/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pvgmsh/__init__.py b/pvgmsh/__init__.py index 1e5f0f34..368709f5 100644 --- a/pvgmsh/__init__.py +++ b/pvgmsh/__init__.py @@ -4,4 +4,5 @@ def generate_mesh(surf): gmsh.initialize() gmsh.clear() + gmsh.finalize() return surf From 0b9f14b08c194a50a624da4ae2b3ce36394ed9cd Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 29 Jul 2022 12:58:46 +0900 Subject: [PATCH 24/45] Update __init__.py --- pvgmsh/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pvgmsh/__init__.py b/pvgmsh/__init__.py index 368709f5..3730edd8 100644 --- a/pvgmsh/__init__.py +++ b/pvgmsh/__init__.py @@ -5,4 +5,5 @@ def generate_mesh(surf): gmsh.initialize() gmsh.clear() gmsh.finalize() - return surf + mesh = surf.copy() + return mesh From 26fdc47f841069f5c3a4c3cc61fc1c3c9586e4bd Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Mon, 1 Aug 2022 12:41:14 +0900 Subject: [PATCH 25/45] Update testing-and-deployment.yml --- .github/workflows/testing-and-deployment.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index 2e363d04..549ce6a1 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -57,6 +57,10 @@ jobs: packages: libgl1-mesa-glx xvfb python-tk version: 1.0 + - name: Install gmsh + run: | + sudo apt-get install -y python3-gmsh + - name: Install Testing Requirements run: pip install -r requirements_test.txt From 6afc9d5aeaeac1387f50d90dd80f988df6b31681 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Mon, 1 Aug 2022 12:50:57 +0900 Subject: [PATCH 26/45] Update test_gmsh.py --- tests/test_gmsh.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_gmsh.py b/tests/test_gmsh.py index 1dd90a38..bdd415f2 100644 --- a/tests/test_gmsh.py +++ b/tests/test_gmsh.py @@ -11,5 +11,5 @@ def test_tutorial1(): surf = pyvista.PolyData(vertices, faces) # pvgmsh does not support PhysicalGroup; group configuration can be easily done with PyVista. mesh = pvgmsh.generate_mesh(surf) - assert mesh.n_pts > surf.n_pts - assert mesh.n_cells > surf.n_cells + assert mesh.number_of_points > surf.number_of_points + assert mesh.number_of_cells > surf.number_of_cells From 8180a0a320ee5f3f07c328a1868f896fc4a4ce13 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Mon, 1 Aug 2022 12:58:18 +0900 Subject: [PATCH 27/45] Update __init__.py --- pvgmsh/__init__.py | 112 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-) diff --git a/pvgmsh/__init__.py b/pvgmsh/__init__.py index 3730edd8..12cdcb3c 100644 --- a/pvgmsh/__init__.py +++ b/pvgmsh/__init__.py @@ -1,9 +1,119 @@ import gmsh +import pyvista as pv def generate_mesh(surf): + # Before using any functions in the Python API, Gmsh must be initialized: gmsh.initialize() + + # Next we add a new model named "t1" (if gmsh.model.add() is not called a new + # unnamed model will be created on the fly, if necessary): + gmsh.model.add("t1") + + # The Python API provides direct access to each supported geometry (CAD) + # kernel. The built-in kernel is used in this first tutorial: the corresponding + # API functions have the `gmsh.model.geo' prefix. + + # The first type of `elementary entity' in Gmsh is a `Point'. To create a point + # with the built-in CAD kernel, the Python API function is + # gmsh.model.geo.addPoint(): + # - the first 3 arguments are the point coordinates (x, y, z) + # - the next (optional) argument is the target mesh size close to the point + # - the last (optional) argument is the point tag (a stricly positive integer + # that uniquely identifies the point) + lc = 1e-2 + gmsh.model.geo.addPoint(0, 0, 0, lc, 1) + + # Note that in addition to the default ``camelCase'' function name `addPoint', + # the Python API also defines a ``snake case'' alias, i.e. `add_point'. You can + # use either interchangeably; all the tutorials are written using the camelCase + # convention for consistency. + + # The distribution of the mesh element sizes will be obtained by interpolation + # of these mesh sizes throughout the geometry. Another method to specify mesh + # sizes is to use general mesh size Fields (see `t10.py'). A particular case is + # the use of a background mesh (see `t7.py'). + # + # If no target mesh size of provided, a default uniform coarse size will be used + # for the model, based on the overall model size. + # + # We can then define some additional points. All points should have different + # tags: + gmsh.model.geo.addPoint(.1, 0, 0, lc, 2) + gmsh.model.geo.addPoint(.1, .3, 0, lc, 3) + + # If the tag is not provided explicitly, a new tag is automatically created, and + # returned by the function: + p4 = gmsh.model.geo.addPoint(0, .3, 0, lc) + + # Curves are Gmsh's second type of elementery entities, and, amongst curves, + # straight lines are the simplest. The API to create straight line segments with + # the built-in kernel follows the same conventions: the first 2 arguments are + # point tags (the start and end points of the line), and the last (optional one) + # is the line tag. + # + # In the commands below, for example, the line 1 starts at point 1 and ends at + # point 2. + # + # Note that curve tags are separate from point tags - hence we can reuse tag `1' + # for our first curve. And as a general rule, elementary entity tags in Gmsh + # have to be unique per geometrical dimension. + gmsh.model.geo.addLine(1, 2, 1) + gmsh.model.geo.addLine(3, 2, 2) + gmsh.model.geo.addLine(3, p4, 3) + gmsh.model.geo.addLine(4, 1, p4) + + # The third elementary entity is the surface. In order to define a simple + # rectangular surface from the four curves defined above, a curve loop has first + # to be defined. A curve loop is defined by an ordered list of connected curves, + # a sign being associated with each curve (depending on the orientation of the + # curve to form a loop). The API function to create curve loops takes a list + # of integers as first argument, and the curve loop tag (which must be unique + # amongst curve loops) as the second (optional) argument: + gmsh.model.geo.addCurveLoop([4, 1, -2, 3], 1) + + # We can then define the surface as a list of curve loops (only one here, + # representing the external contour, since there are no holes--see `t4.py' for + # an example of a surface with a hole): + gmsh.model.geo.addPlaneSurface([1], 1) + + # Before they can be meshed (and, more generally, before they can be used by API + # functions outside of the built-in CAD kernel functions), the CAD entities must + # be synchronized with the Gmsh model, which will create the relevant Gmsh data + # structures. This is achieved by the gmsh.model.geo.synchronize() API call for + # the built-in CAD kernel. Synchronizations can be called at any time, but they + # involve a non trivial amount of processing; so while you could synchronize the + # internal CAD data after every CAD command, it is usually better to minimize + # the number of synchronization points. + gmsh.model.geo.synchronize() + + # At this level, Gmsh knows everything to display the rectangular surface 1 and + # to mesh it. An optional step is needed if we want to group elementary + # geometrical entities into more meaningful groups, e.g. to define some + # mathematical ("domain", "boundary"), functional ("left wing", "fuselage") or + # material ("steel", "carbon") properties. + # + # Such groups are called "Physical Groups" in Gmsh. By default, if physical + # groups are defined, Gmsh will export in output files only mesh elements that + # belong to at least one physical group. (To force Gmsh to save all elements, + # whether they belong to physical groups or not, set the `Mesh.SaveAll' option + # to 1.) Physical groups are also identified by tags, i.e. stricly positive + # integers, that should be unique per dimension (0D, 1D, 2D or 3D). Physical + # groups can also be given names. + # + # Here we define a physical curve that groups the left, bottom and right curves + # in a single group (with prescribed tag 5); and a physical surface with name + # "My surface" (with an automatic tag) containing the geometrical surface 1: + gmsh.model.addPhysicalGroup(1, [1, 2, 4], 5) + gmsh.model.addPhysicalGroup(2, [1], name = "My surface") + + # We can then generate a 2D mesh... + gmsh.model.mesh.generate(2) + + # ... and save it to disk + gmsh.write("t1.msh") + gmsh.clear() gmsh.finalize() - mesh = surf.copy() + mesh = pv.read("t1.msh") return mesh From 08bee79965f14350724d25dc1c48c1b53b1a0ddd Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Mon, 1 Aug 2022 13:02:22 +0900 Subject: [PATCH 28/45] Update requirements_test.txt --- requirements_test.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements_test.txt b/requirements_test.txt index 7c517f90..2c73578a 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,3 +1,4 @@ pyvista==0.35.2 gmsh==4.10.5 pytest==7.1.2 +meshio==5.3.4 From 716f4a28273de566acc38e056cd26f63512627e2 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Mon, 24 Apr 2023 08:46:39 +0900 Subject: [PATCH 29/45] Create tutorial1.py --- examples/tutorial1.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 examples/tutorial1.py diff --git a/examples/tutorial1.py b/examples/tutorial1.py new file mode 100644 index 00000000..d5e2893d --- /dev/null +++ b/examples/tutorial1.py @@ -0,0 +1,22 @@ +import pvgmsh +import pyvista +import numpy as np + + +# Gmsh Python tutorial 1 +# https://gitlab.onelab.info/gmsh/gmsh/blob/gmsh_4_10_5/tutorials/python/t1.py + +vertices = np.array([[0, 0, 0], [0.1, 0, 0], [0.1, 0.3, 0], [0, 0.3, 0]]) +faces = np.hstack([[4, 0, 1, 2, 3]]) +surf = pyvista.PolyData(vertices, faces) + +# pvgmsh does not support PhysicalGroup; group configuration can be easily done with PyVista. + +mesh = pvgmsh.generate_mesh(surf) + +plotter = pyvista.Plotter(shape=(1, 2)) +plotter.subplot(0, 0) +plotter.add_mesh(surf, color="tan", show_edges=True) +plotter.subplot(0, 1) +plotter.add_mesh(mesh, color="tan", show_edges=True) +plotter.show(cpos="xy") From ed00b6f9c8a8898086d54f61000f0af57c8aecdd Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Mon, 24 Apr 2023 08:48:43 +0900 Subject: [PATCH 30/45] Create .pre-commit-config.yaml --- .pre-commit-config.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..c473e828 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,11 @@ +# Integration with GitHub Actions +# See https://pre-commit.ci/ +ci: + autofix_prs: true + autoupdate_schedule: weekly + +repos: +- repo: https://github.com/psf/black + rev: 23.3.0 + hooks: + - id: black From 94f4e1f145461163bfd3601c8ef8f195d068ce91 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 23 Apr 2023 23:48:51 +0000 Subject: [PATCH 31/45] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pvgmsh/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pvgmsh/__init__.py b/pvgmsh/__init__.py index 12cdcb3c..927d1199 100644 --- a/pvgmsh/__init__.py +++ b/pvgmsh/__init__.py @@ -39,12 +39,12 @@ def generate_mesh(surf): # # We can then define some additional points. All points should have different # tags: - gmsh.model.geo.addPoint(.1, 0, 0, lc, 2) - gmsh.model.geo.addPoint(.1, .3, 0, lc, 3) + gmsh.model.geo.addPoint(0.1, 0, 0, lc, 2) + gmsh.model.geo.addPoint(0.1, 0.3, 0, lc, 3) # If the tag is not provided explicitly, a new tag is automatically created, and # returned by the function: - p4 = gmsh.model.geo.addPoint(0, .3, 0, lc) + p4 = gmsh.model.geo.addPoint(0, 0.3, 0, lc) # Curves are Gmsh's second type of elementery entities, and, amongst curves, # straight lines are the simplest. The API to create straight line segments with @@ -105,7 +105,7 @@ def generate_mesh(surf): # in a single group (with prescribed tag 5); and a physical surface with name # "My surface" (with an automatic tag) containing the geometrical surface 1: gmsh.model.addPhysicalGroup(1, [1, 2, 4], 5) - gmsh.model.addPhysicalGroup(2, [1], name = "My surface") + gmsh.model.addPhysicalGroup(2, [1], name="My surface") # We can then generate a 2D mesh... gmsh.model.mesh.generate(2) From 1ad238f1cfe2cf86f2d5db9a38639273cf9128af Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Mon, 24 Apr 2023 08:50:10 +0900 Subject: [PATCH 32/45] Update test_gmsh.py --- tests/test_gmsh.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_gmsh.py b/tests/test_gmsh.py index bdd415f2..4df1c85b 100644 --- a/tests/test_gmsh.py +++ b/tests/test_gmsh.py @@ -3,9 +3,7 @@ import numpy as np -def test_tutorial1(): - # Gmsh Python tutorial 1 - # https://gitlab.onelab.info/gmsh/gmsh/blob/gmsh_4_10_5/tutorials/python/t1.py +def test_generate_mesh(): vertices = np.array([[0, 0, 0], [0.1, 0, 0], [0.1, 0.3, 0], [0.3, 0, 0]]) faces = np.hstack([[4, 0, 1, 2, 3]]) surf = pyvista.PolyData(vertices, faces) From 3f98c28ee77baf20d5237fdd292cacb953359661 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Mon, 24 Apr 2023 09:05:39 +0900 Subject: [PATCH 33/45] Update __init__.py --- pvgmsh/__init__.py | 95 ---------------------------------------------- 1 file changed, 95 deletions(-) diff --git a/pvgmsh/__init__.py b/pvgmsh/__init__.py index 927d1199..86c482a2 100644 --- a/pvgmsh/__init__.py +++ b/pvgmsh/__init__.py @@ -3,116 +3,21 @@ def generate_mesh(surf): - # Before using any functions in the Python API, Gmsh must be initialized: gmsh.initialize() - - # Next we add a new model named "t1" (if gmsh.model.add() is not called a new - # unnamed model will be created on the fly, if necessary): - gmsh.model.add("t1") - - # The Python API provides direct access to each supported geometry (CAD) - # kernel. The built-in kernel is used in this first tutorial: the corresponding - # API functions have the `gmsh.model.geo' prefix. - - # The first type of `elementary entity' in Gmsh is a `Point'. To create a point - # with the built-in CAD kernel, the Python API function is - # gmsh.model.geo.addPoint(): - # - the first 3 arguments are the point coordinates (x, y, z) - # - the next (optional) argument is the target mesh size close to the point - # - the last (optional) argument is the point tag (a stricly positive integer - # that uniquely identifies the point) lc = 1e-2 gmsh.model.geo.addPoint(0, 0, 0, lc, 1) - - # Note that in addition to the default ``camelCase'' function name `addPoint', - # the Python API also defines a ``snake case'' alias, i.e. `add_point'. You can - # use either interchangeably; all the tutorials are written using the camelCase - # convention for consistency. - - # The distribution of the mesh element sizes will be obtained by interpolation - # of these mesh sizes throughout the geometry. Another method to specify mesh - # sizes is to use general mesh size Fields (see `t10.py'). A particular case is - # the use of a background mesh (see `t7.py'). - # - # If no target mesh size of provided, a default uniform coarse size will be used - # for the model, based on the overall model size. - # - # We can then define some additional points. All points should have different - # tags: gmsh.model.geo.addPoint(0.1, 0, 0, lc, 2) gmsh.model.geo.addPoint(0.1, 0.3, 0, lc, 3) - - # If the tag is not provided explicitly, a new tag is automatically created, and - # returned by the function: p4 = gmsh.model.geo.addPoint(0, 0.3, 0, lc) - - # Curves are Gmsh's second type of elementery entities, and, amongst curves, - # straight lines are the simplest. The API to create straight line segments with - # the built-in kernel follows the same conventions: the first 2 arguments are - # point tags (the start and end points of the line), and the last (optional one) - # is the line tag. - # - # In the commands below, for example, the line 1 starts at point 1 and ends at - # point 2. - # - # Note that curve tags are separate from point tags - hence we can reuse tag `1' - # for our first curve. And as a general rule, elementary entity tags in Gmsh - # have to be unique per geometrical dimension. gmsh.model.geo.addLine(1, 2, 1) gmsh.model.geo.addLine(3, 2, 2) gmsh.model.geo.addLine(3, p4, 3) gmsh.model.geo.addLine(4, 1, p4) - - # The third elementary entity is the surface. In order to define a simple - # rectangular surface from the four curves defined above, a curve loop has first - # to be defined. A curve loop is defined by an ordered list of connected curves, - # a sign being associated with each curve (depending on the orientation of the - # curve to form a loop). The API function to create curve loops takes a list - # of integers as first argument, and the curve loop tag (which must be unique - # amongst curve loops) as the second (optional) argument: gmsh.model.geo.addCurveLoop([4, 1, -2, 3], 1) - - # We can then define the surface as a list of curve loops (only one here, - # representing the external contour, since there are no holes--see `t4.py' for - # an example of a surface with a hole): gmsh.model.geo.addPlaneSurface([1], 1) - - # Before they can be meshed (and, more generally, before they can be used by API - # functions outside of the built-in CAD kernel functions), the CAD entities must - # be synchronized with the Gmsh model, which will create the relevant Gmsh data - # structures. This is achieved by the gmsh.model.geo.synchronize() API call for - # the built-in CAD kernel. Synchronizations can be called at any time, but they - # involve a non trivial amount of processing; so while you could synchronize the - # internal CAD data after every CAD command, it is usually better to minimize - # the number of synchronization points. gmsh.model.geo.synchronize() - - # At this level, Gmsh knows everything to display the rectangular surface 1 and - # to mesh it. An optional step is needed if we want to group elementary - # geometrical entities into more meaningful groups, e.g. to define some - # mathematical ("domain", "boundary"), functional ("left wing", "fuselage") or - # material ("steel", "carbon") properties. - # - # Such groups are called "Physical Groups" in Gmsh. By default, if physical - # groups are defined, Gmsh will export in output files only mesh elements that - # belong to at least one physical group. (To force Gmsh to save all elements, - # whether they belong to physical groups or not, set the `Mesh.SaveAll' option - # to 1.) Physical groups are also identified by tags, i.e. stricly positive - # integers, that should be unique per dimension (0D, 1D, 2D or 3D). Physical - # groups can also be given names. - # - # Here we define a physical curve that groups the left, bottom and right curves - # in a single group (with prescribed tag 5); and a physical surface with name - # "My surface" (with an automatic tag) containing the geometrical surface 1: - gmsh.model.addPhysicalGroup(1, [1, 2, 4], 5) - gmsh.model.addPhysicalGroup(2, [1], name="My surface") - - # We can then generate a 2D mesh... gmsh.model.mesh.generate(2) - - # ... and save it to disk gmsh.write("t1.msh") - gmsh.clear() gmsh.finalize() mesh = pv.read("t1.msh") From 94d81f433c692c354f6babc2655de299b28243e8 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Thu, 21 Dec 2023 18:58:17 +0900 Subject: [PATCH 34/45] Update testing-and-deployment.yml --- .github/workflows/testing-and-deployment.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index 549ce6a1..a5194fb9 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -58,8 +58,7 @@ jobs: version: 1.0 - name: Install gmsh - run: | - sudo apt-get install -y python3-gmsh + run: pip install gmsh - name: Install Testing Requirements run: pip install -r requirements_test.txt From c48edfae98b1090457586e7a00b507e0aa278391 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 22 Dec 2023 16:02:09 +0900 Subject: [PATCH 35/45] Update testing-and-deployment.yml --- .github/workflows/testing-and-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index a5194fb9..49c6a052 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -29,7 +29,7 @@ jobs: # see discussion at https://github.com/pyvista/pyvista/issues/2867 matrix: include: - - python-version: '3.10' + - python-version: '3.11' vtk-version: 'latest' steps: - uses: actions/checkout@v3 From 68e38416dc05faadcbbb1ec682cc516b0705d290 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 22 Dec 2023 16:04:29 +0900 Subject: [PATCH 36/45] Update testing-and-deployment.yml --- .github/workflows/testing-and-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index 49c6a052..3126f6fa 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -54,7 +54,7 @@ jobs: - uses: awalsh128/cache-apt-pkgs-action@v1.0.3 with: - packages: libgl1-mesa-glx xvfb python-tk + packages: libgl1-mesa-glx xvfb python-tk libglu1 libxcursor-dev libxft2 libxinerama1 libfltk1.3-dev libfreetype6-dev libgl1-mesa-dev libocct-foundation-dev libocct-data-exchange-dev version: 1.0 - name: Install gmsh From c0b8ead99807a10ebd8178e1e7f7ed107f0c011c Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 22 Dec 2023 16:06:33 +0900 Subject: [PATCH 37/45] Update testing-and-deployment.yml --- .github/workflows/testing-and-deployment.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index 3126f6fa..db79677a 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -52,13 +52,10 @@ jobs: if: ${{ matrix.vtk-version != 'latest' }} run: pip install vtk==${{ matrix.vtk-version }} - - uses: awalsh128/cache-apt-pkgs-action@v1.0.3 - with: - packages: libgl1-mesa-glx xvfb python-tk libglu1 libxcursor-dev libxft2 libxinerama1 libfltk1.3-dev libfreetype6-dev libgl1-mesa-dev libocct-foundation-dev libocct-data-exchange-dev - version: 1.0 - - name: Install gmsh - run: pip install gmsh + run: | + sudo apt -y install libgl1-mesa-glx xvfb python-tk libglu1 libxcursor-dev libxft2 libxinerama1 libfltk1.3-dev libfreetype6-dev libgl1-mesa-dev libocct-foundation-dev libocct-data-exchange-dev + pip install gmsh - name: Install Testing Requirements run: pip install -r requirements_test.txt From f1b18385d83a9f37912ead539ec0ecc7cc770bb5 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Sat, 23 Dec 2023 13:33:43 +0900 Subject: [PATCH 38/45] Add pyproject.toml --- pvgmsh/__init__.py | 1 + pvgmsh/_version.py | 14 ++++++++++++++ pyproject.toml | 20 ++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 pvgmsh/_version.py create mode 100644 pyproject.toml diff --git a/pvgmsh/__init__.py b/pvgmsh/__init__.py index 86c482a2..49f1dafd 100644 --- a/pvgmsh/__init__.py +++ b/pvgmsh/__init__.py @@ -1,5 +1,6 @@ import gmsh import pyvista as pv +from pvgmsh._version import __version__ # noqa: F401 def generate_mesh(surf): diff --git a/pvgmsh/_version.py b/pvgmsh/_version.py new file mode 100644 index 00000000..65863abe --- /dev/null +++ b/pvgmsh/_version.py @@ -0,0 +1,14 @@ +"""Version info for fe2pv. +On the ``main`` branch, use 'dev0' to denote a development version. +For example: +version_info = 0, 1, 'dev0' +--- +When generating pre-release wheels, use '0rcN', for example: +version_info = 0, 2, '0rc1' +Denotes the first release candidate. +""" +# major, minor, patch +version_info = 0, 0, "dev0" + +# Nice string for the version +__version__ = ".".join(map(str, version_info)) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..fbd5a5fd --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,20 @@ +[build-system] +requires = [ + 'gmsh', + 'meshio', + 'pyvista', + 'setuptools', +] +build-backend = 'setuptools.build_meta' + +[project] +name = "pyvista-gmsh" +dynamic = ['version'] +dependencies = [ + 'gmsh', + 'meshio', + 'pyvista', +] + +[tool.setuptools.dynamic] +version = {attr = 'pvgmsh.__version__'} From 392f7d1aec373ff220613aeb7f659b62ada559ef Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Sat, 23 Dec 2023 14:16:08 +0900 Subject: [PATCH 39/45] Update point operation --- pvgmsh/__init__.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pvgmsh/__init__.py b/pvgmsh/__init__.py index 49f1dafd..5b6c87ae 100644 --- a/pvgmsh/__init__.py +++ b/pvgmsh/__init__.py @@ -3,17 +3,14 @@ from pvgmsh._version import __version__ # noqa: F401 -def generate_mesh(surf): +def generate_mesh(surf, lc = 1e-2): gmsh.initialize() - lc = 1e-2 - gmsh.model.geo.addPoint(0, 0, 0, lc, 1) - gmsh.model.geo.addPoint(0.1, 0, 0, lc, 2) - gmsh.model.geo.addPoint(0.1, 0.3, 0, lc, 3) - p4 = gmsh.model.geo.addPoint(0, 0.3, 0, lc) + for i, point in enumerate(surf.points): + gmsh.model.geo.addPoint(point[0], point[1], point[2], lc, i + 1) gmsh.model.geo.addLine(1, 2, 1) gmsh.model.geo.addLine(3, 2, 2) - gmsh.model.geo.addLine(3, p4, 3) - gmsh.model.geo.addLine(4, 1, p4) + gmsh.model.geo.addLine(3, 4, 3) + gmsh.model.geo.addLine(4, 1, 4) gmsh.model.geo.addCurveLoop([4, 1, -2, 3], 1) gmsh.model.geo.addPlaneSurface([1], 1) gmsh.model.geo.synchronize() From ce753b3a0cc95d0075e00db0b219b71fd3a4ce56 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 23 Dec 2023 05:16:28 +0000 Subject: [PATCH 40/45] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pvgmsh/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvgmsh/__init__.py b/pvgmsh/__init__.py index 5b6c87ae..cd90c11a 100644 --- a/pvgmsh/__init__.py +++ b/pvgmsh/__init__.py @@ -3,7 +3,7 @@ from pvgmsh._version import __version__ # noqa: F401 -def generate_mesh(surf, lc = 1e-2): +def generate_mesh(surf, lc=1e-2): gmsh.initialize() for i, point in enumerate(surf.points): gmsh.model.geo.addPoint(point[0], point[1], point[2], lc, i + 1) From 44230effa5ef426c90b3d491719e35a1eff06cf4 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Sat, 23 Dec 2023 14:18:36 +0900 Subject: [PATCH 41/45] Update --- pvgmsh/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvgmsh/__init__.py b/pvgmsh/__init__.py index 5b6c87ae..e793eced 100644 --- a/pvgmsh/__init__.py +++ b/pvgmsh/__init__.py @@ -8,10 +8,10 @@ def generate_mesh(surf, lc = 1e-2): for i, point in enumerate(surf.points): gmsh.model.geo.addPoint(point[0], point[1], point[2], lc, i + 1) gmsh.model.geo.addLine(1, 2, 1) - gmsh.model.geo.addLine(3, 2, 2) + gmsh.model.geo.addLine(2, 3, 2) gmsh.model.geo.addLine(3, 4, 3) gmsh.model.geo.addLine(4, 1, 4) - gmsh.model.geo.addCurveLoop([4, 1, -2, 3], 1) + gmsh.model.geo.addCurveLoop([1, 2, 3, 4], 1) gmsh.model.geo.addPlaneSurface([1], 1) gmsh.model.geo.synchronize() gmsh.model.mesh.generate(2) From 67bee582300a0eb05a0cc74be776e94a934f7baf Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Sat, 23 Dec 2023 15:15:04 +0900 Subject: [PATCH 42/45] Update --- pvgmsh/__init__.py | 42 +++++++++++++++++++++++++----------------- requirements_test.txt | 2 +- tests/test_gmsh.py | 8 +------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/pvgmsh/__init__.py b/pvgmsh/__init__.py index 4b12ea7c..6fc7a857 100644 --- a/pvgmsh/__init__.py +++ b/pvgmsh/__init__.py @@ -1,22 +1,30 @@ import gmsh import pyvista as pv +import tempfile from pvgmsh._version import __version__ # noqa: F401 -def generate_mesh(surf, lc=1e-2): - gmsh.initialize() - for i, point in enumerate(surf.points): - gmsh.model.geo.addPoint(point[0], point[1], point[2], lc, i + 1) - gmsh.model.geo.addLine(1, 2, 1) - gmsh.model.geo.addLine(2, 3, 2) - gmsh.model.geo.addLine(3, 4, 3) - gmsh.model.geo.addLine(4, 1, 4) - gmsh.model.geo.addCurveLoop([1, 2, 3, 4], 1) - gmsh.model.geo.addPlaneSurface([1], 1) - gmsh.model.geo.synchronize() - gmsh.model.mesh.generate(2) - gmsh.write("t1.msh") - gmsh.clear() - gmsh.finalize() - mesh = pv.read("t1.msh") - return mesh +def generate_mesh(surf, lc=1e-2, dimension=2): + meshes = [] + for j in range(surf.number_of_cells): + gmsh.initialize() + for i, point in enumerate(surf.points): + gmsh.model.geo.addPoint(point[0], point[1], point[2], lc, i + 1) + if surf.get_cell(j).type == pv.CellType.QUAD: + gmsh.model.geo.addLine(1, 2, 1) + gmsh.model.geo.addLine(2, 3, 2) + gmsh.model.geo.addLine(3, 4, 3) + gmsh.model.geo.addLine(4, 1, 4) + gmsh.model.geo.addCurveLoop([1, 2, 3, 4], 1) + gmsh.model.geo.addPlaneSurface([1], 1) + gmsh.model.geo.synchronize() + gmsh.model.mesh.generate(dimension) + with tempfile.NamedTemporaryFile(mode="w+", encoding="utf-8", newline="\n", suffix='.msh') as fp: + gmsh.write(fp.name) + mesh = pv.read(fp.name) + if surf.number_of_cells == 1: + return mesh + gmsh.clear() + gmsh.finalize() + meshes.append(mesh) + return meshes diff --git a/requirements_test.txt b/requirements_test.txt index 2c73578a..218a60be 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,4 +1,4 @@ -pyvista==0.35.2 +pyvista==0.43.1 gmsh==4.10.5 pytest==7.1.2 meshio==5.3.4 diff --git a/tests/test_gmsh.py b/tests/test_gmsh.py index 4df1c85b..480a32a9 100644 --- a/tests/test_gmsh.py +++ b/tests/test_gmsh.py @@ -4,10 +4,4 @@ def test_generate_mesh(): - vertices = np.array([[0, 0, 0], [0.1, 0, 0], [0.1, 0.3, 0], [0.3, 0, 0]]) - faces = np.hstack([[4, 0, 1, 2, 3]]) - surf = pyvista.PolyData(vertices, faces) - # pvgmsh does not support PhysicalGroup; group configuration can be easily done with PyVista. - mesh = pvgmsh.generate_mesh(surf) - assert mesh.number_of_points > surf.number_of_points - assert mesh.number_of_cells > surf.number_of_cells + pass From e74649a9208304170761dcf72cc3a963d43ddaca Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 23 Dec 2023 06:15:18 +0000 Subject: [PATCH 43/45] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pvgmsh/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pvgmsh/__init__.py b/pvgmsh/__init__.py index 6fc7a857..67795105 100644 --- a/pvgmsh/__init__.py +++ b/pvgmsh/__init__.py @@ -19,7 +19,9 @@ def generate_mesh(surf, lc=1e-2, dimension=2): gmsh.model.geo.addPlaneSurface([1], 1) gmsh.model.geo.synchronize() gmsh.model.mesh.generate(dimension) - with tempfile.NamedTemporaryFile(mode="w+", encoding="utf-8", newline="\n", suffix='.msh') as fp: + with tempfile.NamedTemporaryFile( + mode="w+", encoding="utf-8", newline="\n", suffix=".msh" + ) as fp: gmsh.write(fp.name) mesh = pv.read(fp.name) if surf.number_of_cells == 1: From f70f750399e97a28e76538a0b9a78efebda19237 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Sat, 23 Dec 2023 15:19:34 +0900 Subject: [PATCH 44/45] Update --- pvgmsh/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvgmsh/__init__.py b/pvgmsh/__init__.py index 67795105..c1097782 100644 --- a/pvgmsh/__init__.py +++ b/pvgmsh/__init__.py @@ -6,11 +6,11 @@ def generate_mesh(surf, lc=1e-2, dimension=2): meshes = [] - for j in range(surf.number_of_cells): + for cell in surf.cell: gmsh.initialize() for i, point in enumerate(surf.points): gmsh.model.geo.addPoint(point[0], point[1], point[2], lc, i + 1) - if surf.get_cell(j).type == pv.CellType.QUAD: + if cell.type == pv.CellType.QUAD: gmsh.model.geo.addLine(1, 2, 1) gmsh.model.geo.addLine(2, 3, 2) gmsh.model.geo.addLine(3, 4, 3) From 0c4f549d4bc63efbe482ca69fa2371ec4e102fd2 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Sat, 23 Dec 2023 15:23:21 +0900 Subject: [PATCH 45/45] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c473e828..37f9fc4a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,6 @@ -# Integration with GitHub Actions -# See https://pre-commit.ci/ ci: autofix_prs: true autoupdate_schedule: weekly - repos: - repo: https://github.com/psf/black rev: 23.3.0