mixed matrix type?

Barry Smith bsmith at mcs.anl.gov
Wed May 21 11:26:21 CDT 2008


    We would like very much to have flexible code that did all this  
stuff for you, sadly we are far far away from this.

    I would suggest looking at DAGetMatrix() and pick the one that  
matches your DA (2d or 3d) etc. Then you
could modify the code that preallocates the matrix with the additional  
preallocation information and then modify the part that
puts in the locations of nonzeros to match your structure. This way  
you will get perfect preallocation (which will be
important for you to get good speed). I would just use the MPIAIJ  
matrix format for now (and maybe forever is ok)
because the inode code will make that smaller dense part pretty fast  
anyways without requiring massively complicated
matrix data structures that store parts dense and parts sparse.

    Barry

On May 21, 2008, at 11:14 AM, Sean Dettrick wrote:

> Hi,
>
> I have a sparse N*N matrix generated from a DA and a 5 point  
> stencil, with a total of approx 5*N non-zero entries.  Now I would  
> like to extend this matrix by adding a smaller M*M dense matrix to  
> the bottom right hand side, i.e. so that there is a dense square in  
> the bottom right hand corner of the otherwise sparse matrix.  The  
> total number of new non-zero entries, M*M, is comparable to the  
> total number of old entries, 5*N.  On top of this, there would be a  
> small number of non-zero entries in the new upper-right and lower- 
> left rectangular portions of the matrix, due to coupling of the two  
> systems.  The new total matrix size (including zeroes) would be (N 
> +M)*(N+M).
>
> Can anybody recommend a Mat type to store the new matrix?
>
> One possibility I was thinking of was to establish the original  
> sparse Mat with a DA in a sub-communicator (with half the CPUs), and  
> get the ownership range with MatGetOwnershipRange.  Then in the  
> petsc_comm_world communicator, the complete matrix could be  
> constructed (by element-wise copying the old one I suppose), and the  
> ownership range could be maintained manually.
>
> Does this sound like a reasonable strategy?
>
> I would very much appreciate any suggestions or advice.
>
> Thanks,
>
> Sean Dettrick
>
>




More information about the petsc-users mailing list