Note that Paraview already knows the cell number and can display it
Now that would have been useful to know months ago.

Here is me making a similar field containing the rank instead of the cell 
number:
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?

Best,

Jacob

On Oct 4, 2019, at 9:42 AM, Matthew Knepley 
<knep...@gmail.com<mailto:knep...@gmail.com>> wrote:

On Thu, Oct 3, 2019 at 11:42 AM Matthew Knepley 
<knep...@gmail.com<mailto:knep...@gmail.com>> wrote:
On Tue, Oct 1, 2019 at 11:57 AM Faibussowitsch, Jacob via petsc-dev 
<petsc-dev@mcs.anl.gov<mailto:petsc-dev@mcs.anl.gov>> wrote:
Hello All,

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:

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)

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:

PetscErrorCode        (*PetscViewerVTKWriteFunction) (PetscObject, PetscViewer);

ierr = PetscViewerCreate(comm=PETSC_COMM_WORLD, &vtkviewer);CHKERRQ(ierr);
ierr = PetscViewerVTKOpen(comm=PETSC_COMM_WORLD, "mesh.vtk", FILE_MODE_WRITE, 
&vtkviewer);CHKERRQ(ierr);
ierr = PetscViewerSetUp(vtkviewer);CHKERRQ(ierr);

PetscViewerVTKWriteFunction = (CellNum vtkviewer);
ierr = PetscViewerVTKAddField(vtkviewer, (PetscObject) dm, 
PetscViewerVTKWriteFunction, PETSC_VTK_CELL_FIELD, PETSC_TRUE, 
CellNum);CHKERRQ(ierr);
ierr = DMPlexVTKWriteAll((PetscObject) dm, vtkviewer);CHKERRQ(ierr);

Any help would be greatly appreciated!

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.

Here is me making a similar field containing the rank instead of the cell 
number:

  
https://www.mcs.anl.gov/petsc/petsc-master/docs/manualpages/DMPLEX/DMPlexCreateRankField.html

Note that Paraview already knows the cell number and can display it

  Thanks,

     Matt

   Matt

Best,

Jacob



--
What most experimenters take for granted before they begin their experiments is 
infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>


--
What most experimenters take for granted before they begin their experiments is 
infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>

Reply via email to