Can I use MatSetBlockSize() for MPIAIJ

Ryan Yan vyan2000 at gmail.com
Sat Nov 7 13:57:28 CST 2009


Hi All,
I have a question as follows:

In order to use MatSetValuesBlocked() for a MPIAIJ matrix. I need to call
MatSetBlockSize() when I create the matrix.

so I did the following. Here the blocksize = 5;


Mat *A;
....
  MatCreate(MPI_COMM_WORLD,A);
  MatSetSizes(*A,m*blocksize,n*blocksize,M*blocksize,N*blocksize);
  MatSetType(*A,MATMPIAIJ);
  MatSetBlockSize(*A,blocksize);
  ierr=MatMPIAIJSetPreallocation(*A,0,ourlens_ptws,0,offlens_ptws);
CHKERRQ(ierr);

  ierr = MatAssemblyBegin(*A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
  ierr = MatAssemblyEnd(*A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
  PetscPrintf(PETSC_COMM_WORLD,"the bs BEFORE is %d\n", bs);
  MatGetBlockSize(*A,&bs);

  PetscPrintf(PETSC_COMM_WORLD,"the bs is %d\n", bs);
  PetscPrintf(PETSC_COMM_WORLD,"the blocksize is %d\n", blocksize);
...

The output I get is:

the bs BEFORE is 0
the bs is 1
the blocksize is 5


It seems like the Mat A does not absorb the information blocksize=5 at all.
How should I make the function-call sequence correct, if I want to set a
blocksize for the MPIAIJ.

Thanks for any suggestions in advance,

Yan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20091107/a2343a44/attachment.htm>


More information about the petsc-users mailing list