A question regarding KSP options

Hello, I want to ask a question regarding the KSP options. I’m solving some simulatios with the following setting:

la::petsc::options::set("ksp_type", "preonly");
la::petsc::options::set("pc_type", "lu");

The problem is that my model is 3D, so the mass matrix is heavy to invert, which make it very slow. Then I have modified it into

la::petsc::options::set("pc_type", "hypre");

and the computation is accelerated a lot, but the issue is that the results are not accurate (I know the analytical solution and the difference is observed). So I thought it might be some issue with the tolerance, then I add the following command:

la::petsc::options::set("ksp_rtol", 1e-10);

but it doesn’t change anything.
I’m not sure that I change the tolerance in the correct way, because it does not report error even if I set any options that doesn’t exist:

la::petsc::options::set("hahaha", 1e-10);

So I wonder that what is correct name of the parameter that is related to the tolerance? Could anyone give me some suggestions, what could be reasonable KSP settings? (I solve some 3D PDE using explicite schme, so the LHS is the mass matrix.) Thanks!

la::petsc::options is a lightweight wrapper surrounding PetscOptionsSetValue: dolfinx/cpp/dolfinx/la/petsc.h at v0.7.3 · FEniCS/dolfinx · GitHub so it is up to petsc to catch the error.

I do for instance not have any issues setting the value when I do:

    la::petsc::options::set("ksp_type", "cg");
    la::petsc::options::set("pc_type", "hypre");
    la::petsc::options::set("ksp_rtol", "5.3e-12");
    la::petsc::options::set("ksp_view", "");

in the biharmonic C++ demo.
Note that if you use ksp_type “preonly”, the tolerances for the ksp will be ignored, please use “cg” or “gmres” as your ksp type.

2 Likes