[petsc-users] Determining the correct Preallocation

Andrew Spott andrew.spott at gmail.com
Mon Oct 22 17:18:15 CDT 2012


I want to preallocate a MPIAIJ matrix correctly, using 

MatMPIAIJSetPreallocation(A, PETSC_NULL, dnnz, PETSC_NULL, onnz);

The problem is that I don't know how many local rows, or where the local columns are until I run said function, but I need to know the number of local rows and local columns so I can determine the correct preallocation.

So how am I supposed to do a proper preallocation?  Is there something I'm missing, or do I just guess and correct?  If I know that my matrix is evenly sparse, should I just assume that it is evenly split up among processors, and go from there?  Or should I "MatSetUp", determine the correct preallocation and then do a MatMPIAIJSetPreallocation?

-Andrew




More information about the petsc-users mailing list