> On Jun 5, 2015, at 3:02 PM, Paul T. Bauman <[email protected]> wrote:
>
>
>
> On Fri, Jun 5, 2015 at 3:37 PM, Barry Smith <[email protected]> wrote:
>
> > On Jun 5, 2015, at 1:49 PM, Paul T. Bauman <[email protected]> wrote:
> >
> >
> >
> > On Fri, Jun 5, 2015 at 2:42 PM, Harshad Sahasrabudhe <[email protected]>
> > wrote:
> > It is not the coloring you need to generate, just the nonzero structure.
> > (From that PETSc computes the coloring) so do as I suggest in my other
> > email.
> >
> > Thanks, I'll try that out.
> >
> > FYI, this information is contained in the libMesh::CouplingMatrix which you
> > can get from the libMesh::DofMap.
>
> Thanks. Maybe using this information could be "automated" within
> PETSc/libMesh so that one could "trivially" use the finite differencing to
> compute the Jacobian with coloring within PETSc/libMesh when the Jacobian
> cannot be provided directly by the user?
>
> Thanks Barry, this is a good suggestion. To be honest, however, since MOOSE
> does its own finite differencing (I think...) and other libMesh-based
> infrastructure does as well,
We should fix that :-) Have one common abstraction/API for "differencing"
for Jacobians with multiple implementations instead of multiple APIs and
multiple implementations :-)
Barry
> this may not be a developer priority immediately. (Might be something good to
> hack on in a couple weeks at PETSc 20.) That said...
>
> For example within PETSc if one provides the option -snes_fd_color then SNES
> does
>
> ierr = PetscOptionsBool("-snes_fd_color","Use finite differences with
> coloring to compute
> Jacobian","SNESComputeJacobianDefaultColor",flg,&flg,NULL);CHKERRQ(ierr);
> if (flg) {
> DM dm;
> DMSNES sdm;
> ierr = SNESGetDM(snes,&dm);CHKERRQ(ierr);
> ierr = DMGetDMSNES(dm,&sdm);CHKERRQ(ierr);
> sdm->jacobianctx = NULL;
> ierr =
> SNESSetJacobian(snes,snes->jacobian,snes->jacobian_pre,SNESComputeJacobianDefaultColor,0);CHKERRQ(ierr);
> ierr = PetscInfo(snes,"Setting default finite difference coloring
> Jacobian matrix\n");CHKERRQ(ierr);
> }
>
> with PETSc/libMesh it would have to stick the correct matrix nonzero
> structure (from? "libMesh::CouplingMatrix") into the ,snes->jacobian_pre
> "Jacobian" "matrix"
>
> Looks easy enough. Looking at the SNESSetJacobian documentation, the ctx (in
> your example, 0) would need to be a pointer a MatFDColoring?
>
> Best,
>
> Paul