← Back to team overview

dolfin team mailing list archive

bug with preallocation in petsc matrix (set from command line)

 

In PETScMatrix::init(uint M, uint N, const uint* nz), you see the following:

    MatCreate(PETSC_COMM_SELF, &A);
    MatSetSizes(A,  PETSC_DECIDE,  PETSC_DECIDE, M, N);
    setType();
    MatSeqAIJSetPreallocation(A, PETSC_DEFAULT, (int*)nz);
    MatSetFromOptions(A);
    MatSetOption(A, MAT_KEEP_ZEROED_ROWS,PETSC_TRUE);
    MatZeroEntries(A);


Since MatSetFromOptions follows MatSeqAIJSetPreallocation, when I have tried
to use a different mat_type from the petsc command line arguments the
preallocation data is getting thrown away.  If we switch the order of these
two calls, it works fine if I use a matrix derived from SeqAIJ.  Is there a
reason these calls are this way and if not we might consider switching them.
 I have just tested this a small amount now so there might be some lurking
issue under the hood, but I thought I might bring it up.

Andy

Follow ups