<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jun 22, 2015 at 6:02 PM, Stephan Kramer <span dir="ltr"><<a href="mailto:s.kramer@imperial.ac.uk" target="_blank">s.kramer@imperial.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
On Mon, Jun 22, 2015 at 1:13 PM, Stephan Kramer <s.kramer at <a href="http://imperial.ac.uk" rel="noreferrer" target="_blank">imperial.ac.uk</a>><br>
wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Dear petsc devs<br>
<br>
I've been trying to move our code from using KSPSetNullSpace to use<br>
MatSetNullSpace instead. Although I appreciate the convenience of the<br>
nullspace being propagated automatically through the solver hierarchy, I'm<br>
still a little confused on how to deal with the case that mat/=pmat in a<br>
ksp.<br>
<br>
If I read the code correctly I need to call MatSetNullSpace on the pmat in<br>
order for a ksp to project that nullspace out of the residual during the<br>
krylov iteration. However the nullspaces of mat and pmat are not<br>
necessarily the same. For instance, what should I do if the system that I<br>
want to solve has a nullspace (i.e. the `mat` has a null vector), but the<br>
preconditioner matrix does not.<br>
<br>
As an example of existing setups that we have for which this is the case:<br>
take a standard Stokes velocity, pressure system - where we want to solve<br>
for pressure through a Schur complement. Suppose the boundary conditions<br>
are Dirichlet for velocity on all boundaries, then the pressure equation<br>
has the standard, constant nullspace. A frequently used preconditioner is<br>
the "scaled pressure mass matrix" where G^T K^{-1} G is approximated by a<br>
pressure mass matrix that is scaled by the value of the viscosity. So in<br>
this case the actual system has a nullspace, but the preconditioner matrix<br>
does not.<br>
<br>
The way we previously used to solve this is by setting the nullspace on<br>
the ksp of the Schur system, where the mat comes from<br>
MatCreateSchurComplement and the pmat is the scaled mass matrix. We then<br>
set the pctype to PCKSP and do not set a nullspace on its associated ksp. I<br>
don't really see how I can do this using only MatSetNullSpace - unless I<br>
create a copy of the mass matrix and have one copy with and one copy<br>
without a nullspace so that I could use the one with the nullspace for the<br>
pmat of the Schur ksp (and thus the mat of the pcksp) and the copy without<br>
the nullspace as the pmat for the pcksp.<br>
<br>
We would very much appreciate some guidance on what the correct way to<br>
deal with this kind of situation is<br>
<br>
</blockquote>
<br></div></div><span class="">
I can understand that this is inconsistent (we have not really thought of a<br>
good way to make this consistent). However, does<br>
this produce the wrong results? If A has a null space, won't you get the<br>
same answer by attaching it to P, or am I missing the<br>
import of the above example?<br>
</span></blockquote>
<br>
Attaching the nullspace to P means it will be applied in the PCKSP solve as<br>
well - which in this case is just a mass matrix solve which doesn't<br>
have a nullspace. I was under the impression that removing a nullspace in a solve<br>
where the matrix doesn't having one, would lead to trouble - but I'm happy to<br>
be told wrong.<br></blockquote><div><br></div><div>I guess I was saying that this solve is only applied after a system with that null space,</div><div>so I did not think it would change the answer.</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">
Cheers<span class="HOEnZb"><font color="#888888"><br>
Stephan<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="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>