<div dir="ltr"><div><div><div>Hi,<br><br></div>I am a little confused about the statement in KSPSateOperators.<br><br><br><pre>        <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSP.html#KSP">KSP</a>/<a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCGetOperators.html#PCGetOperators">PCGetOperators</a>(ksp/pc,&mat,&pmat); is equivalent to
</pre>
<pre>          set size, type, etc of mat and pmat
</pre>
<p>
</p><pre>        <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreate.html#MatCreate">MatCreate</a>(comm,&mat);
</pre>
<pre>        <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreate.html#MatCreate">MatCreate</a>(comm,&pmat);
</pre>
<pre>        <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSP.html#KSP">KSP</a>/<a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCSetOperators.html#PCSetOperators">PCSetOperators</a>(ksp/pc,mat,pmat);
</pre>
<pre>        <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscObjectDereference.html#PetscObjectDereference">PetscObjectDereference</a>((<a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</a>)mat);
</pre>
<pre>        <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscObjectDereference.html#PetscObjectDereference">PetscObjectDereference</a>((<a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</a>)pmat);
</pre>
<pre>          set size, type, etc of mat and pmat
</pre><br><br></div>In my case I want to construct preconditioner from P which will be assembled differently from A.<br></div><br>So I only need to do <br>KSPSetOperators(ksp, A, P);<br clear="all"><div><div><div><div>after A & P are created.<br><br></div><div>or do I need to also do <br></div><div>PCSetOperators(pc, A, P);<br></div><div>as well?<br><br></div><div>and what are those <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscObjectDereference.html#PetscObjectDereference">PetscObjectDereference</a> about?<br><br></div><div>I have tried doing only <br></div><div></div><div>KSPSetOperators(ksp, A, P);<br><br></div><div>and I saw the performance of linear solver changed and I got right answer but I am not sure is if it was doing the thing I think it was doing.<br><br></div><div>And is it anyway to know if it is doing what I am asking?<br><br></div><div>Thanks,<br><br></div><div>Kan<br></div><div>-- <br><div class="gmail_signature"><p><b>Cheers</b></p></div>
</div></div></div></div></div>