[petsc-dev] DMGetMatrix --> DMGetMatrices?

Barry Smith bsmith at mcs.anl.gov
Fri Feb 10 16:56:10 CST 2012


On Feb 10, 2012, at 3:40 PM, Jed Brown wrote:

> On Fri, Feb 10, 2012 at 15:24, Dmitry Karpeev <karpeev at mcs.anl.gov> wrote:
> So, as I understand, this behavior is reasonable for the use with SNES, since the matrix is assembled with a call to SNES(DM)ComputeJacobian. DMGetMatrix is also used with KSP, when  it is also expected to assemble the matrix.
> This seems to make the behavior of DMGetMatrix a bit schizophrenic and dependent on whether it is used from a SNES or a KSP.  Should we try to unify this instead?  One option is to assume that DMGetMatrix (or DMGetOperators) merely preallocates the matrix of a DM-preferred type, while a call to SNESDMComputeJacobian or (the  new method) KSPDMFormOperators, respectively, would actually compute the values and assemble or do the equivalent thing for MF.  In fact, one could unify this behavior already by treating linear problems as nonlinear.
> 
> "DMGetMatrix" (which is spelled "DMCreateMatrix") allocates the matrix. It does not fill in the entries (except with zeros during preallocation).
> 
> 
> The concept of creating a preconditioning matrix with different sparsity is actually hacky to deal with now. I have various code where I make a complete copy of a STENCIL_BOX or stencil_width=2 DM, changing these values to STENCIL_STAR or stencil_width=1, just so I can call DMCreateMatrix(). Unfortunately, I don't know a nice way to do this at the generic DM level.


  DM determines the matrix sparsity pattern because it encapsulates the discretization being used. It doesn't make sense for a DM to also determine a "different" sparsity pattern. You should have a different DM that determines the sparsity pattern of the preconditioner, hence SNES and KSP should take two DMs, one that defines the operator and an optional one that determines the preconditioner. 

   This is the correct model, obviously.

   Barry


I realize that since the DMs may often share "the grid information" and only be different in the stencil width or box type or something Jed (or maybe it is Matt) is going to get all upset that their are two DMs with common information sometimes. My response is "get over it"   :-).





More information about the petsc-dev mailing list