[petsc-users] move from KSPSetNullSpace to MatSetNullSpace
Stephan Kramer
s.kramer at imperial.ac.uk
Mon Jun 22 18:02:27 CDT 2015
> On Mon, Jun 22, 2015 at 1:13 PM, Stephan Kramer <s.kramer at imperial.ac.uk>
> wrote:
>
>> Dear petsc devs
>>
>> I've been trying to move our code from using KSPSetNullSpace to use
>> MatSetNullSpace instead. Although I appreciate the convenience of the
>> nullspace being propagated automatically through the solver hierarchy, I'm
>> still a little confused on how to deal with the case that mat/=pmat in a
>> ksp.
>>
>> If I read the code correctly I need to call MatSetNullSpace on the pmat in
>> order for a ksp to project that nullspace out of the residual during the
>> krylov iteration. However the nullspaces of mat and pmat are not
>> necessarily the same. For instance, what should I do if the system that I
>> want to solve has a nullspace (i.e. the `mat` has a null vector), but the
>> preconditioner matrix does not.
>>
>> As an example of existing setups that we have for which this is the case:
>> take a standard Stokes velocity, pressure system - where we want to solve
>> for pressure through a Schur complement. Suppose the boundary conditions
>> are Dirichlet for velocity on all boundaries, then the pressure equation
>> has the standard, constant nullspace. A frequently used preconditioner is
>> the "scaled pressure mass matrix" where G^T K^{-1} G is approximated by a
>> pressure mass matrix that is scaled by the value of the viscosity. So in
>> this case the actual system has a nullspace, but the preconditioner matrix
>> does not.
>>
>> The way we previously used to solve this is by setting the nullspace on
>> the ksp of the Schur system, where the mat comes from
>> MatCreateSchurComplement and the pmat is the scaled mass matrix. We then
>> set the pctype to PCKSP and do not set a nullspace on its associated ksp. I
>> don't really see how I can do this using only MatSetNullSpace - unless I
>> create a copy of the mass matrix and have one copy with and one copy
>> without a nullspace so that I could use the one with the nullspace for the
>> pmat of the Schur ksp (and thus the mat of the pcksp) and the copy without
>> the nullspace as the pmat for the pcksp.
>>
>> We would very much appreciate some guidance on what the correct way to
>> deal with this kind of situation is
>>
>
> I can understand that this is inconsistent (we have not really thought of a
> good way to make this consistent). However, does
> this produce the wrong results? If A has a null space, won't you get the
> same answer by attaching it to P, or am I missing the
> import of the above example?
Attaching the nullspace to P means it will be applied in the PCKSP solve as
well - which in this case is just a mass matrix solve which doesn't
have a nullspace. I was under the impression that removing a nullspace in a solve
where the matrix doesn't having one, would lead to trouble - but I'm happy to
be told wrong.
Cheers
Stephan
More information about the petsc-users
mailing list