Actual source code: ex78.c
1: #include <petsc.h>
3: static char help[] = "Exercises switching back and forth between different KSP and KSPHPDDM types.\n\n";
5: int main(int argc, char **args)
6: {
7: KSP ksp;
8: #if defined(PETSC_HAVE_HPDDM)
9: KSPHPDDMType type;
10: PetscBool flg;
11: #endif
12: PetscInt i;
13: const char *common[] = {KSPGMRES, KSPCG, KSPPREONLY};
16: PetscInitialize(&argc, &args, NULL, help);
17: KSPCreate(PETSC_COMM_WORLD, &ksp);
18: for (i = 0; i < 3; i++) {
19: KSPSetType(ksp, common[i]);
20: KSPSetType(ksp, KSPHPDDM);
21: #if defined(PETSC_HAVE_HPDDM)
22: KSPHPDDMGetType(ksp, &type);
23: PetscStrcmp(KSPHPDDMTypes[type], common[i], &flg);
25: KSPSetFromOptions(ksp);
26: KSPHPDDMGetType(ksp, &type);
28: KSPHPDDMSetType(ksp, KSP_HPDDM_TYPE_BGMRES);
29: #endif
30: }
31: KSPDestroy(&ksp);
32: PetscFinalize();
33: return 0;
34: }
36: /*TEST
38: test:
39: requires: hpddm
40: nsize: 1
41: suffix: 1
42: output_file: output/ex77_preonly.out
43: args: -ksp_type hpddm -ksp_hpddm_type gcrodr
45: TEST*/