Skip to content

Commit

Permalink
Also work in 3D
Browse files Browse the repository at this point in the history
Signed-off-by: Umberto Zerbinati <[email protected]>
  • Loading branch information
Umberto Zerbinati committed Apr 25, 2024
1 parent 1fa964f commit 22fc522
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions ngsPETSc/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ def createPETScDMPlex(self, mesh, labels):
else:
self.ngMesh = mesh
comm = self.comm
# Map Netgen string to ids for the labels
newLabels = []
if len(labels) > 0:
for key in labels.keys():
for i, s in enumerate(self.ngMesh.GetRegionNames(dim=self.ngMesh.dim-1)):
if key == s:
newLabels = newLabels + [(i+1, labels[key])]
newLabels = dict(newLabels)
if self.ngMesh.dim == 3:
if comm.rank == 0:
V = self.ngMesh.Coordinates()
Expand All @@ -179,7 +187,10 @@ def createPETScDMPlex(self, mesh, labels):
else:
for e in self.ngMesh.Elements2D():
join = plex.getFullJoin([vStart+v.nr-1 for v in e.vertices])
plex.setLabelValue(FACE_SETS_LABEL, join[0], int(e.index))
if e.index in newLabels:
plex.setLabelValue(FACE_SETS_LABEL, join[0], int(newLabels[e.index]))
else:
plex.setLabelValue(FACE_SETS_LABEL, join[0], int(e.index))
for e in self.ngMesh.Elements1D():
join = plex.getJoin([vStart+v.nr-1 for v in e.vertices])
plex.setLabelValue(EDGE_SETS_LABEL, join[0], int(e.index))
Expand All @@ -192,14 +203,6 @@ def createPETScDMPlex(self, mesh, labels):
self.petscPlex = plex
elif self.ngMesh.dim == 2:
if comm.rank == 0:
# Map Netgen string to ids for the labels
newLabels = []
if len(labels) > 0:
for key in labels.keys():
for i, s in enumerate(self.ngMesh.GetRegionNames(dim=1)):
if key == s:
newLabels = newLabels + [(i+1, labels[key])]
newLabels = dict(newLabels)
V = self.ngMesh.Coordinates()
T = self.ngMesh.Elements2D().NumPy()["nodes"]
T = np.array([list(np.trim_zeros(a, 'b')) for a in list(T)])-1
Expand Down

0 comments on commit 22fc522

Please sign in to comment.