Commits

Satish Balay committed 8f6ae3c Merge

Merge branch 'jed/fix-gamg-coarse' into maint

  • Participants
  • Parent commits a278d85, 248bfaf

Comments (0)

Files changed (2)

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

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

 #include "petsc-private/matimpl.h"
 #include <../src/ksp/pc/impls/gamg/gamg.h>           /*I "petscpc.h" I*/
 #include <petsc-private/kspimpl.h>
+#include <../src/ksp/pc/impls/bjacobi/bjacobi.h> /* Hack to access same_local_solves */
 
 #if defined PETSC_GAMG_USE_LOG
 PetscLogEvent petsc_gamg_setup_events[NUM_SET];
       ierr = PCSetType(pc2, PCLU);CHKERRQ(ierr);
       ierr = PCFactorSetShiftType(pc2,MAT_SHIFT_INBLOCKS);CHKERRQ(ierr);
       ierr = KSPSetTolerances(k2[0],PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT,1);CHKERRQ(ierr);
+      /* This flag gets reset by PCBJacobiGetSubKSP(), but our BJacobi really does the same algorithm everywhere (and in
+       * fact, all but one process will have zero dofs), so we reset the flag to avoid having PCView_BJacobi attempt to
+       * view every subdomain as though they were different. */
+      ((PC_BJacobi*)subpc->data)->same_local_solves = PETSC_TRUE;
     }
 
     /* should be called in PCSetFromOptions_GAMG(), but cannot be called prior to PCMGSetLevels() */