Commits

Peter Brune committed c52e227

Better scoping for -snes_fd_color option to prevent odd side-effects

Getting the DM in SNESSetFromOptions broke FAS. As -snes_fd_color has no real use
in SNESFAS, SNESGetDM should only be called when needed in SNESSetFromOptions().

  • Participants
  • Parent commits 3fd6d45

Comments (0)

Files changed (1)

src/snes/interface/snes.c

 @*/
 PetscErrorCode  SNESSetFromOptions(SNES snes)
 {
-  DM             dm;
-  DMSNES         sdm;
   PetscBool      flg,pcset;
   PetscInt       i,indx,lag,grids;
   MatStructure   matflag;
 
   PetscFunctionBegin;
   PetscValidHeaderSpecific(snes,SNES_CLASSID,1);
-  ierr = SNESGetDM(snes,&dm);CHKERRQ(ierr);
   if (!SNESRegisterAllCalled) {ierr = SNESRegisterAll();CHKERRQ(ierr);}
   ierr = PetscObjectOptionsBegin((PetscObject)snes);CHKERRQ(ierr);
   if (((PetscObject)snes)->type_name) deft = ((PetscObject)snes)->type_name;
   flg  = PETSC_FALSE;
   ierr = PetscOptionsBool("-snes_fd_color","Use finite differences with coloring to compute Jacobian","SNESComputeJacobianDefaultColor",flg,&flg,NULL);CHKERRQ(ierr);
   if (flg) {
+    DM             dm;
+    DMSNES         sdm;
+    ierr = SNESGetDM(snes,&dm);CHKERRQ(ierr);
     ierr = DMGetDMSNES(dm,&sdm);CHKERRQ(ierr);
     sdm->jacobianctx = NULL;
     ierr = SNESSetJacobian(snes,snes->jacobian,snes->jacobian_pre,SNESComputeJacobianDefaultColor,0);CHKERRQ(ierr);