zero'ing parts of blocks

Matthew Knepley knepley at
Fri Dec 4 13:53:31 CST 2009

On Fri, Dec 4, 2009 at 12:58 PM, Craig Tanis <craig-tanis at> wrote:

> First of all, thanks for all the help on my recent questions!  Here's a new
> one:
> I have multiple degrees of freedom per node in an unstructured mesh.  I
> have set up an AO to get  the PETSC ordering for these global nodes, and
> then a LocalToGlobalMapping to map local indices to these AO-renumbered
> global nodes.   This appears to be working correctly.
> I create a Mat of type MATMPIBAIJ, and I use MatSetValuesBlockedLocal to
> add things to my matrix, as expected.   I have some boundary conditions that
> require certain rows within certain blocks to be zeroed out.  Conceptually,
> I would like to use MatZeroRowsLocal (which appears to operate on individual
> rows.. not on constituent blocks).  The problem is that this call complains
> that I have not set a LocalToGlobalMapping (since I've only set the block
> one).
> Is it common (or even possible) to register a LocalToGlobalMapping  a
> LocalToGlobalMappingBlock for a given Mat?
> Is there a way to extrapolate one from the other?

The easiest thing to do is take your block l2g mapping and produce a
row-wise l2g mapping by unrolling the
blocks. Set that in the matrix. Then the MatZeroRowsLocal will work.


> If there is no way to Zero these rows individually, am I forced to get the
> block values, zero out the rows manually and then INSERT them back in?
> thanks again,
> Craig

What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the petsc-users mailing list