<div dir="ltr"><div dir="ltr">On Fri, Oct 4, 2019 at 7:46 PM Faibussowitsch, Jacob <<a href="mailto:jfaibussowitsch@anl.gov">jfaibussowitsch@anl.gov</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">



<div style="word-wrap:break-word">
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_quote">
<div>If you are requesting a Vec from a Plex, then the discretization in its DS determines its size.</div>
</div>
</div>
</blockquote>
<div>What if I have multiple fields on a single DM with varying numComponents per field (although each one has the same quadrature number and dimension I believe)? Does it just make the vec based on field 0?</div></div></blockquote><div><br></div><div>No, the Vec holds everything in the DS.</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"><div style="word-wrap:break-word"><div> I have made a PetscFE,  and used it to set
 each field, then called DMCreateDS on the dm afterwards. </div>
<div><br>
</div>
<div>
<div>Best,</div>
<div><br>
</div>
<div>Jacob</div>
</div>
<div><br>
<blockquote type="cite">
<div>On Oct 4, 2019, at 4:59 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:</div>
<br>
<div>
<div dir="ltr" style="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;text-decoration:none">
<div dir="ltr">On Fri, Oct 4, 2019 at 3:09 PM Faibussowitsch, Jacob <<a href="mailto:jfaibussowitsch@anl.gov" target="_blank">jfaibussowitsch@anl.gov</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">
<div style="word-wrap:break-word">
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_quote">
<div>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>
<div><br>
</div>
<div>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_quote">
<div>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.</div>
</div>
</blockquote>
<div><br>
</div>
<div>If you are requesting a Vec from a Plex, then the discretization in its DS determines its size. You need to</div>
<div><br>
</div>
<div>  make a clone (DMClone) and set a P0 discretization</div>
<div><br>
</div>
<div>This is what I do there.</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">
<div style="word-wrap:break-word">
<div>I omitted the PETSc__rank_ options prefix part when creating the default fe, is that responsible for setting the vec size here?</div>
<div><br>
</div>
<div>
<div>Best,</div>
<div><br>
</div>
<div>Jacob</div>
</div>
<div><br>
<blockquote type="cite">
<div>On Oct 4, 2019, at 9:42 AM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:</div>
<br>
<div>
<div dir="ltr" style="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;text-decoration:none">
<div dir="ltr">On Thu, Oct 3, 2019 at 11:42 AM Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</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">
<div dir="ltr">
<div dir="ltr">On Tue, Oct 1, 2019 at 11:57 AM Faibussowitsch, Jacob via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank">petsc-dev@mcs.anl.gov</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">
Hello All,<br>
<br>
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>
<br>
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>
<br>
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>
<br>
PetscErrorCode        (*PetscViewerVTKWriteFunction) (PetscObject, PetscViewer);<br>
<br>
ierr = PetscViewerCreate(comm=PETSC_COMM_WORLD, &vtkviewer);CHKERRQ(ierr);<br>
ierr = PetscViewerVTKOpen(comm=PETSC_COMM_WORLD, "mesh.vtk", FILE_MODE_WRITE, &vtkviewer);CHKERRQ(ierr);<br>
ierr = PetscViewerSetUp(vtkviewer);CHKERRQ(ierr);<br>
<br>
PetscViewerVTKWriteFunction = (CellNum vtkviewer);                                           <span> </span><br>
ierr = PetscViewerVTKAddField(vtkviewer, (PetscObject) dm, PetscViewerVTKWriteFunction, PETSC_VTK_CELL_FIELD, PETSC_TRUE, CellNum);CHKERRQ(ierr);<br>
ierr = DMPlexVTKWriteAll((PetscObject) dm, vtkviewer);CHKERRQ(ierr);<br>
<br>
Any help would be greatly appreciated!<br>
</blockquote>
<div><br>
</div>
<div>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><br>
</div>
<div>Here is me making a similar field containing the rank instead of the cell number:</div>
<div><br>
</div>
<div>  <a href="https://www.mcs.anl.gov/petsc/petsc-master/docs/manualpages/DMPLEX/DMPlexCreateRankField.html" target="_blank">https://www.mcs.anl.gov/petsc/petsc-master/docs/manualpages/DMPLEX/DMPlexCreateRankField.html</a></div>
<div><br>
</div>
<div>Note that Paraview already knows the cell number and can display it</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">
<div dir="ltr">
<div class="gmail_quote">
<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">
Best,<br>
<br>
Jacob<br>
<br>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
--<span> </span><br>
<div dir="ltr">
<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>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
--<span> </span><br>
<div dir="ltr">
<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></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
--<span> </span><br>
<div dir="ltr">
<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></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>

</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>