[petsc-users] Problem with GAMG elasticity case:'createdefaultdata' not set(?) need to support NULL data!

Jed Brown jedbrown at mcs.anl.gov
Wed Oct 16 21:38:34 CDT 2013


"Mark F. Adams" <mfadams at lbl.gov> writes:
> I pushed a pull request to fix this.  You should not fail here but you
> should always use KSPSetFromOptions anyway.

Amended PR and merged to 'next'.

Mark, relative to your patch, I simplified setting and took out the
now-unnecessary logic in PCSetFromOptions_GAMG.

commit bd94a7aa4cff05a8b49c3b8be9fd5e557f431631
Author: Jed Brown <jedbrown at mcs.anl.gov>
Date:   Wed Oct 16 18:45:43 2013 -0400

    PCGAMG: set default type (AGG); PCSetUp_GAMG crashes if not set
    
    If PCSetFromOptions had not been called, PCSetUp_GAMG would crash due to
    missing subtype.  It is more conventional with top-level objects to use
    a lazy choice of type, but there is no great setup involved, and no
    known order-dependence, so it looks safe to simply set the type to the
    default value (AGG) up-front.
    
    Reported-by: Einar Sørheim <einar.sorheim at gmail.com>
    Based-on-patch-by: Mark Adams <mfadams at lbl.gov>

diff --git a/src/ksp/pc/impls/gamg/gamg.c b/src/ksp/pc/impls/gamg/gamg.c
index 39b3ac4..dadb0e2 100644
--- a/src/ksp/pc/impls/gamg/gamg.c
+++ b/src/ksp/pc/impls/gamg/gamg.c
@@ -1275,12 +1275,11 @@ PetscErrorCode PCSetFromOptions_GAMG(PC pc)
   {
     /* -pc_gamg_type */
     {
-      char tname[256] = PCGAMGAGG;
-      const char *deftype = pc_gamg->gamg_type_name ? pc_gamg->gamg_type_name : tname;
-      ierr = PetscOptionsList("-pc_gamg_type","Type of AMG method","PCGAMGSetType",GAMGList, tname, tname, sizeof(tname), &flag);CHKERRQ(ierr);
+      char tname[256];
+      ierr = PetscOptionsList("-pc_gamg_type","Type of AMG method","PCGAMGSetType",GAMGList, pc_gamg->gamg_type_name, tname, sizeof(tname), &flag);CHKERRQ(ierr);
       /* call PCCreateGAMG_XYZ */
-      if (flag || !pc_gamg->gamg_type_name) {
-        ierr = PCGAMGSetType(pc, flag ? tname : deftype);CHKERRQ(ierr);
+      if (flag) {
+        ierr = PCGAMGSetType(pc,tname);CHKERRQ(ierr);
       }
     }
     /* -pc_gamg_verbose */
@@ -1468,7 +1467,8 @@ PETSC_EXTERN PetscErrorCode PCCreate_GAMG(PC pc)
 #endif
   }
 #endif
-
+  /* PCSetUp_GAMG assumes that the type has been set, so set it to the default now */
+  ierr = PCGAMGSetType(pc,PCGAMGAGG);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20131016/1600440e/attachment.pgp>


More information about the petsc-users mailing list