[petsc-users] Assembly of local Mat's to a parallel Mat

Jed Brown jedbrown at mcs.anl.gov
Fri Apr 12 12:10:35 CDT 2013

Hui Zhang <mike.hui.zhang at hotmail.com> writes:

> On Apr 12, 2013, at 5:22 PM, Jed Brown wrote:
> I can understand this method.  A further question: since Ai itself is shared 
> by many processors,  MatSetValues to A should be called by only one of the 
> processor sharing Ai.  Is it right?

If your Ai are already shared, why can't you just start by creating the
big block-diagonal system containing all the Ai along the diagonal?
Then MatGetSubMatrix() will give you the part if you really need to do
something separate with it.

>> or you can create a block diagonal parallel
>> matrix A_i constructed by joining together all the diagonal blocks.
> Which function can do this?  I only found diagonal block Mat with each block 
> of the same size and dense.  Thanks!

There is no function to do it in-place, but you can just create the big
matrix and loop through the small matrix inserting rows.  It's usually
better to start with the big matrix.

More information about the petsc-users mailing list