[petsc-users] access to matnest block (0,1) ?

Jed Brown jedbrown at mcs.anl.gov
Thu Jan 19 08:57:24 CST 2012


On Thu, Jan 19, 2012 at 02:42, Klaij, Christiaan <C.Klaij at marin.nl> wrote:

> > > I have two DMs which I add to a DMComposite and then use MATNEST when
> > > getting the corresponding matrix. This gives me block (0,0) and block
> > > (1,1). How do I set/get blocks (0,1) and (1,0)? Looking at ex28 I tried
> > > MatGetLocalSubMatrix but it gives a null arg...
> > >
> >
> > So the problem is that we have no way of knowing what preallocation
> > (nonzero pattern) _should_ go in the off-diagonal part. Unfortunately,
> the
> > current preallocation mechanism (DMCompositeSetCoupling()) is a difficult
> > thing to implement and the mechanism does not directly apply to MatNest.
> If
> > you have ideas for a good preallocation API, I would like to hear it. I
> > need to get back to the preallocation issue because it's an obvious wart
> in
> > the multiphysics support (as long as we don't have fast dynamic
> > preallocation, which is a somewhat viable alternative). What I would like
> > is for the user to call MatGetLocalSubMatrix() for any blocks that they
> > want allocated and set preallocation in terms of the local ordering.
> >
> > The current (unfortunate) solution for MatNest with off-diagonal parts is
> > to create the submatrices after DMGetMatrix(), preallocate as you like,
> and
> > copy the ISLocalToGlobalMappings over.
>
> I see the problem, no ideas for a good general preallocation
> mechanism, sorry. Preallocation would depend on how the user
> discretizes the cross terms, wouldn't it? So how can we expect
> PETSc to "deduce" it from the diagonal blocks? As a user I would
> be happy to preallocate myself.
>
> Out of curiosity, how does it happen in ex28.c: I only see two
> matrices being defined (line 347 and 355), I don't see
> DMCompositeSetCoupling() at all, yet on line 271 block (0,1) is
> available...
>

It only assembles the block diagonal when you use MatNest.

  if (!Buk) PetscFunctionReturn(0); /* Not assembling this block */

It builds the whole matrix when you use AIJ, but preallocation isn't
correct.


>
> What about a less general (but important) case: saddle point
> problems arising from incompressible Stokes, Oseen and
> Navier-Stokes eqs. with Schur type preconditioning. In 2D with N
> cells and co-located variables arranged
> as (u1,...,uN,v1,...,vN,p1,...pN) the matrix would have the form
> [Q G, D 0] with Q a 2N-by-2N matrix, G a 2N-by-N matrix and D a
> N-by-2N matrix. Since the variables are co-located, they share
> the same partitioning but could have different stencils. How to use
> the "split local space", DMComposite and MATNEST in this case?
>

If you order this way, then you don't need DMComposite or MatNest (although
you can still make a MatNest that operates in this ordering, we just don't
have a way to make it automatically).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120119/9d2ff3aa/attachment.htm>


More information about the petsc-users mailing list