<div dir="ltr">This appears to be broken because whoever made this example was demonstrating a very specific capability and didn't provide the sparsity pattern.  It's created as values are inserted.  This is therefore unlikely to work without some serious changes to the example, or calling the Jacobian creation routine beforehand, as:<div>
<br></div><div><div>index 0a48162..466507e 100644</div><div>--- a/src/snes/examples/tutorials/ex28.c</div><div>+++ b/src/snes/examples/tutorials/ex28.c</div><div>@@ -415,6 +415,7 @@ int main(int argc, char *argv[])</div><div>
     ierr = DMCompositeRestoreAccess(pack,F,0,&Fk);CHKERRQ(ierr);</div><div>     break;</div><div>   case 2:</div><div>+    MatStructure flag;</div><div>     ierr = DMCreateMatrix(pack,NULL,&B);CHKERRQ(ierr);</div>
<div>     /* This example does not correctly allocate off-diagonal blocks. These options allows new nonzeros (slow). */</div><div>     ierr = MatSetOption(B,MAT_NEW_NONZERO_LOCATION_ERR,PETSC_FALSE);CHKERRQ(ierr);</div><div>
@@ -434,6 +435,7 @@ int main(int argc, char *argv[])</div><div>        * of splits, but it requires using a DM (perhaps your own implementation). */</div><div>       ierr = SNESSetDM(snes,pack);CHKERRQ(ierr);</div><div>     }</div>
<div>+    ierr = FormJacobian_All(snes,X,&B,&B,&flag,user);CHKERRQ(ierr);</div><div>     ierr = SNESSolve(snes,NULL,X);CHKERRQ(ierr);</div><div>     break;</div><div>   }</div></div><div><br></div><div>which will fill in the sparsity pattern.<br>
<div><br></div><div>- Peter</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Sep 30, 2013 at 8:38 AM, Peter Brune <span dir="ltr"><<a href="mailto:prbrune@gmail.com" target="_blank">prbrune@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">This is not the full FD Jacobian, but the one constructed by coloring. It's a hunch, but I'd bet DMComposite doesn't have a proper coloring in place. This should error out. I'll check out why not.</p>


<p dir="ltr">You don't have to alter the source to do this. You can use -snes_fd_coloring or -snes_fd.</p>
<p dir="ltr">- Peter</p><span class="HOEnZb"><font color="#888888">
<p dir="ltr">- Peter<br></p></font></span><div class="HOEnZb"><div class="h5">
<div class="gmail_quote">On Sep 29, 2013 3:07 PM, "Lulu Liu" <<a href="mailto:lulu.liu@kaust.edu.sa" target="_blank">lulu.liu@kaust.edu.sa</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr"><div>Run the example /petsc/src/snes/examples/tutorials/ex28.c using the following options(found in the makefile)</div><div><br></div><div> ./ex28 -da_grid_x 20 -snes_converged_reason -snes_monitor_short -problem_type 2<br>


</div><div><br></div><div>It works using default analytic Jacobian to solve coupled system, however, I comment </div><div><br></div><div> Line 434 : ierr = SNESSetJacobian(snes,B,B,FormJacobian_All,user);CHKERRQ(ierr);</div>


<div><br></div><div>and run the code again using the same options (i.e., FD Jacobian instead of analytic Jacobian), we will get the results:</div><div><br></div><div>Nonlinear solve did not converge due to DIVERGED_MAX_IT iterations 50<br>


</div><div><br></div><div>Could you explain why it does not work using FD Jacobian in this example?</div><div><br></div><div>Thanks</div><div><br></div><div> <br></div></div>

<br>
<div><hr></div><font face="Arial" size="1">This message and its contents, including attachments are intended solely for the original recipient. If you are not the intended recipient or have received this message in error, please notify me immediately and delete this message from your computer system. Any unauthorized use or distribution is prohibited. Please consider the environment before printing this email.</font></blockquote>

</div>
</div></div></blockquote></div><br></div>