Commits

Jed Brown committed 248bfaf

PCBJacobi: call KSPSetFromOptions(subksp) when PCSetUp was called first

Prior to this patch, -mg_coarse_sub_pc_ options were never parsed when
using PCGAMG, which changes the coarse solver and calls
PCSetUp_BJacobi_Singleblock so that PCBJacobiGetSubKSP is available.

  • Participants
  • Parent commits 5b42dca

Comments (0)

Files changed (1)

File src/ksp/pc/impls/bjacobi/bjacobi.c

 {
   PC_BJacobi     *jac = (PC_BJacobi*)pc->data;
   PetscErrorCode ierr;
-  PetscInt       blocks;
+  PetscInt       blocks,i;
   PetscBool      flg;
 
   PetscFunctionBegin;
   if (flg) {
     ierr = PCBJacobiSetTotalBlocks(pc,blocks,NULL);CHKERRQ(ierr);
   }
+  if (jac->ksp) {
+    /* The sub-KSP has already been set up (e.g., PCSetUp_BJacobi_Singleblock), but KSPSetFromOptions was not called
+     * unless we had already been called. */
+    for (i=0; i<jac->n_local; i++) {
+      ierr = KSPSetFromOptions(jac->ksp[i]);CHKERRQ(ierr);
+    }
+  }
   ierr = PetscOptionsTail();CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }
     ierr = KSPSetOperators(ksp,pmat,pmat,pc->flag);CHKERRQ(ierr);
   }
   if (!wasSetup && pc->setfromoptionscalled) {
+    /* If PCSetFromOptions_BJacobi is called later, KSPSetFromOptions will be called at that time. */
     ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
   }
   PetscFunctionReturn(0);