<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<blockquote type="cite" class="">
<div dir="ltr" class="" style="caret-color: rgb(0, 0, 0);">
<div class="gmail_quote">
<div class="">Note that Paraview already knows the cell number and can display it</div>
</div>
</div>
</blockquote>
Now that would have been useful to know months ago.<br class="">
<div class=""><br class="webkit-block-placeholder">
</div>
<div class="">
<blockquote type="cite" class="">
<div dir="ltr" class="" style="caret-color: rgb(0, 0, 0);">
<div class="gmail_quote">
<div class="">Here is me making a similar field containing the rank instead of the cell number:</div>
</div>
</div>
</blockquote>
Yes I ended up cannibalizing that function and this worked well enough. One thing I noticed however is that it the global vector this creates is of the size of number of cells, but when I create a global vector it is the size of num vertices. I omitted the
 PETSc__rank_ options prefix part when creating the default fe, is that responsible for setting the vec size here?</div>
<div class=""><br class="webkit-block-placeholder">
</div>
<div class="">
<div>Best,</div>
<div><br class="">
</div>
<div>Jacob</div>
</div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Oct 4, 2019, at 9:42 AM, Matthew Knepley <<a href="mailto:knepley@gmail.com" class="">knepley@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<div dir="ltr" class="">On Thu, Oct 3, 2019 at 11:42 AM Matthew Knepley <<a href="mailto:knepley@gmail.com" class="">knepley@gmail.com</a>> wrote:<br class="">
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr" class="">
<div dir="ltr" class="">On Tue, Oct 1, 2019 at 11:57 AM Faibussowitsch, Jacob via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank" class="">petsc-dev@mcs.anl.gov</a>> wrote:<br class="">
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
Hello All,<br class="">
<br class="">
I am plotting an output value from a vecview, and want to show in a separate plot which cells correspond to which values in the vec. I plan to do this by making a field on the cells whose value is the global number of that cell. I have 2 issues with this:<br class="">
<br class="">
1. How do I guarantee that the ordering of the Vec I made corresponds to the DMPlex cell ordering such that Vec(0) corresponds to Cells(0) etc. (I make the Vec separately from the DM since using DMCreateLocalVector makes a vector on the vertices)<br class="">
<br class="">
2. I am trying to use DMPlexVTKWriteAll to make my output, so I am adding my field to the DMPlexVTK using PetscViewerVTKAddField, but I can’t seem to get PetscViewerVTKWriteFunction to work properly, and the man pages don’t link to an example. Here is my code
 for this section:<br class="">
<br class="">
PetscErrorCode        (*PetscViewerVTKWriteFunction) (PetscObject, PetscViewer);<br class="">
<br class="">
ierr = PetscViewerCreate(comm=PETSC_COMM_WORLD, &vtkviewer);CHKERRQ(ierr);<br class="">
ierr = PetscViewerVTKOpen(comm=PETSC_COMM_WORLD, "mesh.vtk", FILE_MODE_WRITE, &vtkviewer);CHKERRQ(ierr);<br class="">
ierr = PetscViewerSetUp(vtkviewer);CHKERRQ(ierr);<br class="">
<br class="">
PetscViewerVTKWriteFunction = (CellNum vtkviewer);                                           <span class="Apple-converted-space"> </span><br class="">
ierr = PetscViewerVTKAddField(vtkviewer, (PetscObject) dm, PetscViewerVTKWriteFunction, PETSC_VTK_CELL_FIELD, PETSC_TRUE, CellNum);CHKERRQ(ierr);<br class="">
ierr = DMPlexVTKWriteAll((PetscObject) dm, vtkviewer);CHKERRQ(ierr);<br class="">
<br class="">
Any help would be greatly appreciated!<br class="">
</blockquote>
<div class=""><br class="">
</div>
<div class="">I think what you want is to make a Section over cells with 1 dof, fill it with the cell number (from a global numbering), and then view that Vec.</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">Here is me making a similar field containing the rank instead of the cell number:</div>
<div class=""><br class="">
</div>
<div class="">  <a href="https://www.mcs.anl.gov/petsc/petsc-master/docs/manualpages/DMPLEX/DMPlexCreateRankField.html" class="">https://www.mcs.anl.gov/petsc/petsc-master/docs/manualpages/DMPLEX/DMPlexCreateRankField.html</a></div>
<div class=""><br class="">
</div>
<div class="">Note that Paraview already knows the cell number and can display it</div>
<div class=""><br class="">
</div>
<div class="">  Thanks,</div>
<div class=""><br class="">
</div>
<div class="">     Matt</div>
<div class=""> </div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr" class="">
<div class="gmail_quote">
<div class="">   Matt</div>
<div class=""> </div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
Best,<br class="">
<br class="">
Jacob<br class="">
<br class="">
</blockquote>
</div>
<br clear="all" class="">
<div class=""><br class="">
</div>
--<span class="Apple-converted-space"> </span><br class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br class="">
-- Norbert Wiener</div>
<div class=""><br class="">
</div>
<div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" class="">https://www.cse.buffalo.edu/~knepley/</a><br class="">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all" class="">
<div class=""><br class="">
</div>
--<span class="Apple-converted-space"> </span><br class="">
<div dir="ltr" class="gmail_signature">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br class="">
-- Norbert Wiener</div>
<div class=""><br class="">
</div>
<div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" class="">https://www.cse.buffalo.edu/~knepley/</a></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</body>
</html>