[petsc-users] access to matnest block (0,1) ?

Klaij, Christiaan C.Klaij at marin.nl
Thu Feb 2 03:14:37 CST 2012


> How did you create the MatNest? Did you use the same index sets?

This is in short what I did:

  Mat A,subA[4];

  MatCreate(PETSC_COMM_WORLD,&subA[0]);
  MatSetSizes(subA[0],PETSC_DECIDE,PETSC_DECIDE,2*nx*ny,2*nx*ny);
  /* set type, set prefix, set values here */

  MatCreate(PETSC_COMM_WORLD,&subA[1]);
  MatSetSizes(subA[1],PETSC_DECIDE,PETSC_DECIDE,2*nx*ny,nx*ny);
  /* set type, set prefix, set values */

  MatTranspose(subA[1],MAT_INITIAL_MATRIX,&subA[2]);

  MatCreate(PETSC_COMM_WORLD,&subA[3]);
  MatSetSizes(subA[3],PETSC_DECIDE,PETSC_DECIDE,nx*ny,nx*ny);
  /* set type, set prefix, set values */

  MatCreateNest(PETSC_COMM_WORLD,2,PETSC_NULL,2,PETSC_NULL,subA,&A);


> This really can't be right. Modify ex28 to have it print out the index
> sets. If distributed evenly over two procs, we might expect the first index
> set to hold [0..11; 18..29] and the second to hold [12..17; 30..35]. The
> way you are addressing would force a non-contiguous row partition.

The partitioning corresponds to the grid. With the 3x4 grid and 2
procs, I have 6 cells per proc. subA[0] corresponds to two
variables per cell (u and v) so 12 rows on proc0 and 12 on
proc1. SubA[3] has one variable per cell (p) so 6 rows on proc0
and 6 on proc1. I tried to create the matching ISs but something's wrong.
What would be the right way to do it?


dr. ir. Christiaan Klaij
CFD Researcher
Research & Development
E mailto:C.Klaij at marin.nl
T +31 317 49 33 44

MARIN
2, Haagsteeg, P.O. Box 28, 6700 AA Wageningen, The Netherlands
T +31 317 49 39 11, F +31 317 49 32 45, I www.marin.nl



More information about the petsc-users mailing list