Skip to content

Add mesh boundary gluing (post facial-adjacency overhaul) - #253

Merged
inducer merged 23 commits into
inducer:mainfrom
majosm:mesh-boundary-gluing-post-adj-overhaul
Oct 20, 2021
Merged

Add mesh boundary gluing (post facial-adjacency overhaul)#253
inducer merged 23 commits into
inducer:mainfrom
majosm:mesh-boundary-gluing-post-adj-overhaul

Conversation

@majosm

@majosm majosm commented Aug 9, 2021

Copy link
Copy Markdown
Collaborator

Possibly supersedes #204, pending review/merge of the changes from #252.

@majosm
majosm force-pushed the mesh-boundary-gluing-post-adj-overhaul branch 2 times, most recently from d060ad9 to 0511de1 Compare August 9, 2021 22:17
@majosm
majosm force-pushed the mesh-boundary-gluing-post-adj-overhaul branch from 0511de1 to f556ec5 Compare September 21, 2021 21:49
@majosm
majosm force-pushed the mesh-boundary-gluing-post-adj-overhaul branch from f556ec5 to 6ae6b0e Compare September 23, 2021 14:24
@majosm
majosm force-pushed the mesh-boundary-gluing-post-adj-overhaul branch from 6ae6b0e to b18b5a7 Compare September 23, 2021 14:27
Comment thread meshmode/mesh/processing.py Outdated
@majosm
majosm marked this pull request as ready for review September 24, 2021 20:27
@majosm
majosm requested a review from inducer September 24, 2021 20:27
@majosm

majosm commented Sep 24, 2021

Copy link
Copy Markdown
Collaborator Author

I think this is ready for a look (apart from the one TODO I mentioned above).

@inducer inducer left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This looks super clean. I like it a lot. Here's some initial progress on reviewing this.

Comment thread meshmode/mesh/generation.py Outdated
Comment thread meshmode/mesh/generation.py Outdated
Comment thread meshmode/mesh/processing.py Outdated
Comment thread meshmode/mesh/processing.py
Comment thread meshmode/mesh/processing.py Outdated
transformation (though the vertex ordering need not be the same).

:arg glued_boundary_mappings: a :class:`list` of tuples
*(btag_m, btag_n, aff_map, tol)* which each specify a mapping between two

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think four is big enough to warrant a dataclass. What do you think?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up just grouping the first 3 arguments and leaving the tolerance separate. (4664575)

Comment thread meshmode/mesh/processing.py Outdated
glued_boundary_mappings = []
for btag_m, btag_n, aff_map, tol in partial_glued_boundary_mappings:
glued_boundary_mappings.append((btag_m, btag_n, aff_map, tol))
if (btag_n, btag_m) not in partial_btag_pairs:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this case be banned?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually went the other direction and banned passing both. I like the convenience of just passing one mapping; the code can figure out the inverse.

Comment thread meshmode/mesh/processing.py Outdated
Comment on lines +897 to +898
# FIXME: This tree-based approach is probably slow; see if there's a way to do
# something like this using numpy constructs

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could check how slow the O(N^2) think with numpy is and where the cross-over point with the tree is. A somewhat numpy-ish process to do this is here:

dist_vecs = (ibatch.result_unit_nodes.reshape(dim, -1, 1)
- from_grp.unit_nodes.reshape(dim, 1, -1))
dists = la.norm(dist_vecs, axis=0, ord=2)
result = np.zeros(ntgt_nodes, dtype=self.to_discr.mesh.element_id_dtype)
for irow in range(ntgt_nodes):
close_indices, = np.where(dists[irow] < tol)
if len(close_indices) != 1:
return None
close_index, = close_indices
result[irow] = close_index

Note that there's a Python loop left still.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the numpy version. (06565f4) On my laptop the numpy version is faster when the number of boundary vertices is less than 10k or so.

majosm and others added 2 commits October 4, 2021 13:37
Comment thread meshmode/mesh/processing.py Outdated
Comment thread meshmode/mesh/processing.py Outdated
Comment thread meshmode/mesh/processing.py Outdated
is the tolerance allowed between the vertex coordinates of *btag_n* and the
transformed vertex coordinates of *btag_m* when attempting to match the two.
"""
glued_boundary_mappings = _complete_glued_boundary_mappings(

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way it's currently structured, I think this calls _match_boundary_faces twice for each input "mapping pair". (Once for a->b and once for b->a.) Eliminate or add a comment to justify.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. (2ddc9ec)

Comment thread meshmode/mesh/processing.py Outdated
Comment thread test/test_meshmode.py
h = 1/mesh_par
else:
mesh = mgen.generate_annular_cylinder_slice_mesh(
mesh_par, (1, 2, 3), 0.5, 1, periodic=True)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f is not periodic on that mesh though?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out it is, just because the mesh is symmetric about the x-axis and so is f.

@majosm
majosm force-pushed the mesh-boundary-gluing-post-adj-overhaul branch from 02a995c to 7252fee Compare October 4, 2021 21:54
@inducer

inducer commented Oct 4, 2021

Copy link
Copy Markdown
Owner

Unsubscribing... @-mention or request review once it's ready for a look or needs attention.

@majosm
majosm force-pushed the mesh-boundary-gluing-post-adj-overhaul branch from 7252fee to a75aa7c Compare October 7, 2021 21:34
@majosm
majosm force-pushed the mesh-boundary-gluing-post-adj-overhaul branch from a75aa7c to 06565f4 Compare October 8, 2021 20:47
@majosm
majosm requested a review from inducer October 8, 2021 21:39

@inducer inducer left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! I'll apply the one suggestion.

Comment thread meshmode/mesh/processing.py Outdated
@inducer
inducer enabled auto-merge (rebase) October 20, 2021 17:27
auto-merge was automatically disabled October 20, 2021 18:20

Rebase failed

@inducer

inducer commented Oct 20, 2021

Copy link
Copy Markdown
Owner

@majosm Would you like to manually rebase or are you OK with me squashing this?

@majosm

majosm commented Oct 20, 2021

Copy link
Copy Markdown
Collaborator Author

@majosm Would you like to manually rebase or are you OK with me squashing this?

Looks OK to squash I think.

@inducer
inducer merged commit 9898f3c into inducer:main Oct 20, 2021
@inducer

inducer commented Oct 20, 2021

Copy link
Copy Markdown
Owner

Sounds good. In it goes! Thanks again for your work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants