<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>I understand that, but I'm trying to provide default behavior for the solver because the default one (no parameters) works very bad in my case.</div><div>However, I'm stuck because I can't set the same parameters that I obtain with command line arguments "-pc_type asm -sub_pc_type lu".</div><div><br></div><div>Can someone point me where is the error with the following code?</div><div><br></div><div>...</div><div>...</div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PetscInitialize(&amp;argc, &amp;argv,<span style="color: #8c225f">NULL</span>,<span style="color: #8c225f">NULL</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PetscErrorCode <span style="color: #4d8186">ierr</span> = MatCreate(PETSC_COMM_WORLD,&amp;A_);<span style="color: #794830">CHKERR</span>(<span style="color: #4d8186">ierr</span>);</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; min-height: 21.0px">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); "><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>// create linear solver context</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #4d8186">ierr</span> = KSPCreate(PETSC_COMM_WORLD,&amp;ksp_);<span style="color: #794830">CHKERR</span>(<span style="color: #4d8186">ierr</span>);</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; min-height: 21.0px">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); "><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>// initial nonzero guess</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #4d8186">ierr</span> = KSPSetInitialGuessNonzero(ksp_,PETSC_TRUE); <span style="color: #794830">CHKERR</span>(<span style="color: #4d8186">ierr</span>);</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; min-height: 21.0px">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); "><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>// set runtime options</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); "><span style="color: #000000">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #4d8186">ierr</span> = KSPSetFromOptions(ksp_);<span style="color: #794830">CHKERR</span>(<span style="color: #4d8186">ierr</span>);</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); "><span style="color: #000000"><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); "><span style="color: #000000">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span>// set the default preconditioner for this program to be ASM</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PC <span style="color: #4d8186">pc</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #4d8186">ierr</span> = KSPGetPC(ksp_,&amp;<span style="color: #4d8186">pc</span>); <span style="color: #794830">CHKERR</span>(<span style="color: #4d8186">ierr</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #4d8186">ierr</span> = PCSetType(<span style="color: #4d8186">pc</span>, PCASM); <span style="color: #794830">CHKERR</span>(<span style="color: #4d8186">ierr</span>);</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; min-height: 21.0px"><br></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); "><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; KSP&nbsp; &nbsp; &nbsp; &nbsp; *</span><span style="color: #4d8186">subksp</span><span style="color: #000000">; &nbsp; &nbsp; &nbsp; </span>/* array of KSP contexts for local subblocks */</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); "><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PetscInt &nbsp; </span><span style="color: #4d8186">nlocal</span><span style="color: #000000">,</span><span style="color: #4d8186">first</span><span style="color: #000000">;&nbsp; </span>/* number of local subblocks, first local subblock */</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PC &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #4d8186">subpc</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #267e3d">/* PC context for subblock */</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); "><span class="Apple-style-span" style="color: rgb(0, 0, 0); ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><span style="color: #267e3d">/*&nbsp;</span></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Call KSPSetUp() to set the block Jacobi data structures (including</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; creation of an internal KSP context for each block).</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #267e3d; min-height: 21.0px">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Note: KSPSetUp() MUST be called before PCASMGetSubKSP().</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #4d8186">ierr</span> = KSPSetUp(ksp_);<span style="color: #794830">CHKERR</span>(<span style="color: #4d8186">ierr</span>);</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; min-height: 21.0px">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #267e3d">/*</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Extract the array of KSP contexts for the local blocks</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #4d8186">ierr</span> = PCASMGetSubKSP(<span style="color: #4d8186">pc</span>,&amp;<span style="color: #4d8186">nlocal</span>,&amp;<span style="color: #4d8186">first</span>,&amp;<span style="color: #4d8186">subksp</span>);<span style="color: #794830">CHKERR</span>(<span style="color: #4d8186">ierr</span>);</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; min-height: 21.0px">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #267e3d">/*</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Loop over the local blocks, setting various KSP options</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for each block. &nbsp;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #8c225f">for</span> (<span style="color: #8c225f">int</span> <span style="color: #4d8186">i</span>=<span style="color: #063ff4">0</span>; <span style="color: #4d8186">i</span>&lt;<span style="color: #4d8186">nlocal</span>; <span style="color: #4d8186">i</span>++) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #4d8186">ierr</span> = KSPGetPC(<span style="color: #4d8186">subksp</span>[<span style="color: #4d8186">i</span>],&amp;<span style="color: #4d8186">subpc</span>);<span style="color: #794830">CHKERR</span>(<span style="color: #4d8186">ierr</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #4d8186">ierr</span> = PCSetType(<span style="color: #4d8186">subpc</span>,PCLU);<span style="color: #794830">CHKERR</span>(<span style="color: #4d8186">ierr</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 18px/normal Menlo; color: rgb(38, 126, 61); "><span class="Apple-style-span" style="color: rgb(0, 0, 0); ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</span></div></div><div><br></div><div>This is the error I get:</div><div><br></div><div><div><div>User explicitly sets subdomain solvers.</div><div>[0]PETSC ERROR: --------------------- Error Message ------------------------------------</div><div>[0]PETSC ERROR: Null argument, when expecting valid pointer!</div><div>[0]PETSC ERROR: Null Object: Parameter # 1!</div><div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: Petsc Release Version 3.1.0, Patch 7, Mon Dec 20 14:26:37 CST 2010</div><div>[0]PETSC ERROR: See docs/changes/index.html for recent updates.</div><div>[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.</div><div>[0]PETSC ERROR: See docs/index.html for manual pages.</div><div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: yafeq/a.out on a darwin10. named <a href="http://lsmspc26.epfl.ch">lsmspc26.epfl.ch</a> by aaragon Wed Apr 27 09:14:25 2011</div><div>[0]PETSC ERROR: Libraries linked from /Users/aaragon/Local/lib</div><div>[0]PETSC ERROR: Configure run at Thu Apr &nbsp;7 17:01:26 2011</div><div>[0]PETSC ERROR: Configure options --prefix=/Users/aaragon/Local --with-mpi-include=/Users/aaragon/Local/include --with-mpi-lib=/Users/aaragon/Local/lib/libmpich.a --with-superlu=1 --with-superlu-include=/Users/aaragon/Local/include/superlu --with-superlu-lib=/Users/aaragon/Local/lib/libsuperlu.a --with-superlu_dist=1 --with-superlu_dist-include=/Users/aaragon/Local/include/superlu_dist --with-superlu_dist-lib=/Users/aaragon/Local/lib/libsuperlu_dist.a --with-parmetis=1 --download-parmetis=ifneeded</div><div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: MatGetVecs() line 7265 in src/mat/interface/matrix.c</div><div>[0]PETSC ERROR: KSPGetVecs() line 806 in src/ksp/ksp/interface/iterativ.c</div><div>[0]PETSC ERROR: KSPSetUp_GMRES() line 94 in src/ksp/ksp/impls/gmres/gmres.c</div><div>[0]PETSC ERROR: KSPSetUp() line 199 in src/ksp/ksp/interface/itfunc.c</div><div>[0]PETSC ERROR: User provided function() line 397 in "unknowndirectory/"/Users/aaragon/Local/include/cpputils/solver.hpp</div><div>[0]PETSC ERROR: --------------------- Error Message ------------------------------------</div><div>[0]PETSC ERROR: Operation done in wrong order!</div><div>[0]PETSC ERROR: Need to call PCSetUP() on PC (or KSPSetUp() on the outer KSP object) before calling here!</div><div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: Petsc Release Version 3.1.0, Patch 7, Mon Dec 20 14:26:37 CST 2010</div><div>[0]PETSC ERROR: See docs/changes/index.html for recent updates.</div><div>[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.</div><div>[0]PETSC ERROR: See docs/index.html for manual pages.</div><div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: yafeq/a.out on a darwin10. named <a href="http://lsmspc26.epfl.ch">lsmspc26.epfl.ch</a> by aaragon Wed Apr 27 09:14:25 2011</div><div>[0]PETSC ERROR: Libraries linked from /Users/aaragon/Local/lib</div><div>[0]PETSC ERROR: Configure run at Thu Apr &nbsp;7 17:01:26 2011</div><div>[0]PETSC ERROR: Configure options --prefix=/Users/aaragon/Local --with-mpi-include=/Users/aaragon/Local/include --with-mpi-lib=/Users/aaragon/Local/lib/libmpich.a --with-superlu=1 --with-superlu-include=/Users/aaragon/Local/include/superlu --with-superlu-lib=/Users/aaragon/Local/lib/libsuperlu.a --with-superlu_dist=1 --with-superlu_dist-include=/Users/aaragon/Local/include/superlu_dist --with-superlu_dist-lib=/Users/aaragon/Local/lib/libsuperlu_dist.a --with-parmetis=1 --download-parmetis=ifneeded</div><div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: PCASMGetSubKSP_ASM() line 644 in src/ksp/pc/impls/asm/asm.c</div><div>[0]PETSC ERROR: PCASMGetSubKSP() line 926 in src/ksp/pc/impls/asm/asm.c</div><div>[0]PETSC ERROR: User provided function() line 402 in "unknowndirectory/"/Users/aaragon/Local/include/cpputils/solver.hpp</div><div>[0]PETSC ERROR: --------------------- Error Message ------------------------------------</div><div>[0]PETSC ERROR: Invalid argument!</div><div>[0]PETSC ERROR: Wrong type of object: Parameter # 1!</div><div>[0]PETSC ERROR: ------------------------------------------------------------------------</div><div>[0]PETSC ERROR: Petsc Release Version 3.1.0, Patch 7, Mon Dec 20 14:26:37 CST 2010</div></div></div><div><br></div><div>and the error continues...</div><div><br></div><br><div><div>On Apr 26, 2011, at 5:26 PM, Matthew Knepley wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">2011/4/26 Alejandro Marcos Aragón <span dir="ltr">&lt;<a href="mailto:alejandro.aragon@gmail.com">alejandro.aragon@gmail.com</a>&gt;</span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div style="word-wrap:break-word"><div>Thank you Barry, your suggestion really helped speed up the program. The maximum number of iterations is 48. I still don't know what the asm pre-conditioner is but I guess I just need to read the manual. I'm trying to add code to do what you suggested automatically, and I found that I can add:</div>
<div><br></div><div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;color:rgb(38, 126, 61)"><span style="color:rgb(0, 0, 0)">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PC <span style="color:#4d8186">pc</span>;</span></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#4d8186">ierr</span> = KSPGetPC(ksp_,&amp;<span style="color:#4d8186">pc</span>); <span style="color:#794830">CHKERR</span>(<span style="color:#4d8186">ierr</span>);</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#4d8186">ierr</span> = PCSetType(<span style="color:#4d8186">pc</span>, PCASM); <span style="color:#794830">CHKERR</span>(<span style="color:#4d8186">ierr</span>);</div>
</div><div><br></div><div>However, I cannot find the function to replace the -sub_pc_type. Can you point me where to look? My system may not be symmetric so I can't use the cg option.</div></div></blockquote><div><br>
</div><div>1) Hard coding it in your program does not make sense. You gain nothing, and lose a lot of flexibility.</div><div><br></div><div>2) You can do this using</div><div><br></div><div>&nbsp;&nbsp;<a href="http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/PC/PCASMGetSubKSP.html">http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/PC/PCASMGetSubKSP.html</a></div>
<div><br></div><div>&nbsp;&nbsp; &nbsp;Matt</div><div>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word"><div>Thanks again for your response.</div>
<div><br></div><div>a˛</div><div><br></div><br><div><div>On Apr 26, 2011, at 2:23 PM, Barry Smith wrote:</div><br><blockquote type="cite"><div><br><blockquote type="cite">System solved in 3664 iterations... 42.683 s<br></blockquote>
<br> &nbsp;&nbsp;The preconditioner is simply not up to the task it has been assigned. &nbsp;This number of iterations is problematic.<br><br> &nbsp;&nbsp;&nbsp;Have you tried -pc_type asm -sub_pc_type lu &nbsp;&nbsp;&nbsp;&nbsp;If that works well you can try -pc_type asm -sub_pc_type ilu and see if that still works. &nbsp;<br>
<br> &nbsp;&nbsp;If the matrix is indeed symmetric positive definite you will want to use -ksp_type cg<br><br><br><br> &nbsp;&nbsp;&nbsp;Barry<br><br><br>On Apr 26, 2011, at 1:37 AM, Alejandro Marcos Aragón wrote:<br><br><blockquote type="cite">Hi all,<br>
</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I'm using the standard configuration of the KSP solver, but the time it takes to solve a large system of equations is increasing (because of the increasing number of iterations?). These are my timing lines and the log from the KSP solver in two consecutive solves:<br>
</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">[1] &nbsp;&nbsp;Solving system... 0.154203 s<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">KSP Object:<br></blockquote>
<blockquote type="cite"> type: gmres<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;GMRES: restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement<br></blockquote><blockquote type="cite">
 &nbsp;&nbsp;GMRES: happy breakdown tolerance 1e-30<br></blockquote><blockquote type="cite"> maximum iterations=10000<br></blockquote><blockquote type="cite"> tolerances: &nbsp;relative=1e-05, absolute=1e-50, divergence=10000<br></blockquote>
<blockquote type="cite"> left preconditioning<br></blockquote><blockquote type="cite"> using nonzero initial guess<br></blockquote><blockquote type="cite"> using PRECONDITIONED norm type for convergence test<br></blockquote>
<blockquote type="cite">PC Object:<br></blockquote><blockquote type="cite"> type: bjacobi<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;block Jacobi: number of blocks = 3<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;Local solve is same for all blocks, in the following KSP and PC objects:<br>
</blockquote><blockquote type="cite"> KSP Object:(sub_)<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;type: preonly<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;maximum iterations=10000, initial guess is zero<br></blockquote><blockquote type="cite">
 &nbsp;&nbsp;tolerances: &nbsp;relative=1e-05, absolute=1e-50, divergence=10000<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;left preconditioning<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;using PRECONDITIONED norm type for convergence test<br>
</blockquote><blockquote type="cite"> PC Object:(sub_)<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;type: ilu<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;ILU: out-of-place factorization<br></blockquote><blockquote type="cite">
 &nbsp;&nbsp;&nbsp;&nbsp;0 levels of fill<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;tolerance for zero pivot 1e-12<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;using diagonal shift to prevent zero pivot<br></blockquote><blockquote type="cite">
 &nbsp;&nbsp;&nbsp;&nbsp;matrix ordering: natural<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;factor fill ratio given 1, needed 1<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Factored matrix follows:<br></blockquote><blockquote type="cite">
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Matrix Object:<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type=seqaij, rows=2020, cols=2020<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;package used to perform factorization: petsc<br></blockquote>
<blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;total: nonzeros=119396, allocated nonzeros=163620<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;using I-node routines: found 676 nodes, limit used is 5<br></blockquote><blockquote type="cite">
 &nbsp;&nbsp;linear system matrix = precond matrix:<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;Matrix Object:<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;type=seqaij, rows=2020, cols=2020<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;total: nonzeros=119396, allocated nonzeros=163620<br>
</blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;using I-node routines: found 676 nodes, limit used is 5<br></blockquote><blockquote type="cite"> linear system matrix = precond matrix:<br></blockquote><blockquote type="cite"> Matrix Object:<br>
</blockquote><blockquote type="cite"> &nbsp;&nbsp;type=mpiaij, rows=6058, cols=6058<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;total: nonzeros=365026, allocated nonzeros=509941<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;using I-node (on process 0) routines: found 676 nodes, limit used is 5<br>
</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">[1] &nbsp;&nbsp;System solved in 51 iterations... 0.543215 s<br></blockquote><blockquote type="cite">...<br></blockquote>
<blockquote type="cite">...<br></blockquote><blockquote type="cite">...<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">[1] &nbsp;&nbsp;Solving system... 0.302414 s<br></blockquote><blockquote type="cite">
<br></blockquote><blockquote type="cite">KSP Object:<br></blockquote><blockquote type="cite"> type: gmres<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;GMRES: restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement<br>
</blockquote><blockquote type="cite"> &nbsp;&nbsp;GMRES: happy breakdown tolerance 1e-30<br></blockquote><blockquote type="cite"> maximum iterations=10000<br></blockquote><blockquote type="cite"> tolerances: &nbsp;relative=1e-05, absolute=1e-50, divergence=10000<br>
</blockquote><blockquote type="cite"> left preconditioning<br></blockquote><blockquote type="cite"> using nonzero initial guess<br></blockquote><blockquote type="cite"> using PRECONDITIONED norm type for convergence test<br>
</blockquote><blockquote type="cite">PC Object:<br></blockquote><blockquote type="cite"> type: bjacobi<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;block Jacobi: number of blocks = 3<br></blockquote><blockquote type="cite">
 &nbsp;&nbsp;Local solve is same for all blocks, in the following KSP and PC objects:<br></blockquote><blockquote type="cite"> KSP Object:(sub_)<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;type: preonly<br></blockquote><blockquote type="cite">
 &nbsp;&nbsp;maximum iterations=10000, initial guess is zero<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;tolerances: &nbsp;relative=1e-05, absolute=1e-50, divergence=10000<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;left preconditioning<br>
</blockquote><blockquote type="cite"> &nbsp;&nbsp;using PRECONDITIONED norm type for convergence test<br></blockquote><blockquote type="cite"> PC Object:(sub_)<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;type: ilu<br></blockquote><blockquote type="cite">
 &nbsp;&nbsp;&nbsp;&nbsp;ILU: out-of-place factorization<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;0 levels of fill<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;tolerance for zero pivot 1e-12<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;using diagonal shift to prevent zero pivot<br>
</blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;matrix ordering: natural<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;factor fill ratio given 1, needed 1<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Factored matrix follows:<br>
</blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Matrix Object:<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type=seqaij, rows=2020, cols=2020<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;package used to perform factorization: petsc<br>
</blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;total: nonzeros=119396, allocated nonzeros=163620<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;using I-node routines: found 676 nodes, limit used is 5<br></blockquote>
<blockquote type="cite"> &nbsp;&nbsp;linear system matrix = precond matrix:<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;Matrix Object:<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;type=seqaij, rows=2020, cols=2020<br></blockquote><blockquote type="cite">
 &nbsp;&nbsp;&nbsp;&nbsp;total: nonzeros=119396, allocated nonzeros=163620<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;using I-node routines: found 676 nodes, limit used is 5<br></blockquote><blockquote type="cite"> linear system matrix = precond matrix:<br>
</blockquote><blockquote type="cite"> Matrix Object:<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;type=mpiaij, rows=6058, cols=6058<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;total: nonzeros=365026, allocated nonzeros=509941<br>
</blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;using I-node (on process 0) routines: found 676 nodes, limit used is 5<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">[1] &nbsp;&nbsp;System solved in 3664 iterations... 42.683 s<br>
</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">As you can see, the second iteration takes more than 40 seconds to solve. Could some explain why this is happening and why he number of iterations is increasing dramatically between solves? Thank you all,<br>
</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Alejandro M. Aragón, Ph.D.<br></blockquote><br></div></blockquote></div><br></div></blockquote></div><br><br clear="all"><br>-- <br>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<br>
</blockquote></div><br></body></html>