<div class="gmail_extra">On Thu, Apr 26, 2012 at 9:24 AM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
On Apr 26, 2012, at 6:28 AM, Dominik Szczerba wrote:<br>
<br>
> Jed, Barry, Matt:<br>
><br>
> Below a collection of all pending answers in one mail.<br></div></div></blockquote><div><br></div><div>You can use -pc_type lu to test for a rank deficient preconditioning matrix.</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"><div class="HOEnZb"><div class="h5">
>> How do you define "right results"?<br>
><br>
> I run the exact same problem on in a commercial FEM package and<br>
> compare the results. The test problem is diffusion-reaction, with a<br>
> nonlinear reaction term of a polynomial form (tested up to order 5). I<br>
> Form the Jacobian as follows. We have a problem Ax = b(x), with A<br>
> constant and b depending pointwise on x (i.e. db/dxn does not depend<br>
> on xm, m!=n). Therefore I provide a simple Jacobian equal to A with<br>
> the diagonal augmented with -db/dx. The relevant code is below. I do<br>
> hope I do something wrong and you can point it out.<br>
><br>
> ierr = MatCopy(that->system.A, *B, SAME_NONZERO_PATTERN); CHKERRQ(ierr);<br>
><br>
> ierr = VecScale(that->dbdx, -1.0); CHKERRQ(ierr);<br>
> ierr = MatDiagonalSet(*B, that->dbdx, ADD_VALUES); CHKERRQ(ierr);<br>
><br>
> ierr = MatAssemblyBegin(*B, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);<br>
> ierr = MatAssemblyEnd(*B, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);<br>
><br>
> if(*J != *B)<br>
> {<br>
> ierr = MatAssemblyBegin(*J, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);<br>
> ierr = MatAssemblyEnd(*J, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);<br>
> }<br>
><br>
> *flag = SAME_NONZERO_PATTERN;<br>
><br>
><br>
>> Is SNES converging quadratically when you<br>
>> do not use -snes_mf_operator?<br>
><br>
> Without -snes_mf_operator, providing analytically derived Jacobian:<br>
><br>
> 0 SNES Function norm 1.747536282885e+01<br>
> 1 SNES Function norm 1.918464419679e-03<br>
> 2 SNES Function norm 1.086746779744e-03<br>
> 3 SNES Function norm 2.904556511511e-06<br>
> 4 SNES Function norm 7.804808098453e-08<br>
><br>
> Without -snes_mf_operator, passing A as the jacobian (which you call<br>
> Picard), and slightly underrelaxing the linear solves (otherwise it<br>
> would not converge):<br>
><br>
> 0 SNES Function norm 1.747886139999e+01<br>
> 1 SNES Function norm 3.495796117011e+00<br>
> 2 SNES Function norm 6.991806248330e-01<br>
> 3 SNES Function norm 1.398879936054e-01<br>
> 4 SNES Function norm 2.809047018752e-02<br>
> 5 SNES Function norm 5.843745932752e-03<br>
> 6 SNES Function norm 1.594583643926e-03<br>
> 7 SNES Function norm 7.712066092135e-04<br>
> 8 SNES Function norm 4.932447251451e-04<br>
> 9 SNES Function norm 3.217945635817e-04<br>
> 10 SNES Function norm 2.129867244811e-04<br>
> 11 SNES Function norm 1.399983127264e-04<br>
> 12 SNES Function norm 9.246882776024e-05<br>
> 13 SNES Function norm 6.088284618615e-05<br>
> 14 SNES Function norm 4.017029247381e-05<br>
> 15 SNES Function norm 2.646770266042e-05<br>
> 16 SNES Function norm 1.745497080382e-05<br>
> 17 SNES Function norm 1.150437737331e-05<br>
> 18 SNES Function norm 7.585434690336e-06<br>
> 19 SNES Function norm 5.000147553531e-06<br>
> 20 SNES Function norm 3.296560754852e-06<br>
> 21 SNES Function norm 2.173152296533e-06<br>
> 22 SNES Function norm 1.432685503660e-06<br>
> 23 SNES Function norm 9.444717211995e-07<br>
> 24 SNES Function norm 6.226464090397e-07<br>
> 25 SNES Function norm 4.104757979681e-07<br>
> 26 SNES Function norm 2.706068836265e-07<br>
> 27 SNES Function norm 1.783963930887e-07<br>
> 28 SNES Function norm 1.176079057620e-07<br>
><br>
> Dominik<br>
><br>
>> Run with -snes_type test and see what it reports.<br>
><br>
> Running with the options:<br>
><br>
> -ksp_type bcgs -pc_type jacobi -ksp_rtol 1e-4 -ksp_max_it 1000<br>
> -ksp_converged_use_initial_residual_norm -ksp_norm_type<br>
> unpreconditioned -ksp_monitor_true_residual -ksp_converged_reason<br>
> -ksp_view -snes_monitor -snes_converged_reason -snes_ls_monitor<br>
> -snes_view -snes_type test -snes_test_display<br>
><br>
> I get the output:<br>
><br>
> Testing hand-coded Jacobian, if the ratio is<br>
> O(1.e-8), the hand-coded Jacobian is probably correct.<br>
><br>
> and the procedure stagnates, calling FormJacobian only once, and then<br>
> FormFunction infinitely, with my own computation of ||F|| indicating<br>
> stagnation.<br>
<br>
</div></div> It is not calling it infinitely. Run with the -snes_type test option for a small problem, with say 10 unknowns to start.<br>
<br>
Barry<br>
<br>
><br>
> Regards,<br>
> Dominik<br>
<br>
</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<br>
</div>