-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change tag/face mapping argument of _compute_facial_adjacency_from_vertices
#352
base: main
Are you sure you want to change the base?
Conversation
…rtices change the structure to something that can be constructed more efficiently
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just added some nitpicks, otherwise this looks good to me!
Any idea of how much faster this is compared to #350?
Co-authored-by: Alex Fikl <[email protected]>
Co-authored-by: Alex Fikl <[email protected]>
8c3430a
to
db96dca
Compare
db96dca
to
65f7f01
Compare
On my laptop, for a mesh with 1.2M elements:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments from an initial scroll.
@@ -1345,6 +1345,29 @@ def _concatenate_face_ids(face_ids_list): | |||
faces=np.concatenate([ids.faces for ids in face_ids_list])) | |||
|
|||
|
|||
def _find_matching_index_pairs_merged(indices): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Describe shape of indices
(and describe the axis along which the return value indexes).
return np.stack((order[match_indices], order[match_indices+1])) | ||
|
||
|
||
def _find_matching_index_pairs(left_indices, right_indices): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Describe shape of left_indices
and right_indices
(and describe the axis along which indiex_pairs
indexes).
meshmode/mesh/__init__.py
Outdated
:class:`numpy.ndarray` of shape ``(2, nfaces)`` containing | ||
the element and face indices of each tagged face in the group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing you mean element indices in tag_to_group_faces[0]
and face indices in tag_to_group_faces[1]
? If so, say so.
""" | ||
Return an array of dimension ``(2, nmatches)`` containing pairs of indices into | ||
*indices* representing entries that are the same. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document the interface consequences of lexsort
being stable that are being used below.
""" | ||
index_pairs = _find_matching_index_pairs_merged( | ||
np.concatenate((left_indices, right_indices), axis=1)) | ||
index_pairs[1, :] -= left_indices.shape[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might it be worthwhile to assert that these are in range (i.e. not drawn into negative)?
meshmode/mesh/__init__.py
Outdated
face_index_pairs = _find_matching_index_pairs( | ||
tagged_elements_and_faces.T, | ||
np.stack((bdry_elements, bdry_element_faces))) | ||
face_indices = face_index_pairs[1, :] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
face_indices = face_index_pairs[1, :] | |
bdry_face_indices = face_index_pairs[1, :] |
meshmode/mesh/__init__.py
Outdated
is_tagged = np.full(len(bdry_elements), False) | ||
|
||
for tag, tagged_elements_and_faces in tag_to_group_faces[igrp].items(): | ||
face_index_pairs = _find_matching_index_pairs( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
face_index_pairs = _find_matching_index_pairs( | |
vol_bdry_index_pairs = _find_matching_index_pairs( |
Return an array containing pairs of indices into *indices* representing entries | ||
that are the same. | ||
|
||
Given an array *indices* of shape ``(N, nindices)`` containing integer-valued |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given an array *indices* of shape ``(N, nindices)`` containing integer-valued | |
Given an array *indices* of shape ``(N, ntuples)`` containing integer-valued |
Returned matches are ordered such that the second element of the pair occurs | ||
after the first in *indices*. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert (result[0] < result[1]).all()
?
(Also improve phrasing here.)
# Indices into left_indices are the same as indices into all_indices, but need | ||
# a conversion for right_indices | ||
index_pairs[1, :] -= left_indices.shape[1] | ||
assert index_pairs[1, :] >= 0 # Sanity check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert index_pairs[1, :] >= 0 # Sanity check | |
assert (index_pairs[1, :] >= 0).all() # Sanity check |
Now accepts a list of dicts (one per mesh group), where each dict maps a tag to a numpy array of element/face indices that belong to that tag. This removes the need to use Python loops over elements when generating and using the tag/face mappings.