[petsc-dev] Best Way to Assign Cell Number to VTK Plot in DMPlex

Matthew Knepley knepley at gmail.com
Thu Oct 3 10:42:49 CDT 2019


On Tue, Oct 1, 2019 at 11:57 AM Faibussowitsch, Jacob via petsc-dev <
petsc-dev at 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.

   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/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20191003/496846c2/attachment-0001.html>


More information about the petsc-dev mailing list