[petsc-users] Question on matrix assembly

Barry Smith bsmith at petsc.dev
Sat Aug 22 18:19:51 CDT 2020

  Oh, sorry, it is unusable for MPI AIJ matrixes. We would need a special little additional code for MPIAIJ also to get it to work.

  Since your matrices were so tiny I just assumed their usage was sequential.

  For MPI there would need to be a new 

   MatMPIAIJSetTotalPreallocation(A, PetscInt d, PetscInt o) that would call the new MatSeqAIJSetTotalPreallocation() on each part of the MPI matrix and a new

   MatSetValues_MPIAIJ_xxx() that found for each row the parts you past in for diagonal part and off diagonal part, mapped the indices appropriately and call the MatSetValues() one each for the two submatrices appropriately. This would mean packing the two off diagonal parts in the input row data structure together for the call to MatSetValues() on the off-diagonal part. Kind of annoying; instead one could add support to the special MatSetValues_SeqIAIJ_xxx() function to allow it to be called multiple times for each row so long as the each new part came after the previous in column index.


> On Aug 22, 2020, at 5:47 PM, Sajid Ali <sajidsyed2021 at u.northwestern.edu> wrote:
> Hi Barry, 
> Thanks for creating the new function. I'm somewhat confused as to how I'd use it. Given an MPIAIJ matrix, is one supposed to extract the local SeqAIJ matrix and set the preallocation on each mpi-rank independently followed by MatSetValues (on the MPIAIJ matrix) to fill the rows? Or, does one create SeqAIJ matrices on each rank and then combine them into a parallel MPIAIJ matrix say by using MatCreateMPIMatConcatenateSeqMat?
> I tried the second approach but leaving the "number of local columns" for MatCreateMPIMatConcatenateSeqMat as PETSC_DECIDE causes a crash (when running with 1 mpi rank). Is this the correct approach to take and if yes what does "number of local columns" mean when combining the seqaij matrices ?
> Thank You,
> Sajid Ali | PhD Candidate
> Applied Physics
> Northwestern University
> s-sajid-ali.github.io <http://s-sajid-ali.github.io/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200822/127008c6/attachment.html>

More information about the petsc-users mailing list