[petsc-users] RE : RE : PETSc : how to get back d_nnz and o_nnz ?
Jed Brown
jedbrown at mcs.anl.gov
Wed Jul 3 15:47:14 CDT 2013
HOUSSEN Franck <Franck.Houssen at cea.fr> writes:
> I iterate on solving a AX=B system. I can not know in advance the
> maximum non zero values in A (at least, I am not sure to know how to
> do this). So I wanted to try to check if the existing A matrix is OK
> for the new solve to come : if so I keep it as it is, if not so I
> wanted to re-preallocate (increasing the number of non zero value in a
> suitable way).
The problem is that you need to know whether the entries changed, not
just the total number of entries. That is, once you insert values in
one place, those column indices are permanent until your re-allocate.
If your nonzero pattern is changing, then you can call
MatXAIJSetPreallocation (or MatSeqAIJSetPreallocation and
MatMPIAIJSetPreallocation) every time you assemble. Re-allocation will
not be a performance issue, but it requires you to call the function you
have that figures out how many nonzeros per row (it sounds like you are
doing this part anyway).
> "doesn't work" means, even using the CHCKERR marco, I do not get any
> stack in the error traces but just a message saying something like "a
> sig sev error occured" (occuring somewhere but no info about where -
> my install of petsc is a debug one).
Does your code call PetscPushSignalHandler?
> When I commented MatGetRow (that I tried to use instead of MatMPIxxx
> to avoid handling on one hand MPI matrices and on the other hand Seq
> matrices - the code handles both MPI or Seq matrices depending on the
> number of MPI procs), the code does something "wrong" (or say no what
> I want) but it does not crash : so I know the crash is du to the
> MatGetRow call.
You can run in a debugger to see where the crash is. If you called
MatMPIAIJGetSeqAIJ on a SeqAIJ matrix, you would have gotten nonsense
back. But your approach of comparing the number of nonzeros is not
correct unless the nonzero locations are guaranteed to be nested.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130703/835e309f/attachment.pgp>
More information about the petsc-users
mailing list