[petsc-users] Customizeing MatSetValuesBlocked(...)

Jed Brown jedbrown at mcs.anl.gov
Wed Aug 8 15:11:09 CDT 2012


On Wed, Aug 8, 2012 at 1:32 PM, Jinquan Zhong <jzhong at scsolutions.com>wrote:

>  Thanks, Jed.****
>
> ** **
>
> So would you prefer to using MatCreateAIJ(…) or
> MatXAIJSetPreallocation(…)?  I am having trouble to fill out the
> parameters.  My local dense matrix is A(LDA, LDB). The global size of
> square matrix is N.  What would be the parameters to use them?
>

You said you want to expand this into a larger sparse matrix, therefore you
need to figure out how that larger matrix will be organized.

I like MatXAIJSetPreallocation() because it works with "blocked" formats,
but keep in mind that "blocked" in PETSc does not mean the same as
"blocked" for dense matrices.


> ****
>
> ** **
>
> I used ****
>
> MatCreateAIJ(PETSC_COMM_WORLD,  LDA,LDB,  N,N,  d_nz, d_nnz,o_nz,o_nnz,
> &A);****
>
> MatXAIJSetPreallocation(PETSC_COMM_WORLD, 1, d_nz, d_nnz,o_nz,o_nnz, &A);*
> ***
>
> ** **
>
> However, I have trouble to figure out the values for *d_nz, d_nnz,o_nz,
> o_nnz* since the local A is a block consisting of several sub-blocks from
> ScaLAPACK.  I think MatCreateAIJ and MatXAIJSetPreallocation both take
> several rows together.
>

If I understand you correctly, ScaLAPACK blocks don't have anything to do
with the sparse matrix structure.


> ****
>
> ** **
>
> Do you think it is still doable to preallocate A using either function?
>

Yes, definitely. Look at examples and/or the users manual for further
explanation of preallocation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120808/3f99accb/attachment.html>


More information about the petsc-users mailing list