[petsc-users] petsc4py: Mat().setSizes()

Matthew Knepley knepley at gmail.com
Fri Jan 9 12:26:02 CST 2015


On Fri, Jan 9, 2015 at 8:47 AM, Serge Van Criekingen <
serge.van.criekingen at u-picardie.fr> wrote:

> Hi,
>
> Using petsc4py, I wish to control the distribution of matrix rows/columns
> among the processors.
> I found out how to do this for vectors in the archives:
> https://lists.mcs.anl.gov/mailman/htdig/petsc-users/
> 2013-February/016358.html
> But how can I do this with matrices? In other words, how is the
> "MatSetSizes" PETSc routine interfaced in petsc4py?
>
> To take an example, how can I specify the local number of rows/columns
> when running this minimal code in parallel:
>
> mpi_rank = PETSc.COMM_WORLD.getRank()
> M = PETSc.Mat().create(comm=PETSc.COMM_WORLD)
> M.setType('aij')
> M.setSizes((8,8),bsize=1)
>

For example

  M.setSizes(((locSize, PETSC_DETERMINE), (locSize, PETSC_DETERMINE)),
bsize=1)

  Thanks,

    Matt


> M.setUp()
> PETSc.Sys.syncPrint("rank: ",mpi_rank,"   M.sizes: ",M.sizes)
> PETSc.Sys.syncFlush()
>
> Thanks a lot,
> Serge
>
>
>
>


-- 
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/20150109/fcb2e210/attachment.html>


More information about the petsc-users mailing list