[petsc-users] A qustion of PETSc

Matthew Knepley knepley at gmail.com
Sat May 26 07:17:42 CDT 2012


Use -ksp_type preonly -pc_type lu.

   Matt

On Sat, May 26, 2012 at 8:04 AM, w_ang_temp <w_ang_temp at 163.com> wrote:

> Besides,I test several situations.
> When process=1(mpiexec -n 1),the results are right,compared with the true
> results.
> When process=2 or 5,both of the results are same.And from the tenth loop,
> it begins the strange error Ax!=b.
> When process=3 or 4,both of the results are same.And from the first
> loop,it begins the error.
> Thanks.
>
>
> >At 2012-05-26 15:01:28,w_ang_temp <w_ang_temp at 163.com> wrote:
>
>  >Hello, Matt
> >   First,thanks for your help, and I have a new recognition of MPI. As
> you said(only part of a Vec is stored on each MPI process),I use
> >MPI_Send,MPI_Recv and MPI_Bcast to deal with it and get some right results.
> >   However,I have not yet fully solved this problem.The number of loops
> of the subroutine named PETSCSOLVE to solve Ax=b with PETSc is 20 >times.I
> print the results of each loop and find that the front 9 times are right.
> In the 10 time,there is a strange error: plug the result x into the
> >equation I find that Ax!=b.
> >   The code and the A,x,b are shown below.So can you give me some hints?
> Thank you very much!
> >                                                        Jim
> >   (1)code
> >      call MatView(A,PETSC_VIEWER_STDOUT_WORLD,ierr)
> >      call VecView(b,PETSC_VIEWER_STDOUT_WORLD,ierr)
> >      call KSPSolve(ksp,b,x,ierr)
> >      call VecView(x,PETSC_VIEWER_STDOUT_WORLD,ierr)
> >   (2)Ax=b
> >  A:
> >  type: mpiaij
> > row 0: (0, 1)  (1, 0)  (2, 0)  (3, 0)  (4, 0)  (5, 0)  (6, 0)  (7, 0)
> (8, 0)
> > row 1: (0, 0)  (1, 1)  (2, 0)  (3, 0)  (4, 0)  (5, 0)  (6, 0)  (7, 0)
> (8, 0)
> > row 2: (0, 0)  (1, 0)  (2, -2e-06)  (3, -50)  (4, 0)  (5, 0)  (6, 0)
> (7, -50)  (8, 0)
> > row 3: (0, 0)  (1, 0)  (2, -50)  (3, 1.36265e+07)  (4, 0)  (5, 0)  (6,
> 0)  (7, 1.23877e+06)  (8, 0)
> > row 4: (0, 0)  (1, 0)  (2, 0)  (3, 0)  (4, 1)  (5, 0)  (6, 0)  (7, 0)
> (8, 0)
> > row 5: (0, 0)  (1, 0)  (2, 0)  (3, 0)  (4, 0)  (5, 1)  (6, 0)  (7, 0)
> (8, 0)
> > row 6: (0, 0)  (1, 0)  (2, 0)  (3, 0)  (4, 0)  (5, 0)  (6, 1)  (7, 0)
> (8, 0)
> > row 7: (0, 0)  (1, 0)  (2, -50)  (3, 1.23877e+06)  (4, 0)  (5, 0)  (6,
> 0)  (7, 1.36265e+07)  (8, 0)
> > row 8: (0, 0)  (1, 0)  (2, 0)  (3, 0)  (4, 0)  (5, 0)  (6, 0)  (7, 0)
> (8, 1)
> >  b:
> >  type: mpi
> > Process [0]
> > 0
> > 0
> > -0.75
> > 96949.5
> > 0
> > Process [1]
> > 0
> > -0.015
> > 96949.5
> > -0.015
>  > x:
>   >type: mpi
>  >Process [0]
> > 0
> > 0
> > 1167.84
> > 0.00819383
>  >0
>  >Process [1]
>  >0
> > -0.00824055
> > 0.00390865
> > -0.00824055
>
>
>
> >在 2012-05-22 19:33:10,"Matthew Knepley" <knepley at gmail.com> 写道:
>
> >On Tue, May 22, 2012 at 5:17 AM, w_ang_temp <w_ang_temp at 163.com> wrote:
>
>>  >Hello
>>  >    I am a beginner of PETSc.I find the petsc-users lists is very
>> useful, however I do not know how to ask a question in it. So can you tell
>> me? >And below is what I want to ask.
>>  >   I am solving Ax=b with PETSc. And I only use it in a fortran
>> subroutine to get x ,then the main function of my program use x to do other
>> >things. The question is that: when the process is 1(mpiexec -n 1),the
>> result of my program is ok, but when the process is more than 1 the
>> > result is wrong.
>>
>
> > "Wrong" is not an acceptable description. I suspect that you do not
> understand that only part of a Vec
> > is stored on each MPI process. First, get the book Using MPI, and then
> read the PETSc manual
> > section on vectors.
>
>   > Thanks,
>
>      > Matt
>
>
>>  >     So where could be wrong? Can you give me some hints on how I can
>> debug? Thanks.
>> >                                   Jim
>>
> > --
> > 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
>
>
>
>
>
>


-- 
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/20120526/42a4403e/attachment-0001.html>


More information about the petsc-users mailing list