[petsc-users] vtk format

Matthew Knepley knepley at gmail.com
Mon Dec 16 19:08:42 CST 2013


On Mon, Dec 16, 2013 at 6:33 PM, Arash Mehraban <arashm81 at gmail.com> wrote:

>
> Dear Matt,
>
> I added the following lines of code to ex29.c to get the solution in a vtk
> file format:
>
>    PetscViewer    viewer;
>
>    ierr = PetscViewerCreate(PETSC_COMM_WORLD, &viewer);CHKERRQ(ierr);
>    ierr = PetscViewerSetType(viewer, PETSCVIEWERVTK);CHKERRQ(ierr);
>
>    ierr = PetscViewerFileSetName(viewer, "poisson.vtk");CHKERRQ(ierr);
>    ierr = PetscViewerSetFormat(viewer,
> PETSC_VIEWER_ASCII_VTK);CHKERRQ(ierr);
>    DMDAVTKWriteAll((PetscObject)da, viewer);
>

This is mixing a few things. I think you want binary VTK, so

   ierr = PetscViewerCreate(PETSC_COMM_WORLD, &viewer);CHKERRQ(ierr);
   ierr = PetscViewerSetType(viewer, PETSCVIEWERVTK);CHKERRQ(ierr);
   ierr = PetscViewerFileSetName(viewer, "poisson.vtu");CHKERRQ(ierr);
   ierr = VecView(v);CHKERRQ(ierr);
  ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr);

     Matt


>    ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr);
>
>
> I get errors. I have put a part of the list of errors I get in the
> logfile:
>
> [37]PETSC ERROR: Configure run at Mon Sep  9 15:18:06 2013
> [37]PETSC ERROR: Configure options --with-mpi=1 --download-f-blas-lapack=1
> --with-clanguage=cxx
> [37]PETSC ERROR:
> ------------------------------------------------------------------------
> [37]PETSC ERROR: User provided function() line 0 in unknown directory
> unknown file
> or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory
> corruption errors
> See docs/index.html for manual pages.
> [39]PETSC ERROR:
> ------------------------------------------------------------------------
> [39]PETSC ERROR: ./ex29 on a arch-linux2-cxx-debug named node0310 by
> arme5062 Mon Dec 16 17:20:55 2013
> [39]PETSC ERROR: Libraries linked from
> /projects/arme5062/petsc/arch-linux2-cxx-debug/lib
> [39]PETSC ERROR: Configure run at Mon Sep  9 15:18:06 2013
> [39]PETSC ERROR: Configure options --with-mpi=1 --download-f-blas-lapack=1
> --with-clanguage=cxx
> [39]PETSC ERROR:
> ------------------------------------------------------------------------
> [39]PETSC ERROR: User provided function() line 0 in unknown directory
> unknown file
> Note: The EXACT line numbers in the stack are not available,
> [20]PETSC ERROR:       INSTEAD the line number of the start of the function
> [20]PETSC ERROR:       is given.
> [20]PETSC ERROR: [20] PetscTraceBackErrorHandler line 172
> src/sys/error/errtrace.c
> [20]PETSC ERROR: [20] PetscError line 361 src/sys/error/err.c
> [20]PETSC ERROR: [20] DMDAVTKWriteAll line 249 src/dm/impls/da/grvtk.c
> [20]PETSC ERROR: --------------------- Error Message
> ------------------------------------
> [20]PETSC ERROR: Signal received!
> [20]PETSC ERROR:
> ------------------------------------------------------------------------
> [20]PETSC ERROR: Petsc Release Version 3.4.2, unknown
> [20]PETSC ERROR: See docs/changes/index.html for recent updates.
> [20]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
> [20]PETSC ERROR: See docs/index.html for manual pages.
> [20]PETSC ERROR:
> ------------------------------------------------------------------------
> [20]PETSC ERROR: [40]PETSC ERROR: Configure run at Mon Sep  9 15:18:06 2013
> [40]PETSC ERROR: Configure options --with-mpi=1 --download-f-blas-lapack=1
> --with-clanguage=cxx
> [40]PETSC ERROR:
> ------------------------------------------------------------------------
> [40]PETSC ERROR: User provided function() line 0 in unknown directory
> unknown file
> ./ex29 on a arch-linux2-cxx-debug named node0311 by arme5062 Mon Dec 16
> 17:20:55 2013
> [20]PETSC ERROR: Libraries linked from
> /projects/arme5062/petsc/arch-linux2-cxx-debug/lib
> [20]PETSC ERROR: Configure run at Mon Sep  9 15:18:06 2013
> [20]PETSC ERROR: Configure options --with-mpi=1 --download-f-blas-lapack=1
> --with-clanguage=cxx
> [20]PETSC ERROR:
> ------------------------------------------------------------------------
> [20]PETSC ERROR: User provided function() line 0 in unknown directory
> unknown file
> [46]PETSC ERROR:
> ------------------------------------------------------------------------
> [46]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation,
> probably memory access out of range
> [46]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
> [46]PETSC ERROR: or see
> http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind[46]PETSCERROR: or try
> http://valgrind.org on GNU/linux and Apple Mac OS X to find memory
> corruption errors
> [19]PETSC ERROR: likely location of problem given in stack below
> [19]PETSC ERROR: ---------------------  Stack Frames
> ------------------------------------
> [19]PETSC ERROR: Note: The EXACT line numbers in the stack are not
> available,
> [19]PETSC ERROR:       INSTEAD the line number of the start of the function
> [19]PETSC ERROR:       is given.
> [19]PETSC ERROR: [19] PetscTraceBackErrorHandler line 172
> src/sys/error/errtrace.c
> [19]PETSC ERROR: [19] PetscError line 361 src/sys/error/err.c
> [19]PETSC ERROR: [19] DMDAVTKWriteAll line 249 src/dm/impls/da/grvtk.c
> [19]PETSC ERROR: --------------------- Error Message
> ------------------------------------
> [19]PETSC ERROR: Signal received!
> [19]PETSC ERROR:
> ------------------------------------------------------------------------
> [19]PETSC ERROR: Petsc Release Version 3.4.2, unknown
> [19]PETSC ERROR: See docs/changes/index.html for recent updates.
> [19]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
> [19]PETSC ERROR: See docs/index.html for manual pages.
> [19]PETSC ERROR:
> ------------------------------------------------------------------------
> [19]PETSC ERROR: [42]PETSC ERROR: likely location of problem given in
> stack below
> [42]PETSC ERROR: ---------------------  Stack Frames
> ------------------------------------
> [42]PETSC ERROR: Note: The EXACT line numbers in the stack are not
> available,
> [42]PETSC ERROR:       INSTEAD the line number of the start of the function
> [42]PETSC ERROR:       is given.
> [42]PETSC ERROR: [42] PetscTraceBackErrorHandler line 172
> src/sys/error/errtrace.c
> [42]PETSC ERROR: [42] PetscError line 361 src/sys/error/err.c
> [42]PETSC ERROR: [42] DMDAVTKWriteAll line 249 src/dm/impls/da/grvtk.c
> [42]PETSC ERROR: --------------------- Error Message
> ------------------------------------
> [42]PETSC ERROR: Signal received!
> [42]PETSC ERROR:
> ------------------------------------------------------------------------
> [42]PETSC ERROR: Petsc Release Version 3.4.2, unknown
> [42]PETSC ERROR: See docs/changes/index.html for recent updates.
> [42]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
> [42]PETSC ERROR: See docs/index.html for manual pages.
>
>
>
>
>
> On Mon, Dec 16, 2013 at 1:55 PM, Matthew Knepley <knepley at gmail.com>wrote:
>
>> On Sun, Dec 15, 2013 at 5:47 PM, Arash Mehraban <arashm81 at gmail.com>wrote:
>>
>>> Hi all,
>>>
>>> I was wondering if PETSc could write my (vector) solution into a *vtk*format file?
>>> I think DMDAVTKWriteAll might work, but I couldn't get it to work. For
>>> example, how could I store the solution in ex29.c on
>>> http://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/examples/tutorials/ex29.c.html
>>> into a vtk-format file?
>>>
>>
>> You should be able to use -vec_view ::vtk from the command line or
>> PetscViewerSetType(viewer, PETSCVIEWERVTK) for binary
>> output, and PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_VTK) for
>> text.
>>
>>   Thanks,
>>
>>       Matt
>>
>>
>>> Thanks in advance,
>>>
>>> Arash
>>>
>>
>>
>>
>> --
>> 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
>>
>
>


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


More information about the petsc-users mailing list