On Tue, Mar 1, 2016 at 10:36 AM, Jed Brown <[email protected]> wrote:
> Matthew Knepley <[email protected]> writes: > > > On Tue, Mar 1, 2016 at 10:19 AM, Jed Brown <[email protected]> wrote: > > > >> Matthew Knepley <[email protected]> writes: > >> > I was confusing the VecGhostUpdate() above which puts local values in > the > >> > global vector > >> > with the update which would refresh the local portion. The former > update > >> > should be called > >> > automatically during assembly, which already happens in the > >> > FormFunctionLocals, > >> > >> Uh, no, and they don't use VecGhost... > > > > > > Yes, it most certainly does happen when FormFunctionLocal is > > used. PETSc calls Assembly, at least in the Plex variant. Of course, > > they do not use VecGhost. > > SNESComputeFunction_DMDA: > > switch (dmdasnes->residuallocalimode) { > case INSERT_VALUES: { > ierr = DMDAVecGetArray(dm,F,&f);CHKERRQ(ierr); > ierr = PetscLogEventBegin(SNES_FunctionEval,snes,X,F,0);CHKERRQ(ierr); > CHKMEMQ; > ierr = > (*dmdasnes->residuallocal)(&info,x,f,dmdasnes->residuallocalctx);CHKERRQ(ierr); > CHKMEMQ; > ierr = PetscLogEventEnd(SNES_FunctionEval,snes,X,F,0);CHKERRQ(ierr); > ierr = DMDAVecRestoreArray(dm,F,&f);CHKERRQ(ierr); > } break; > case ADD_VALUES: { > Vec Floc; > ierr = DMGetLocalVector(dm,&Floc);CHKERRQ(ierr); > ierr = VecZeroEntries(Floc);CHKERRQ(ierr); > ierr = DMDAVecGetArray(dm,Floc,&f);CHKERRQ(ierr); > ierr = PetscLogEventBegin(SNES_FunctionEval,snes,X,F,0);CHKERRQ(ierr); > CHKMEMQ; > ierr = > (*dmdasnes->residuallocal)(&info,x,f,dmdasnes->residuallocalctx);CHKERRQ(ierr); > CHKMEMQ; > ierr = PetscLogEventEnd(SNES_FunctionEval,snes,X,F,0);CHKERRQ(ierr); > ierr = DMDAVecRestoreArray(dm,Floc,&f);CHKERRQ(ierr); > ierr = VecZeroEntries(F);CHKERRQ(ierr); > ierr = DMLocalToGlobalBegin(dm,Floc,ADD_VALUES,F);CHKERRQ(ierr); > ierr = DMLocalToGlobalEnd(dm,Floc,ADD_VALUES,F);CHKERRQ(ierr); > ierr = DMRestoreLocalVector(dm,&Floc);CHKERRQ(ierr); > } break; > > See how this uses DMLocalToGlobal and there is no VecAssembly. > Yes, no Assembly. We only call it for matrices. The asymmetry is a little strange. > src/snes/utils/dmplexsnes.c is far more confusing, but still contains no > VecAssembly. > It does not seem confusing to me. Matt -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener
