[petsc-users] petsc4py and numpy

Christian Staudt christian.staudt at ira.uka.de
Tue May 8 12:38:45 CDT 2012


@ Aron Ahmadia:


> Conversion between ndarray
> and PETSc Vecs is practically free, so I would keep them as numpy arrays
> for as long as possible (this is the strategy in pyclaw).

Thanks for the hint. I was wondering whether I should start with a working prototype based on numpy, then do parallelization with PETSc on demand - or start with PETSc wherever matrices and vectors are needed.


> Also, I'm excited by the new opportunities for parallel programming and
> development offered by the IPython parallel programming extensions (
> http://ipython.org/ipython-doc/dev/parallel/index.html), but have not had a
> chance to try them out.  If you get a chance to use them for development,
> please let us know if you find them to be useful.

You're not the first person to mention iPython, so I'll definitely have a look and let you know in case I have used it successfully.


@ Lisandro Dalcin:

> For matrices, it depends on the matrix type. For dense matrices,
> currently petsc4py does not support getting the array. For sparse (aka
> AIJ) matrices, you can use mat.getValuesCSR(), however this will
> involve copies. For the other way, you can use
> PETSc.Mat().createAIJ(size=(nrows,ncols), csr=(ai,aj,aa)).

That's basically what I wanted to know.


ps. Thanks for providing petsc4py. Being able to develop in Python is currently saving me a lot of time and pain (compared to the alternative, C++)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120508/5f9008bd/attachment.htm>


More information about the petsc-users mailing list