[petsc-users] object name overwritten in VecView
Danyang Su
danyang.su at gmail.com
Wed Feb 28 09:07:32 CST 2018
Hi Matt,
Thanks for your suggestion and I will use xmf instead.
Regards,
Danyang
On February 28, 2018 3:58:08 AM PST, Matthew Knepley <knepley at gmail.com> wrote:
>On Wed, Feb 28, 2018 at 12:39 AM, Smith, Barry F. <bsmith at mcs.anl.gov>
>wrote:
>
>>
>> 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).
>>
>
>Danyang,
>
>Barry is right, and the bug can be fixed the way he says. However, this
>points out why VTK is bad format. I think a better choice is
>to use HDF5 and XDMF. For example, in my code now I always use
>
> DMVIewFromOptions(dm, NULL, "-dm_view");
>
>and then later (perhaps several times)
>
> VecViewFromOptions(u, NULL, "-u_vec_view")
> VecViewFromOptions(v, NULL, "-v_vec_view")
>
>and then on the command line
>
> -dm_view hdf5:test.h5 -u_vec_view hdf5:test.h5::append -v_vec_view
>hdf5:test.h5::append
>
>which produces a file
>
> test.h5
>
>Then I run
>
> $PETSC_DIR/bin/petsc_gen_xdmf.py test.h5
>
>which produces another file
>
> test.xmf
>
>This can be loaded by Paraview for visualization.
>
> Thanks,
>
> Matt
>
>
>
>>
>> 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>
>>
>>
>
>
>--
>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.caam.rice.edu/~mk51/>
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180228/adf9111b/attachment-0001.html>
More information about the petsc-users
mailing list