[petsc-dev] About -pc_factor_levels

Barry Smith bsmith at mcs.anl.gov
Fri Mar 10 16:52:39 CST 2017


   What is happening here is that though the second call to KSPSetFromOptions() is changing the levels option in the PC object, since the KSPSetUp() was already called and built the preconditioned it does not build the preconditioner again based on the fact that the option was changed.

   Once KSPSetUp() is called it just returns immediately the next time unless the matrix hence changed; that is it doesn't look and see if any option is changed (and if so) rebuild the preconditioner.

    We never considered the use case below. To handle it would require keeping track of it an "option changed" to trigger the building of the preconditioner.

    I think you just need to live with this "feature"

   Barry



> On Mar 10, 2017, at 4:42 PM, Pierre Jolivet <pierre.jolivet at enseeiht.fr> wrote:
> 
> Hello,
> I don’t know if this is intended, but here is a small example that exhibits an odd behavior.
> 
> diff --git a/src/ksp/ksp/examples/tutorials/ex3.c b/src/ksp/ksp/examples/tutorials/ex3.c
> index b6e41f2..f1f8860 100644
> --- a/src/ksp/ksp/examples/tutorials/ex3.c
> +++ b/src/ksp/ksp/examples/tutorials/ex3.c
> @@ -139,6 +139,11 @@ int main(int argc,char **args)
>   ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
>   ierr = KSPSetInitialGuessNonzero(ksp,PETSC_TRUE);CHKERRQ(ierr);
>   ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
> +  ierr = KSPSetUp(ksp);CHKERRQ(ierr);
> +  char right_options[] = "-pc_factor_levels 26";
> +  PetscOptionsInsertString(NULL,right_options);
> +  ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
> +  ierr = KSPSetUp(ksp);CHKERRQ(ierr);
> 
> $ mpirun -np 1 ./ex3 -ksp_view -pc_type ilu -m 40
> [..]
>    26 levels of fill
> [..]
>          total: nonzeros=13849, allocated nonzeros=13849
> [..]
> Norm of error 6.69508e-06 Iterations 16
> 
> $ mpirun -np 1 ./ex3 -ksp_view -pc_type ilu -m 40 -pc_factor_levels 26
> [..]
>          total: nonzeros=115288, allocated nonzeros=115288
> [..]
> Norm of error 7.3575e-07 Iterations 2
> 
> Is this the expected behavior? I don’t mind setting the option -pc_factor_levels before any call to KSPSetUp, but it seems weird that the number of levels of fill is being changed for the output during -ksp_view.
> 
> Thanks,
> Pierre
> 
> 




More information about the petsc-dev mailing list