<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 5, 2015 at 3:37 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5"><br>
> On Jun 5, 2015, at 1:49 PM, Paul T. Bauman <<a href="mailto:ptbauman@gmail.com">ptbauman@gmail.com</a>> wrote:<br>
><br>
><br>
><br>
> On Fri, Jun 5, 2015 at 2:42 PM, Harshad Sahasrabudhe <<a href="mailto:hsahasra@purdue.edu">hsahasra@purdue.edu</a>> wrote:<br>
> 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.<br>
><br>
> Thanks, I'll try that out.<br>
><br>
> FYI, this information is contained in the libMesh::CouplingMatrix which you can get from the libMesh::DofMap.<br>
<br>
</div></div> 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? </blockquote><div><br></div><div>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, this may not be a developer priority immediately. (Might be something good to hack on in a couple weeks at PETSc 20.) That said...</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> For example within PETSc if one provides the option -snes_fd_color then SNES does<br>
<br>
ierr = PetscOptionsBool("-snes_fd_color","Use finite differences with coloring to compute Jacobian","SNESComputeJacobianDefaultColor",flg,&flg,NULL);CHKERRQ(ierr);<br>
if (flg) {<br>
DM dm;<br>
DMSNES sdm;<br>
ierr = SNESGetDM(snes,&dm);CHKERRQ(ierr);<br>
ierr = DMGetDMSNES(dm,&sdm);CHKERRQ(ierr);<br>
sdm->jacobianctx = NULL;<br>
ierr = SNESSetJacobian(snes,snes->jacobian,snes->jacobian_pre,SNESComputeJacobianDefaultColor,0);CHKERRQ(ierr);<br>
ierr = PetscInfo(snes,"Setting default finite difference coloring Jacobian matrix\n");CHKERRQ(ierr);<br>
}<br>
<br>
with PETSc/libMesh it would have to stick the correct matrix nonzero structure (from? "libMesh::CouplingMatrix") into the ,snes->jacobian_pre "Jacobian" "matrix"<br></blockquote><div><br></div><div>Looks easy enough. Looking at the SNESSetJacobian documentation, the ctx (in your example, 0) would need to be a pointer a MatFDColoring?</div><div><br></div><div>Best,</div><div><br></div><div>Paul</div></div><br></div></div>