[petsc-users] FETI-DP implementation and call sequence

Satish Balay balay at mcs.anl.gov
Fri Sep 5 22:22:43 CDT 2014


On Fri, 5 Sep 2014, Jed Brown wrote:

> Satish Balay <balay at mcs.anl.gov> writes:
> 
> > Ok - looks like this error check in
> > ISLocalToGlobalMappingRestoreBlockInfo() was added a couple of days
> > back.
> >
> >>>>
> > https://bitbucket.org/petsc/petsc/commits/cbc1caf078fb2bf42b82e0b5ac811b1101900405
> >   PetscValidHeaderSpecific(mapping,IS_LTOGM_CLASSID,1);
> > <<<
> >
> >  This is breaking PCISDestroy() - which is attempting to pass in a null for 'mapping'
> >
> >>>>>>>
> >   if (pcis->ISLocalToGlobalMappingGetInfoWasCalled) {
> >     ierr = ISLocalToGlobalMappingRestoreInfo((ISLocalToGlobalMapping)0,&(pcis->n_neigh),&(pcis->neigh),&(pcis->n_shared),&(pcis->shared));CHKERRQ(ierr);
> 
> Yuck.
> 
> >   }
> > <<<<<<
> >
> > Commenting out the error check gets the code working.
> 
> I consider the error check to be correct; the code using it needs to be fixed.

Perhaps the following is the fix [with proper comments, more error
checks?]. But someone more familiar with this code should check this..

Satish

--------------
$ git diff |cat
diff --git a/src/ksp/pc/impls/is/pcis.c b/src/ksp/pc/impls/is/pcis.c
index dab5836..0fa0217 100644
--- a/src/ksp/pc/impls/is/pcis.c
+++ b/src/ksp/pc/impls/is/pcis.c
@@ -140,6 +140,8 @@ PetscErrorCode  PCISSetUp(PC pc)
   ierr = PetscObjectTypeCompare((PetscObject)pc->pmat,MATIS,&flg);CHKERRQ(ierr);
   if (!flg) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_ARG_WRONG,"Preconditioner type of Neumann Neumman requires matrix of type MATIS");
   matis = (Mat_IS*)pc->pmat->data;
+  PetscObjectReference((PetscObject)pc->pmat);
+  pcis->pmat = pc->pmat;
 
   pcis->pure_neumann = matis->pure_neumann;
 
@@ -378,8 +380,9 @@ PetscErrorCode  PCISDestroy(PC pc)
   ierr = VecScatterDestroy(&pcis->global_to_B);CHKERRQ(ierr);
   ierr = PetscFree(pcis->work_N);CHKERRQ(ierr);
   if (pcis->ISLocalToGlobalMappingGetInfoWasCalled) {
-    ierr = ISLocalToGlobalMappingRestoreInfo((ISLocalToGlobalMapping)0,&(pcis->n_neigh),&(pcis->neigh),&(pcis->n_shared),&(pcis->shared));CHKERRQ(ierr);
+    ierr = ISLocalToGlobalMappingRestoreInfo(((Mat_IS*)pcis->pmat->data)->mapping,&(pcis->n_neigh),&(pcis->neigh),&(pcis->n_shared),&(pcis->shared));CHKERRQ(ierr);
   }
+  ierr = MatDestroy(&pcis->pmat);CHKERRQ(ierr);
   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCISSetUseStiffnessScaling_C",NULL);CHKERRQ(ierr);
   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCISSetSubdomainScalingFactor_C",NULL);CHKERRQ(ierr);
   ierr = PetscObjectComposeFunction((PetscObject)pc,"PCISSetSubdomainDiagonalScaling_C",NULL);CHKERRQ(ierr);
diff --git a/src/ksp/pc/impls/is/pcis.h b/src/ksp/pc/impls/is/pcis.h
index 4a42cf9..736ea8c 100644
--- a/src/ksp/pc/impls/is/pcis.h
+++ b/src/ksp/pc/impls/is/pcis.h
@@ -73,6 +73,7 @@ typedef struct {
   /* We need:                                                                                 */
   /* proc[k].loc_to_glob(proc[k].shared[i][m]) == proc[l].loc_to_glob(proc[l].shared[j][m])   */
   /* for all 0 <= m < proc[k].n_shared[i], or equiv'ly, for all 0 <= m < proc[l].n_shared[j]  */
+  Mat pmat;
 } PC_IS;
 
 PETSC_EXTERN PetscErrorCode PCISSetUp(PC pc);


More information about the petsc-users mailing list