<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jun 23, 2016 at 2:43 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"><span class=""><br>
> On Jun 23, 2016, at 1:36 PM, Xiangdong <<a href="mailto:epscodes@gmail.com">epscodes@gmail.com</a>> wrote:<br>
><br>
> Hi Barry and Matt,<br>
><br>
> The behavior I reported before can be reproduced with snes example ex18.<br>
> <a href="http://www.mcs.anl.gov/petsc/petsc-current/src/snes/examples/tutorials/ex18.c.html" rel="noreferrer" target="_blank">http://www.mcs.anl.gov/petsc/petsc-current/src/snes/examples/tutorials/ex18.c.html</a><br>
><br>
> ./ex18 -sens_type aspin -snes_fd_color is okay;<br>
><br>
> ./ex18 -snes_type aspin crashes.<br>
><br>
> So there is something messed up in the function FormJacobian(SNES snes,Vec X,Mat jac,Mat jacpre,void *ptr).<br>
><br>
> If the analytical Jacobian is calculated and put into the matrix jac (like ex18.c), the program crash with the aspin option. However, if the same analytical Jacobian is put into jacpre (like ex20.c), it works fine with the aspin option.<br>
><br>
> In general, for the analytical Jacobian, should I put it into jac or jacpre in the FormJaciban() function?<br>
<br>
</span> Thanks for figuring this out; it is exactly the problem. When providing explicit Jacobian entries; either analytic or some approximation they should always be set in the second Mat argument the jacpre matrix, not in the first matrix argument. I have fixed ex18.c in the maint branch to use the second matrix argument and now the aspin type runs fine.<br>
<br>
The reason they should be set in the second argument is that in some circumstances including -snes_mf_operator and with aspin PC internally, in the PETSc solvers, we change the first mat argument to some other form that one cannot set values directly into such as a matrix-free operator or a shell operator.<br>
<br>
The reason ./ex18 -sens_type aspin -snes_fd_color is okay is because PETSc manages setting the matrix entries when doing the Jacobian with coloring and skips the user provided (in this case wrong) FormJacobian() function.</blockquote><div><br></div><div>Should we have an error check for J != P and J a Mat?</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>
> Thanks.<br>
><br>
> Best,<br>
> Xiangdong<br>
><br>
><br>
><br>
><br>
> On Mon, Jun 20, 2016 at 9:51 PM, Barry Smith <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br>
><br>
> Could you reproduce the error with a PETSc example or send us the code? If we can run a code that generates an error then we can debug it and maybe fix it. If we can't run something with the same error it is hard for us to fix it. We'd just be making wild guesses.<br>
><br>
> Barry<br>
><br>
> > On Jun 20, 2016, at 8:06 PM, Xiangdong <<a href="mailto:epscodes@gmail.com">epscodes@gmail.com</a>> wrote:<br>
> ><br>
> ><br>
> ><br>
> > On Mon, Jun 20, 2016 at 1:02 PM, Barry Smith <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br>
> ><br>
> > Are you providing a shell matrix to the solver?<br>
> ><br>
> > No. The matrix (global Jacobian) is setup by MatSetValuesStencil. It works for the standard newtonls as well as nasm preconditioner. I think the aspin will assemble the new Jacobian for me based on the information of old Jacobian.<br>
> ><br>
> > Do I need to provide something special to use the aspin?<br>
> ><br>
> > Thanks.<br>
> ><br>
> > Best,<br>
> > Xiangdong<br>
> ><br>
> > Barry<br>
> ><br>
> > > On Jun 20, 2016, at 11:32 AM, Xiangdong <<a href="mailto:epscodes@gmail.com">epscodes@gmail.com</a>> wrote:<br>
> > ><br>
> > > Hello everyone,<br>
> > ><br>
> > > I am trying different snes_type in petsc. The newtonls and nasm all works well. However, when I switched to aspin, I got the error like "No support for this operation for this object type" "Mat type shell". I am using the dmda 3d in petsc 3.6.3. The full error messages are below.<br>
> > ><br>
> > > Any hint for me to fix this? Thanks.<br>
> > ><br>
> > > Best,<br>
> > > Xiangdong<br>
> > ><br>
> > > [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<br>
> > > [0]PETSC ERROR: No support for this operation for this object type<br>
> > > [0]PETSC ERROR: Mat type shell<br>
> > > [0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" rel="noreferrer" target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.<br>
> > > [0]PETSC ERROR: Petsc Release Version 3.6.3, unknown<br>
> > > [0]PETSC ERROR: #1 MatZeroEntries() line 5404 in /home/shared/MyLocal_stor/petsc/petsc-dev/src/mat/interface/matrix.c<br>
> > > [0]PETSC ERROR: #2 FormJacobianLocal() line 37 in /home/MyCodes/epscprplus/Jacobian.c<br>
> > > [0]PETSC ERROR: #3 SNESComputeJacobian_DMDA() line 175 in /home/shared/MyLocal_stor/petsc/petsc-dev/src/snes/utils/dmdasnes.c<br>
> > > [0]PETSC ERROR: #4 SNESComputeJacobian() line 2232 in /home/shared/MyLocal_stor/petsc/petsc-dev/src/snes/interface/snes.c<br>
> > > [0]PETSC ERROR: #5 SNESNASMComputeFinalJacobian_Private() line 770 in /home/shared/MyLocal_stor/petsc/petsc-dev/src/snes/impls/nasm/nasm.c<br>
> > > [0]PETSC ERROR: #6 SNESSolve_NASM() line 888 in /home/shared/MyLocal_stor/petsc/petsc-dev/src/snes/impls/nasm/nasm.c<br>
> > > [0]PETSC ERROR: #7 SNESSolve() line 3906 in /home/shared/MyLocal_stor/petsc/petsc-dev/src/snes/interface/snes.c<br>
> > > [0]PETSC ERROR: #8 SNESApplyNPC() line 48 in /home/shared/MyLocal_stor/petsc/petsc-dev/src/snes/interface/snespc.c<br>
> > > [0]PETSC ERROR: #9 SNESSolve_NEWTONLS() line 173 in /home/shared/MyLocal_stor/petsc/petsc-dev/src/snes/impls/ls/ls.c<br>
> > > [0]PETSC ERROR: #10 SNESSolve() line 3906 in /home/shared/MyLocal_stor/petsc/petsc-dev/src/snes/interface/snes.c<br>
> > > [0]PETSC ERROR: #11 main() line 794 in /home/MyCodes/epscprplus/twophaseow.c<br>
> > ><br>
> ><br>
> ><br>
><br>
><br>
<br>
</div></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>