[petsc-users] Setting GAMG options C code

Jose E. Roman jroman at dsic.upv.es
Tue Jul 4 07:48:02 CDT 2017


> El 4 jul 2017, a las 14:31, Harshad Sahasrabudhe <hsahasra at purdue.edu> escribió:
> 
> Hello,
> 
> I am using PCGAMG+KSPBCGS for shift and invert spectral transformation in SLEPc. I optimized the options that I need for GAMG using command line:
> 
> -st_ksp_type bcgs
> -st_pc_type gamg
> -st_pc_gamg_agg_nsmooths 1
> -st_mg_levels_ksp_type chebyshev 
> -st_mg_levels_pc_type jacobi 
> -st_mg_levels_ksp_max_it 8 
> -st_pc_gamg_threshold 0.01
> 
> How can I set these options inside my production code? Is okay to use PetscOptionsSetValue for setting the options as following?
> 
>           ierr = PetscOptionsSetValue(NULL, "-st_mg_levels_ksp_type", "chebyshev");
>           chkerr(ierr);
>           ierr = PetscOptionsSetValue(NULL, "-st_mg_levels_pc_type", "jacobi");
>           chkerr(ierr);
>           ierr = PetscOptionsSetValue(NULL, "-st_mg_levels_ksp_max_it", "8");
>           chkerr(ierr);
>           ierr = PetscOptionsSetValue(NULL, "-st_pc_gamg_threshold", "0.01");
>           chkerr(ierr);
> 
> Thanks!
> Harshad

It is better to set pass the options directly to the objects. For instance the following example calls EPSGetST(), STGetKSP(), KSPGetPC() to extract objects that are nested one inside the other:
http://slepc.upv.es/documentation/current/src/eps/examples/tutorials/ex12.c.html

Jose



More information about the petsc-users mailing list