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

Fix input arguments to dolfinx.mesh.refine_plaza #3018

Merged
merged 3 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions python/dolfinx/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ def refine_plaza(mesh: Mesh, edges: typing.Optional[np.ndarray] = None, redistri
Refined mesh, list of parent cell for each refine cell, and list
"""
if edges is None:
mesh1, cells, facets = _cpp.refinement.refine_plaza(mesh._cpp_object, redistribute)
mesh1, cells, facets = _cpp.refinement.refine_plaza(mesh._cpp_object, redistribute, option)
else:
mesh1, cells, facets = _cpp.refinement.refine_plaza(mesh._cpp_object, edges, redistribute)
mesh1, cells, facets = _cpp.refinement.refine_plaza(mesh._cpp_object, edges, redistribute, option)
return Mesh(mesh1, mesh._ufl_domain), cells, facets


Expand Down
24 changes: 17 additions & 7 deletions python/test/unit/mesh/test_refinement.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
refine, refine_plaza, transfer_meshtag)


def test_Refinecreate_unit_square():
def test_refine_create_unit_square():
"""Refine mesh of unit square."""
mesh = create_unit_square(MPI.COMM_WORLD, 5, 7, ghost_mode=GhostMode.none)
mesh.topology.create_entities(1)
Expand All @@ -26,7 +26,7 @@ def test_Refinecreate_unit_square():
assert mesh.topology.index_map(2).size_global == 280


def test_Refinecreate_unit_cube_repartition():
def test_refine_create_unit_cube_repartition():
"""Refine mesh of unit cube."""
mesh = create_unit_cube(MPI.COMM_WORLD, 5, 7, 9, ghost_mode=GhostMode.none)
mesh.topology.create_entities(1)
Expand All @@ -44,7 +44,7 @@ def test_Refinecreate_unit_cube_repartition():
assert Q


def test_Refinecreate_unit_cube_keep_partition():
def test_refine_create_unit_cube_keep_partition():
"""Refine mesh of unit cube."""
mesh = create_unit_cube(MPI.COMM_WORLD, 5, 7, 9, ghost_mode=GhostMode.none)
mesh.topology.create_entities(1)
Expand Down Expand Up @@ -118,7 +118,12 @@ def left_side(x, tol=1e-16):


@pytest.mark.parametrize("tdim", [2, 3])
def test_refine_facet_meshtag(tdim):
@pytest.mark.parametrize("refine_plaza_wrapper", [
lambda mesh: refine_plaza(mesh, None, False, RefinementOption.parent_cell_and_facet),
lambda mesh: refine_plaza(
mesh, np.arange(mesh.topology.index_map(1).size_local), False, RefinementOption.parent_cell_and_facet)
])
def test_refine_facet_meshtag(tdim, refine_plaza_wrapper):
if tdim == 3:
mesh = create_unit_cube(MPI.COMM_WORLD, 2, 3, 5, CellType.tetrahedron, ghost_mode=GhostMode.none)
else:
Expand All @@ -134,7 +139,7 @@ def test_refine_facet_meshtag(tdim):
meshtag = meshtags(mesh, tdim - 1, np.array(facet_indices, dtype=np.int32),
np.arange(len(facet_indices), dtype=np.int32))

fine_mesh, parent_cell, parent_facet = refine_plaza(mesh, False, RefinementOption.parent_cell_and_facet)
fine_mesh, parent_cell, parent_facet = refine_plaza_wrapper(mesh)
fine_mesh.topology.create_entities(tdim - 1)
new_meshtag = transfer_meshtag(meshtag, fine_mesh, parent_cell, parent_facet)
assert len(new_meshtag.indices) == (tdim * 2 - 2) * len(meshtag.indices)
Expand All @@ -154,7 +159,12 @@ def test_refine_facet_meshtag(tdim):


@pytest.mark.parametrize("tdim", [2, 3])
def test_refine_cell_meshtag(tdim):
@pytest.mark.parametrize("refine_plaza_wrapper", [
lambda mesh: refine_plaza(mesh, None, False, RefinementOption.parent_cell_and_facet),
lambda mesh: refine_plaza(
mesh, np.arange(mesh.topology.index_map(1).size_local), False, RefinementOption.parent_cell_and_facet)
])
def test_refine_cell_meshtag(tdim, refine_plaza_wrapper):
if tdim == 3:
mesh = create_unit_cube(MPI.COMM_WORLD, 2, 3, 5, CellType.tetrahedron, ghost_mode=GhostMode.none)
else:
Expand All @@ -165,7 +175,7 @@ def test_refine_cell_meshtag(tdim):
meshtag = meshtags(mesh, tdim, np.array(cell_indices, dtype=np.int32),
np.arange(len(cell_indices), dtype=np.int32))

fine_mesh, parent_cell, _ = refine_plaza(mesh, False, RefinementOption.parent_cell_and_facet)
fine_mesh, parent_cell, _ = refine_plaza_wrapper(mesh)
new_meshtag = transfer_meshtag(meshtag, fine_mesh, parent_cell)
assert sum(new_meshtag.values) == (tdim * 4 - 4) * sum(meshtag.values)
assert len(new_meshtag.indices) == (tdim * 4 - 4) * len(meshtag.indices)
Loading