From 2d6b40eba4649a4da0db3b59751d34f7cb3a510d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Sat, 5 Oct 2024 06:55:36 +0000 Subject: [PATCH 1/8] Add tests for submesh of vertices --- python/test/unit/mesh/test_mesh.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/python/test/unit/mesh/test_mesh.py b/python/test/unit/mesh/test_mesh.py index bc9bfeb68bb..675163713aa 100644 --- a/python/test/unit/mesh/test_mesh.py +++ b/python/test/unit/mesh/test_mesh.py @@ -503,15 +503,15 @@ def boundary_2(x): # TODO Test that submesh of full mesh is a copy of the mesh -@pytest.mark.parametrize("d", [2, 3]) +@pytest.mark.parametrize("d", [1, 2, 3]) @pytest.mark.parametrize("n", [3, 6]) @pytest.mark.parametrize("codim", [0, 1, 2]) @pytest.mark.parametrize("marker", [lambda x: x[0] >= 0.5, lambda x: x[0] >= -1]) @pytest.mark.parametrize("ghost_mode", [GhostMode.none, GhostMode.shared_facet]) @pytest.mark.parametrize("simplex", [True, False]) def test_submesh_full(d, n, codim, marker, ghost_mode, simplex): - if d == codim: - pytest.xfail("Cannot create vertex submesh") + if d == 1: + mesh = create_unit_interval(MPI.COMM_WORLD, n, ghost_mode=ghost_mode) if d == 2: ct = CellType.triangle if simplex else CellType.quadrilateral mesh = create_unit_square(MPI.COMM_WORLD, n, n, ghost_mode=ghost_mode, cell_type=ct) @@ -526,15 +526,18 @@ def test_submesh_full(d, n, codim, marker, ghost_mode, simplex): submesh_geometry_test(mesh, submesh, entity_map, geom_map, edim) -@pytest.mark.parametrize("d", [2, 3]) +@pytest.mark.parametrize("d", [1, 2, 3]) @pytest.mark.parametrize("n", [3, 6]) @pytest.mark.parametrize("boundary", [boundary_0, boundary_1, boundary_2]) @pytest.mark.parametrize("ghost_mode", [GhostMode.none, GhostMode.shared_facet]) def test_submesh_boundary(d, n, boundary, ghost_mode): - if d == 2: + if d == 1: + mesh = create_unit_interval(MPI.COMM_WORLD, n, ghost_mode=ghost_mode) + elif d == 2: mesh = create_unit_square(MPI.COMM_WORLD, n, n, ghost_mode=ghost_mode) else: mesh = create_unit_cube(MPI.COMM_WORLD, n, n, n, ghost_mode=ghost_mode) + edim = mesh.topology.dim - 1 entities = locate_entities_boundary(mesh, edim, boundary) submesh, entity_map, vertex_map, geom_map = create_submesh(mesh, edim, entities) From 2d19c4dcd26018ae023e248945b1a1886c57722c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Sat, 5 Oct 2024 06:57:06 +0000 Subject: [PATCH 2/8] Redirect basix branch --- .github/workflows/ccpp.yml | 6 +++--- .github/workflows/macos.yml | 2 +- .github/workflows/oneapi.yml | 2 +- .github/workflows/pyvista.yml | 2 +- .github/workflows/redhat.yml | 2 +- .github/workflows/sonarcloud.yml | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 88add093759..c5b40c85988 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -103,7 +103,7 @@ jobs: if: github.event_name != 'workflow_dispatch' run: | pip install git+https://github.com/FEniCS/ufl.git - pip install git+https://github.com/FEniCS/basix.git + pip install git+https://github.com/FEniCS/basix.git@dokken/vertex-submesh pip install git+https://github.com/FEniCS/ffcx.git - name: Install FEniCS Python components if: github.event_name == 'workflow_dispatch' @@ -173,7 +173,7 @@ jobs: if: github.event_name != 'workflow_dispatch' run: | pip install git+https://github.com/FEniCS/ufl.git - pip install git+https://github.com/FEniCS/basix.git + pip install git+https://github.com/FEniCS/basix.git@dokken/vertex-submesh pip install git+https://github.com/FEniCS/ffcx.git - name: Install FEniCS Python components @@ -251,7 +251,7 @@ jobs: if: github.event_name != 'workflow_dispatch' run: | pip install git+https://github.com/FEniCS/ufl.git - pip install git+https://github.com/FEniCS/basix.git + pip install git+https://github.com/FEniCS/basix.git@dokken/vertex-submesh pip install git+https://github.com/FEniCS/ffcx.git - name: Install FEniCS Python components if: github.event_name == 'workflow_dispatch' diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 6ff1ceda5d2..08144c808f1 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -62,7 +62,7 @@ jobs: - name: Install FEniCSx dependencies run: | - python -m pip install git+https://github.com/FEniCS/basix.git + python -m pip install git+https://github.com/FEniCS/basix.git@dokken/vertex-submesh python -m pip install git+https://github.com/FEniCS/ufl.git python -m pip install git+https://github.com/FEniCS/ffcx.git diff --git a/.github/workflows/oneapi.yml b/.github/workflows/oneapi.yml index 09b96b25359..f0d2e2f6563 100644 --- a/.github/workflows/oneapi.yml +++ b/.github/workflows/oneapi.yml @@ -52,7 +52,7 @@ jobs: conda list - name: Install Basix - run: pip install --no-build-isolation git+https://github.com/FEniCS/basix.git + run: pip install --no-build-isolation git+https://github.com/FEniCS/basix.git@dokken/vertex-submesh - name: Clone FFCx uses: actions/checkout@v4 diff --git a/.github/workflows/pyvista.yml b/.github/workflows/pyvista.yml index 6263f0ae29a..707c68e23ca 100644 --- a/.github/workflows/pyvista.yml +++ b/.github/workflows/pyvista.yml @@ -39,7 +39,7 @@ jobs: - name: Install FEniCS Python components run: | pip install git+https://github.com/FEniCS/ufl.git - pip install git+https://github.com/FEniCS/basix.git + pip install git+https://github.com/FEniCS/basix.git@dokken/vertex-submesh pip install git+https://github.com/FEniCS/ffcx.git apt-get update apt-get install -y --no-install-recommends libgl1-mesa-dev xvfb # pyvista diff --git a/.github/workflows/redhat.yml b/.github/workflows/redhat.yml index 76aaadca04e..d85044f7130 100644 --- a/.github/workflows/redhat.yml +++ b/.github/workflows/redhat.yml @@ -31,7 +31,7 @@ jobs: - name: Install FEniCS Python components run: | python3 -m pip install git+https://github.com/FEniCS/ufl.git - python3 -m pip install git+https://github.com/FEniCS/basix.git + python3 -m pip install git+https://github.com/FEniCS/basix.git@dokken/vertex-submesh python3 -m pip install git+https://github.com/FEniCS/ffcx.git - name: Configure C++ diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 092e2eb84b6..1e7415f14ab 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -59,7 +59,7 @@ jobs: - name: Install FEniCS Python components run: | python3 -m pip install git+https://github.com/FEniCS/ufl.git - python3 -m pip install git+https://github.com/FEniCS/basix.git + python3 -m pip install git+https://github.com/FEniCS/basix.git@dokken/vertex-submesh python3 -m pip install git+https://github.com/FEniCS/ffcx.git - name: Run build-wrapper run: | From 50f48f68afee3242a5a0ef613abb6c3e94d390e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Sat, 5 Oct 2024 07:03:20 +0000 Subject: [PATCH 3/8] Ruff formatting --- python/test/unit/mesh/test_mesh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/test/unit/mesh/test_mesh.py b/python/test/unit/mesh/test_mesh.py index 675163713aa..72b1f7f9bcc 100644 --- a/python/test/unit/mesh/test_mesh.py +++ b/python/test/unit/mesh/test_mesh.py @@ -537,7 +537,7 @@ def test_submesh_boundary(d, n, boundary, ghost_mode): mesh = create_unit_square(MPI.COMM_WORLD, n, n, ghost_mode=ghost_mode) else: mesh = create_unit_cube(MPI.COMM_WORLD, n, n, n, ghost_mode=ghost_mode) - + edim = mesh.topology.dim - 1 entities = locate_entities_boundary(mesh, edim, boundary) submesh, entity_map, vertex_map, geom_map = create_submesh(mesh, edim, entities) From 9fa907d9f9862d32423f60449bb34bee09f98541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Sat, 5 Oct 2024 07:04:11 +0000 Subject: [PATCH 4/8] Add fixes and simplifications for submesh of vertices --- cpp/dolfinx/mesh/utils.h | 7 ++++++- python/dolfinx/mesh.py | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cpp/dolfinx/mesh/utils.h b/cpp/dolfinx/mesh/utils.h index 7479ef67bcd..1fa5724e39d 100644 --- a/cpp/dolfinx/mesh/utils.h +++ b/cpp/dolfinx/mesh/utils.h @@ -1250,7 +1250,12 @@ create_subgeometry(const Mesh& mesh, int dim, // Create sub-geometry coordinate element CellType sub_coord_cell = cell_entity_type(geometry.cmap().cell_shape(), dim, 0); - fem::CoordinateElement sub_cmap(sub_coord_cell, geometry.cmap().degree(), + // Special handling if point meshes, as they only support constant basis + // functions + int degree = geometry.cmap().degree(); + if (sub_coord_cell == CellType::point) + degree = 0; + fem::CoordinateElement sub_cmap(sub_coord_cell, degree, geometry.cmap().variant()); // Sub-geometry input_global_indices diff --git a/python/dolfinx/mesh.py b/python/dolfinx/mesh.py index 2203ca8d961..e58563a2bf1 100644 --- a/python/dolfinx/mesh.py +++ b/python/dolfinx/mesh.py @@ -675,11 +675,10 @@ def create_submesh( submsh, entity_map, vertex_map, geom_map = _cpp.mesh.create_submesh( msh._cpp_object, dim, entities ) - submsh_ufl_cell = ufl.Cell(to_string(submsh.topology.cell_type)) submsh_domain = ufl.Mesh( basix.ufl.element( "Lagrange", - submsh_ufl_cell.cellname(), + to_string(submsh.topology.cell_type), submsh.geometry.cmap.degree, basix.LagrangeVariant(submsh.geometry.cmap.variant), shape=(submsh.geometry.dim,), From a602cc2648b0a2c04f934acd97caae12d5e7ac58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Schartum=20Dokken?= Date: Sat, 5 Oct 2024 09:12:15 +0200 Subject: [PATCH 5/8] Tidy up test --- python/test/unit/mesh/test_mesh.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/test/unit/mesh/test_mesh.py b/python/test/unit/mesh/test_mesh.py index 72b1f7f9bcc..bc81af46083 100644 --- a/python/test/unit/mesh/test_mesh.py +++ b/python/test/unit/mesh/test_mesh.py @@ -512,7 +512,7 @@ def boundary_2(x): def test_submesh_full(d, n, codim, marker, ghost_mode, simplex): if d == 1: mesh = create_unit_interval(MPI.COMM_WORLD, n, ghost_mode=ghost_mode) - if d == 2: + elif d == 2: ct = CellType.triangle if simplex else CellType.quadrilateral mesh = create_unit_square(MPI.COMM_WORLD, n, n, ghost_mode=ghost_mode, cell_type=ct) else: @@ -537,7 +537,6 @@ def test_submesh_boundary(d, n, boundary, ghost_mode): mesh = create_unit_square(MPI.COMM_WORLD, n, n, ghost_mode=ghost_mode) else: mesh = create_unit_cube(MPI.COMM_WORLD, n, n, n, ghost_mode=ghost_mode) - edim = mesh.topology.dim - 1 entities = locate_entities_boundary(mesh, edim, boundary) submesh, entity_map, vertex_map, geom_map = create_submesh(mesh, edim, entities) From 965b7f3349b2dcc27eb8dbbfee487ef8abb2a2d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Sat, 5 Oct 2024 10:06:23 +0000 Subject: [PATCH 6/8] Ignore when edim becomes negative by setting to zero in parametrized test --- python/test/unit/mesh/test_mesh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/test/unit/mesh/test_mesh.py b/python/test/unit/mesh/test_mesh.py index bc81af46083..e620e1c0569 100644 --- a/python/test/unit/mesh/test_mesh.py +++ b/python/test/unit/mesh/test_mesh.py @@ -519,7 +519,7 @@ def test_submesh_full(d, n, codim, marker, ghost_mode, simplex): ct = CellType.tetrahedron if simplex else CellType.hexahedron mesh = create_unit_cube(MPI.COMM_WORLD, n, n, n, ghost_mode=ghost_mode, cell_type=ct) - edim = mesh.topology.dim - codim + edim = max(mesh.topology.dim - codim, 0) entities = locate_entities(mesh, edim, marker) submesh, entity_map, vertex_map, geom_map = create_submesh(mesh, edim, entities) submesh_topology_test(mesh, submesh, entity_map, vertex_map, edim) From 809db421d7f61c0fdc4cc01e6d3ebc3f06b51c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Schartum=20Dokken?= Date: Mon, 7 Oct 2024 11:48:34 +0200 Subject: [PATCH 7/8] Revert branches --- .github/workflows/ccpp.yml | 6 +++--- .github/workflows/macos.yml | 2 +- .github/workflows/oneapi.yml | 2 +- .github/workflows/pyvista.yml | 2 +- .github/workflows/redhat.yml | 2 +- .github/workflows/sonarcloud.yml | 3 ++- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index c5b40c85988..88add093759 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -103,7 +103,7 @@ jobs: if: github.event_name != 'workflow_dispatch' run: | pip install git+https://github.com/FEniCS/ufl.git - pip install git+https://github.com/FEniCS/basix.git@dokken/vertex-submesh + pip install git+https://github.com/FEniCS/basix.git pip install git+https://github.com/FEniCS/ffcx.git - name: Install FEniCS Python components if: github.event_name == 'workflow_dispatch' @@ -173,7 +173,7 @@ jobs: if: github.event_name != 'workflow_dispatch' run: | pip install git+https://github.com/FEniCS/ufl.git - pip install git+https://github.com/FEniCS/basix.git@dokken/vertex-submesh + pip install git+https://github.com/FEniCS/basix.git pip install git+https://github.com/FEniCS/ffcx.git - name: Install FEniCS Python components @@ -251,7 +251,7 @@ jobs: if: github.event_name != 'workflow_dispatch' run: | pip install git+https://github.com/FEniCS/ufl.git - pip install git+https://github.com/FEniCS/basix.git@dokken/vertex-submesh + pip install git+https://github.com/FEniCS/basix.git pip install git+https://github.com/FEniCS/ffcx.git - name: Install FEniCS Python components if: github.event_name == 'workflow_dispatch' diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 08144c808f1..6ff1ceda5d2 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -62,7 +62,7 @@ jobs: - name: Install FEniCSx dependencies run: | - python -m pip install git+https://github.com/FEniCS/basix.git@dokken/vertex-submesh + python -m pip install git+https://github.com/FEniCS/basix.git python -m pip install git+https://github.com/FEniCS/ufl.git python -m pip install git+https://github.com/FEniCS/ffcx.git diff --git a/.github/workflows/oneapi.yml b/.github/workflows/oneapi.yml index f0d2e2f6563..09b96b25359 100644 --- a/.github/workflows/oneapi.yml +++ b/.github/workflows/oneapi.yml @@ -52,7 +52,7 @@ jobs: conda list - name: Install Basix - run: pip install --no-build-isolation git+https://github.com/FEniCS/basix.git@dokken/vertex-submesh + run: pip install --no-build-isolation git+https://github.com/FEniCS/basix.git - name: Clone FFCx uses: actions/checkout@v4 diff --git a/.github/workflows/pyvista.yml b/.github/workflows/pyvista.yml index 707c68e23ca..6263f0ae29a 100644 --- a/.github/workflows/pyvista.yml +++ b/.github/workflows/pyvista.yml @@ -39,7 +39,7 @@ jobs: - name: Install FEniCS Python components run: | pip install git+https://github.com/FEniCS/ufl.git - pip install git+https://github.com/FEniCS/basix.git@dokken/vertex-submesh + pip install git+https://github.com/FEniCS/basix.git pip install git+https://github.com/FEniCS/ffcx.git apt-get update apt-get install -y --no-install-recommends libgl1-mesa-dev xvfb # pyvista diff --git a/.github/workflows/redhat.yml b/.github/workflows/redhat.yml index d85044f7130..76aaadca04e 100644 --- a/.github/workflows/redhat.yml +++ b/.github/workflows/redhat.yml @@ -31,7 +31,7 @@ jobs: - name: Install FEniCS Python components run: | python3 -m pip install git+https://github.com/FEniCS/ufl.git - python3 -m pip install git+https://github.com/FEniCS/basix.git@dokken/vertex-submesh + python3 -m pip install git+https://github.com/FEniCS/basix.git python3 -m pip install git+https://github.com/FEniCS/ffcx.git - name: Configure C++ diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 1e7415f14ab..8383848ce2c 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -59,7 +59,8 @@ jobs: - name: Install FEniCS Python components run: | python3 -m pip install git+https://github.com/FEniCS/ufl.git - python3 -m pip install git+https://github.com/FEniCS/basix.git@dokken/vertex-submesh + python3 -m pip install git+https://github.com/FEniCS/basix.git +`` python3 -m pip install git+https://github.com/FEniCS/ffcx.git - name: Run build-wrapper run: | From e86432c664e9e887ae7b0a59e169ed5da2a2217d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Schartum=20Dokken?= Date: Mon, 7 Oct 2024 11:49:13 +0200 Subject: [PATCH 8/8] Remove formatting error --- .github/workflows/sonarcloud.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 8383848ce2c..092e2eb84b6 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -60,7 +60,6 @@ jobs: run: | python3 -m pip install git+https://github.com/FEniCS/ufl.git python3 -m pip install git+https://github.com/FEniCS/basix.git -`` python3 -m pip install git+https://github.com/FEniCS/ffcx.git - name: Run build-wrapper run: |