<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jun 30, 2015 at 3:10 PM, Sander Land <span dir="ltr"><<a href="mailto:sander.land@gmail.com" target="_blank">sander.land@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>This gives<br>[0]PETSC ERROR: Object is in wrong state<br>[0]PETSC ERROR: Matrix must be set first<br><br>The PC is from a SNESGetKSP, and I have called SNESSetJacobian before this.<br></div></div></blockquote><div><br></div><div>If this is embedded in a SNES, it is very messy to yank it out and do thing manually. However, if you</div><div>set the matrix in the PC manually, it might work.</div><div><br></div><div>However, I would encourage you to try an alternate scheme and see if you think it is easier. We have</div><div>started to use the DM object to hold this kind of information. For FieldSplit, I think it is easier to tell</div><div>a DMShell about your field division, and then have it pass this on to PCFIELDSPLIT. So you would</div><div><br></div><div>  a) Create a DMSHELL</div><div><br></div><div>  b) Create a PetscSection and call DMSetDefaultSection()</div><div><br></div><div>  c) Call SNESSetDM()</div><div><br></div><div>  d) use command line options to configure the split -pc_fieldsplit_0_fields 0 -pc_fieldsplit_1_fields 1</div><div><br></div><div>Then everything should work, and can work in any embedded context. Does this make sense?</div><div><br></div><div>  Thanks,</div><div><br></div><div>    Matt</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div></div><div>Thanks,<br></div>Sander<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 30, 2015 at 2:09 PM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@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_extra"><div class="gmail_quote"><div><div>On Tue, Jun 30, 2015 at 11:43 AM, Sander Land <span dir="ltr"><<a href="mailto:sander.land@gmail.com" target="_blank">sander.land@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>I am trying to use the Schur complement preconditioner in petsc, but am encountering a null argument error calling PCFieldSplitGetSubKSP.<br></div><div>This only happens on PC_COMPOSITE_SCHUR, the multiplicative/additive options do return a KSP array.<br></div><div><br></div>Error message:<br><div><br>[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<br>[0]PETSC ERROR: Null argument, when expecting valid pointer<br>[0]PETSC ERROR: Null Object: Parameter # 1<br>[0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.<br>[0]PETSC ERROR: Petsc Release Version 3.6.0, Jun, 09, 2015 <br>[0]PETSC ERROR: ./elecmech on a arch-linux2-cxx-debug<br>[0]PETSC ERROR: Configure options --with-shared-libraries=1 --with-debugging=1 --download-openmpi=1 --with-clanguage=c++ --download-fblaslapack=1 --download-scalapack=1 --download-blacs=1 --download-suitesparse=1 --download-pastix=1 --download-superlu=1 --dowload-essl=1 --download-ptscotch=1 --download-mumps=1 --download-lusol=1<br>[0]PETSC ERROR: #1 MatSchurComplementGetKSP() line 317 in petsc-3.6/src/ksp/ksp/utils/schurm.c<br>[0]PETSC ERROR: #2 PCFieldSplitGetSubKSP_FieldSplit_Schur() line 1264 in petsc-3.6/src/ksp/pc/impls/fieldsplit/fieldsplit.c<br>[0]PETSC ERROR: #3 PCFieldSplitGetSubKSP() line 1668 in petsc-3.6/src/ksp/pc/impls/fieldsplit/fieldsplit.c<br><br><div>Code snippet:<br></div><div><br>ISCreateGeneral(PETSC_COMM_SELF,xp_dofs,&ii[0],PETSC_COPY_VALUES,&is_xp);<br>ISCreateGeneral(PETSC_COMM_SELF,all_dofs - xp_dofs,&ii[xp_dofs],PETSC_COPY_VALUES,&is_wk);<br><br>PCSetType(pc,PCFIELDSPLIT);<br>PCFieldSplitSetType(pc,PC_COMPOSITE_SCHUR);<br>PCFieldSplitSetIS(pc,"xp",is_xp);<br>PCFieldSplitSetIS(pc,"wk",is_wk);<br>int n;<br>KSP* ksps; <br>PC   subpc;<br>PCFieldSplitGetSubKSP(pc,&n,&ksps);<br><br><br></div><div>ii here is simply an array with ii[i] = i. There is probably a better way to simply indicate two blocks of different size, but I couldn't find it.<br></div></div></div></blockquote><div><br></div></div></div><div>It looks like the PC is not setup. Can you try calling PCSetUp(pc) before GetSubKSP()?</div><div><br></div><div>  Thanks,</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></div><div>Thanks,<br></div><div>Sander<span><font color="#888888"><br></font></span></div></div></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br><br clear="all"><span><font color="#888888"><div><br></div>-- <br><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>
</font></span></font></span></div></div>
</blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><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></div>