Skip to content

Commit 74425fe

Browse files
committed
detect elements that belong to multiple parts
1 parent e76d2cb commit 74425fe

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

meshmode/mesh/processing.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,13 @@ def _get_mesh_part(mesh, part_id_to_elements, self_part_id):
422422
423423
.. versionadded:: 2017.1
424424
"""
425-
nelements = sum(len(elems) for elems in part_id_to_elements.values())
426-
if nelements != mesh.nelements:
427-
raise ValueError(
428-
"counts of partitioned elements don't add up to mesh.nelements")
425+
element_counts = np.zeros(mesh.nelements)
426+
for elements in part_id_to_elements.values():
427+
element_counts[elements] += 1
428+
if np.any(element_counts > 1):
429+
raise ValueError("elements cannot belong to multiple parts")
430+
if np.any(element_counts < 1):
431+
raise ValueError("partition must contain all elements")
429432

430433
part_id_to_part_index = {
431434
part_id: part_index

0 commit comments

Comments
 (0)