On 03/05/2018 02:54 PM, Feimi Yu wrote:

## Advertising

I changed my strategy to use set(r, c, v) function to set the values so that Ican use the const iterators. also called compress after every add:for(autor =Abs_A_matrix->block(0, 0).local_range().first; r <Abs_A_matrix->block(0, 0).local_range().second; ++r) { for(autoitr =Abs_A_matrix->block(0, 0).begin(r); itr !=Abs_A_matrix->block(0, 0).end(r); ++itr) { Abs_A_matrix->block(0, 0).set(itr->row(), itr->column(), std::abs(itr->value())); Abs_A_matrix->block(0, 0).compress(VectorOperation::add); } } This time it says: *** Error in ' ' :free(): invalid size: 0x0000556443d63e50 ***This seems like a out of bounds access. This happens even when I run with 1process.

`This is the right approach -- you do need to restrict work to the locally`

`owned range of rows, but if you do that on every processor, then you cover all`

`rows.`

`But you can't call 'compress()' after every set operation. That's because`

`compress() is a *collective* operation, i.e., it has to be called on all`

`processors at the same time. Since different processors may have different`

`numbers of entries, what you are doing here leads to different numbers of`

`calls on different processors.`

`In addition, it is *very* inefficient to call the function so many times. Just`

`move the call to after the loop. (And change the argument to`

`VectorOperation::set -- you are *setting* elements, after all, not adding to`

`them.)`

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.