@@ -116,52 +116,38 @@ def _filter_mesh_groups(mesh, selected_elements, vertex_id_dtype):
116116 :arg selected_elements: A sorted array of indices of elements to be included in
117117 the filtered groups.
118118 :arg vertex_id_dtype: The vertex index data type.
119- :returns: A tuple ``(new_groups, group_to_new_group, required_vertex_indices)``,
120- where *new_groups* is made up of groups from *groups* with elements not in
121- *selected_elements* removed (Note: empty groups are omitted),
122- *group_to_new_group* maps groups in *groups* to their corresponding location
123- in *new_groups*, and *required_vertex_indices* contains indices of all
124- vertices required for elements belonging to *new_groups*.
119+ :returns: A tuple ``(new_groups, required_vertex_indices)``, where *new_groups*
120+ is made up of groups from *groups* containing only elements from
121+ *selected_elements* (Note: resulting groups may be empty) and
122+ *required_vertex_indices* contains indices of all vertices required for
123+ elements belonging to *new_groups*.
125124 """
126125
127- # {{{ find n_new_groups, group_to_new_group, filtered_group_elements
126+ # {{{ find filtered_group_elements
128127
129128 group_elem_starts = [
130129 np .searchsorted (selected_elements , base_element_nr )
131130 for base_element_nr in mesh .base_element_nrs
132131 ] + [len (selected_elements )]
133132
134- new_group_to_old_group = []
135133 filtered_group_elements = []
136134 for igrp in range (len (mesh .groups )):
137135 start_idx , end_idx = group_elem_starts [igrp :igrp + 2 ]
138- # if end_idx == start_idx:
139- # continue
140136
141- new_group_to_old_group .append (igrp )
142137 filtered_group_elements .append (
143138 selected_elements [start_idx :end_idx ] - mesh .base_element_nrs [igrp ])
144139
145- n_new_groups = len (new_group_to_old_group )
146-
147- group_to_new_group = [None ] * len (mesh .groups )
148- for i_new_grp , i_old_grp in enumerate (new_group_to_old_group ):
149- group_to_new_group [i_old_grp ] = i_new_grp
150-
151140 # }}}
152141
153142 # {{{ filter vertex indices
154143
155144 filtered_vertex_indices = [
156- mesh .groups [i_old_grp ].vertex_indices [
157- filtered_group_elements [i_new_grp ], :]
158- for i_new_grp , i_old_grp in enumerate ( new_group_to_old_group )]
145+ mesh .groups [igrp ].vertex_indices [
146+ filtered_group_elements [igrp ], :]
147+ for igrp in range ( len ( mesh . groups ) )]
159148
160- if n_new_groups > 0 :
161- filtered_vertex_indices_flat = np .concatenate ([indices .ravel () for indices
162- in filtered_vertex_indices ])
163- else :
164- filtered_vertex_indices_flat = np .empty (0 , dtype = vertex_id_dtype )
149+ filtered_vertex_indices_flat = np .concatenate ([indices .ravel () for indices
150+ in filtered_vertex_indices ])
165151
166152 required_vertex_indices , new_vertex_indices_flat = np .unique (
167153 filtered_vertex_indices_flat , return_inverse = True )
@@ -178,14 +164,13 @@ def _filter_mesh_groups(mesh, selected_elements, vertex_id_dtype):
178164
179165 from dataclasses import replace
180166 new_groups = [
181- replace (mesh .groups [i_old_grp ],
182- vertex_indices = new_vertex_indices [i_new_grp ],
183- nodes = mesh .groups [i_old_grp ].nodes [
184- :, filtered_group_elements [i_new_grp ], :].copy (),
167+ replace (grp ,
168+ vertex_indices = new_vertex_indices [igrp ],
169+ nodes = grp .nodes [:, filtered_group_elements [igrp ], :].copy (),
185170 element_nr_base = None , node_nr_base = None )
186- for i_new_grp , i_old_grp in enumerate (new_group_to_old_group )]
171+ for igrp , grp in enumerate (mesh . groups )]
187172
188- return new_groups , group_to_new_group , required_vertex_indices
173+ return new_groups , required_vertex_indices
189174
190175
191176def _get_connected_partitions (
@@ -235,8 +220,7 @@ def _get_connected_partitions(
235220
236221
237222def _create_self_to_self_adjacency_groups (mesh , global_elem_to_part_elem ,
238- self_part_index , self_mesh_groups , global_group_to_self_group ,
239- self_mesh_group_elem_base ):
223+ self_part_index , self_mesh_groups , self_mesh_group_elem_base ):
240224 r"""
241225 Create self-to-self facial adjacency groups for a partitioned mesh.
242226
@@ -248,9 +232,6 @@ def _create_self_to_self_adjacency_groups(mesh, global_elem_to_part_elem,
248232 the range ``[0, num_parts)``.
249233 :arg self_mesh_groups: An array of :class:`~meshmode.mesh.MeshElementGroup`
250234 instances representing the partitioned mesh groups.
251- :arg global_group_to_self_group: An array mapping groups in *mesh* to groups in
252- *self_mesh_groups* (or `None` if the group is not part of the current
253- partition).
254235 :arg self_mesh_group_elem_base: An array containing the starting partition-wide
255236 element index for each group in *self_mesh_groups*.
256237
@@ -261,21 +242,13 @@ def _create_self_to_self_adjacency_groups(mesh, global_elem_to_part_elem,
261242 self_to_self_adjacency_groups = [[] for _ in self_mesh_groups ]
262243
263244 for igrp , facial_adj_list in enumerate (mesh .facial_adjacency_groups ):
264- i_self_grp = global_group_to_self_group [igrp ]
265- if i_self_grp is None :
266- continue
267-
268245 int_grps = [
269246 grp for grp in facial_adj_list
270247 if isinstance (grp , InteriorAdjacencyGroup )]
271248
272249 for facial_adj in int_grps :
273250 jgrp = facial_adj .ineighbor_group
274251
275- j_self_grp = global_group_to_self_group [jgrp ]
276- if j_self_grp is None :
277- continue
278-
279252 elem_base_i = mesh .base_element_nrs [igrp ]
280253 elem_base_j = mesh .base_element_nrs [jgrp ]
281254
@@ -287,8 +260,8 @@ def _create_self_to_self_adjacency_groups(mesh, global_elem_to_part_elem,
287260 adj_indices , = np .where (elements_are_self & neighbors_are_self )
288261
289262 if len (adj_indices ) > 0 :
290- self_elem_base_i = self_mesh_group_elem_base [i_self_grp ]
291- self_elem_base_j = self_mesh_group_elem_base [j_self_grp ]
263+ self_elem_base_i = self_mesh_group_elem_base [igrp ]
264+ self_elem_base_j = self_mesh_group_elem_base [jgrp ]
292265
293266 elements = global_elem_to_part_elem [facial_adj .elements [
294267 adj_indices ] + elem_base_i , 1 ] - self_elem_base_i
@@ -297,10 +270,10 @@ def _create_self_to_self_adjacency_groups(mesh, global_elem_to_part_elem,
297270 adj_indices ] + elem_base_j , 1 ] - self_elem_base_j
298271 neighbor_faces = facial_adj .neighbor_faces [adj_indices ]
299272
300- self_to_self_adjacency_groups [i_self_grp ].append (
273+ self_to_self_adjacency_groups [igrp ].append (
301274 InteriorAdjacencyGroup (
302- igroup = i_self_grp ,
303- ineighbor_group = j_self_grp ,
275+ igroup = igrp ,
276+ ineighbor_group = jgrp ,
304277 elements = elements ,
305278 element_faces = element_faces ,
306279 neighbors = neighbors ,
@@ -312,8 +285,7 @@ def _create_self_to_self_adjacency_groups(mesh, global_elem_to_part_elem,
312285
313286def _create_self_to_other_adjacency_groups (
314287 mesh , part_id_to_part_index , global_elem_to_part_elem , self_part_id ,
315- self_mesh_groups , global_group_to_self_group , self_mesh_group_elem_base ,
316- connected_parts ):
288+ self_mesh_groups , self_mesh_group_elem_base , connected_parts ):
317289 """
318290 Create self-to-other adjacency groups for the partitioned mesh.
319291
@@ -326,9 +298,6 @@ def _create_self_to_other_adjacency_groups(
326298 :arg self_part_id: The identifier of the partition currently being created.
327299 :arg self_mesh_groups: An array of `~meshmode.mesh.MeshElementGroup` instances
328300 representing the partitioned mesh groups.
329- :arg global_group_to_self_group: An array mapping groups in *mesh* to groups in
330- *self_mesh_groups* (or `None` if the group is not part of the current
331- partition).
332301 :arg self_mesh_group_elem_base: An array containing the starting partition-wide
333302 element index for each group in *self_mesh_groups*.
334303 :arg connected_parts: A :class:`set` containing the partitions connected to
@@ -343,10 +312,6 @@ def _create_self_to_other_adjacency_groups(
343312 self_to_other_adj_groups = [[] for _ in self_mesh_groups ]
344313
345314 for igrp , facial_adj_list in enumerate (mesh .facial_adjacency_groups ):
346- i_self_grp = global_group_to_self_group [igrp ]
347- if i_self_grp is None :
348- continue
349-
350315 int_grps = [
351316 grp for grp in facial_adj_list
352317 if isinstance (grp , InteriorAdjacencyGroup )]
@@ -372,7 +337,7 @@ def _create_self_to_other_adjacency_groups(
372337 & (neighbor_part_indices == neighbor_part_index ))
373338
374339 if len (adj_indices ) > 0 :
375- self_elem_base_i = self_mesh_group_elem_base [i_self_grp ]
340+ self_elem_base_i = self_mesh_group_elem_base [igrp ]
376341
377342 elements = global_elem_to_part_elem [facial_adj .elements [
378343 adj_indices ] + elem_base_i , 1 ] - self_elem_base_i
@@ -381,9 +346,9 @@ def _create_self_to_other_adjacency_groups(
381346 global_neighbors [adj_indices ], 1 ]
382347 neighbor_faces = facial_adj .neighbor_faces [adj_indices ]
383348
384- self_to_other_adj_groups [i_self_grp ].append (
349+ self_to_other_adj_groups [igrp ].append (
385350 InterPartitionAdjacencyGroup (
386- igroup = i_self_grp ,
351+ igroup = igrp ,
387352 boundary_tag = BTAG_PARTITION (neighbor_part_id ),
388353 elements = elements ,
389354 element_faces = element_faces ,
@@ -395,7 +360,7 @@ def _create_self_to_other_adjacency_groups(
395360
396361
397362def _create_boundary_groups (mesh , global_elem_to_part_elem , self_part_index ,
398- self_mesh_groups , global_group_to_self_group , self_mesh_group_elem_base ):
363+ self_mesh_groups , self_mesh_group_elem_base ):
399364 """
400365 Create boundary groups for partitioned mesh.
401366
@@ -407,9 +372,6 @@ def _create_boundary_groups(mesh, global_elem_to_part_elem, self_part_index,
407372 the range ``[0, num_parts)``.
408373 :arg self_mesh_groups: An array of `~meshmode.mesh.MeshElementGroup` instances
409374 representing the partitioned mesh groups.
410- :arg global_group_to_self_group: An array mapping groups in *mesh* to groups in
411- *self_mesh_groups* (or `None` if the group is not part of the current
412- partition).
413375 :arg self_mesh_group_elem_base: An array containing the starting partition-wide
414376 element index for each group in *self_mesh_groups*.
415377
@@ -420,10 +382,6 @@ def _create_boundary_groups(mesh, global_elem_to_part_elem, self_part_index,
420382 bdry_adj_groups = [[] for _ in self_mesh_groups ]
421383
422384 for igrp , facial_adj_list in enumerate (mesh .facial_adjacency_groups ):
423- i_self_grp = global_group_to_self_group [igrp ]
424- if i_self_grp is None :
425- continue
426-
427385 bdry_grps = [
428386 grp for grp in facial_adj_list
429387 if isinstance (grp , BoundaryAdjacencyGroup )]
@@ -436,17 +394,17 @@ def _create_boundary_groups(mesh, global_elem_to_part_elem, self_part_index,
436394 == self_part_index )
437395
438396 if len (adj_indices ) > 0 :
439- self_elem_base = self_mesh_group_elem_base [i_self_grp ]
397+ self_elem_base = self_mesh_group_elem_base [igrp ]
440398 elements = global_elem_to_part_elem [bdry_grp .elements [adj_indices ]
441399 + elem_base , 1 ] - self_elem_base
442400 element_faces = bdry_grp .element_faces [adj_indices ]
443401 else :
444402 elements = np .empty (0 , dtype = mesh .element_id_dtype )
445403 element_faces = np .empty (0 , dtype = mesh .face_id_dtype )
446404
447- bdry_adj_groups [i_self_grp ].append (
405+ bdry_adj_groups [igrp ].append (
448406 BoundaryAdjacencyGroup (
449- igroup = i_self_grp ,
407+ igroup = igrp ,
450408 boundary_tag = bdry_grp .boundary_tag ,
451409 elements = elements ,
452410 element_faces = element_faces ))
@@ -481,10 +439,8 @@ def _get_mesh_part(mesh, part_id_to_elements, self_part_id):
481439
482440 # Create new mesh groups that mimic the original mesh's groups but only contain
483441 # the current partition's elements
484- self_mesh_groups , global_group_to_self_group , required_vertex_indices = \
485- _filter_mesh_groups (
486- mesh , part_id_to_elements [self_part_id ],
487- mesh .vertex_id_dtype )
442+ self_mesh_groups , required_vertex_indices = _filter_mesh_groups (
443+ mesh , part_id_to_elements [self_part_id ], mesh .vertex_id_dtype )
488444
489445 self_part_index = part_id_to_part_index [self_part_id ]
490446
@@ -494,8 +450,8 @@ def _get_mesh_part(mesh, part_id_to_elements, self_part_id):
494450
495451 self_mesh_group_elem_base = [0 for _ in self_mesh_groups ]
496452 el_nr = 0
497- for i_self_grp , grp in enumerate (self_mesh_groups ):
498- self_mesh_group_elem_base [i_self_grp ] = el_nr
453+ for igrp , grp in enumerate (self_mesh_groups ):
454+ self_mesh_group_elem_base [igrp ] = el_nr
499455 el_nr += grp .nelements
500456
501457 connected_parts = _get_connected_partitions (
@@ -504,23 +460,22 @@ def _get_mesh_part(mesh, part_id_to_elements, self_part_id):
504460
505461 self_to_self_adj_groups = _create_self_to_self_adjacency_groups (
506462 mesh , global_elem_to_part_elem , self_part_index , self_mesh_groups ,
507- global_group_to_self_group , self_mesh_group_elem_base )
463+ self_mesh_group_elem_base )
508464
509465 self_to_other_adj_groups = _create_self_to_other_adjacency_groups (
510466 mesh , part_id_to_part_index , global_elem_to_part_elem , self_part_id ,
511- self_mesh_groups , global_group_to_self_group ,
512- self_mesh_group_elem_base , connected_parts )
467+ self_mesh_groups , self_mesh_group_elem_base , connected_parts )
513468
514469 boundary_adj_groups = _create_boundary_groups (
515470 mesh , global_elem_to_part_elem , self_part_index , self_mesh_groups ,
516- global_group_to_self_group , self_mesh_group_elem_base )
471+ self_mesh_group_elem_base )
517472
518473 # Combine adjacency groups
519474 self_facial_adj_groups = [
520- self_to_self_adj_groups [i_self_grp ]
521- + self_to_other_adj_groups [i_self_grp ]
522- + boundary_adj_groups [i_self_grp ]
523- for i_self_grp in range (len (self_mesh_groups ))]
475+ self_to_self_adj_groups [igrp ]
476+ + self_to_other_adj_groups [igrp ]
477+ + boundary_adj_groups [igrp ]
478+ for igrp in range (len (self_mesh_groups ))]
524479
525480 from meshmode .mesh import Mesh
526481 self_mesh = Mesh (
0 commit comments