From c1ac4750318caafa07c4dba02aedffffabf64957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Schartum=20Dokken?= Date: Thu, 21 Nov 2024 23:00:15 +0100 Subject: [PATCH] Fix topological dimension of vertex-meshes (#3523) * Add fix for point mesh tdim * Add fix in topology constructor after checking that new assertion fails in previous commit * Apply suggestions from code review --------- Co-authored-by: Garth N. Wells --- cpp/dolfinx/mesh/Topology.cpp | 3 ++- python/test/unit/mesh/test_mesh.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cpp/dolfinx/mesh/Topology.cpp b/cpp/dolfinx/mesh/Topology.cpp index 451965634fd..0c688e24753 100644 --- a/cpp/dolfinx/mesh/Topology.cpp +++ b/cpp/dolfinx/mesh/Topology.cpp @@ -773,7 +773,8 @@ Topology::Topology( // Cell Types _entity_types.insert(_entity_types.end(), cell_types.begin(), cell_types.end()); - _entity_type_offsets.push_back(_entity_types.size()); + if (tdim > 0) + _entity_type_offsets.push_back(_entity_types.size()); std::int8_t conn_size = _entity_type_offsets.back(); _index_map.resize(conn_size); diff --git a/python/test/unit/mesh/test_mesh.py b/python/test/unit/mesh/test_mesh.py index e620e1c0569..7d721f1d4f7 100644 --- a/python/test/unit/mesh/test_mesh.py +++ b/python/test/unit/mesh/test_mesh.py @@ -522,6 +522,7 @@ def test_submesh_full(d, n, codim, marker, ghost_mode, simplex): 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) + assert submesh.topology.dim == edim submesh_topology_test(mesh, submesh, entity_map, vertex_map, edim) submesh_geometry_test(mesh, submesh, entity_map, geom_map, edim)