[petsc-users] Solving Singular Systems

Barry Smith bsmith at mcs.anl.gov
Fri May 29 13:47:27 CDT 2015


> On May 29, 2015, at 1:33 PM, Young, Matthew, Adam <may at bu.edu> wrote:
> 
> I have an elliptic PDE of the form Div[n(x) T Grad(phi)]=f(n,...) subject to periodic BC. (phi is the electrostatic potential in a PIC/fluid model). I expect there to be a constant null space but I'm not sure I'm dealing with it properly. 
> 
> 1) Section 4.6 of the manual suggests MatNullSpaceCreate() followed by KSPSetNullSpace(), but I have also seen examples that use MatSetNullSpace(). Is one preferred over the other?

   MatSetNullSpace() is preferred. We are deprecating the KSP version.

> 2) Should I follow XXXSetNullSpace() with MatNullSpaceRemove() on the RHS Vec?

   This will make your linear system consistent so you should probably do it. 

> 3) Do I need to MatNullSpaceDestroy() for either XXXSetNullSpace() option?

   Yes, otherwise you will have a memory leak.
> 4) If so, should the destruction happen after KSPSolve()?

   It doesn't matter when since PETSc does reference counting.


> 5) The manual (same section) says "You can run with the additional options -pc_factor_shift_nonzero <dampingfactor> or -pc_factor_shift_nonzero <dampingfactor> to prevent a zero pivot." This seems like a typo.

   Thanks, looks like it is fixed in the development copy.

   In our next release is a new function MatSetTransposeNullSpace() if you call that also then KSPSolve() will use it to automatically remove from the right hand side the inconsistent part so you do not need to call the MatNullSpaceRemove your self.


> 
> I believe I've done my due Google diligence, but I'm happy to be pointed elsewhere if these questions have come up before.
> 
> --A Different Matt
> 
> --------------------------------------------------------------
> Matthew Young
> Graduate Student
> Boston University Dept. of Astronomy
> --------------------------------------------------------------



More information about the petsc-users mailing list