[petsc-users] Two Questions about Matrix Preallocation

Barry Smith bsmith at mcs.anl.gov
Wed Dec 14 08:22:33 CST 2011


On Dec 14, 2011, at 2:02 AM, behzad baghapour wrote:

> Dear Developers,
> 
> I am facing with two questions about Block-Sparse Preallocation:
> 
> 1- I set array "nnz[]" and did:
> 
>     MatSetType ( JAC, MATSEQBAIJ );
>     MatSetSizes( JAC, PETSC_DECIDE, PETSC_DECIDE, nt, nt );    
>     MatSeqAIJSetPreallocation( JAC, 0, nnz );
> 
> but when I saw log file with -info -mat_view_info, I found this message:
> 
> [0] MatSetUpPreallocation(): Warning not preallocating matrix storage

   Since you are using BAIJ matrix type you need to also call MatSeqBAIJSetPreallocation()

> 
> What this means? Did I correctly preallocate the matrix?
> 
> 2- I need to test MatSeqBAIJSetPreallocation() too but I little confused with descriptions of the command in man-page:
> 
> what are "nz" and "nnz[]" in this case?
> 
> what about number of blocks per row?

   nz is the maximum number of blocks per row, just like with other matrix formats or you can set nnz[] which for each row is the number of blocks from the diagonal block to the end of the row.  For example with a block size of one the matrix

  1   0  2
   0  3 4
   2  4  5 

would have a nnz[] = 2,2,1

 Barry

> 
> Thanks bothering too much :-)
> BehZad
> 



More information about the petsc-users mailing list