[petsc-users] MatCreateBAIJ, SNES, Preallocation...

Mark Adams mfadams at lbl.gov
Fri May 17 06:16:05 CDT 2019


On Thu, May 16, 2019 at 6:28 PM William Coirier via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> Ok, got it. My misinterpretation was how to fill the d_nnz and o_nnz
> arrays.
>
> Thank you for your help!
>
> Might I make a suggestion related to the documentation? Perhaps I have not
> fully read the page on the MatMPIBAIJSetPreallocation so you can simply
> disregard and I'm ok with that! The documentation has for the d_nnz:
>
> d_nnz   - array containing the number of block nonzeros in the various
> block rows of the in diagonal portion of the local (possibly different for
> each block row) or NULL. If you plan to factor the matrix you must leave
> room for the diagonal entry and set it even if it is zero.
>
> Am I correct in that this array should be of size numRows, where numRows
> is found from  calling MatGetOwnershipRange(J,&iLow,&iHigh) so
> numRows=iHigh-iLow.
>

yes, this interface does not change if you set the block size or not. It is
at the equation level.


>
> I think my error was allocating this only to be numRows/bs since I thought
> it's a block size thing.
>
>
This documentation looks wrong to me, and at least confusing. "number of
block nonzeros" reads wrong to me. We now have:

d_nz- number of block nonzeros per block row in diagonal portion of local
submatrix (same for all local rows)
d_nnz- array containing the number of block nonzeros in the various block
rows of the in diagonal portion of the local (possibly different for each
block row) or NULL. If you plan to factor the matrix you must leave room
for the diagonal entry and set it even if it is zero.
o_nz- number of block nonzeros per block row in the off-diagonal portion of
local submatrix (same for all local rows).
o_nnz- array containing the number of nonzeros in the various block rows of
the off-diagonal portion of the local submatrix (possibly different for
each block row) or NULL.

I can suggest:

d_nz- number of nonzeros per row in diagonal portion of local submatrix
(same for all local rows)
d_nnz- array containing the number of nonzeros in each row of the diagonal
portion of the local matrix (the same for each row within a block) or NULL.
You must have a diagonal entry and set it even if it is zero if you plan to
factor the matrix.
o_nz- number of nonzeros per row in the off-diagonal portion of local
submatrix (same for all local rows).
o_nnz- array containing the number of nonzeros in each row of the
off-diagonal portion of the local submatrix (the same for each row within a
block) or NULL.

I can change this if this is acceptable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190517/0f937174/attachment.html>


More information about the petsc-users mailing list