Skip to content

Commit

Permalink
Merge branch 'main' into dokken/remove-nbx-submap
Browse files Browse the repository at this point in the history
  • Loading branch information
garth-wells committed Sep 24, 2024
2 parents a93f175 + 6021fd5 commit 16aa0c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion python/dolfinx/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,9 @@ def refine(
mesh1, parent_cell, parent_facet = _cpp.refinement.refine(
mesh._cpp_object, edges, redistribute, ghost_mode, option
)
return Mesh(mesh1, mesh._ufl_domain), parent_cell, parent_facet
# Create new ufl domain as it will carry a reference to the C++ mesh in the ufl_cargo
ufl_domain = ufl.Mesh(mesh._ufl_domain.ufl_coordinate_element()) # type: ignore
return Mesh(mesh1, ufl_domain), parent_cell, parent_facet


def create_mesh(
Expand Down
11 changes: 9 additions & 2 deletions python/test/unit/refinement/test_refinement.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (C) 2018-2021 Chris N Richardson and Jørgen S. Dokken
#
# Copyright (C) 2018-2024 Chris N Richardson and Jørgen S. Dokken

# This file is part of DOLFINx (https://www.fenicsproject.org)
#
# SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down Expand Up @@ -212,3 +212,10 @@ def test_refine_cell_meshtag(tdim, refine_plaza_wrapper):
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)


def test_refine_ufl_cargo():
mesh = create_unit_cube(MPI.COMM_WORLD, 4, 3, 3)
mesh.topology.create_entities(1)
refined_mesh, _, _ = refine(mesh, redistribute=False)
assert refined_mesh.ufl_domain().ufl_cargo() != mesh.ufl_domain().ufl_cargo()

0 comments on commit 16aa0c2

Please sign in to comment.