1. petsc
  2. PETSc
  3. petsc

Commits

BarryFSmith  committed 03ccd0b

fixed PCView_Redundant() so it will not crash if it is not yet setup
petsc-maint 43609

Hg-commit: 65606a034d3227abc104637fa2c8e2c8f2969f9c

  • Participants
  • Parent commits 0bc5a21
  • Branches master

Comments (0)

Files changed (1)

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

View file
  • Ignore whitespace
   PetscErrorCode ierr;
   PetscMPIInt    rank;
   PetscTruth     iascii,isstring;
-  PetscViewer    sviewer,subviewer;
-  PetscInt       color = red->psubcomm->color;
+  PetscViewer    subviewer;
 
   PetscFunctionBegin;
   ierr = MPI_Comm_rank(((PetscObject)pc)->comm,&rank);CHKERRQ(ierr);
   ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&iascii);CHKERRQ(ierr);
   ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_STRING,&isstring);CHKERRQ(ierr);
   if (iascii) {
-    ierr = PetscViewerASCIIPrintf(viewer,"  Redundant preconditioner: First (color=0) of %D PCs follows\n",red->nsubcomm);CHKERRQ(ierr);
-    ierr = PetscViewerGetSubcomm(viewer,((PetscObject)red->pc)->comm,&subviewer);CHKERRQ(ierr);
-    if (!color) { /* only view first redundant pc */
-      ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
-      ierr = KSPView(red->ksp,subviewer);CHKERRQ(ierr);
-      ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
+    if (!red->psubcomm) {
+      ierr = PetscViewerASCIIPrintf(viewer,"  Redundant preconditioner: Not yet setup\n");CHKERRQ(ierr);
+    } else {
+      ierr = PetscViewerASCIIPrintf(viewer,"  Redundant preconditioner: First (color=0) of %D PCs follows\n",red->nsubcomm);CHKERRQ(ierr);
+      ierr = PetscViewerGetSubcomm(viewer,((PetscObject)red->pc)->comm,&subviewer);CHKERRQ(ierr);
+      if (red->psubcomm->color) { /* only view first redundant pc */
+	ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
+	ierr = KSPView(red->ksp,subviewer);CHKERRQ(ierr);
+	ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
+      }
+      ierr = PetscViewerRestoreSubcomm(viewer,((PetscObject)red->pc)->comm,&subviewer);CHKERRQ(ierr);
     }
-    ierr = PetscViewerRestoreSubcomm(viewer,((PetscObject)red->pc)->comm,&subviewer);CHKERRQ(ierr);
-  } else if (isstring) { /* not test it yet! */
+  } else if (isstring) { 
     ierr = PetscViewerStringSPrintf(viewer," Redundant solver preconditioner");CHKERRQ(ierr);
-    ierr = PetscViewerGetSingleton(viewer,&sviewer);CHKERRQ(ierr);
-    if (!rank) {
-      ierr = KSPView(red->ksp,sviewer);CHKERRQ(ierr);
-    }
-    ierr = PetscViewerRestoreSingleton(viewer,&sviewer);CHKERRQ(ierr);
   } else {
     SETERRQ1(PETSC_ERR_SUP,"Viewer type %s not supported for PC redundant",((PetscObject)viewer)->type_name);
   }