[petsc-users] Null space correction depends on solver?

Thomas Witkowski thomas.witkowski at tu-dresden.de
Tue Aug 28 02:17:28 CDT 2012


Part II of my never ending null space story :) Now I solve Poisson 
equation in 3D, discretized with FEM and using free boundaries. In the 
PETSc solver part, I added some test to check whether the solution is 
still orthogonal to the constant nullspace. The result is somehow hard 
to explain. Maybe one of you could spend one minute to give me some 
explanation what's going wrong and how to fix it. First, some code snippet:

Vec rhs;
Mat mat;
....
Vec nsb;
VecDuplicate(rhs, &nsb);
VecSet(nsb, 1.0);

MatNullSpace matNullspace;
MatNullSpaceCreate(MPI::COMM_WORLD, PETSC_TRUE, 0, PETSC_NULL, 
&matNullspace);
MatNullSpaceRemove(matNullspace, rhs, PETSC_NULL);

PetscScalar dot;
VecDot(nsb, rhs, &dot);
MSG("TEST 1 = %e\n", dot);

KSP ksp;
KSPCreate(MPI::COMM_WORLD, &kspMat11);
KSPSetOperators(ksp, mat, mat, SAME_NONZERO_PATTERN);

MatSetNullSpace(mat, matNullspace);
KSPSetNullSpace(ksp, matNullspace);

KSPSolve(mat, rhs, rhs);

VecDot(nsb, rhs, &dot);
MSG("TEST 2 = %e\n", dot);


So, nothing really special. Now, I run the code with two different solvers:

1) -ksp_type fgmres -pc_type hypre -pc_hypre_type boomeramg 
-pc_hypre_boomeramg_relax_type_coarse Jacobi

                TEST 1 = 5.503931e-14
                TEST 2 = -2.043290e+10

2) -ksp_type gmres -pc_type none
                TEST 1 = 5.503931e-14
                TEST 2 = 3.195510e-09


How to interpret the results? For the first case, is the null space 
information forwarded to the preconditioner? And even for using just 
gmres without any preconditioner, the dot product is much closer to zero 
but still far away.

Thomas



More information about the petsc-users mailing list