To use the PETSc coloring based Jacobian computer (which uses finite differences) you absolutely have to be able to provide the nonzero structure of the Jacobian.
Now once you provide the nonzero structure of the Jacobian the PETSc MatColoring routines can actually compute the coloring for you. So in other words you need not worry about the coloring at all, you just need to worry about providing the nonzero structure. Since you are using a finite volume method presumably all your coupling is between faces? In this case explicitly computing the nonzero structure of the Jacobian is probably pretty straightforward and you should just do it. Barry > On Nov 7, 2017, at 10:13 AM, Matthew Knepley <[email protected]> wrote: > > On Tue, Nov 7, 2017 at 10:18 AM, SIERRA-AUSIN Javier > <[email protected]> wrote: > Hi, > > I would like to ask you concerning the computation of the Jacobian matrix > via finite difference and coloring of the connectivity graph. > I wonder whether it is possible or not to color the Jacobian matrix of a > given solver that evaluates the RHS with its associated connectivity in the > global indeces of my solver (not PETSc). > As well, if it is possible to do this from an already partioned domain in > parallel. > All of this is better explained in this post : > https://scicomp.stackexchange.com/questions/28209/linking-petsc-with-an-already-parallel-in-house-finite-volume-solver > > > The simplest thing you can do is to use the finite-difference Jacobian action > (MatMFFD). This is setup automatically by SNES > if you give a FormFunction pointer, but no FormJacobian routine. Just tell > the PETSc Vecs to use your ParMetis layout (by > setting the local sizes), and it should run fine in SNES. > > However, usually you need some kind of preconditioning. Thus you either have > to form the Jacobian or some approximation. If > you cannot form an approximation, then you can use coloring. Once option is > to create a DMPlex with your mesh information. > This can be done in parallel after you have already partitioned with ParMetis > (as long as you know the "overlap" of vertices, or > adjacency of cells). Then the coloring can be done automatically using that > DM information. Otherwise, you will have to supply > a coloring to the SNES. > > Thanks, > > Matt > > Thanks in advance, > > Javier. > > > > > -- > 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 > > https://www.cse.buffalo.edu/~knepley/
