O.k., I will just avoid holding it in that way. Unfortunately, the man page
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMGetGlobalVector.html gives no hint that a "complicated PETSc solver", a presumably well-defined phrase ;-), interferes with this particular DM functionality. Ed On Wed, Apr 29, 2015 at 9:57 PM, Barry Smith <[email protected]> wrote: > > To quote Steve Jobs, you are using it wrong :-) > > The DMGetXXX routines are not intended to be used to obtain vectors > that are kept around while complicated PETSc solvers are being used. They > are for obtaining work vectors for example for a function evaluation inside > an ODE or nonlinear solver call. If you plan to keep it around you should > use the Create versions. > > Barry > > > On Apr 29, 2015, at 2:38 PM, Ed Bueler <[email protected]> wrote: > > > > Dear Petsc -- > > > > The patch at bottom is off of current master. Applying it shows that in > SNES example ex9.c the rsls version of SNESVI breaks. Note that "./ex9 > -snes_type vinewtonssls" does not break. > > > > The expected behavior is no change, but the actual behavior with the > patched version gives a "Clearing DM of global vectors that has a global > vector obtained with DMGetGlobalVector()" message. That is, > > > > $ ./ex9 > > setup done: grid Mx,My = 11,11 with spacing dx,dy = 0.4000,0.4000 > > [0]PETSC ERROR: --------------------- Error Message > -------------------------------------------------------------- > > [0]PETSC ERROR: Object is in wrong state > > [0]PETSC ERROR: Clearing DM of global vectors that has a global vector > obtained with DMGetGlobalVector() > > [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html > for trouble shooting. > > [0]PETSC ERROR: Petsc Development GIT revision: v3.5.3-2797-g27699ca > GIT Date: 2015-04-27 23:20:45 -0500 > > [0]PETSC ERROR: ./ex9 on a linux-c-opt named bueler-leopard by ed Wed > Apr 29 13:34:36 2015 > > [0]PETSC ERROR: Configure options --download-mpich --with-debugging=0 > > [0]PETSC ERROR: #1 DMClearGlobalVectors() line 196 in > /home/ed/petsc/src/dm/interface/dmget.c > > [0]PETSC ERROR: #2 DMSetVI() line 238 in > /home/ed/petsc/src/snes/impls/vi/rs/virs.c > > [0]PETSC ERROR: #3 SNESSolve_VINEWTONRSLS() line 461 in > /home/ed/petsc/src/snes/impls/vi/rs/virs.c > > [0]PETSC ERROR: #4 SNESSolve() line 3884 in > /home/ed/petsc/src/snes/interface/snes.c > > [0]PETSC ERROR: #5 main() line 103 in > /home/ed/petsc/src/snes/examples/tutorials/ex9.c > > [0]PETSC ERROR: No PETSc Option Table entries > > [0]PETSC ERROR: ----------------End of Error Message -------send entire > error message to [email protected] > > application called MPI_Abort(MPI_COMM_WORLD, 73) - process 0 > > [unset]: aborting job: > > application called MPI_Abort(MPI_COMM_WORLD, 73) - process 0 > > > > > > Note that all I have done is use DMGetGlobalVector() on the DM for a > dummy vector. I guess that since the SNES messes with the DM things get > confused. > > > > An easy workaround is to use DMCreateGlobalVector() or VecDuplicate() > etc., so no crisis. > > > > Generally rsls is doing heroic work for me, so no serious complaints. > > > > Ed > > > > > > > > From c9a0f2dd913b3a0ab3cf39379d9361d10d22a2b4 Mon Sep 17 00:00:00 2001 > > From: Ed Bueler <[email protected]> > > Date: Wed, 29 Apr 2015 13:29:02 -0600 > > Subject: [PATCH] Pairing DM{Get/Restore}GlobalVector() before/after > > SNESSolve() breaks vinewtonrsls. > > > > --- > > src/snes/examples/tutorials/ex9.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/src/snes/examples/tutorials/ex9.c > b/src/snes/examples/tutorials/ex9.c > > index ca4d344..3afa8b9 100644 > > --- a/src/snes/examples/tutorials/ex9.c > > +++ b/src/snes/examples/tutorials/ex9.c > > @@ -96,9 +96,14 @@ int main(int argc,char **argv) > > ierr = PetscPrintf(PETSC_COMM_WORLD,"setup done: grid Mx,My = %D,%D > with spacing dx,dy = %.4f,%.4f\n", > > info.mx > ,info.my,4.0/(PetscReal)(info.mx-1),4.0/(PetscReal)(info.my-1));CHKERRQ(ierr); > > > > +Vec foo; > > +ierr = DMGetGlobalVector(da,&foo);CHKERRQ(ierr); > > + > > /* solve nonlinear system */ > > ierr = SNESSolve(snes,NULL,u);CHKERRQ(ierr); > > > > +ierr = DMRestoreGlobalVector(da,&foo);CHKERRQ(ierr); > > + > > /* compare to exact */ > > ierr = VecAXPY(u,-1.0,user.uexact);CHKERRQ(ierr); /* u <- u - uexact > */ > > ierr = VecNorm(u,NORM_1,&error1);CHKERRQ(ierr); > > -- > > 1.9.1 > > > > > > -- > > 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) > > -- 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)
