Wrong elements in partition boundaries
I'm trying to use a mesh partition in the Gmsh Python SDK and I'm having trouble with partition boundaries. I'm using getBoundary and getting elements whose elemNodeTag does not belong to parent entity nodeTags (via getNodes with includeBoundary).
Also I got different results with getNodes(includeBoundary=True)
and getNodesByElementType
which seems wrong.
I'm using the dipole2d.geo Gmsh file and the Python code below to reproduce this issue.
#!apt install libglu1-mesa
#!pip install --upgrade gmsh # also tried gmsh 4.11.1
!pip install -i https://gmsh.info/python-packages-dev-nox --force-reinstall --no-cache-dir gmsh
import gmsh
import numpy as np
gmsh.initialize()
try:
gmsh.open('/content/dipole2d.geo')
gmsh.model.mesh.generate(gmsh.model.getDimension())
gmsh.option.setNumber("Mesh.PartitionCreateTopology", 1)
gmsh.option.setNumber("Mesh.PartitionCreatePhysicals", 1)
#gmsh.model.mesh.refine()
gmsh.model.mesh.partition(10)
for dim, tag in gmsh.model.getEntities(gmsh.model.getDimension()):
partitions = gmsh.model.getPartitions(dim, tag)
if not len(partitions):
continue
nodeTags, nodeCoords, _ = gmsh.model.mesh.getNodes(dim, tag, True, False)
for bdim, btag in gmsh.model.getBoundary([(dim, tag)]):
for elemType, elemTags, elemNodeTag in zip(*gmsh.model.mesh.getElements(bdim, abs(btag))):
nodeTags2, _, _ = gmsh.model.mesh.getNodes(bdim, abs(btag), True, False)
nodeTags3, _, _ = gmsh.model.mesh.getNodesByElementType(elemType, abs(btag), False)
assert len(bad_indices := np.setdiff1d(elemNodeTag, nodeTags)) == 0, (bad_indices, elemNodeTag, nodeTags, nodeTags2, nodeTags3)
finally:
gmsh.clear()
gmsh.finalize()
AssertionError: (array([22], dtype=uint64), array([22, 23], dtype=uint64), array([126, 124, 133, 132, 109, 104, 108, 112, 119, 103, 125, 145, 144,
149, 151, 49, 50, 51, 52, 21, 121, 128, 127, 113, 135, 116,
117, 102, 120, 140, 142, 1, 2, 8, 136, 24, 48, 114, 23],
dtype=uint64), array([23], dtype=uint64), array([22, 23], dtype=uint64))