Barry and Jed --

Actually, I think I do see a bug that has caused me some problems, namely
that when RSLS diverges, stuff is corrupt.  This seems to be because
DMDestroyVI() was not called when the diverged cause a "break" out of the
for loop in SNESSolve_VINEWTONRSLS().  Part of the problem was the indent
level. ;-)

I've decided to follow this advice:
"""
*For very small changes you can clone the petsc repository, create a new
branch on your local repository from master, apply and commit your changes
there, and use git format-patch origin/master to create the patch. Send the
patch to [email protected].
"""

The attached should explain itself, but note I branched off of
barry/snes-monitor-vi-residual, and thus did
   git format-patch barry/snes-monitor-vi-residual
to generate the patch.

Is this an easy to apply form, compared to me being confused about my fork?

Ed

-- 
Ed Bueler
Dept of Math and Stat and Geophysical Institute
University of Alaska Fairbanks
Fairbanks, AK 99775-6660
301C Chapman and 410D Elvey
907 474-7693 and 907 474-7199  (fax 907 474-5394)
From 45250b6abe79369698f2e95bbbbaeba3294fd647 Mon Sep 17 00:00:00 2001
From: Ed Bueler <[email protected]>
Date: Wed, 18 Mar 2015 15:26:04 -0600
Subject: [PATCH] DMDestroyVI() needs to go *after* end of for loop, or else
 snes->dm is corrupted on divergence.  (I think ...)

---
 src/snes/impls/vi/rs/virs.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/snes/impls/vi/rs/virs.c b/src/snes/impls/vi/rs/virs.c
index 419e517..a5b5de4 100644
--- a/src/snes/impls/vi/rs/virs.c
+++ b/src/snes/impls/vi/rs/virs.c
@@ -596,8 +596,7 @@ PetscErrorCode SNESSolve_VINEWTONRSLS(SNES snes)
     if (snes->reason == SNES_DIVERGED_FUNCTION_COUNT) break;
     if (snes->domainerror) {
       snes->reason = SNES_DIVERGED_FUNCTION_DOMAIN;
-      ierr         = DMDestroyVI(snes->dm);CHKERRQ(ierr);
-      PetscFunctionReturn(0);
+      break;
     }
     if (!lssucceed) {
       if (++snes->numFailures >= snes->maxFailures) {
@@ -607,8 +606,8 @@ PetscErrorCode SNESSolve_VINEWTONRSLS(SNES snes)
         if (ismin) snes->reason = SNES_DIVERGED_LOCAL_MIN;
         break;
       }
-   }
-   ierr = DMDestroyVI(snes->dm);CHKERRQ(ierr);
+    }
+
     /* Update function and solution vectors */
     fnorm = gnorm;
     /* Monitor convergence */
@@ -622,7 +621,9 @@ PetscErrorCode SNESSolve_VINEWTONRSLS(SNES snes)
     if (snes->ops->converged != SNESConvergedSkip) { ierr = VecNorm(X,NORM_2,&xnorm);CHKERRQ(ierr); }
     ierr = (*snes->ops->converged)(snes,snes->iter,xnorm,ynorm,fnorm,&snes->reason,snes->cnvP);CHKERRQ(ierr);
     if (snes->reason) break;
-  }
+  } // end for
+  ierr = DMDestroyVI(snes->dm);CHKERRQ(ierr);
+
   if (i == maxits) {
     ierr = PetscInfo1(snes,"Maximum number of iterations has been reached: %D\n",maxits);CHKERRQ(ierr);
     if (!snes->reason) snes->reason = SNES_DIVERGED_MAX_IT;
-- 
1.9.1

Reply via email to