Skip to content

Commit 65f7f01

Browse files
committed
add docs for tag_to_group_faces
1 parent 2df7116 commit 65f7f01

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

meshmode/mesh/__init__.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from abc import ABC, abstractmethod
2424
from dataclasses import dataclass, replace, field
25-
from typing import Any, ClassVar, Hashable, Optional, Tuple, Type, Sequence
25+
from typing import Any, ClassVar, Hashable, Optional, Tuple, Type, Sequence, Mapping
2626

2727
import numpy as np
2828
import numpy.linalg as la
@@ -1416,13 +1416,21 @@ def vertex_index_map_func(vertices):
14161416

14171417

14181418
def _compute_facial_adjacency_from_vertices(
1419-
groups, element_id_dtype, face_id_dtype, tag_to_faces=None
1419+
groups: Sequence[MeshElementGroup],
1420+
element_id_dtype,
1421+
face_id_dtype,
1422+
tag_to_group_faces: Optional[Sequence[Mapping[Any, np.ndarray]]] = None
14201423
) -> Sequence[Sequence[FacialAdjacencyGroup]]:
1424+
"""
1425+
:arg tag_to_group_faces: for each group, a mapping from tag to
1426+
:class:`numpy.ndarray` of shape ``(2, nfaces)`` containing
1427+
the element and face indices of each tagged face in the group.
1428+
"""
14211429
if not groups:
14221430
return []
14231431

1424-
if tag_to_faces is None:
1425-
tag_to_faces = [{} for grp in groups]
1432+
if tag_to_group_faces is None:
1433+
tag_to_group_faces = [{} for grp in groups]
14261434

14271435
# Match up adjacent faces according to their vertex indices
14281436

@@ -1503,7 +1511,7 @@ def _compute_facial_adjacency_from_vertices(
15031511

15041512
is_tagged = np.full(len(bdry_elements), False)
15051513

1506-
for tag, tagged_elements_and_faces in tag_to_faces[igrp].items():
1514+
for tag, tagged_elements_and_faces in tag_to_group_faces[igrp].items():
15071515
face_index_pairs = _find_matching_index_pairs(
15081516
tagged_elements_and_faces.T,
15091517
np.stack((bdry_elements, bdry_element_faces)))

meshmode/mesh/io.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def get_mesh(self, return_tag_to_elements_map=False):
187187
group_base_elem_nr = 0
188188

189189
tag_to_meshwide_elements = {}
190-
tag_to_faces = []
190+
tag_to_group_faces = []
191191

192192
for group_el_type, ngroup_elements in el_type_hist.items():
193193
if group_el_type.dimensions != mesh_bulk_dim:
@@ -267,7 +267,7 @@ def get_mesh(self, return_tag_to_elements_map=False):
267267

268268
group_base_elem_nr += group.nelements
269269

270-
group_tag_to_faces = {}
270+
tag_to_faces = {}
271271

272272
for tag, tagged_fvis in tag_to_fvis.items():
273273
for fid, ref_fvi in enumerate(group.face_vertex_indices()):
@@ -285,19 +285,19 @@ def get_mesh(self, return_tag_to_elements_map=False):
285285
np.sort(padded_fvis, axis=1).T)
286286
face_element_indices = face_element_index_pairs[1, :]
287287
if len(face_element_indices) > 0:
288-
elements_and_faces = np.stack(
288+
group_faces = np.stack(
289289
(
290290
face_element_indices,
291291
np.full(face_element_indices.shape, fid)),
292292
axis=-1)
293-
if tag in group_tag_to_faces:
294-
group_tag_to_faces[tag] = np.concatenate((
295-
group_tag_to_faces[tag],
296-
elements_and_faces))
293+
if tag in tag_to_faces:
294+
tag_to_faces[tag] = np.concatenate((
295+
tag_to_faces[tag],
296+
group_faces))
297297
else:
298-
group_tag_to_faces[tag] = elements_and_faces
298+
tag_to_faces[tag] = group_faces
299299

300-
tag_to_faces.append(group_tag_to_faces)
300+
tag_to_group_faces.append(tag_to_faces)
301301

302302
for tag in tag_to_meshwide_elements.keys():
303303
tag_to_meshwide_elements[tag] = np.array(
@@ -314,7 +314,7 @@ def get_mesh(self, return_tag_to_elements_map=False):
314314
if is_conforming and self.tags:
315315
from meshmode.mesh import _compute_facial_adjacency_from_vertices
316316
facial_adjacency_groups = _compute_facial_adjacency_from_vertices(
317-
groups, np.int32, np.int8, tag_to_faces)
317+
groups, np.int32, np.int8, tag_to_group_faces)
318318

319319
mesh = Mesh(
320320
vertices, groups,

0 commit comments

Comments
 (0)