block matrices

Manav Bhatia bhatiamanav at
Sun Sep 28 12:44:52 CDT 2008

Hi Jed,

    Thanks for your insightful comments on this.
    I randomly came up with this B sub-structure and did not pay any  
attention to the indefinite nature of the matrix. My main aim was to  
get across the idea of what I wanted to achieve.

    In my application, I already have a lot of code that calculates  
the individual sub-matrices S1, S2,...  Hence, as much as possible, I  
would like to be able to build the B matrix from these matrices. This  
brings me to two questions:

I was reading the Petsc manual pages and came across the following  
functions: MatCreateBlockMat, MatCreateSeqAIJWithArrays and  

1> So, if I have the S1,S2,...,S5, and I want to build the B matrix as  
mentioned below, would the BAIJ matrix be better to use than the AIJ?

2> And which one of the above three methods would be best to create B ?

I would appreciate any comments on this.


On Sep 22, 2008, at 4:43 AM, Jed Brown wrote:

> On Sun 2008-09-21 12:11, Manav Bhatia wrote:
>> B = 3 x 3 blocks
>> row 1 of B = 0, S1, 0
>> row 2 of B = S2, 0 , S3
>> row 3 of B = S4, S5, 0
> What sort of preconditioner do you intend to use?  If you are using a
> direct solver, then you will need to explicitly assemble B.  This  
> can be
> done in a black-box manner from the sub-matrices, but it might be  
> better
> to assemble B and extract the submatrices using MatGetSubMatrix()
> (assuming you need them elsewhere).  If you will be using an iterative
> solver, normal preconditioners will fail because the matrix is
> indefinite.  In this case, you can create a MATSHELL (which implements
> MatMult, the action of B on a vector) and a PCSHELL which  
> approximately
> inverts B using a block factorization.
> Jed

More information about the petsc-users mailing list