[petsc-users] Null space correction depends on solver?
Barry Smith
bsmith at mcs.anl.gov
Tue Aug 28 08:19:02 CDT 2012
> 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.
Are you sure the null space you provide is truly the null space of the matrix? Call MatNullSpaceTest().
GMRES uses left preconditioning by default which forces the null space into the Krylov space at each iteration. FGMRES uses right preconditioning and doesn't do anything to the null space because it is naturally in the Krylov space (since the result with fgmres contains the constants this is why I suspect the matrix actually doesn't have the null space you think it has). You can try running -ksp_type gmres -ksp_pc_side right my guess is that you will not get near zero for the dot.
Barry
On Aug 28, 2012, at 2:17 AM, Thomas Witkowski <thomas.witkowski at tu-dresden.de> wrote:
> 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