[petsc-users] Dump a matrix to a .py file
Matthew Knepley
knepley at gmail.com
Mon Apr 14 09:43:39 CDT 2014
On Mon, Apr 14, 2014 at 9:02 AM, Adriano Côrtes <adrimacortes at gmail.com>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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140414/f049a60b/attachment.html>
More information about the petsc-users
mailing list