Commits

BarryFSmith  committed b77cb7c

The KSPCreate() for TAO GPCG solver is now done at TaoCreate_GPCG() instead of TaoSetUp()
this allows users to change KSP options from the code easily and matches the style of other Tao solvers that use KSP

Reported by: Tianyi Li

  • Participants
  • Parent commits 54908dc

Comments (0)

Files changed (1)

File src/tao/bound/impls/gpcg/gpcg.c

   ierr = PetscOptionsHead("Gradient Projection, Conjugate Gradient method for bound constrained optimization");CHKERRQ(ierr);
   ierr=PetscOptionsInt("-tao_gpcg_maxpgits","maximum number of gradient projections per GPCG iterate",0,gpcg->maxgpits,&gpcg->maxgpits,&flg);CHKERRQ(ierr);
   ierr = PetscOptionsTail();CHKERRQ(ierr);
+  ierr = KSPSetFromOptions(tao->ksp);CHKERRQ(ierr);
   ierr = TaoLineSearchSetFromOptions(tao->linesearch);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }
   ierr=VecDuplicate(tao->solution,&gpcg->DXFree);CHKERRQ(ierr);
   ierr=VecDuplicate(tao->solution,&gpcg->R);CHKERRQ(ierr);
   ierr=VecDuplicate(tao->solution,&gpcg->PG);CHKERRQ(ierr);
-  ierr = KSPCreate(((PetscObject)tao)->comm, &tao->ksp);CHKERRQ(ierr);
-  ierr = KSPSetType(tao->ksp,KSPNASH);CHKERRQ(ierr);
-  ierr = KSPSetFromOptions(tao->ksp);CHKERRQ(ierr);
   /*
     if (gpcg->ksp_type == GPCG_KSP_NASH) {
         ierr = KSPSetType(tao->ksp,KSPNASH);CHKERRQ(ierr);
   gpcg->subset_type = TAO_SUBSET_MASK;
   /* gpcg->ksp_type = GPCG_KSP_STCG; */
 
+  ierr = KSPCreate(((PetscObject)tao)->comm, &tao->ksp);CHKERRQ(ierr);
+  ierr = KSPSetType(tao->ksp,KSPNASH);CHKERRQ(ierr);
+
   ierr = TaoLineSearchCreate(((PetscObject)tao)->comm, &tao->linesearch);CHKERRQ(ierr);
   ierr = TaoLineSearchSetType(tao->linesearch, TAOLINESEARCHGPCG);CHKERRQ(ierr);
   ierr = TaoLineSearchSetObjectiveAndGradientRoutine(tao->linesearch, GPCGObjectiveAndGradient, tao);CHKERRQ(ierr);