[petsc-users] KSP linear solver

Matthew Knepley knepley at gmail.com
Sat Jan 18 13:54:56 CST 2014


On Sat, Jan 18, 2014 at 1:46 PM, Que Cat <quecat001 at gmail.com> wrote:
Dear Petsc-Users,
>
>
> I debug my code. I solve the small linear system using KSP.
> The matrix is:
>
> row 0: (0, -123354)  (1, 6.92922e-310)  (2, 123354)  (3, 1.38582e-309)
> row 1: (0, 1.3858e-309)  (1, 91156.6)  (2, 6.92901e-310)  (3, 91156.6)
> row 2: (0, 8768.96)  (1, 2.47033e-323)  (2, -171955)  (3, 1.02212e-316)
>  (4, 163186)  (5, 0)
> row 3: (0, 0)  (1, -59201.7)  (2, 0)  (3, 156037)  (4, 0)  (5, 93996.1)
> row 4: (2, 13422.8)  (3, 0)  (4, -13422.8)  (5, 0)
> row 5: (2, 0)  (3, -58000.3)  (4, 0)  (5, 59201.7)
>
>
1) Get rid of the entries that are 1e-300 or below


> the RHS vector:
>
> -9115.66
> -17760.5
> -425.926
> -35400.9
> 9541.58
> -17520.2
>
> the solution I got was:
>
> -2.00943e+52
> -1.17929e+18
> -2.00943e+52
> 7.121e+16
> -2.00943e+52
> -7.0943e+16
>
> I checked with matlab and I got the totally different solution. I guess
> there is something wrong with the linear solver I set up as follow:
>
>     KSPSetOperators(ksp, mat_A, mat_A, SAME_NONZERO_PATTERN);
>
>     // set the linear solve options
>     KSPSetType(ksp, KSPGMRES);
>     KSPGMRESSetRestart(ksp, 100);
>     // set preconditioning options
>     KSPGetPC(ksp, &pc);
>     PCSetType(pc, PCBJACOBI);
>     KSPSetFromOptions(ksp);
>     // Solve the linear system
>     KSPSolve(ksp,vec_rhs,vec_sol);
>
> Could anyone give me a suggestion where should be the source of error?
> Thank you!
>

2) Always start with -pc_type lu -ksp_type preonly

3) It appears that your matrix is close to singular (LU will check)

  Matt


> Que
>
>


-- 
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/20140118/231c7590/attachment.html>


More information about the petsc-users mailing list