[petsc-users] Use parallel PETSc linear solver in a sequential program

Qin Lu lu_qin_2000 at yahoo.com
Thu Oct 31 15:56:22 CDT 2013

What about MatCreateSeqAIJWithArrays? Is it also implemented by looping over
the rows calling MatSetValues?
My CRS matrix is constructed in the master processor when using a parallel solver. Do I have to manually partition it (using metis, for instance) and distribute it to all processors using MPI, or PETSc has any subroutines to do this job?

On Thursday, October 31, 2013 3:50 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
Qin Lu <lu_qin_2000 at yahoo.com> writes:

> Jed,   Thanks a lot for your nice suggestions. The CRS matrix has
> already been created by the program and I don't want to change that,
> do you mean I should read the arrays (i, j, a) and set coefficients
> row by row using MatSetValues? Will it be much slower than passing the
> arrays directly to MatCreateSeqAIJWithArrays or
> MatCreateMPIAIJWithArrays, especially when the matrix is big?

Are your *parallel* matrices already assembled in that form (which is
not suitable to compute with)?

In any case, MatCreateMPIAIJWithArrays is *implemented* by looping over
the rows calling MatSetValues.  The best is to generate the matrix by
row or element and insert at that time, but that is mostly for memory
reasons.  Copying the entries by row is not that expensive.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20131031/c0ba1eeb/attachment.html>

More information about the petsc-users mailing list