Hello, I am having convergence issues solving a nearly singular system using a KSP object with -pc_type lu. From the PETSc documentation, I understand that adding a nullspace constraint using MatNullSpace might help solve my issue. However, when I try to add such a constraint, I see no difference in the solver behavior with the additional MatNullSpace parameter added. Does anyone have any advice or an example code that uses this feature? The null vector in my case does not correspond to any simple solid body motion as in the other FreeFEM examples I’ve found here. I am using it as below:
Mat dA;
real[int,int] NSVec(dA.n,1);
real[int] q; // a known approximation of the nullspace
NSVec(:,0) = q;
set(dA, sparams = "...", MatNullSpace = NSVec);
preonly. You can read about a similar system in Govaertz 2000 Ch 4.1.2. Basically, it involves a (nonsingular) bordered block matrix consisting of a near-singular Jacobian matrix augmented by one additional row and column which resolve the singularity. In this case, the system is solved using Schur complement factorizations that exploit the matrix’s block structure, then an LU factorization of the large, sparse 00-block. No explicit inverses are ever needed.