<div dir="ltr"><div class="gmail_default" style="font-size:small">I'm more confused than ever. I don't understand the output of -snes_type test -snes_test_display.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">For the user-defined state of the vector (where I'd like to test the Jacobian), the finite difference Jacobian at row 0 evaluates as:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">row 0: (0, 10768.6)<span class="gmail-Apple-converted-space"> </span>(1, 2715.33)<span class="gmail-Apple-converted-space"> </span>(2, -1422.41)<span class="gmail-Apple-converted-space"> </span>(3, -6121.71)<span class="gmail-Apple-converted-space"> </span>(4, 287.797)<span class="gmail-Apple-converted-space"> </span>(5, 744.695)<span class="gmail-Apple-converted-space"> </span>(9, -1454.66)<span class="gmail-Apple-converted-space"> </span>(10, 6.08793)<span class="gmail-Apple-converted-space"> </span>(11, 148.172)<span class="gmail-Apple-converted-space"> </span>(12, 13.1089)<span class="gmail-Apple-converted-space"> </span>(13, -36.5783)<span class="gmail-Apple-converted-space"> </span>(14, -9.99399)<span class="gmail-Apple-converted-space"> </span>(27, -3423.49)<span class="gmail-Apple-converted-space"> </span>(28, -2175.34)<span class="gmail-Apple-converted-space"> </span>(29, 548.662)<span class="gmail-Apple-converted-space"> </span>(30, 145.753)<span class="gmail-Apple-converted-space"> </span>(31, 17.6603)<span class="gmail-Apple-converted-space"> </span>(32, -15.1079)<span class="gmail-Apple-converted-space"> </span>(36, 76.8575)<span class="gmail-Apple-converted-space"> </span>(37, 16.325)<span class="gmail-Apple-converted-space"> </span>(38, 4.83918)</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">But the hand-coded Jacobian at row 0 evaluates as:</div><div class="gmail_default" style="font-size:small"><span class="gmail-s1"><br></span></div><div class="gmail_default" style="font-size:small"><span class="gmail-s1">row 0: (0, 10768.6)<span class="gmail-Apple-converted-space"> </span>(1, 2715.33)<span class="gmail-Apple-converted-space"> </span>(2, -1422.41)<span class="gmail-Apple-converted-space"> </span>(3, -6121.71)<span class="gmail-Apple-converted-space"> </span>(4, 287.797)<span class="gmail-Apple-converted-space"> </span>(5, 744.695)<span class="gmail-Apple-converted-space"> </span>(33, -1454.66)<span class="gmail-Apple-converted-space"> </span>(34, 6.08792)<span class="gmail-Apple-converted-space"> </span>(35, 148.172)<span class="gmail-Apple-converted-space"> </span>(36, 13.1089)<span class="gmail-Apple-converted-space"> </span>(37, -36.5783)<span class="gmail-Apple-converted-space"> </span>(38, -9.99399)<span class="gmail-Apple-converted-space"> </span>(231, -3423.49)<span class="gmail-Apple-converted-space"> </span>(232, -2175.34)<span class="gmail-Apple-converted-space"> </span>(2</span>33, 548.662)<span class="gmail-Apple-converted-space"> </span>(234, 145.753)<span class="gmail-Apple-converted-space"> </span>(235, 17.6603)<span class="gmail-Apple-converted-space"> </span>(236, -15.1079)<span class="gmail-Apple-converted-space"> </span>(264, 76.8575)<span class="gmail-Apple-converted-space"> </span>(265, 16.325)<span class="gmail-Apple-converted-space"> </span>(266, 4.83917)<span class="gmail-Apple-converted-space"> </span>(267, 0.)<span class="gmail-Apple-converted-space"> </span>(268, 0.)<span class="gmail-Apple-converted-space"> </span>(269, 0.)<br></div><div class="gmail_default" style="font-size:small"><p class="gmail-p1"><span class="gmail-s1">and the difference between the Jacobians at row 0 evaluates as:</span></p><p class="gmail-p1"><span class="gmail-s1">row 0: (0, 0.000189908)<span class="gmail-Apple-converted-space"> </span>(1, 7.17315e-05)<span class="gmail-Apple-converted-space"> </span>(2, 9.31778e-05)<span class="gmail-Apple-converted-space"> </span>(3, 0.000514947)<span class="gmail-Apple-converted-space"> </span>(4, 0.000178659)<span class="gmail-Apple-converted-space"> </span>(5, 0.000178217)<span class="gmail-Apple-converted-space"> </span>(9, -2.25457e-05)<span class="gmail-Apple-converted-space"> </span>(10, -6.34278e-06)<span class="gmail-Apple-converted-space"> </span>(11, -5.93241e-07)<span class="gmail-Apple-converted-space"> </span>(12, 9.48544e-06)<span class="gmail-Apple-converted-space"> </span>(13, 4.79709e-06)<span class="gmail-Apple-converted-space"> </span>(14, 2.400</span>16e-06)<span class="gmail-Apple-converted-space"> </span>(27, -0.000335696)<span class="gmail-Apple-converted-space"> </span>(28, -0.000106734)<span class="gmail-Apple-converted-space"> </span>(29, -0.000106653)<span class="gmail-Apple-converted-space"> </span>(30, 2.73119e-06)<span class="gmail-Apple-converted-space"> </span>(31, -7.93382e-07)<span class="gmail-Apple-converted-space"> </span>(32, 1.24048e-07)<span class="gmail-Apple-converted-space"> </span>(36, -4.0302e-06)<span class="gmail-Apple-converted-space"> </span>(37, 3.67494e-06)<span class="gmail-Apple-converted-space"> </span>(38, -2.70115e-06)<span class="gmail-Apple-converted-space"> </span>(39, 0.)<span class="gmail-Apple-converted-space"> </span>(40, 0.)<span class="gmail-Apple-converted-space"> </span>(41, 0.)</p><p class="gmail-p1">The difference between the column numbering between the finite difference and the hand-coded Jacobians looks like a serious problem to me, but I'm probably missing something.</p><p class="gmail-p1">I am trying to use a 3D DMDA with 3 dof, a box stencil of width 1, and for this test problem the grid dimensions are 11x7x6. For a grid point x,y,z, and dof c, is the index calculated as c + 3*x + 3*11*y + 3*11*7*z? If so, then the column numbers of the hand-coded Jacobian match those of the 27 point stencil I have in mind. However, I am then at a loss to explain the column numbers in the finite difference Jacobian.</p><p class="gmail-p1"><span class="gmail-s1"><br></span></p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 7, 2017 at 1:49 PM, zakaryah . <span dir="ltr"><<a href="mailto:zakaryah@gmail.com" target="_blank">zakaryah@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-size:small">OK - I ran with <span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(254,244,156);font-family:Menlo;font-size:11px">-snes_monitor -snes_converged_reason -snes_linesearch_monitor -ksp_monitor -ksp_monitor_true_residual -ksp_converged_reason -pc_type svd -pc_svd_monitor -snes_type newtonls -snes_compare_explicit</span></div><div class="gmail_default" style="font-size:small"><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(254,244,156);font-family:Menlo;font-size:11px"><br></span></div><div class="gmail_default" style="font-size:small">and here is the full error message, output immediately after </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Finite difference Jacobian<br></div><div class="gmail_default" style="font-size:small">Mat Object: 24 MPI processes</div><div class="gmail_default" style="font-size:small"> type: mpiaij</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><span class="">
<p class="m_-3020606467033979545gmail-p1"><span class="m_-3020606467033979545gmail-s1">[0]PETSC ERROR: --------------------- Error Message ------------------------------<wbr>------------------------------<wbr>--</span></p>
</span><p class="m_-3020606467033979545gmail-p1"><span class="m_-3020606467033979545gmail-s1">[0]PETSC ERROR: Invalid argument</span></p><span class="">
<p class="m_-3020606467033979545gmail-p1"><span class="m_-3020606467033979545gmail-s1">[0]PETSC ERROR: Matrix not generated from a DMDA</span></p>
</span><p class="m_-3020606467033979545gmail-p1"><span class="m_-3020606467033979545gmail-s1">[0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" target="_blank">http://www.mcs.anl.gov/petsc/<wbr>documentation/faq.html</a> for trouble shooting.</span></p>
<p class="m_-3020606467033979545gmail-p1"><span class="m_-3020606467033979545gmail-s1">[0]PETSC ERROR: Petsc Release Version 3.7.6, Apr, 24, 2017<span class="m_-3020606467033979545gmail-Apple-converted-space"> </span></span></p>
<p class="m_-3020606467033979545gmail-p1"><span class="m_-3020606467033979545gmail-s1">[0]PETSC ERROR: ./CalculateOpticalFlow on a arch-linux2-c-opt named node046.hpc.rockefeller.<wbr>internal by zfrentz Sat Oct<span class="m_-3020606467033979545gmail-Apple-converted-space"> </span>7 13:44:44 2017</span></p>
<p class="m_-3020606467033979545gmail-p1"><span class="m_-3020606467033979545gmail-s1">[0]PETSC ERROR: Configure options --prefix=/ru-auth/local/home/<wbr>zfrentz/PETSc-3.7.6 --download-fblaslapack -with-debugging=0</span></p>
<p class="m_-3020606467033979545gmail-p1"><span class="m_-3020606467033979545gmail-s1">[0]PETSC ERROR: #1 MatView_MPI_DA() line 551 in /rugpfs/fs0/home/zfrentz/<wbr>PETSc/build/petsc-3.7.6/src/<wbr>dm/impls/da/fdda.c</span></p>
<p class="m_-3020606467033979545gmail-p1"><span class="m_-3020606467033979545gmail-s1">[0]PETSC ERROR: #2 MatView() line 901 in /rugpfs/fs0/home/zfrentz/<wbr>PETSc/build/petsc-3.7.6/src/<wbr>mat/interface/matrix.c</span></p>
<p class="m_-3020606467033979545gmail-p1"><span class="m_-3020606467033979545gmail-s1">[0]PETSC ERROR: #3 SNESComputeJacobian() line 2371 in /rugpfs/fs0/home/zfrentz/<wbr>PETSc/build/petsc-3.7.6/src/<wbr>snes/interface/snes.c</span></p>
<p class="m_-3020606467033979545gmail-p1"><span class="m_-3020606467033979545gmail-s1">[0]PETSC ERROR: #4 SNESSolve_NEWTONLS() line 228 in /rugpfs/fs0/home/zfrentz/<wbr>PETSc/build/petsc-3.7.6/src/<wbr>snes/impls/ls/ls.c</span></p>
<p class="m_-3020606467033979545gmail-p1"><span class="m_-3020606467033979545gmail-s1">[0]PETSC ERROR: #5 SNESSolve() line 4005 in /rugpfs/fs0/home/zfrentz/<wbr>PETSc/build/petsc-3.7.6/src/<wbr>snes/interface/snes.c</span></p>
<p class="m_-3020606467033979545gmail-p1"><span class="m_-3020606467033979545gmail-s1">[0]PETSC ERROR: #6 solveWarp3D() line 659 in /ru-auth/local/home/zfrentz/<wbr>Code/OpticalFlow/working/<wbr>October6_2017/mshs.c</span></p></div>
</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 3, 2017 at 5:37 PM, Jed Brown <span dir="ltr"><<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Always always always send the whole error message.<br>
<div class="m_-3020606467033979545HOEnZb"><div class="m_-3020606467033979545h5"><br>
"zakaryah ." <<a href="mailto:zakaryah@gmail.com" target="_blank">zakaryah@gmail.com</a>> writes:<br>
<br>
> I tried -snes_compare_explicit, and got the following error:<br>
><br>
> [0]PETSC ERROR: Invalid argument<br>
><br>
> [0]PETSC ERROR: Matrix not generated from a DMDA<br>
><br>
> What am I doing wrong?<br>
><br>
> On Tue, Oct 3, 2017 at 10:08 AM, Jed Brown <<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>> wrote:<br>
><br>
>> Barry Smith <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>> writes:<br>
>><br>
>> >> On Oct 3, 2017, at 5:54 AM, zakaryah . <<a href="mailto:zakaryah@gmail.com" target="_blank">zakaryah@gmail.com</a>> wrote:<br>
>> >><br>
>> >> I'm still working on this. I've made some progress, and it looks like<br>
>> the issue is with the KSP, at least for now. The Jacobian may be<br>
>> ill-conditioned. Is it possible to use -snes_test_display during an<br>
>> intermediate step of the analysis? I would like to inspect the Jacobian<br>
>> after several solves have already completed,<br>
>> ><br>
>> > No, our currently code for testing Jacobians is poor quality and<br>
>> poorly organized. Needs a major refactoring to do things properly. Sorry<br>
>><br>
>> You can use -snes_compare_explicit or -snes_compare_coloring to output<br>
>> differences on each Newton step.<br>
>><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>