[petsc-dev] DMGetMatrix --> DMGetMatrices?

Jed Brown jedbrown at mcs.anl.gov
Fri Feb 10 15:40:44 CST 2012


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20120210/f8a80954/attachment.html>


More information about the petsc-dev mailing list