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

Jed Brown jedbrown at mcs.anl.gov
Thu Feb 2 08:07:35 CST 2012


On Thu, Feb 2, 2012 at 11:14, Klaij, Christiaan <C.Klaij at marin.nl> wrote:

>  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);
>

I should add a MatNestGetISs() so you can get out the automatically-created
ISs. They will have the structure described below. If you want to work with
the released version, you should create the ISs yourself.


>
>
> > 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?
>

A has a contigous distribution, so the ISs must respect that. Did you try
creating the index sets described above? Please explain "something's wrong".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120202/1485c53e/attachment-0001.htm>


More information about the petsc-users mailing list