Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertex submesh support #3455

Merged
merged 8 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
jorgensd marked this conversation as resolved.
Show resolved Hide resolved
jorgensd marked this conversation as resolved.
Show resolved Hide resolved
pip install git+https://github.com/FEniCS/ffcx.git
- name: Install FEniCS Python components
if: github.event_name == 'workflow_dispatch'
Expand Down Expand Up @@ -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
jorgensd marked this conversation as resolved.
Show resolved Hide resolved
pip install git+https://github.com/FEniCS/ffcx.git

- name: Install FEniCS Python components
Expand Down Expand Up @@ -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
jorgensd marked this conversation as resolved.
Show resolved Hide resolved
pip install git+https://github.com/FEniCS/ffcx.git
- name: Install FEniCS Python components
if: github.event_name == 'workflow_dispatch'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
jorgensd marked this conversation as resolved.
Show resolved Hide resolved
python -m pip install git+https://github.com/FEniCS/ufl.git
python -m pip install git+https://github.com/FEniCS/ffcx.git

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/oneapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
jorgensd marked this conversation as resolved.
Show resolved Hide resolved

- name: Clone FFCx
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pyvista.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
jorgensd marked this conversation as resolved.
Show resolved Hide resolved
pip install git+https://github.com/FEniCS/ffcx.git
apt-get update
apt-get install -y --no-install-recommends libgl1-mesa-dev xvfb # pyvista
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
jorgensd marked this conversation as resolved.
Show resolved Hide resolved
python3 -m pip install git+https://github.com/FEniCS/ffcx.git

- name: Configure C++
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
jorgensd marked this conversation as resolved.
Show resolved Hide resolved
python3 -m pip install git+https://github.com/FEniCS/ffcx.git
- name: Run build-wrapper
run: |
Expand Down
7 changes: 6 additions & 1 deletion cpp/dolfinx/mesh/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,12 @@ create_subgeometry(const Mesh<T>& mesh, int dim,
// Create sub-geometry coordinate element
CellType sub_coord_cell
= cell_entity_type(geometry.cmap().cell_shape(), dim, 0);
fem::CoordinateElement<T> 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<T> sub_cmap(sub_coord_cell, degree,
geometry.cmap().variant());

// Sub-geometry input_global_indices
Expand Down
3 changes: 1 addition & 2 deletions python/dolfinx/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,),
Expand Down
13 changes: 8 additions & 5 deletions python/test/unit/mesh/test_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
jorgensd marked this conversation as resolved.
Show resolved Hide resolved
ct = CellType.triangle if simplex else CellType.quadrilateral
mesh = create_unit_square(MPI.COMM_WORLD, n, n, ghost_mode=ghost_mode, cell_type=ct)
Expand All @@ -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)

jorgensd marked this conversation as resolved.
Show resolved Hide resolved
edim = mesh.topology.dim - 1
entities = locate_entities_boundary(mesh, edim, boundary)
submesh, entity_map, vertex_map, geom_map = create_submesh(mesh, edim, entities)
Expand Down
Loading