On Mon, Apr 14, 2014 at 9:02 AM, Adriano Côrtes <[email protected]>wrote:

> Dear all,
>
> I'm on a debugging process, and I'd like to know if there is a way of
> using PetscViewer to dump Mat and Vec objects to a .py file, to be
> load and manipulated with numpy/scipy to inspect some properties.
>

break in the debugger:

(gdb) call MatView(M, PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD))

which writes the 'binaryoutput' file. Then in Python make sure you have
$PETSC_DIR/bin/pythonscripts in your PYTHONPATH, and

  >>> import PetscBinaryIO
  >>> io = PetscBinaryIO.PetscBinaryIO()
  >>> objects = io.readBinaryFile('file.dat')

I just tested this and it worked for me.

   Matt


> Many thanks in advance.
> Adriano.
>
> --
> Adriano Côrtes
> =================================================
> Post-doctoral fellow
> Center for Numerical Porous Media
> King Abdullah University of Science and Technology (KAUST)
>



-- 
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

Reply via email to