-
Notifications
You must be signed in to change notification settings - Fork 167
Closure orientation changes (WIP) #3332
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
base: master
Are you sure you want to change the base?
Conversation
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 think the idea is interesting, and some components might be useful. I think, though, we are to abandon global vertex number based approaches as hex requires something more general.
def orient_mesh(PETSc.DM dm, vertex_numbering): | ||
cdef: | ||
PetscDMPolytopeType ct | ||
PetscInt o, nverts | ||
|
||
pstart, pend = dm.getChart() | ||
for p in range(pstart, pend): | ||
cell_type = dm.getCellType(p) | ||
|
||
# vertices have just a single orientation | ||
if cell_type == PETSc.DM.PolytopeType.POINT: | ||
continue | ||
|
||
ct = cell_type | ||
nverts = DMPolytopeTypeGetNumVertices(ct) | ||
verts = dm.getTransitiveClosure(p)[0][-nverts:] | ||
verts_renum = [vertex_numbering.getOffset(v) for v in verts] | ||
vertex_ordering = _ordering(verts_renum) | ||
o = cell_orientation_from_vertex_arrangement(cell_type, vertex_ordering) | ||
DMPlexOrientPoint(dm.dm, p, o) |
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.
To make this globally consistent, you need to use global section; see
Line 1092 in d282271
vertex_numbering = self._vertex_numbering.createGlobalSection(plex.getPointSF()) |
-(o + 1)
rule.
We decided to order DoFs on each entity relative to the cone of that entity for checkpointing purpose because the ordering of the cone is guaranteed to be preserved in the save-load cycle.
Modifying cones using DMPlexOrientPoint()
based on the global vertex numbers is actually not desired as global vertex numbers are not preserved in the save-load cycle (or upon redistribution of the mesh).
I think we can make the global vertex numbers (and actually all the global entity numbers) preserved upon save/load or redistribution, but it has yet to be done. Even if it has been implemented, I think, we should abandon all approaches based on the global vertex numbers as hex requires a more generic approach anyway.
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.
To make this globally consistent, you need to use global section
Sure. That should be straightforward to add.
global vertex numbers is actually not desired as global vertex numbers are not preserved in the save-load cycle
I didn't realise this. How come checkpointing works currently then? What I have here is a simplification of the prior approach so the same limitations should apply.
I think, we should abandon all approaches based on the global vertex numbers
I disagree with this. I think that we want to have this because it allows us to pack/unpack H(div) and H(curl) spaces without potentially expensive runtime transformations.
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.
Another contribution of this PR that I want to emphasise is that it unifies the code paths for cell_closure
and entity_orientations
. I think we can pretty much rely on the orientations from getTransitiveClosure
for our own work (with a single transformation from canonical plex to canonical FIAT).
Basically PETSc tells us things like "relative to this cell, this edge is flipped". I believe that, subject to a canonical transformation, this is universal information applicable to both DMPlex and FIAT.
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.
We decided to order DoFs on each entity relative to the cone of that entity for checkpointing purpose because the ordering of the cone is guaranteed to be preserved in the save-load cycle.
Modifying cones using DMPlexOrientPoint() based on the global vertex numbers is actually not desired as global vertex numbers are not preserved in the save-load cycle (or upon redistribution of the mesh).
I have thought more on this and this makes a lot of sense. The cones should not be arbitrarily modified upon loading the mesh. However, I still think that my approach has value. Could we introduce perhaps a DMCopy
of the topology just for tabulating the closure, called, say, closure_dm
? The advantage of having such a DM is then we get nicely ordered closures and can preserve the orientable properties of simplices and quads.
I have had a lengthy discussion with @ksagiyam and we have concluded the following:
|
Actually, I/O backward compatibility requires more thoughts. If we load a mesh from an old file, cones will not be ordered in the way you want. If we then reorder the cones using whatever we use to reorder cones, then we will not be able to later load functions onto that mesh as those functions assume old cone orderings. |
Good point. We didn't discuss preserving saved functions when we discussed backwards compatibility. I think what will need to happen is the following:
|
In theory, I think, we could directly fix it, but it might be cumbersome. We should note that:
|
That's fine. We can store some
It's very hard to be sure, but I think that this might be OK and "just work". Once we've done the appropriate permutation I imagine that whatever |
Ideally this will all get ripped out or moved if #3332 goes anywhere. For now I have simply tried to minimise the footprint of the niche reordering code. This has entailed rewriting a fair bit of the algorithm and it is a bit slower since we have to undo some renumbering and this requires Python, not Cython. Tests appear to be passing with segfaulting.
Description
This PR contains a first stab at a big refactor of how we compute cell closures and orientations.
This work was motivated by the fact that we have totally distinct code paths for determining closures and orientations for simplices, quads and hexes. This PR is an attempt to unify them and also to make greater use of DMPlex orientations.
One thing in particular that bothered me was that
entity_orientations
(which contains the orientations of points in the closure relative to some canonical orientation) for simplices and quads was not zero. This doesn't make sense because we cleverly design our closures using the vertex numbering in order to ensure that a canonical ordering is always possible, and hence thatentity_orientations
should always be zero.I have figured out that using
DMPlexOrientPoint
, coupled with a single transformation from plex closure to FIAT closure seems to get the job done. DMPlex does pretty much all the heavy lifting for us in terms of determining orientations so all we have to do is know the transformation from its canonical represent to FIAT's.Thus far I have only done this for triangles (and lines and points). I haven't yet done the work to get other polytopes transforming correctly.
@ksagiyam I would be particularly interested in getting your feedback on this. I may be barking up totally the wrong tree.