[petsc-users] setting block matrices with preallocation

Matthew Knepley knepley at gmail.com
Mon Jan 18 09:48:00 CST 2010


I would probably do what Barry & Jed have suggested. However, if you really
want to work with blocks,
you can also consider what Dave has done. It is much closer to what you are
asking for

  http://jupiter.ethz.ch/~dmay/Research/PetscExt/index.html

  Matt

On Mon, Jan 18, 2010 at 9:41 AM, Umut Tabak <u.tabak at tudelft.nl> wrote:

> Dear all,
>
> Some time ago, I asked some questions about setting entries of a sparse
> matrix efficiently. I got some response from Jed Brown and Barry Smith. I
> can set the matrix entries of one sparse matrix very efficiently for the
> moment. I use MatSetValues and preallocate the array as explained in the
> manual for performance and set the rows in once in a loop. My actual goal
> was to set the entries of a matrix in blocks. Let me rephrase, say I would
> like to set the blocks of a matrix like
>      1       1
> 1 [  Kaa  Kas ]               or     [  Kaa    0    ]              does not
> matter.
> 2 [    0     Kss ]                       [  Ksa   Kss  ]
>
> Since I can read the matrices Kaa, Ksa, Kss, and their non-zeros, row and
> column indices of these matrices alone.
>
> I thought that to get the same efficient setting of values, I can do some
> kind of block selection on a 'switch' where I can allocate the nnz, and
> values for the rows of this big matrix and set the row and column indices
> with some offsets. I mean sth like if blocks are on the same global row, say
> 1, change nnz for those rows in that block and allocate the necessary space
> and set the values of this array. But I thought this should be done before
> me by someone else, so just wanted some advice before coding. All blocks are
> pretty sparse if that helps from the point of view of ideas. If I do not do
> this preallocation, the performance decreases, as explained in the manual,
> drastically(not for this case but for stand alone matrices for instance.)
>
> I appreciate any brighter ideas.
>
> Umut
>
>


-- 
What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100118/1b4ac4a5/attachment.htm>


More information about the petsc-users mailing list