Skip to content

Commit

Permalink
bug fix: read the appropriate key of topologies
Browse files Browse the repository at this point in the history
  • Loading branch information
pierricmora authored Sep 24, 2024
1 parent 4919588 commit 4e8ad33
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions python/dolfinx/io/gmshio.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,20 +269,21 @@ def model_to_mesh(

# Check that all cells are tagged once
_d = model.getDimension()
if _d not in topologies.keys():
raise RuntimeError("All cells are expected to be tagged once; none found")
_elementTypes, _elementTags, _nodeTags = model.mesh.getElements(dim=_d, tag=-1)
# assert only one type of elements
# assert len(_elementTypes) == 1 # NOTE: already checked in extract_topology_and_markers
_elementType_dim = _elementType[0]
if _elementType_dim not in topologies.keys():
raise RuntimeError("All cells are expected to be tagged once; none found")
nbcells = len(_elementTags[0])
nbcells_tagged = len(topologies[_d]["entity_tags"])
nbcells_tagged = len(topologies[_elementType_dim]["entity_tags"])
if nbcells != nbcells_tagged:
e = (
"All cells are expected to be tagged once;"
f"found: {nbcells_tagged}, expected: {nbcells}"
)
raise RuntimeError(e)
nbcells_tagged_once = len(np.unique(topologies[_d]["entity_tags"]))
nbcells_tagged_once = len(np.unique(topologies[_elementType_dim]["entity_tags"]))
if nbcells_tagged != nbcells_tagged_once:
e = "All cells are expected to be tagged once; found duplicates"
raise RuntimeError(e)
Expand Down

0 comments on commit 4e8ad33

Please sign in to comment.