An update:

I tried to use a iteration below to iterate over local entries: (The reason 
I use local_range() for only (0, 0) block and iterator for the entire block 
matrix is because I only need the block(0, 0), and sparse matrix class does 
not have a non-const iterator, I have to call the local range in the (0, 0) 
block and initialize an iterator from the blockmatrix)

for (auto r = Abs_A_matrix->block(0, 0).local_range().first;
r < Abs_A_matrix->block(0, 0).local_range().second; ++r)
{
for (auto itr = Abs_A_matrix->begin(r);
itr != Abs_A_matrix->end(r);
++itr)
{
itr->set_value(std::abs(itr->value()));
}
}

However, it doesn't work. The error message says:

dealii/install/include/deal.II/lac/matrix_iterator.h:45:41:   required from 
‘class 
dealii::MatrixIterator<dealii::BlockMatrixIterators::Accessor<dealii::BlockMatrixBase<dealii::PETScWrappers::MPI::SparseMatrix>,
 
false> >’

dealii/install/include/deal.II/lac/block_matrix_base.h:178:51: error: no 
type named ‘iterator’ in 
‘dealii::BlockMatrixBase<dealii::PETScWrappers::MPI::SparseMatrix>::BlockType 
{aka class dealii::PETScWrappers::MPI::SparseMatrix}’
     typename BlockMatrixType::BlockType::iterator base_iterator;
                                                   ^~~~~~~~~~~~~

Thanks for any help!
Feimi


On Monday, March 5, 2018 at 12:21:46 PM UTC-5, Feimi Yu wrote:
>
> Hi,
>
> I'm using PETScWrapper to parallelize my code. In my preconditioner for 
> the GMRES solver, there is one step that requires a matrix copied from the 
> system matrix, and set all the elements to be the absolute value. It was 
> fine in serial because I can iterator over all the entries simply using the 
> iterator, but it does not work in parallel since each process only owns 
> local entries. When I run the code using iteration the error message will 
> tell me "argument out of range; Not local rows". It also tells me "Object 
> is in wrong state; Not for unassembled matrix" despite the fact that I 
> called compress(VectorOperation:add) right before the iteration.
>
> Is there any way to bypass the iteration to get an absolute value matrix 
> or to iterate locally and not trigger the "unassembled matrix" error?
>
> Thanks,
> Feimi
>
>

-- 
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.

Reply via email to