<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Aug 18, 2016 at 2:14 PM, 최경준 <span dir="ltr"><<a href="mailto:kyungjun.choi92@gmail.com" target="_blank">kyungjun.choi92@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">I called SNESView() at right above call SNESSolve() to check options that I applied.</div></blockquote><div><br></div><div>Okay, I am not understanding what you want to do. Below, you have setup SNES to</div><div>calculate the entire Jacobian using a finite-difference (FD) approximation. This is the same</div><div>as using</div><div><br></div><div> -snes_fd</div><div><br></div><div>I thought you wanted to use a matrix-free action for the Jacobian</div><div><br></div><div> -snes_mf</div><div><br></div><div>and no preconditioner</div><div><br></div><div> -pc_type none</div><div><br></div><div>although I have no idea what kind of a problem this would work for.</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 dir="ltr"><div><div>SNES Object: 1 MPI processes</div><div> type: newtonls</div><div> SNES has not been set up so information may be incomplete</div><div> maximum iterations=1, maximum function evaluations=10000</div><div> tolerances: relative=1e-08, absolute=1e-32, solution=1e-08</div><div> total number of linear solver iterations=0</div><div> total number of function evaluations=0</div><div> norm schedule ALWAYS</div><div> SNESLineSearch Object: 1 MPI processes</div><div> type: bt</div><div> interpolation: cubic</div><div> alpha=1.000000e-04</div><div> maxstep=1.000000e+08, minlambda=1.000000e-12</div><div> tolerances: relative=1.000000e-08, absolute=1.000000e-15, lambda=1.000000e-08</div><div> maximum iterations=40</div><div> KSP Object: 1 MPI processes</div><div> type: gmres</div><div> GMRES: restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement</div><div> GMRES: happy breakdown tolerance 1e-30</div><div> maximum iterations=10000</div><div> tolerances: relative=0.001, absolute=1e-50, divergence=10000.</div><div> left preconditioning</div><div> using nonzero initial guess</div><div> using DEFAULT norm type for convergence test</div><div> PC Object: 1 MPI processes</div><div> type: none</div><div> PC has not been set up so information may be incomplete</div><div> linear system matrix = precond matrix:</div><div> Mat Object: 1 MPI processes</div><div> type: mffd</div><div> rows=64, cols=64</div><div> Matrix-free approximation:</div><div> err=1.49012e-08 (relative error in function evaluation)</div><div> The compute h routine has not yet been set</div></div><div><br></div><div>------------------------------<wbr>------------------------------<wbr>-------------------------</div><div><br></div><div>And this is the whole error message</div><div><br></div><div><div>[0]PETSC ERROR: --------------------- Error Message ------------------------------<wbr>------------------------------<wbr>--</div><div>[0]PETSC ERROR: No support for this operation for this object type</div><div>[0]PETSC ERROR: Mat type mffd</div><div>[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.</div><div>[0]PETSC ERROR: Petsc Release Version 3.7.3, Jul, 24, 2016 </div><div>[0]PETSC ERROR: ./flus � ��� on a arch-linux2-c-debug named ckj-System by ckj Fri Aug 19 04:09:56 2016</div><div>[0]PETSC ERROR: Configure options --with-cc=icc --with-cxx=icpc --with-fc=ifort --with-mpi-include=/opt/intel/<wbr>impi/<a href="http://5.0.1.035/intel64/include" target="_blank">5.0.1.035/intel64/include</a> --with-mpi-lib="-L/opt/intel//<wbr>impi/<a href="http://5.0.1.035/intel64/release" target="_blank">5.0.1.035/intel64/release</a> -L/opt/intel//impi/<a href="http://5.0.1.035/intel64/lib" target="_blank">5.0.1.035/<wbr>intel64/lib</a> -lmpifort -lmpi -lmpigi -ldl -lrt -lpthread" --with-blas-lapack-dir=/opt/<wbr>intel/mkl --prefix=/opt/petsc/3.7.3</div><div>[0]PETSC ERROR: #1 MatZeroEntries() line 5511 in /home/ckj/Repository/petsc-3.<wbr>7.3/src/mat/interface/matrix.c</div><div>[0]PETSC ERROR: #2 SNESComputeJacobianDefault() line 65 in /home/ckj/Repository/petsc-3.<wbr>7.3/src/snes/interface/snesj.c</div><div>[0]PETSC ERROR: #3 oursnesjacobian() line 105 in /home/ckj/Repository/petsc-3.<wbr>7.3/src/snes/interface/ftn-<wbr>custom/zsnesf.c</div><div>[0]PETSC ERROR: #4 SNESComputeJacobian() line 2312 in /home/ckj/Repository/petsc-3.<wbr>7.3/src/snes/interface/snes.c</div><div>[0]PETSC ERROR: #5 SNESSolve_NEWTONLS() line 228 in /home/ckj/Repository/petsc-3.<wbr>7.3/src/snes/impls/ls/ls.c</div><div>[0]PETSC ERROR: #6 SNESSolve() line 4005 in /home/ckj/Repository/petsc-3.<wbr>7.3/src/snes/interface/snes.c</div></div><div><br></div><div>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>---</div><div><br></div><div>I checked that the program got out of calling SNESSolve() after this error message.</div><div><br></div><div>But I can't figure out the reason for this error.</div><div><br></div><div><br></div><div>Best,</div><div><br></div><div>Kyungjun</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-08-19 4:05 GMT+09:00 Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span><div>On Thu, Aug 18, 2016 at 2:03 PM, 최경준 <span dir="ltr"><<a href="mailto:kyungjun.choi92@gmail.com" target="_blank">kyungjun.choi92@gmail.com</a>></span> wrote:<br></div></span><div class="gmail_extra"><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I got stuck at FormJacobian stage.<div><br></div><div>- call SNESComputeJacobianDefault(sne<wbr>s, v, J, pJ, FormResidual, ier) --> J & pJ are same with A matrix-free matrix (input argument)</div><div><br><div><br></div><div><br></div><div>with these kind of messages..</div><div><br></div><div><div>[0]PETSC ERROR: No support for this operation for this object type</div><div>[0]PETSC ERROR: Mat type mffd</div></div></div></div></blockquote><div><br></div></span><div>1) Always give the ENTIRE error message</div><div><br></div><div>2) As I said in the last two messages, you can only use this without a preconditioner, so you need</div><div><br></div><div> -pc_type none</div><div><br></div><div> Matt</div><div><div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><br></div><div>Guess it's because I used A matrix-free matrix (which is mffd type) into pJ position.</div><div><br></div><div>Is there any solution for this kind of situation?</div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-08-19 2:05 GMT+09:00 Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span>:<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_extra"><div class="gmail_quote"><span>On Thu, Aug 18, 2016 at 12:04 PM, 최경준 <span dir="ltr"><<a href="mailto:kyungjun.choi92@gmail.com" target="_blank">kyungjun.choi92@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">Then in order not to use preconditioner, <div><br></div><div>is it ok if I just put A matrix-free matrix (made from MatCreateSNESMF()) into the place where preA should be?</div></div></blockquote><div><br></div></span><div>Yes, but again the solve will likely perform very poorly.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div><div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>The flow goes like this</div><div>- call SNESCreate</div><div>- call SNESSetFunction(snes, r, FormResidual, userctx, ier)</div><div>- call MatCreateSNESMF(snes, A, ier)</div><div>- call SNESSetJacobian(snes, A, A, FormJacobian, userctx, ier)</div><div>- call SNESSetFromOptions()</div><div><br></div><div>- call SNESGetKSP(snes, ksp, ier)</div><div>- call KSPSetType(ksp, KSPGMRES, ier)</div><div>- call KSPGetPC(ksp, pc, ier)</div><div>- call PCSetType(pc, PCNONE, ier)</div><div>- call KSPGMRESSetRestart(ksp, 30, ier)</div><div><br></div><div>- call SNESSolve()</div><div>.</div><div>.</div><div><br></div><div><br></div><div>and inside the FormJacobian routine</div><div>- call SNESComputeJacobian(snes, v, J, pJ, userctx, ier) --> J and pJ must be pointed with A and A.</div><div><br><div><br></div><div><br></div></div><div>Thank you again,</div><div><br></div><div>Kyungjun.</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-08-19 1:44 GMT+09:00 Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span>:<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_extra"><div class="gmail_quote"><span>On Thu, Aug 18, 2016 at 11:42 AM, 최경준 <span dir="ltr"><<a href="mailto:kyungjun.choi92@gmail.com" target="_blank">kyungjun.choi92@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">Thanks for your helpful answers.<div><br></div><div>Here's another question...</div><div><br></div><div>As I read some example PETSc codes, I noticed that there should be a preconditioning matrix (e.g. approx. jacobian matrix) when using MatCreateSNESMF().</div><div><br></div><div>I mean,</div><div>after calling MatCreateSNESMF(snes, A, ier),</div><div>there should be another matrix preA(preconditioning matrix) to use SNESSetJacobian(snes, A, preA, FormJacobian, ctx, ier).</div><div><br></div><div><br></div><div>1) Is there any way that I can use matrix-free method without making preconditioning matrix?</div></div></blockquote><div><br></div></span><div>Don't use a preconditioner. As you might expect, this does not often work out well.</div><span><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>2) I have a reference code, and the code adopts </div><div><br></div><div>MatFDColoringCreate()</div><div>and finally uses</div><div>SNESComputeJacobianDefaultColo<wbr>r() at FormJacobian stage.</div><div><br></div><div>But I can't see the inside of the fdcolor and I'm curious of this mechanism. Can you explain this very briefly or tell me an example code that I can refer to. ( I think none of PETSc example code is using fdcolor..)</div></div></blockquote><div><br></div></span><div>This is the default, so there is no need for all that code. We use naive graph 2-coloring. I think there might be a review article by Alex Pothen about that.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div><div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Best,</div><div><br></div><div>Kyungjun.</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-08-19 0:54 GMT+09:00 Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span>:<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_extra"><div class="gmail_quote"><span>On Thu, Aug 18, 2016 at 10:39 AM, 최경준 <span dir="ltr"><<a href="mailto:kyungjun.choi92@gmail.com" target="_blank">kyungjun.choi92@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">1) I wanna know the difference between applying option with command line and within source code.<br>From my experience, command line option helps set other default settings that I didn't applied, I guess.</div></blockquote><div><br></div></span><div>The command line arguments are applied to an object when *SetFromOptions() is called, so in this case</div><div>you want SNESSetFromOptions() on the solver. There should be no difference from using the API.</div><span><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>2) I made a matrix-free matrix with MatCreateSNESMF function, and every time I check my snes context with SNESView, </div><div><br></div><div><div> Mat Object: 1 MPI processes<br></div><div> type: mffd</div><div> rows=11616, cols=11616</div><div> Matrix-free approximation:</div><div> err=1.49012e-08 (relative error in function evaluation)</div><div> The compute h routine has not yet been set</div></div><div><br></div><div>at the end of line shows there's no routine for computing h value.</div><div>I used MatMFFDWPSetComputeNormU function, but it didn't work I think.</div><div>Is it ok if I leave the h value that way? Or should I have to set h computing routine?</div></div></blockquote><div><br></div></span><div>I am guessing you are calling the function on a different object from the one that is viewed here.</div><div>However, there will always be a default function for computing h.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><span><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Kyungjun.</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-08-18 23:18 GMT+09:00 Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span>:<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_extra"><div class="gmail_quote"><span>On Thu, Aug 18, 2016 at 8:35 AM, 최경준 <span dir="ltr"><<a href="mailto:kyungjun.choi92@gmail.com" target="_blank">kyungjun.choi92@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi, I'm trying to set my SNES matrix-free with Walker & Pernice way of computing h value.<div><br></div><div>I found above command (MatSNESMFWPSetComputeNormU) but my fortran compiler couldn't fine any reference of that command.</div><div><br></div><div>I checked Petsc changes log, but there weren't any mentions about that command.</div><div><br></div><div>Should I have to include another specific header file? </div></div></blockquote><div><br></div></span><div>We have this function</div><div><br></div><div> <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatMFFDWPSetComputeNormU.html" target="_blank">http://www.mcs.anl.gov/petsc<wbr>/petsc-current/docs/manualpage<wbr>s/Mat/MatMFFDWPSetComputeNormU<wbr>.html</a></div><div><br></div><div>but I would recommend using the command line option</div><div><br></div><div> <b style="color:rgb(0,0,0);font-family:Times;font-size:medium">-mat_mffd_compute_normu</b></div><div> </div><div> Thanks,</div><div><br></div><div> Matt</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Thank you always.</div></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br><br clear="all"><span><font color="#888888"><span><font color="#888888"><div><br></div>-- <br><div data-smartmail="gmail_signature">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>
</font></span></font></span></font></span></div></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br></font></span></div><span><font color="#888888">
</font></span></blockquote></span></div><span><font color="#888888"><span><br><br clear="all"><span><font color="#888888"><div><br></div>-- <br><div data-smartmail="gmail_signature">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>
</font></span></span></font></span></div></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br></font></span></div><span><font color="#888888">
</font></span></blockquote></div></div></div><span><font color="#888888"><div><div><br><br clear="all"><span><font color="#888888"><div><br></div>-- <br><div data-smartmail="gmail_signature">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>
</font></span></div></div></font></span></div></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br></font></span></div><span><font color="#888888">
</font></span></blockquote></div></div></div><span><font color="#888888"><div><div><br><br clear="all"><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br><div data-smartmail="gmail_signature">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>
</font></span></div></div></font></span></div></div><span class="HOEnZb"><font color="#888888">
</font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888">
</font></span></blockquote></div></div></div><span class="HOEnZb"><font color="#888888"><div><div><br><br clear="all"><div><br></div>-- <br><div data-smartmail="gmail_signature">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></div></font></span></div></div>
</blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">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></div>