[petsc-users] Clarification on MatMPIBAIJSetPreallocation (d_nnz and o_nnz)

Jed Brown jed at jedbrown.org
Mon Oct 24 11:02:33 CDT 2022


This looks like one block row per process? (BAIJ formats store explicit zeros that appear within nonzero blocks.) You'd use d_nnz[] = {1}, o_nnz[] = {1} on each process.

If each of the dummy numbers there was replaced by a nonzero block (so the diagram would be sketching nonzero 3x3 blocks of an 18x18 matrix), then you'd have bs=3 with:

rank 0:
d_nnz[] = {2,2,1}, o_nnz[] = {1,1,2};
rank 1:
d_nnz[] = {1,1,1}, o_nnz[] = {2,1,1};

Edoardo alinovi <edoardo.alinovi at gmail.com> writes:

> Thank you Jed for the hint.
>
> So just to understand it with an example. Say I have this matrix here,
> which has 4 3x3 blocks
>
> 1 2 0 | 0 5 0 |
> 0 2 3 | 0 0 1 |       <---- Proc 1
> 0 0 1 | 0 2 2 |
> --------|--------|
> 1 2 0 | 0 5 0 |
> 0 2 0 | 0 0 1 |       <---- Proc 2
> 0 0 1 | 0 0 2 |
> -------|---------|
>
> This can be represented as a collection of submatrices like:
> A  B
> C  D
>
> A and D are the diagonal blocks, while B and C are the off-diagonal ones.
> How should I set d_nnz and o_nnz in this case?


More information about the petsc-users mailing list