<div dir="ltr"><div dir="ltr">On Mon, Mar 8, 2021 at 11:18 AM Nicolas Barral <<a href="mailto:nicolas.barral@math.u-bordeaux.fr">nicolas.barral@math.u-bordeaux.fr</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 08/03/2021 15:55, Matthew Knepley wrote:<br>
> On Mon, Mar 8, 2021 at 4:02 AM Nicolas Barral <br>
> <<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a> <br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>>> wrote:<br>
> <br>
> On 07/03/2021 22:56, Matthew Knepley wrote:<br>
> > On Sun, Mar 7, 2021 at 4:51 PM Nicolas Barral<br>
> > <<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>><br>
> > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>>>> wrote:<br>
> ><br>
> ><br>
> > On 07/03/2021 22:30, Matthew Knepley wrote:<br>
> > > On Sun, Mar 7, 2021 at 4:13 PM Nicolas Barral<br>
> > > <<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>><br>
> > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>>><br>
> > > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>><br>
> > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>>>>> wrote:<br>
> > ><br>
> > > On 07/03/2021 16:54, Matthew Knepley wrote:<br>
> > > > On Sun, Mar 7, 2021 at 8:52 AM Nicolas Barral<br>
> > > > <<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>><br>
> > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>>><br>
> > > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>><br>
> > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>>>><br>
> > > > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>><br>
> > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>>><br>
> > > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>><br>
> > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>>>>>> wrote:<br>
> > > ><br>
> > > > Matt,<br>
> > > ><br>
> > > > Thanks for your answer.<br>
> > > ><br>
> > > > However, DMPlexComputeCellGeometryFVM does not<br>
> compute<br>
> > what I<br>
> > > need<br>
> > > > (normals of height 1 entities). I can't find any<br>
> > function doing<br>
> > > > that, is<br>
> > > > there one ?<br>
> > > ><br>
> > > ><br>
> > > > The normal[] in DMPlexComputeCellGeometryFVM() is<br>
> exactly what<br>
> > > you want.<br>
> > > > What does not look right to you?<br>
> > ><br>
> > ><br>
> > > So it turns out it's not what I want because I need<br>
> > non-normalized<br>
> > > normals. It doesn't seem like I can easily retrieve<br>
> the norm,<br>
> > can I?<br>
> > ><br>
> > ><br>
> > > You just want area-weighted normals I think, which means<br>
> that you<br>
> > just<br>
> > > multiply by the area,<br>
> > > which comes back in the same function.<br>
> > ><br>
> ><br>
> > Ah by the area times 2, of course, my bad.<br>
> > Do you order height-1 elements in a certain way ? I need to<br>
> access the<br>
> > facet (resp. edge) opposite to a vertex in a tet (resp.<br>
> triangle).<br>
> ><br>
> ><br>
> > Yes. Now that I have pretty much settled on it, I will put it in the<br>
> > manual. It is currently here:<br>
> ><br>
> ><br>
> <a href="https://gitlab.com/petsc/petsc/-/blob/main/src/dm/impls/plex/plexinterpolate.c#L56" rel="noreferrer" target="_blank">https://gitlab.com/petsc/petsc/-/blob/main/src/dm/impls/plex/plexinterpolate.c#L56</a><br>
> ><br>
> > All normals are outward facing, but hopefully the ordering in the<br>
> sourse<br>
> > file makes sense.<br>
> <br>
> Thanks Matt, but I'm not sure I understand well. What I do so far is:<br>
> <br>
> ierr = DMPlexGetCone(dm, c, &cone);CHKERRQ(ierr);<br>
> for (i=0; i<dim+1; ++i) {<br>
> f = cone[i];<br>
> ierr = DMPlexComputeCellGeometryFVM(dm, f, &area, NULL,<br>
> &vn[i*dim]);CHKERRQ(ierr);<br>
> if (dim == 3) { area *= 2; }<br>
> for (j=0; j<dim; ++j) { vn[i*dim+j] *= area; }<br>
> <br>
> So in 3D, it seems that:<br>
> (vn[9],vn[10],vn[11]) is the inward normal to the facet opposing vertex0<br>
> (vn[6],vn[7],vn[8]) " " 1<br>
> (vn[3],vn[4],vn[5]) " " 2<br>
> (vn[0],vn[1],vn[2]) " " 3<br>
> <br>
> in 2D:<br>
> (vn[2],vn[3]) is a normal to the edge opposing vertex 0<br>
> (vn[4],vn[5]) " " 1<br>
> (vn[0],vn[1]) " " 2<br>
> Yet in 2D, whether the normals are inward or outward does not seem<br>
> consistent across elements.<br>
> <br>
> What am I wrongly assuming ?<br>
> <br>
> <br>
> Ah, I see the problem. I probably need another function. You can tell <br>
> that not many people use Plex this way yet.<br>
> The logic for what you want is embedded my traversal, but it simple:<br>
> <br>
> ierr = DMPlexGetConeSize(dm, c, &coneSize);CHKERRQ(ierr);<br>
> ierr = DMPlexGetCone(dm, c, &cone);CHKERRQ(ierr);<br>
> ierr = DMPlexGetConeOrientation(dm, c, &ornt);CHKERRQ(ierr);<br>
> for (i=0; i<coneSize; ++i) {<br>
> f = cone[i];<br>
> flip = ornt[i] >= 0 ? 1 : -1;<br>
> ierr = DMPlexComputeCellGeometryFVM(dm, f, &area, NULL, <br>
> &vn[i*dim]);CHKERRQ(ierr);<br>
> if (dim == 3) { area *= 2; }<br>
> for (j=0; j<dim; ++j) { vn[i*dim+j] *= area * flip; }<br>
> I could make a function that returns all normals, properly oriented. It <br>
> would just do this.<br>
<br>
Ah this works now, thanks Matt. Toby is correct, it is ultimately <br>
related to Jacobians, and what I need can be done differently, not sure <br>
it's clearer though.<br>
<br>
Out of curiosity, what is the logic in the facet ordering ?<br></blockquote><div><br></div><div>The order of faces in a cell was somewhat arbitrary. However, I wanted that</div><div><br></div><div> select vertices from closure(cell) = vertices before interpolation of cell</div><div><br></div><div>so the canonical orientation of face should have the vertices such that they give</div><div>me the order of vertices I expect in cell-vertex meshes. This way</div><div><br></div><div> Uninterpolate(Interpolate(dm))</div><div><br></div><div>is idempotent.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Thanks<br>
<br>
-- <br>
Nicolas<br>
<br>
> <br>
> Thanks,<br>
> <br>
> Matt<br>
> <br>
> Thanks,<br>
> <br>
> -- <br>
> Nicolas<br>
> <br>
> ><br>
> > Thanks,<br>
> ><br>
> > Matt<br>
> ><br>
> > Thanks<br>
> ><br>
> > --<br>
> > Nicolas<br>
> ><br>
> ><br>
> > > Thanks,<br>
> > ><br>
> > > Matt<br>
> > ><br>
> > > If not, I'll fallback to computing them by hand for<br>
> now. Is the<br>
> > > following assumption safe or do I have to use<br>
> > DMPlexGetOrientedFace?<br>
> > > > if I call P0P1P2P3 a tet and note x the cross<br>
> product,<br>
> > > > P3P2xP3P1 is the outward normal to face P1P2P3<br>
> > > > P0P2xP0P3 " P0P2P3<br>
> > > > P3P1xP3P0 " P0P1P3<br>
> > > > P0P1xP0P2 " P0P1P2<br>
> > ><br>
> > > Thanks<br>
> > ><br>
> > > --<br>
> > > Nicolas<br>
> > > ><br>
> > > > Thanks,<br>
> > > ><br>
> > > > Matt<br>
> > > ><br>
> > > > So far I've been doing it by hand, and after a<br>
> lot of<br>
> > > experimenting the<br>
> > > > past weeks, it seems that if I call P0P1P2P3 a<br>
> tetrahedron<br>
> > > and note x<br>
> > > > the cross product,<br>
> > > > P3P2xP3P1 is the outward normal to face P1P2P3<br>
> > > > P0P2xP0P3 " P0P2P3<br>
> > > > P3P1xP3P0 " P0P1P3<br>
> > > > P0P1xP0P2 " P0P1P2<br>
> > > > Have I been lucky but can't expect it to be true ?<br>
> > > ><br>
> > > > (Alternatively, there is a link between the normals<br>
> > and the<br>
> > > element<br>
> > > > Jacobian, but I don't know the formula and can <br>
> find them)<br>
> > > ><br>
> > > ><br>
> > > > Thanks,<br>
> > > ><br>
> > > > --<br>
> > > > Nicolas<br>
> > > ><br>
> > > > On 08/02/2021 15:19, Matthew Knepley wrote:<br>
> > > > > On Mon, Feb 8, 2021 at 6:01 AM Nicolas Barral<br>
> > > > > <<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>><br>
> > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>>><br>
> > > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>><br>
> > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>>>><br>
> > > > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>><br>
> > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>>><br>
> > > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>><br>
> > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>>>>><br>
> > > > > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>><br>
> > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>>><br>
> > > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>><br>
> > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>>>><br>
> > > > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>><br>
> > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>>><br>
> > > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>><br>
> > <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a><br>
> <mailto:<a href="mailto:nicolas.barral@math.u-bordeaux.fr" target="_blank">nicolas.barral@math.u-bordeaux.fr</a>>>>>>> wrote:<br>
> > > > ><br>
> > > > > Hi all,<br>
> > > > ><br>
> > > > > Can I make any assumption on the<br>
> orientation of<br>
> > triangular<br>
> > > > facets in a<br>
> > > > > tetrahedral plex ? I need the inward facet<br>
> > normals. Do<br>
> > > I need<br>
> > > > to use<br>
> > > > > DMPlexGetOrientedFace or can I rely on<br>
> either<br>
> > the tet<br>
> > > vertices<br>
> > > > > ordering,<br>
> > > > > or the faces ordering ? Could<br>
> > > DMPlexGetRawFaces_Internal be<br>
> > > > enough ?<br>
> > > > ><br>
> > > > ><br>
> > > > > You can do it by hand, but you have to<br>
> account for<br>
> > the face<br>
> > > > orientation<br>
> > > > > relative to the cell. That is what<br>
> > > > > DMPlexGetOrientedFace() does. I think it<br>
> would be<br>
> > easier<br>
> > > to use the<br>
> > > > > function below.<br>
> > > > ><br>
> > > > > Alternatively, is there a function that<br>
> > computes the<br>
> > > normals<br>
> > > > - without<br>
> > > > > bringing out the big guns ?<br>
> > > > ><br>
> > > > ><br>
> > > > > This will compute the normals<br>
> > > > ><br>
> > > > ><br>
> > > ><br>
> > ><br>
> ><br>
> <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DMPLEX/DMPlexComputeCellGeometryFVM.html" rel="noreferrer" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DMPLEX/DMPlexComputeCellGeometryFVM.html</a><br>
> > > > > Should not be too heavy weight.<br>
> > > > ><br>
> > > > > THanks,<br>
> > > > ><br>
> > > > > Matt<br>
> > > > ><br>
> > > > > Thanks<br>
> > > > ><br>
> > > > > --<br>
> > > > > Nicolas<br>
> > > > ><br>
> > > > ><br>
> > > > ><br>
> > > > > --<br>
> > > > > What most experimenters take for granted before<br>
> > they begin<br>
> > > their<br>
> > > > > experiments is infinitely more interesting<br>
> than any<br>
> > > results to which<br>
> > > > > their experiments lead.<br>
> > > > > -- Norbert Wiener<br>
> > > > ><br>
> > > > > <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
> > > > <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>><br>
> > > ><br>
> > > ><br>
> > > ><br>
> > > > --<br>
> > > > What most experimenters take for granted before<br>
> they begin<br>
> > their<br>
> > > > experiments is infinitely more interesting than any<br>
> > results to which<br>
> > > > their experiments lead.<br>
> > > > -- Norbert Wiener<br>
> > > ><br>
> > > > <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
> > > <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>><br>
> > ><br>
> > ><br>
> > ><br>
> > > --<br>
> > > What most experimenters take for granted before they begin<br>
> their<br>
> > > experiments is infinitely more interesting than any<br>
> results to which<br>
> > > their experiments lead.<br>
> > > -- Norbert Wiener<br>
> > ><br>
> > > <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
> > <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>><br>
> ><br>
> ><br>
> ><br>
> > --<br>
> > What most experimenters take for granted before they begin their<br>
> > experiments is infinitely more interesting than any results to which<br>
> > their experiments lead.<br>
> > -- Norbert Wiener<br>
> ><br>
> > <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
> <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>><br>
> <br>
> <br>
> <br>
> -- <br>
> What most experimenters take for granted before they begin their <br>
> experiments is infinitely more interesting than any results to which <br>
> their experiments lead.<br>
> -- Norbert Wiener<br>
> <br>
> <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a> <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>