[petsc-users] object name overwritten in VecView
Smith, Barry F.
bsmith at mcs.anl.gov
Tue Feb 27 23:39:19 CST 2018
Matt,
I have confirmed this is reproducible and a bug. The problem arises because
frame #0: 0x000000010140625a libpetsc.3.8.dylib`PetscViewerVTKAddField_VTK(viewer=0x00007fe66760c750, dm=0x00007fe668810820, PetscViewerVTKWriteFunction=(libpetsc.3.8.dylib`DMPlexVTKWriteAll at plexvtk.c:633), fieldtype=PETSC_VTK_POINT_FIELD, vec=0x00007fe66880ee20) at vtkv.c:140
frame #1: 0x0000000101404e6e libpetsc.3.8.dylib`PetscViewerVTKAddField(viewer=0x00007fe66760c750, dm=0x00007fe668810820, PetscViewerVTKWriteFunction=(libpetsc.3.8.dylib`DMPlexVTKWriteAll at plexvtk.c:633), fieldtype=PETSC_VTK_POINT_FIELD, vec=0x00007fe66880ee20) at vtkv.c:46
frame #2: 0x0000000101e0b7c3 libpetsc.3.8.dylib`VecView_Plex_Local(v=0x00007fe66880ee20, viewer=0x00007fe66760c750) at plex.c:301
frame #3: 0x0000000101e0ead7 libpetsc.3.8.dylib`VecView_Plex(v=0x00007fe66880e820, viewer=0x00007fe66760c750) at plex.c:348
keeps a linked list of vectors that are to be viewed and the vectors are the same Vec because they are obtained with DMGetLocalVector().
The safest fix is to have PetscViewerVTKAddField_VTK() do a VecDuplicate() on the vector passed in and store that in the linked list instead of just storing a pointer to the passed in vector (which might and can be overwritten before all the linked vectors are actually stored).
Barry
> On Feb 27, 2018, at 10:44 PM, Danyang Su <danyang.su at gmail.com> wrote:
>
> Hi All,
>
> How to set different object names when using multiple VecView? I try to use PetscObjectSetName with multiple output, but the object name is overwritten by the last one.
>
> As shown below, as well as the enclosed files as example, the vector name in sol.vtk is vec_v for both vector u and v.
>
> call PetscViewerCreate(PETSC_COMM_WORLD, viewer, ierr);CHKERRA(ierr)
> call PetscViewerSetType(viewer, PETSCVIEWERVTK, ierr);CHKERRA(ierr)
> call PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_VTK, ierr);CHKERRA(ierr)
> call PetscViewerFileSetName(viewer, 'sol.vtk', ierr);CHKERRA(ierr)
>
> call PetscObjectSetName(u, 'vec_u', ierr);CHKERRA(ierr)
> call VecView(u, viewer, ierr);CHKERRA(ierr)
>
> call PetscObjectSetName(v, 'vec_v', ierr);CHKERRA(ierr)
> call VecView(v, viewer, ierr);CHKERRA(ierr)
>
> call PetscViewerDestroy(viewer, ierr);CHKERRA(ierr)
>
> call DMRestoreGlobalVector(dm, u, ierr);CHKERRA(ierr)
> call DMRestoreGlobalVector(dm, v, ierr);CHKERRA(ierr)
>
> Thanks,
>
> Danyang
>
> <ex1f90.F90><makefile.txt><sol.vtk>
More information about the petsc-users
mailing list