Converting LinearAlgebra::distributed::Vector to TrilinosWrappers::MPI::Vector

25 views
Skip to first unread message

Doug Shi-Dong

unread,
Dec 4, 2019, 6:25:49 PM12/4/19
to deal.II User Group
Hello,

I am trying to solve a block system using the LinearOperators and Trilinos matrices and vectors.

Currently, all my matrices uses TrilinosWrappers::SparseMatrix, but my vectors use the deal.II LinearAlgebra::distributed::Vector because of how easily it handles ghosted vectors.

When time comes to solve my typical linear system, I directly use the Epetra_Vector, and give it a View, BlockMap, and vector pointer, as done in step-33. For example,

Epetra_Vector b(View,
system_matrix.trilinos_matrix().RangeMap(),
right_hand_side.begin());

Note that the RangeMap of this matrix corresponds to the right_hand_side locally relevant degrees of freedom.

However, now that I am using the deal.II LinearOperator, I need to use the TrilinosWrappers::MPI::Vector, to be consistent with the TrilinosWrappers::SparseMatrix. Now this is partly fine, since I can transfer dealii::LA::dist::Vector my right_hand_side to a TrilinosWrappers::MPI::Vector right_hand_side_trilinos using LinearAlgebra::ReadWriteVector. However, the issue is that the BlockMap of right_hand_side_trilinos does not correspond to the system_matrix.trilinos_matrix().RangeMap(). As a result, I can't perform matrix-vector multiplication between the system_matrix and the right_hand_side_trilinos.

The question is basically: How can I convert a LinearAlgebra::distributed::Vector into a TrilinosWrappers::MPI::Vector such that the deal.II Vector's locally relevant degrees of freedom correspond to the Trilinos' Vector BlockMap in order to perform the appropriate matrix-vector multiplication?

Another note: the matrix I'm looking to use is rectangular, and therefore DomainMap() != RangeMap().

Best regards,

Doug

Doug Shi-Dong

unread,
Dec 24, 2019, 2:42:55 PM12/24/19
to deal.II User Group
Replying to my own post since I found the solution in case someone else ever encounters this.

It was a silly bug from my end. I basically used the empty constructor of LinearAlgebra::ReadWriteVector to transfer the LA::dist::Vector into the TrilinosWrappers::MPI::Vector. As a consequence, the resulting Trilinos vector was empty and would of course not have the same parallel distribution as the matrix it was supposed to be multiplied with.

Doug
Reply all
Reply to author
Forward
0 new messages