<div dir="ltr">Thank you, Matt,<br>as you say, the face orientations do change sign when switching between the two adjacent cells. (I confused my program output. You are right.) But it seems not to be always correct to keep the normal direction for orientation>=0 and invert it for orientation<0:<br><br>I include sample code below to make my question more clear. The program creates a HexBoxMesh split horizontally in two cells (at x=0.5) It produces this output:<br><br>"Face centroids (c) and normals(n):<br>face #008 c=(0.250000 0.000000 0.000000) n=(-0.000000 -0.500000 0.000000)<br>face #009 c=(0.750000 0.000000 0.000000) n=(-0.000000 -0.500000 0.000000)<br>face #010 c=(0.250000 1.000000 0.000000) n=(0.000000 0.500000 0.000000)<br>face #011 c=(0.750000 1.000000 0.000000) n=(0.000000 0.500000 0.000000)<br>face #012 c=(0.000000 0.500000 0.000000) n=(-1.000000 -0.000000 0.000000)<br>face #013 c=(0.500000 0.500000 0.000000) n=(1.000000 0.000000 0.000000)<br>face #014 c=(1.000000 0.500000 0.000000) n=(1.000000 0.000000 0.000000)<br>Cell faces orientations:<br>cell #0, faces:[8 13 10 12] orientations:[0 0 -2 -2]<br>cell #1, faces:[9 14 11 13] orientations:[0 0 -2 -2]"<br><br>Looking at the face normals, all boundary normals point outside (good).<br>The normal of face #013 points outside with respect to the left cell #0, but inside w.r.t. the right cell #1.<br><br>Face 13 is shared between both cells. It has orientation 0 for cell #0, 
but orientation -2 for cell #1 (good).<br>What I don't understand is the orientation 
of face 12 (cell 0) and of face 11 (cell 1). These are negative, which 
would make them point into the cell. Have I done some other stupid mistake?<br><br>Thanks<br>Ingo<br><br>Here is the code:<br><br>static char help[] = "Check face normals orientations.\n\n";<br>#include <petscdmplex.h><br>#undef __FUNCT__<br>#define __FUNCT__ "main"<br><br>int main(int argc, char **argv)<br>{<br>  DM             dm;<br>  PetscErrorCode ierr;<br>  PetscFVCellGeom *cgeom;<br>  PetscFVFaceGeom *fgeom;<br>  Vec cellgeom,facegeom;<br>  int dim=2;<br>  int cells[]={2,1};<br>  int cStart,cEnd,fStart,fEnd;<br>  int coneSize,supportSize;<br>  const int *cone,*coneOrientation;<br><br>  ierr = PetscInitialize(&argc, &argv, NULL, help);CHKERRQ(ierr);<br>  ierr = PetscOptionsGetInt(NULL, NULL, "-dim", &dim, NULL);CHKERRQ(ierr);<br>  ierr = DMPlexCreateHexBoxMesh(PETSC_<wbr>COMM_WORLD, dim, cells,DM_BOUNDARY_NONE,DM_<wbr>BOUNDARY_NONE,DM_BOUNDARY_<wbr>NONE, &dm);CHKERRQ(ierr);<br><br>  ierr = DMPlexComputeGeometryFVM(dm, &cellgeom,&facegeom);CHKERRQ(<wbr>ierr);<br>  ierr = VecGetArray(cellgeom, (PetscScalar**)&cgeom);<wbr>CHKERRQ(ierr);<br>  ierr = VecGetArray(facegeom, (PetscScalar**)&fgeom);<wbr>CHKERRQ(ierr);<br>  ierr = DMPlexGetHeightStratum(dm, 0, &cStart, &cEnd);CHKERRQ(ierr);<br>  ierr = DMPlexGetHeightStratum(dm, 1, &fStart, &fEnd);CHKERRQ(ierr);<br><br>  fprintf(stderr,"Face centroids (c) and normals(n):\n");<br>  for (int f=fStart;f<fEnd;f++){<br>    fprintf(stderr,"face #%03d c=(%03f %03f %03f) n=(%03f %03f %03f)\n",f,<br>      fgeom[f-fStart].centroid[0],<wbr>fgeom[f-fStart].centroid[1],<wbr>fgeom[f-fStart].centroid[2],<br>      fgeom[f-fStart].normal[0],<wbr>fgeom[f-fStart].normal[1],<wbr>fgeom[f-fStart].normal[2]);<br>  }<br><br>  fprintf(stderr,"Cell faces orientations:\n");<br>  for (int c=cStart;c<cEnd;c++){<br>      ierr = DMPlexGetConeSize(dm, c, &coneSize);CHKERRQ(ierr);<br>      ierr = DMPlexGetCone(dm, c, &cone);CHKERRQ(ierr);<br>      ierr = DMPlexGetConeOrientation(dm, c, &coneOrientation);CHKERRQ(<wbr>ierr);<br>      if (dim==2){<br>        if (coneSize!=4){<br>          fprintf(stderr,"Expected coneSize 4, got %d.\n",coneSize);<br>          exit(1);<br>        }<br>        fprintf(stderr,"cell #%d, faces:[%d %d %d %d] orientations:[%d %d %d %d]\n",c,<br>          cone[0],cone[1],cone[2],cone[<wbr>3],<br>          coneOrientation[0],<wbr>coneOrientation[1],<wbr>coneOrientation[2],<wbr>coneOrientation[3]<br>        );<br>      } else if (dim==3){<br>        if (coneSize!=6){<br>          fprintf(stderr,"Expected coneSize 6, got %d.\n",coneSize);<br>          exit(1);<br>        }<br>        fprintf(stderr,"cell #%d, faces:[%d %d %d %d %d %d] orientations:[%d %d %d %d %d %d]\n",c,<br>          cone[0],cone[1],cone[2],cone[<wbr>3],cone[4],cone[5],<br>          coneOrientation[0],<wbr>coneOrientation[1],<wbr>coneOrientation[2],<wbr>coneOrientation[3],<wbr>coneOrientation[4],<wbr>coneOrientation[5]<br>        );<br>      } else {<br>        fprintf(stderr,"Dimension %d not implemented.\n",dim);<br>        exit(1);<br>      }<br>  }<br>  ierr = PetscFinalize();<br>}<br><br><div class="gmail_extra"><br><div class="gmail_quote">2017-04-14 11:00 GMT+02:00 Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-">On Wed, Apr 12, 2017 at 10:52 AM, Ingo Gaertner <span dir="ltr"><<a href="mailto:ingogaertner.tus@gmail.com" target="_blank">ingogaertner.tus@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div>Hello,<br></div>I have problems determining the orientation of the face normals of a DMPlex.<br><br></div>I create a DMPlex, for example with DMPlexCreateHexBoxMesh().<br></div>Next, I get the face normals using DMPlexComputeGeometryFVM(DM dm, Vec *cellgeom, Vec *facegeom). facegeom gives the correct normals, but I don't know how the inside/outside is defined with respect to the adjacant cells?<br></div></div></div></div></div></blockquote><div><br></div></span><div>The normal should be outward, unless the face has orientation < 0.</div><span class="gmail-"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><div></div>Finally, I iterate over all cells. For each cell I iterate over the bounding faces (obtained from DMPlexGetCone) and try to obtain their orientation with respect to the current cell using DMPlexGetConeOrientation(). However, the six integers for the orientation are the same for each cell. I expect them to flip between neighbour cells, because if a face normal is pointing outside for any cell, the same normal is pointing inside for its neighbour. Apparently I have a misunderstanding here.<br></div></div></div></div></blockquote><div><br></div></span><div>I see the orientations changing sign for adjacent cells. Want to send a simple code? You should see this</div><div>for examples. You can run SNES ex12 with -dm_view ::ascii_info_detail to see the change in sign.</div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><span class="gmail-"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div></div>How can I make use of the face normals in facegeom and the orientation values from DMPlexGetConeOrientation() to get the outside face normals for each cell?<br><br></div>Thank you<br></div>Ingo<br></div><div id="gmail-m_-1897645241821352774m_-6432344443275881332DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br> <table style="border-top:1px solid rgb(211,212,222)">
        <tbody><tr>
      <td style="width:55px;padding-top:18px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" style="width: 46px; height: 29px;" height="29" width="46"></a></td>
                <td style="width:470px;padding-top:17px;color:rgb(65,66,78);font-size:13px;font-family:arial,helvetica,sans-serif;line-height:18px">Virenfrei. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" style="color:rgb(68,83,234)" target="_blank">www.avast.com</a>               </td>
        </tr>
</tbody></table>
<a href="#m_-1897645241821352774_m_-6432344443275881332_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div>
</blockquote></span></div><span class="gmail-HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_-1897645241821352774gmail_signature">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>
</font></span></div></div>
</blockquote></div><br></div></div>