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

Serge Van Criekingen serge.van.criekingen at u-picardie.fr
Fri Jan 9 08:47:56 CST 2015


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)
M.setUp()
PETSc.Sys.syncPrint("rank: ",mpi_rank,"   M.sizes: ",M.sizes)
PETSc.Sys.syncFlush()

Thanks a lot,
Serge





More information about the petsc-users mailing list