[petsc-dev] Best Way to Assign Cell Number to VTK Plot in DMPlex
Faibussowitsch, Jacob
jfaibussowitsch at anl.gov
Tue Oct 1 10:57:51 CDT 2019
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!
Best,
Jacob
More information about the petsc-dev
mailing list