Skip to content

Commit

Permalink
add docs for tag_to_group_faces
Browse files Browse the repository at this point in the history
  • Loading branch information
majosm committed Oct 12, 2022
1 parent 2df7116 commit db96dca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
16 changes: 12 additions & 4 deletions meshmode/mesh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1416,13 +1416,21 @@ def vertex_index_map_func(vertices):


def _compute_facial_adjacency_from_vertices(
groups, element_id_dtype, face_id_dtype, tag_to_faces=None
groups: Sequence[MeshElementGroup],
element_id_dtype,
face_id_dtype,
tag_to_group_faces: Optional[Sequence[Mapping[Any, np.ndarray]]] = None
) -> Sequence[Sequence[FacialAdjacencyGroup]]:
"""
:arg tag_to_group_faces: for each group, a mapping from tag to
:class:`numpy.ndarray` of shape ``(2, nfaces)`` containing
the element and face indices of each tagged face in the group.
"""
if not groups:
return []

if tag_to_faces is None:
tag_to_faces = [{} for grp in groups]
if tag_to_group_faces is None:
tag_to_group_faces = [{} for grp in groups]

# Match up adjacent faces according to their vertex indices

Expand Down Expand Up @@ -1503,7 +1511,7 @@ def _compute_facial_adjacency_from_vertices(

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

for tag, tagged_elements_and_faces in tag_to_faces[igrp].items():
for tag, tagged_elements_and_faces in tag_to_group_faces[igrp].items():
face_index_pairs = _find_matching_index_pairs(
tagged_elements_and_faces.T,
np.stack((bdry_elements, bdry_element_faces)))
Expand Down
20 changes: 10 additions & 10 deletions meshmode/mesh/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def get_mesh(self, return_tag_to_elements_map=False):
group_base_elem_nr = 0

tag_to_meshwide_elements = {}
tag_to_faces = []
tag_to_group_faces = []

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

group_base_elem_nr += group.nelements

group_tag_to_faces = {}
tag_to_faces = {}

for tag, tagged_fvis in tag_to_fvis.items():
for fid, ref_fvi in enumerate(group.face_vertex_indices()):
Expand All @@ -285,19 +285,19 @@ def get_mesh(self, return_tag_to_elements_map=False):
np.sort(padded_fvis, axis=1).T)
face_element_indices = face_element_index_pairs[1, :]
if len(face_element_indices) > 0:
elements_and_faces = np.stack(
group_faces = np.stack(
(
face_element_indices,
np.full(face_element_indices.shape, fid)),
axis=-1)
if tag in group_tag_to_faces:
group_tag_to_faces[tag] = np.concatenate((
group_tag_to_faces[tag],
elements_and_faces))
if tag in tag_to_faces:
tag_to_faces[tag] = np.concatenate((
tag_to_faces[tag],
group_faces))
else:
group_tag_to_faces[tag] = elements_and_faces
tag_to_faces[tag] = group_faces

tag_to_faces.append(group_tag_to_faces)
tag_to_group_faces.append(tag_to_faces)

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

mesh = Mesh(
vertices, groups,
Expand Down

0 comments on commit db96dca

Please sign in to comment.