Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
8 changes: 8 additions & 0 deletions cpp/dolfinx/fem/DirichletBC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,17 @@ find_local_entity_index(const mesh::Topology& topology,

std::vector<std::pair<std::int32_t, int>> entity_indices;
entity_indices.reserve(entities.size());
std::int32_t num_entities_local = e_to_c->num_nodes();
for (std::int32_t e : entities)
{
// Get first attached cell
if (num_entities_local <= e)
Comment thread
schnellerhase marked this conversation as resolved.
Outdated
{
throw std::out_of_range(
"Input entity " + std::to_string(e)
+ " is larger than the number of entities on this process ("
+ std::to_string(num_entities_local) + ").");
}
assert(e_to_c->num_links(e) > 0);
const int cell = e_to_c->links(e).front();

Expand Down
13 changes: 13 additions & 0 deletions python/test/unit/fem/test_bcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,16 @@ def test_blocked_dof_ownership(shape):
owned_sub_dofs = boundary_dofs_V[boundary_dofs_V < num_owned_blocked * bs]
assert len(owned_sub_dofs) == num_owned_sub
assert len(unrolled_dofs_sub) == len(boundary_dofs_V)


def test_bc_index_out_of_range():
mesh = create_unit_square(MPI.COMM_WORLD, 4, 4)
mesh.topology.create_connectivity(mesh.topology.dim - 1, mesh.topology.dim)
facet_map = mesh.topology.index_map(mesh.topology.dim - 1)
num_facets_on_proc = facet_map.size_local + facet_map.num_ghosts
facets = np.arange(num_facets_on_proc + 1, dtype=np.int32)
V = functionspace(mesh, ("Lagrange", 1))
with pytest.raises(
RuntimeError, match=r".*is bigger than the number of entities on this process.*"
Comment thread
jorgensd marked this conversation as resolved.
Outdated
):
locate_dofs_topological(V, mesh.topology.dim - 1, facets)
Loading