In addition to the excellent idea by Juan Carlos:

> When I initialize the PETSc sparsity matrix, I don't know where the nonzeros 
> are.
> Then I loop over the locally owned cells on each processor, and guadually 
> know 
> for each row of the matrix the locations and values of the nonzeros. Do you 
> mean that I can't directly use the PETSc_sparsity_matrix.add() function to 
> insert nonzero values into the matrix without telling the sparsity pattern 
> the 
> nonzeros locations?

The way we set up these data structures is that we want to know up front where 
the nonzeros are. It's far more efficient to do it that way, but it is 
possible to add nonzeros on the fly as shown in the post by Juan Carlos.

How do we know where the nonzeros are? We "simulate" what matrix assembly 
would look like, i.e., in a first stage, we record those locations that we 
want to write into later on, and this gives us the sparsity pattern (e.g., 
using a DynamicSparsityPattern). Then, we can in a second stage do the actual 
assembly into a matrix where we already know where the nonzeros are going to be.

Best
  W.

-- 
------------------------------------------------------------------------
Wolfgang Bangerth          email:                 bange...@colostate.edu
                            www: http://www.math.colostate.edu/~bangerth/

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to