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

Matthew Knepley knepley at gmail.com
Thu Oct 31 15:01:40 CDT 2013


On Thu, Oct 31, 2013 at 2:56 PM, Qin Lu <lu_qin_2000 at yahoo.com> wrote:

> Hello,
>
> I have successfully installed a sequential PETSc's linear solver in a
> sequential program. The matrix has been created in CSR format and it was
> passed to  MatCreateSeqAIJWithArrays (instead of using MatSetValues).
>
> Now I want to use a parallel PETSc solver in the same sequential program,
> and use the same CRS matrix mentioned above. I intend to use
> MatCreateMPIAIJWithArrays, since I hope to pass the array direct to PETSc,
> instead of using MatSetValues. There a few questions:
>

There is no preallocation when you do this. However, why do you want to do
this? It is generally a bad idea unless you
have a huge installed codebase that depends on that format.

  Matt


> 1. Is there a sample code for using MatCreateMPIAIJWithArrays?
> 2. There seems to be a subroutine MatDistribute_MPIAIJ, but it is not in
> the PETSc manual. Where can I get the instruction how to use it? It would
> be nice if there is a sample code available.
> 3. Manual says the matrix will be copied by MatCreateMPIAIJWithArrays into
> internal format (while it is not when using MatCreateSeqAIJWithArrays),
> does this mean I have to call MatMPIAIJSetPreallocation first?
> 4. In sample code ex2.c in the manual, both MatMPIAIJSetPreallocation and
> MatSeqAIJSetPreallocation are called to preallocate the matrix A. Is not
> the first subroutine sufficient?
>
> Many thanks for your help.
>
> Regards,
> Qin
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20131031/0ec285e6/attachment.html>


More information about the petsc-users mailing list