1. petsc
  2. PETSc
  3. petsc

Commits

Peter Brune  committed 724f369

SNESASPIN: Fix for the case of zero iterations

In the case where the absolute tolerance is satisfied in the
first subSNES step, the operators are never set on the subKSP,
leading to an error in the outer KSP iteration. For the sake of
generality, have the ASPIN Jacobian call KSPSolve() instead of
PCApply() when multiplying.

  • Participants
  • Parent commits a4a39e5
  • Branches master

Comments (0)

Files changed (1)

File src/snes/impls/nasm/aspin.c

View file
  • Ignore whitespace
   PetscBool      match;
   MPI_Comm       comm;
   KSP            ksp;
-  PC             pc;
   Vec            *x,*b;
   Vec            W;
   SNES           npc;
+  Mat            subJ,subpJ;
 
   PetscFunctionBegin;
   ierr = MatShellGetContext(m,&ctx);CHKERRQ(ierr);
   for (i=0;i<n;i++) {
     ierr = VecScatterEnd(oscatter[i],W,b[i],INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
     ierr = VecSet(x[i],0.);CHKERRQ(ierr);
+    ierr = SNESGetJacobian(subsnes[i],&subJ,&subpJ,NULL,NULL);CHKERRQ(ierr);
     ierr = SNESGetKSP(subsnes[i],&ksp);CHKERRQ(ierr);
-    ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr);
-    ierr = PCApply(pc,b[i],x[i]);CHKERRQ(ierr);
+    ierr = KSPSetOperators(ksp,subJ,subpJ);CHKERRQ(ierr);
+    ierr = KSPSolve(ksp,b[i],x[i]);CHKERRQ(ierr);
     ierr = VecScatterBegin(oscatter[i],x[i],Y,ADD_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
   }
   for (i=0;i<n;i++) {