<div dir="ltr"><div>Thanks a lot, Matthew. Very helpful. <br></div><div><br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Xiaodong Liu, PhD<br>X: Computational Physics Division<br>Los Alamos National Laboratory<br>P.O. Box 1663, <br>Los Alamos, NM 87544<br>505-709-0534<br></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 4, 2020 at 2:53 AM Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>> wrote:<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 dir="ltr">On Tue, Mar 3, 2020 at 11:46 PM Jed Brown <<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Xiaodong Liu <<a href="mailto:xliu29@ncsu.edu" target="_blank">xliu29@ncsu.edu</a>> writes:<br>
<br>
> Thanks a lot. I am transferring a dense matrix from Julia to Petsc.<br>
> I will check this.<br>
> In addition, could you please show me where is<br>
><br>
> Where is the subroutine for the GMRES solver, namely,<br>
> ierr=(*KSP->ops->solve)(ksp);<br>
<br>
$ git grep KSPSolve_GMRES<br>
src/docs/tex/manual/developers.tex:\item Names of implementations of class functions should begin with the function name, an underscore, and the name of the implementation, for example, \lstinline{KSPSolve_GMRES()}.<br>
src/ksp/ksp/impls/gmres/gmres.c:PetscErrorCode KSPSolve_GMRES(KSP ksp)<br>
src/ksp/ksp/impls/gmres/gmres.c: ksp->ops->solve = KSPSolve_GMRES;<br><br></blockquote><div><br></div><div>Note that these implementation links are also at the bottom of the interface manpages:</div><div><br></div><div> <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPSolve.html" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPSolve.html</a></div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
><br>
> Xiaodong Liu, PhD<br>
> X: Computational Physics Division<br>
> Los Alamos National Laboratory<br>
> P.O. Box 1663,<br>
> Los Alamos, NM 87544<br>
> 505-709-0534<br>
><br>
><br>
> On Tue, Mar 3, 2020 at 8:21 PM Jed Brown <<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>> wrote:<br>
><br>
>> Is it possible that Julia is transferring the matrix to PETSc as a dense<br>
>> matrix (storing the nonzeros) instead of preserving sparsity? If you<br>
>> store the zeros, then ILU will be allowed to fill those entries, thereby<br>
>> becoming LU.<br>
>><br>
>> Xiaodong Liu <<a href="mailto:xliu29@ncsu.edu" target="_blank">xliu29@ncsu.edu</a>> writes:<br>
>><br>
>> > I am trying to use Julia to call Petsc.<br>
>> > 1) First, I run the built-in example ex2.c<br>
>> ><br>
>> <a href="https://www.mcs.anl.gov/petsc/petsc-current/src/ksp/pc/examples/tutorials/ex2.c.html" rel="noreferrer" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/src/ksp/pc/examples/tutorials/ex2.c.html</a><br>
>> ><br>
>> > For this case, I tried KSPGMRES , initial zero solution and different PC<br>
>> > (LU, ILU, ICC, JACOBI). And they work as expected.<br>
>> ><br>
>> > 75: KSPSetType(ksp,KSPGMRES);<br>
>> > 76: KSPSetInitialGuessNonzero(ksp,PETSC_FALSE);<br>
>> > 87: KSPGetPC(ksp,&pc);<br>
>> > 88: PCSetType(pc,PCICC);<br>
>> ><br>
>> > 2) Second, I tried to call KSP from Julia using the same matrix and right<br>
>> > hand side as ex2.c . A wrapper has been written to call Petsc code from<br>
>> > Julia. After I transfer matrix to from Julia to Petsc, I checked the<br>
>> matrix<br>
>> > and preconditioner matrix in the context of Petsc. These two matrices are<br>
>> > right. For no preconditioner,Jacobi precontioner and LU, the residual for<br>
>> > Julia version is same as that of original Petsc one for every iteration.<br>
>> > However, for ILU preconditioner, the residual for Julia is alwaysthe same<br>
>> > as the LU one. This is not expected. For both Julia and original Petsc<br>
>> > version, I checked the PC type inside the subroutine PCSetType and the<br>
>> > types are correct, namely ilu.I am trying to dig into the source code to<br>
>> > check how the preconditioner is interacting with GMRES.<br>
>> ><br>
>> > Where is the subroutine for the GMRES solver, namely,<br>
>> > ierr=(*KSP->ops->solve)(ksp);<br>
>> ><br>
>> > Or do you have any suggestions?<br>
>> ><br>
>> > Thanks,<br>
>> ><br>
>> > Xiaodong Liu, PhD<br>
>> > X: Computational Physics Division<br>
>> > Los Alamos National Laboratory<br>
>> > P.O. Box 1663,<br>
>> > Los Alamos, NM 87544<br>
>> > 505-709-0534<br>
>><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>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><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</blockquote></div>