<div dir="ltr">Dear Petsc-Users,<div><br></div><div>I debug my code. I solve the small linear system using KSP. </div><div>The matrix is:</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>row 0: (0, -123354)  (1, 6.92922e-310)  (2, 123354)  (3, 1.38582e-309) </div>
</div><div><div>row 1: (0, 1.3858e-309)  (1, 91156.6)  (2, 6.92901e-310)  (3, 91156.6) </div></div><div><div>row 2: (0, 8768.96)  (1, 2.47033e-323)  (2, -171955)  (3, 1.02212e-316)  (4, 163186)  (5, 0) </div></div><div><div>
row 3: (0, 0)  (1, -59201.7)  (2, 0)  (3, 156037)  (4, 0)  (5, 93996.1) </div></div><div><div>row 4: (2, 13422.8)  (3, 0)  (4, -13422.8)  (5, 0) </div></div><div><div>row 5: (2, 0)  (3, -58000.3)  (4, 0)  (5, 59201.7) </div>
</div></blockquote><div>the RHS vector:</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>-9115.66</div></div><div><div>-17760.5</div></div><div><div>-425.926</div></div><div><div>-35400.9</div>
</div><div><div>9541.58</div></div><div><div>-17520.2</div></div></blockquote>the solution I got was:<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>-2.00943e+52</div></div><div><div>-1.17929e+18</div>
</div><div><div>-2.00943e+52</div></div><div><div>7.121e+16</div></div><div><div>-2.00943e+52</div></div><div><div>-7.0943e+16</div></div></blockquote><div><div>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:</div>
</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div>    KSPSetOperators(ksp, mat_A, mat_A, SAME_NONZERO_PATTERN);</div></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
    // set the linear solve options <br>    KSPSetType(ksp, KSPGMRES);<br>    KSPGMRESSetRestart(ksp, 100);<br>    // set preconditioning options <br>    KSPGetPC(ksp, &pc);<br>    PCSetType(pc, PCBJACOBI);<br>    KSPSetFromOptions(ksp);<br>
    // Solve the linear system<div><div><div>    KSPSolve(ksp,vec_rhs,vec_sol);</div></div></div></blockquote>Could anyone give me a suggestion where should be the source of error? Thank you!<div><br></div><div>Que<br><div>
<div><br></div></div></div></div>