[petsc-users] SNESSetUp

Mark F. Adams mfadams at lbl.gov
Fri Oct 11 14:59:28 CDT 2013


I am working on fixing this in Newton, getting the DM.  I've tested and it seems to work.  Just need to craft a Proustian comment message for Herr Commandant.

PetscErrorCode SNESSetWorkVecs(SNES snes,PetscInt nw)
{
  PetscErrorCode ierr;
  DM             dm;

  PetscFunctionBegin;
  if (snes->work) {ierr = VecDestroyVecs(snes->nwork,&snes->work);CHKERRQ(ierr);}
  snes->nwork = nw;

  ierr = SNESGetDM(snes,&dm);CHKERRQ(ierr);
  if (dm){
    Vec vec;
    ierr = DMCreateGlobalVector(dm,&vec);CHKERRQ(ierr);
    ierr = VecDuplicateVecs(vec,snes->nwork,&snes->work);CHKERRQ(ierr);
    ierr = VecDestroy(&vec);CHKERRQ(ierr);
  }
  else if (snes->vec_sol) {
    ierr = VecDuplicateVecs(snes->vec_sol,snes->nwork,&snes->work);CHKERRQ(ierr);
  }
  else {
    SETERRQ(PetscObjectComm((PetscObject)snes),PETSC_ERR_SUP,"Can not create work vectors.");
  }

  ierr = PetscLogObjectParents(snes,nw,snes->work);CHKERRQ(ierr);
  PetscFunctionReturn(0);
}


On Oct 11, 2013, at 2:11 PM, Matthew Knepley <knepley at gmail.com> wrote:

> On Thu, Oct 10, 2013 at 2:41 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> 
> On Oct 10, 2013, at 2:37 PM, "Mark F. Adams" <mfadams at lbl.gov> wrote:
> 
> >>
> >> That's what I suggested below.  I can test this now if you like.
> >>
> >> Excellent. I just pushed to next.
> >
> > It is almost done but SNESSetWorkVecs tries to use vec_sol to create work vectors.
> >
> 
>    If SNES has a DM then it should be trying to get its work vectors from that.
> 
> Now a SNES always has a DM. Changed.
> 
>   Matt
>  
> 
>    Barry
> 
> 
> 
> 
> -- 
> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20131011/b291414f/attachment.html>


More information about the petsc-users mailing list