@@ -1214,53 +1214,57 @@ def generate_box_mesh(axis_coords, order=1, *, coord_dtype=np.float64,
1214
1214
facial_adjacency_groups = None
1215
1215
face_vertex_indices_to_tags = {}
1216
1216
boundary_tags = list (boundary_tag_to_face .keys ())
1217
+ nbnd_tags = len (boundary_tags )
1217
1218
1218
- if boundary_tags :
1219
+ if nbnd_tags > 0 :
1219
1220
vert_index_to_tuple = {
1220
1221
vertex_indices [itup ]: itup
1221
1222
for itup in np .ndindex (shape )}
1222
1223
1223
- for tag in boundary_tags :
1224
- # Need to map the correct face vertices to the boundary tags
1225
- for face in boundary_tag_to_face [tag ]:
1226
- if len (face ) != 2 :
1227
- raise ValueError ("face identifier '%s' does not "
1228
- "consist of exactly two characters" % face )
1229
-
1230
- side , axis = face
1231
- try :
1232
- axis = axes .index (axis )
1233
- except ValueError as exc :
1234
- raise ValueError (
1235
- f"unrecognized axis in face identifier '{ face } '" ) from exc
1236
- if axis >= dim :
1237
- raise ValueError ("axis in face identifier '%s' does not exist in %dD"
1238
- % (face , dim ))
1239
-
1240
- if side == "-" :
1241
- vert_crit = 0
1242
- elif side == "+" :
1243
- vert_crit = shape [axis ] - 1
1244
- else :
1245
- raise ValueError ("first character of face identifier '%s' is not"
1246
- "'+' or '-'" % face )
1247
-
1248
- for ielem in range (0 , grp .nelements ):
1249
- for ref_fvi in grp .face_vertex_indices ():
1250
- fvi = grp .vertex_indices [ielem , ref_fvi ]
1251
- try :
1252
- fvi_tuples = [vert_index_to_tuple [i ] for i in fvi ]
1253
- except KeyError :
1254
- # Happens for interior faces of "X" meshes because
1255
- # midpoints aren't in vert_index_to_tuple. We don't
1256
- # care about them.
1257
- continue
1258
-
1259
- if all (fvi_tuple [axis ] == vert_crit for fvi_tuple in fvi_tuples ):
1260
- key = frozenset (fvi )
1261
- face_vertex_indices_to_tags .setdefault (key , []).append (tag )
1262
-
1263
- if boundary_tags :
1224
+ for ielem in range (0 , grp .nelements ):
1225
+ for ref_fvi in grp .face_vertex_indices ():
1226
+ fvi = grp .vertex_indices [ielem , ref_fvi ]
1227
+ try :
1228
+ fvi_tuples = [vert_index_to_tuple [i ] for i in fvi ]
1229
+ except KeyError :
1230
+ # Happens for interior faces of "X" meshes because
1231
+ # midpoints aren't in vert_index_to_tuple. We don't
1232
+ # care about them.
1233
+ continue
1234
+
1235
+ for tag in boundary_tags :
1236
+ # Need to map the correct face vertices to the boundary tags
1237
+ for face in boundary_tag_to_face [tag ]:
1238
+ if len (face ) != 2 :
1239
+ raise ValueError (
1240
+ "face identifier '%s' does not "
1241
+ "consist of exactly two characters" % face )
1242
+
1243
+ side , axis = face
1244
+ try :
1245
+ axis = axes .index (axis )
1246
+ except ValueError as exc :
1247
+ raise ValueError (
1248
+ "unrecognized axis in face identifier "
1249
+ f"'{ face } '" ) from exc
1250
+ if axis >= dim :
1251
+ raise ValueError ("axis in face identifier '%s' "
1252
+ "does not exist in %dD" % (face , dim ))
1253
+
1254
+ if side == "-" :
1255
+ vert_crit = 0
1256
+ elif side == "+" :
1257
+ vert_crit = shape [axis ] - 1
1258
+ else :
1259
+ raise ValueError ("first character of face identifier"
1260
+ " '%s' is not '+' or '-'" % face )
1261
+
1262
+ if all (fvi_tuple [axis ] == vert_crit
1263
+ for fvi_tuple in fvi_tuples ):
1264
+ key = frozenset (fvi )
1265
+ face_vertex_indices_to_tags .setdefault (key ,
1266
+ []).append (tag )
1267
+
1264
1268
from meshmode .mesh import _compute_facial_adjacency_from_vertices
1265
1269
facial_adjacency_groups = _compute_facial_adjacency_from_vertices (
1266
1270
[grp ], np .int32 , np .int8 , face_vertex_indices_to_tags )
0 commit comments