Hi<br><br>I am using cell centered finite difference method for<br>-div K (grad p) = f<br>with Neumann boundary condtion.<br><br>I called<br>SNESGetKSP(snes, &ksp);<br>MatNullSpaceCreate(PETSC_COMM_WORLD, PETSC_TRUE, 0, PETSC_NULL, &nullsp);<br>
KSPSetNullSpace(ksp, nullsp);<br>MatNullSpaceDestroy(&nullsp);<br><br>to handle the null space.<br><br>But I got the result like the following<br> 0 SNES Function norm 3.512407365520e+02 <br> Linear solve converged due to CONVERGED_RTOL iterations 16<br>
1 SNES Function norm 6.615335308038e-03 <br> Linear solve converged due to CONVERGED_RTOL iterations 20<br> 2 SNES Function norm 3.979662741066e-08 <br><br>I checked my numerical solution with analytical solution (p=x,y,z,cos(pi*x),cos(pi*y), cos(pi*z).<br>
<br>These are the difference between the petsc result and analytical solution for <br>-da_grid_x 5<br>-da_grid_y 5<br>-da_grid_z 100<br><br>i j k 1 1 0<br>petsc 0.499959<br>true 0.495<br>petsc-true 0.00495888<br>
i j k 1 1 1<br>petsc 0.486626<br>true 0.485<br>petsc-true 0.00162554<br>i j k 1 1 2<br>petsc 0.475959<br>true 0.475<br>petsc-true 0.000958875<br>i j k 1 1 3<br>petsc 0.465673<br>true 0.465<br>
petsc-true 0.000673159<br><br>I think I got the correct solution.<br><br>I do not understand why snes took 2 iterations for a linear problem? Is it normal?<br><br clear="all"><br>-- <br>Hailong<br>