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};

     15:   PetscInitialize(&argc,&args,NULL,help);
     16:   KSPCreate(PETSC_COMM_WORLD,&ksp);
     17:   for (i=0; i<3; i++) {
     18:     KSPSetType(ksp,common[i]);
     19:     KSPSetType(ksp,KSPHPDDM);
     20: #if defined(PETSC_HAVE_HPDDM)
     21:     KSPHPDDMGetType(ksp,&type);
     22:     PetscStrcmp(KSPHPDDMTypes[type],common[i],&flg);
     24:     KSPSetFromOptions(ksp);
     25:     KSPHPDDMGetType(ksp,&type);
     27:     KSPHPDDMSetType(ksp,KSP_HPDDM_TYPE_BGMRES);
     28: #endif
     29:   }
     30:   KSPDestroy(&ksp);
     31:   PetscFinalize();
     32:   return 0;
     33: }

     35: /*TEST

     37:    test:
     38:       requires: hpddm
     39:       nsize: 1
     40:       suffix: 1
     41:       output_file: output/ex77_preonly.out
     42:       args: -ksp_type hpddm -ksp_hpddm_type gcrodr

     44: TEST*/