Commits

Hong Zhang  committed 61d90d3

rename 'adapt_' back to 'est_' for Chebyshev; bugfix for option "-ksp_chebyshev_estimate_eigenvalues_radom" as reported by [petsc-maint #155733] petsc-dev: disappearing options prefix in kspchebyshev

Hg-commit: f633d63d3df398113de0afcb55d828823a1ad3c3

  • Participants
  • Parent commits e5a591f

Comments (0)

Files changed (4)

File src/ksp/ksp/examples/tests/makefile

 	   else echo ${PWD} ; echo "Possible problem with with ex39_2, diffs above \n========================================="; fi; \
 	   ${RM} -f ex39.tmp
 runex39_cheby_hybrid:
-	-@${MPIEXEC} -n 3 ./ex39 -beta -0.6 -ksp_type chebyshev -ksp_monitor_short -adapt_ksp_monitor_short -ksp_chebyshev_hybrid -ksp_chebyshev_hybrid_adaptsteps 5 -ksp_chebyshev_hybrid_chebysteps 6 -ksp_chebyshev_hybrid_purification > ex39.tmp 2>&1;\
+	-@${MPIEXEC} -n 3 ./ex39 -beta -0.6 -ksp_type chebyshev -ksp_monitor_short -est_ksp_monitor_short -ksp_chebyshev_hybrid -ksp_chebyshev_hybrid_eststeps 5 -ksp_chebyshev_hybrid_chebysteps 6 -ksp_chebyshev_hybrid_purification > ex39.tmp 2>&1;\
 	if (${DIFF} output/ex39_cheby_hybrid.out ex39.tmp) then true; \
 	   else echo ${PWD} ; echo "Possible problem with with ex39_cheby_hybrid, diffs above \n========================================="; fi; \
 	   ${RM} -f ex39.tmp
 runex39_fgmres_cheby_hybrid:
-	-@${MPIEXEC} -n 3 ./ex39 -beta -0.6 -ksp_type fgmres -pc_type ksp -ksp_ksp_type chebyshev -ksp_monitor_short -ksp_ksp_max_it 3 -ksp_ksp_chebyshev_hybrid -ksp_ksp_chebyshev_hybrid_chebysteps 2 -ksp_ksp_chebyshev_hybrid_adaptsteps 2 -ksp_ksp_norm_type none > ex39.tmp 2>&1;\
+	-@${MPIEXEC} -n 3 ./ex39 -beta -0.6 -ksp_type fgmres -pc_type ksp -ksp_ksp_type chebyshev -ksp_monitor_short -ksp_ksp_max_it 3 -ksp_ksp_chebyshev_hybrid -ksp_ksp_chebyshev_hybrid_chebysteps 2 -ksp_ksp_chebyshev_hybrid_eststeps 2 -ksp_ksp_norm_type none > ex39.tmp 2>&1;\
 	if (${DIFF} output/ex39_fgmres_cheby_hybrid.out ex39.tmp) then true; \
 	   else echo ${PWD} ; echo "Possible problem with with ex39_fgmres_cheby_hybrid, diffs above \n========================================="; fi; \
 	   ${RM} -f ex39.tmp

File src/ksp/ksp/examples/tutorials/makefile

            ${DIFF} output/ex2_chebyest_1.out ex2.tmp || echo ${PWD} "\nPossible problem with with ex2_chebyest_1, diffs above \n========================================="; \
            ${RM} -f ex2.tmp
 runex2_chebyest_2:
-	-@${MPIEXEC} -n 1 ./ex2 -m 80 -n 80 -ksp_pc_side right -pc_type ksp -ksp_ksp_type chebyshev -ksp_ksp_max_it 5 -ksp_ksp_chebyshev_estimate_eigenvalues 0.9,0,0,1.1 -ksp_adapt_ksp_type cg -ksp_monitor_short > ex2.tmp 2>&1; \
+	-@${MPIEXEC} -n 1 ./ex2 -m 80 -n 80 -ksp_pc_side right -pc_type ksp -ksp_ksp_type chebyshev -ksp_ksp_max_it 5 -ksp_ksp_chebyshev_estimate_eigenvalues 0.9,0,0,1.1 -ksp_est_ksp_type cg -ksp_monitor_short > ex2.tmp 2>&1; \
            ${DIFF} output/ex2_chebyest_2.out ex2.tmp || echo ${PWD} "\nPossible problem with with ex2_chebyest_2, diffs above \n========================================="; \
            ${RM} -f ex2.tmp
 runex2_chebyest_3:

File src/ksp/ksp/impls/cheby/cheby.c

   ierr = KSPSetWorkVecs(ksp,3);CHKERRQ(ierr);
   if (cheb->emin == 0. || cheb->emax == 0.) { /* We need to estimate eigenvalues */
     ierr = KSPChebyshevSetEstimateEigenvalues(ksp,PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE);CHKERRQ(ierr);
+    /* Enable runtime options for cheb->kspest: 
+       KSPChebyshevSetEstimateEigenvalues() creates cheb->kspest, but does not call KSPSetFromOptions(cheb->kspest)! */
+    ierr = KSPSetFromOptions(cheb->kspest);CHKERRQ(ierr);
   } else if (cheb->hybrid && !cheb->kspest) { /* We need to create cheb->kspest */
     PetscBool nonzero;
     ierr = KSPCreate(PetscObjectComm((PetscObject)ksp),&cheb->kspest);CHKERRQ(ierr);
     ierr = PetscObjectIncrementTabLevel((PetscObject)cheb->kspest,(PetscObject)ksp,1);CHKERRQ(ierr);
     ierr = KSPSetOptionsPrefix(cheb->kspest,((PetscObject)ksp)->prefix);CHKERRQ(ierr);
-    ierr = KSPAppendOptionsPrefix(cheb->kspest,"adapt_");CHKERRQ(ierr);
+    ierr = KSPAppendOptionsPrefix(cheb->kspest,"est_");CHKERRQ(ierr);
 
     ierr = KSPGetPC(cheb->kspest,&cheb->pcnone);CHKERRQ(ierr);
     ierr = PetscObjectReference((PetscObject)cheb->pcnone);CHKERRQ(ierr);
     /* Estimate with a fixed number of iterations */
     ierr = KSPSetConvergenceTest(cheb->kspest,KSPSkipConverged,0,0);CHKERRQ(ierr);
     ierr = KSPSetNormType(cheb->kspest,KSP_NORM_NONE);CHKERRQ(ierr);
-    ierr = KSPSetTolerances(cheb->kspest,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT,cheb->adaptsteps);CHKERRQ(ierr);
+    ierr = KSPSetTolerances(cheb->kspest,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT,cheb->eststeps);CHKERRQ(ierr);
 
     /* Enable runtime options for cheb->kspest */
     ierr = KSPSetFromOptions(cheb->kspest);CHKERRQ(ierr);
       ierr = KSPCreate(PetscObjectComm((PetscObject)ksp),&cheb->kspest);CHKERRQ(ierr);
       ierr = PetscObjectIncrementTabLevel((PetscObject)cheb->kspest,(PetscObject)ksp,1);CHKERRQ(ierr);
       ierr = KSPSetOptionsPrefix(cheb->kspest,((PetscObject)ksp)->prefix);CHKERRQ(ierr);
-      ierr = KSPAppendOptionsPrefix(cheb->kspest,"adapt_");CHKERRQ(ierr);
+      ierr = KSPAppendOptionsPrefix(cheb->kspest,"est_");CHKERRQ(ierr);
 
       ierr = KSPGetPC(cheb->kspest,&cheb->pcnone);CHKERRQ(ierr);
       ierr = PetscObjectReference((PetscObject)cheb->pcnone);CHKERRQ(ierr);
       /* Estimate with a fixed number of iterations */
       ierr = KSPSetConvergenceTest(cheb->kspest,KSPSkipConverged,0,0);CHKERRQ(ierr);
       ierr = KSPSetNormType(cheb->kspest,KSP_NORM_NONE);CHKERRQ(ierr);
-      ierr = KSPSetTolerances(cheb->kspest,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT,cheb->adaptsteps);CHKERRQ(ierr);
-
-      /* Enable runtime options for cheb->kspest */
-      ierr = KSPSetFromOptions(cheb->kspest);CHKERRQ(ierr);
+      ierr = KSPSetTolerances(cheb->kspest,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT,cheb->eststeps);CHKERRQ(ierr);
     }
     if (a >= 0) cheb->tform[0] = a;
     if (b >= 0) cheb->tform[1] = b;
    */
   ierr = PetscOptionsBool("-ksp_chebyshev_hybrid","Use hybrid Chebyshev","",cheb->hybrid,&cheb->hybrid,NULL);CHKERRQ(ierr);
   ierr = PetscOptionsInt("-ksp_chebyshev_hybrid_chebysteps","Number of Chebyshev steps in hybrid Chebyshev","",cheb->chebysteps,&cheb->chebysteps,NULL);CHKERRQ(ierr);
-  ierr = PetscOptionsInt("-ksp_chebyshev_hybrid_adaptsteps","Number of adaptive steps in hybrid Chebyshev","",cheb->adaptsteps,&cheb->adaptsteps,NULL);CHKERRQ(ierr);
+  ierr = PetscOptionsInt("-ksp_chebyshev_hybrid_eststeps","Number of adaptive/est steps in hybrid Chebyshev","",cheb->eststeps,&cheb->eststeps,NULL);CHKERRQ(ierr);
   ierr = PetscOptionsBool("-ksp_chebyshev_hybrid_purification","Use purification in hybrid Chebyshev","",cheb->purification,&cheb->purification,NULL);CHKERRQ(ierr);
 
   ierr = PetscOptionsRealArray("-ksp_chebyshev_eigenvalues","extreme eigenvalues","KSPChebyshevSetEigenvalues",&cheb->emin,&two,0);CHKERRQ(ierr);
     /* Mask the PC so that PCSetFromOptions does not do anything */
     ierr = KSPSetPC(cheb->kspest,cheb->pcnone);CHKERRQ(ierr);
     ierr = KSPSetOptionsPrefix(cheb->kspest,((PetscObject)ksp)->prefix);CHKERRQ(ierr);
-    ierr = KSPAppendOptionsPrefix(cheb->kspest,"adapt_");CHKERRQ(ierr);
+    ierr = KSPAppendOptionsPrefix(cheb->kspest,"est_");CHKERRQ(ierr);
     if (!((PetscObject)cheb->kspest)->type_name) {
       ierr = KSPSetType(cheb->kspest,KSPGMRES);CHKERRQ(ierr);
     }
     if (cheb->kspest) {
       ierr = PetscViewerASCIIPrintf(viewer,"  Chebyshev: estimated using:  [%G %G; %G %G]\n",cheb->tform[0],cheb->tform[1],cheb->tform[2],cheb->tform[3]);CHKERRQ(ierr);
       if (cheb->hybrid) { /* display info about hybrid options being used */
-        ierr = PetscViewerASCIIPrintf(viewer,"  Chebyshev: hybrid is used, adaptsteps %D, chebysteps %D, purification %D\n",cheb->adaptsteps,cheb->chebysteps,cheb->purification);CHKERRQ(ierr);
+        ierr = PetscViewerASCIIPrintf(viewer,"  Chebyshev: hybrid is used, eststeps %D, chebysteps %D, purification %D\n",cheb->eststeps,cheb->chebysteps,cheb->purification);CHKERRQ(ierr);
       }
       if (cheb->random) {
         ierr = PetscViewerASCIIPrintf(viewer,"  Chebyshev: estimating eigenvalues using random right hand side\n");CHKERRQ(ierr);
 
   chebyshevP->hybrid       = PETSC_FALSE;
   chebyshevP->chebysteps   = 20000;
-  chebyshevP->adaptsteps   = 10;
+  chebyshevP->eststeps     = 10;
   chebyshevP->its          = 0;
   chebyshevP->purification = PETSC_TRUE;
 

File src/ksp/ksp/impls/cheby/chebyshevimpl.h

   PetscBool estimate_current;
   PetscBool hybrid;       /* flag for using Hybrid Chebyshev */
   PetscInt  chebysteps;   /* number of Chebyshev steps in Hybrid Chebyshev */
-  PetscInt  adaptsteps;   /* number of adaptive steps in Hybrid Chebyshev */
+  PetscInt  eststeps;     /* number of adaptive/est steps in Hybrid Chebyshev */
   PetscInt  its;          /* total hybrid iterations, used to determine when toGMRES step in hybrid impl */
-  PetscBool purification; /* Hybrid method uses the GMRES adaptive steps to imporve the approximate solution */
+  PetscBool purification; /* Hybrid method uses the GMRES/adaptive/est steps to imporve the approximate solution */
   PetscRandom random;
 } KSP_Chebyshev;