Hi Wolfgang,
This time I used VectorOperation::insert and it didn't happen the memory
error that I posted before.
However, if I put the compress function after the loop, it only sets one
entry on each rank then throws the exception
"Object is in wrong state, not for unassembled matrix."
Putting the compress() in the loop does not throw exceptions, instead, it
iterates forever.
So just as you said it is very inefficient and not an option.
On Tuesday, March 6, 2018 at 4:19:54 AM UTC-5, Wolfgang Bangerth wrote:
>
> On 03/05/2018 02:54 PM, Feimi Yu wrote:
> >
> > I changed my strategy to use set(r, c, v) function to set the values so
> that I
> > can 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 1
> > process.
>
> 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: [email protected]
> <javascript:>
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.