<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, May 13, 2014 at 7:55 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
What do you mean by ‘''the default “coloring” method’’’<br>
<br>
If you are using DMDA and either DMGetColoring or the SNESSetDM approach and dof is 4 then we color each of the 4 variables per grid point with a different color so coupling between variables within a grid point is not a problem. This would not explain the problem you are seeing below.<br>
<br>
Run your code with -snes_type test and read the results and follow the directions to debug your Jacobian.</blockquote><div><br></div><div>I think there may actually be a bug with the coloring for unstructured grids. I am distilling it down to a nice test case.</div>
<div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888"><br>
Barry<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On May 13, 2014, at 1:20 PM, Jean-Arthur Louis Olive <<a href="mailto:jaolive@MIT.EDU">jaolive@MIT.EDU</a>> wrote:<br>
<br>
> Hi all,<br>
> we are using PETSc to solve the steady state Stokes equations with non-linear viscosities using finite difference. Recently we have realized that our true residual norm after the last KSP solve did not match next SNES function norm when solving the linear Stokes equations.<br>
><br>
> So to understand this better, we set up two extremely simple linear residuals, one with no coupling between variables (vx, vy, P and T), the other with one coupling term (shown below).<br>
><br>
> RESIDUAL 1 (NO COUPLING):<br>
> for (j=info->ys; j<info->ys+info->ym; j++) {<br>
> for (i=info->xs; i<info->xs+info->xm; i++) {<br>
> f[j][i].P = x[j][i].P - 3000000;<br>
> f[j][i].vx= 2*x[j][i].vx;<br>
> f[j][i].vy= 3*x[j][i].vy - 2;<br>
> f[j][i].T = x[j][i].T;<br>
> }<br>
><br>
> RESIDUAL 2 (ONE COUPLING TERM):<br>
> for (j=info->ys; j<info->ys+info->ym; j++) {<br>
> for (i=info->xs; i<info->xs+info->xm; i++) {<br>
> f[j][i].P = x[j][i].P - 3;<br>
> f[j][i].vx= x[j][i].vx - 3*x[j][i].vy;<br>
> f[j][i].vy= x[j][i].vy - 2;<br>
> f[j][i].T = x[j][i].T;<br>
> }<br>
> }<br>
><br>
><br>
> and our default set of options is:<br>
><br>
><br>
> OPTIONS: mpiexec -np $np ../Stokes -snes_max_it 4 -ksp_atol 2.0e+2 -ksp_max_it 20 -ksp_rtol 9.0e-1 -ksp_type fgmres -snes_monitor -snes_converged_reason -snes_view -log_summary -options_left 1 -ksp_monitor_true_residual -pc_type none -snes_linesearch_type cp<br>
><br>
><br>
> With the uncoupled residual (Residual 1), we get matching KSP and SNES norm, highlighted below:<br>
><br>
><br>
> Result from Solve - RESIDUAL 1<br>
> 0 SNES Function norm 8.485281374240e+07<br>
> 0 KSP unpreconditioned resid norm 8.485281374240e+07 true resid norm 8.485281374240e+07 ||r(i)||/||b|| 1.000000000000e+00<br>
> 1 KSP unpreconditioned resid norm 1.131370849896e+02 true resid norm 1.131370849896e+02 ||r(i)||/||b|| 1.333333333330e-06<br>
> 1 SNES Function norm 1.131370849896e+02<br>
> 0 KSP unpreconditioned resid norm 1.131370849896e+02 true resid norm 1.131370849896e+02 ||r(i)||/||b|| 1.000000000000e+00<br>
> 2 SNES Function norm 1.131370849896e+02<br>
> Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 2<br>
><br>
><br>
> With the coupled residual (Residual 2), the norms do not match, see below<br>
><br>
><br>
> Result from Solve - RESIDUAL 2:<br>
> 0 SNES Function norm 1.019803902719e+02<br>
> 0 KSP unpreconditioned resid norm 1.019803902719e+02 true resid norm 1.019803902719e+02 ||r(i)||/||b|| 1.000000000000e+00<br>
> 1 KSP unpreconditioned resid norm 8.741176309016e+01 true resid norm 8.741176309016e+01 ||r(i)||/||b|| 8.571428571429e-01<br>
> 1 SNES Function norm 1.697056274848e+02<br>
> 0 KSP unpreconditioned resid norm 1.697056274848e+02 true resid norm 1.697056274848e+02 ||r(i)||/||b|| 1.000000000000e+00<br>
> 1 KSP unpreconditioned resid norm 5.828670868165e-12 true resid norm 5.777940247956e-12 ||r(i)||/||b|| 3.404683942184e-14<br>
> 2 SNES Function norm 3.236770473841e-07<br>
> Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 2<br>
><br>
><br>
> Lastly, if we add -snes_fd to our options, the norms for residual 2 get better - they match after the first iteration but not after the second.<br>
><br>
><br>
> Result from Solve with -snes_fd - RESIDUAL 2<br>
> 0 SNES Function norm 8.485281374240e+07<br>
> 0 KSP unpreconditioned resid norm 8.485281374240e+07 true resid norm 8.485281374240e+07 ||r(i)||/||b|| 1.000000000000e+00<br>
> 1 KSP unpreconditioned resid norm 2.039607805429e+02 true resid norm 2.039607805429e+02 ||r(i)||/||b|| 2.403700850300e-06<br>
> 1 SNES Function norm 2.039607805429e+02<br>
> 0 KSP unpreconditioned resid norm 2.039607805429e+02 true resid norm 2.039607805429e+02 ||r(i)||/||b|| 1.000000000000e+00<br>
> 1 KSP unpreconditioned resid norm 2.529822128436e+01 true resid norm 2.529822128436e+01 ||r(i)||/||b|| 1.240347346045e-01<br>
> 2 SNES Function norm 2.549509757105e+01 [SLIGHTLY DIFFERENT]<br>
> 0 KSP unpreconditioned resid norm 2.549509757105e+01 true resid norm 2.549509757105e+01 ||r(i)||/||b|| 1.000000000000e+00<br>
> 3 SNES Function norm 2.549509757105e+01<br>
> Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 3<br>
><br>
><br>
> Does this mean that our Jacobian is not approximated properly by the default “coloring” method when it has off-diagonal terms?<br>
><br>
> Thanks a lot,<br>
> Arthur and Eric<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
</div></div>