From: kronbichler Date: Mon, 17 Dec 2012 09:22:26 +0000 (+0000) Subject: Matrix-vector product with deal.II vectors and Trilinos matrix are can be readily... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d566fe404e10d7501caf099bacd114e462634536;p=dealii-svn.git Matrix-vector product with deal.II vectors and Trilinos matrix are can be readily performed. git-svn-id: https://svn.dealii.org/trunk@27825 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h b/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h index 57f9da6ce7..d5e86a50f6 100644 --- a/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h +++ b/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h @@ -1676,6 +1676,14 @@ namespace TrilinosWrappers void vmult (parallel::distributed::Vector &dst, const parallel::distributed::Vector &src) const; + /** + * Same as before, but working with + * deal.II's own vector + * class. + */ + void vmult (dealii::Vector &dst, + const dealii::Vector &src) const; + /** * Matrix-vector multiplication: * let dst = @@ -1719,6 +1727,14 @@ namespace TrilinosWrappers void Tvmult (parallel::distributed::Vector &dst, const parallel::distributed::Vector &src) const; + /** + * Same as before, but working with + * deal.II's own vector + * class. + */ + void Tvmult (dealii::Vector &dst, + const dealii::Vector &src) const; + /** * Adding Matrix-vector * multiplication. Add @@ -3271,6 +3287,30 @@ namespace TrilinosWrappers + inline + void + SparseMatrix::vmult (dealii::Vector &dst, + const dealii::Vector &src) const + { + Assert (&src != &dst, ExcSourceEqualsDestination()); + Assert (matrix->Filled(), ExcMatrixNotCompressed()); + + AssertDimension (static_cast(matrix->DomainMap().NumMyElements()), + static_cast(matrix->DomainMap().NumGlobalElements())); + AssertDimension (dst.size(), static_cast(matrix->RangeMap().NumMyElements())); + AssertDimension (src.size(), static_cast(matrix->DomainMap().NumMyElements())); + + Epetra_Vector tril_dst (View, matrix->RangeMap(), dst.begin()); + Epetra_Vector tril_src (View, matrix->DomainMap(), + const_cast(src.begin())); + + const int ierr = matrix->Multiply (false, tril_src, tril_dst); + Assert (ierr == 0, ExcTrilinosError(ierr)); + (void)ierr; // removes -Wunused-variable in optimized mode + } + + + inline void SparseMatrix::Tvmult (VectorBase &dst, @@ -3314,6 +3354,30 @@ namespace TrilinosWrappers + inline + void + SparseMatrix::Tvmult (dealii::Vector &dst, + const dealii::Vector &src) const + { + Assert (&src != &dst, ExcSourceEqualsDestination()); + Assert (matrix->Filled(), ExcMatrixNotCompressed()); + + AssertDimension (static_cast(matrix->DomainMap().NumMyElements()), + static_cast(matrix->DomainMap().NumGlobalElements())); + AssertDimension (dst.size(), static_cast(matrix->DomainMap().NumMyElements())); + AssertDimension (src.size(), static_cast(matrix->RangeMap().NumMyElements())); + + Epetra_Vector tril_dst (View, matrix->DomainMap(), dst.begin()); + Epetra_Vector tril_src (View, matrix->RangeMap(), + const_cast(src.begin())); + + const int ierr = matrix->Multiply (true, tril_src, tril_dst); + Assert (ierr == 0, ExcTrilinosError(ierr)); + (void)ierr; // removes -Wunused-variable in optimized mode + } + + + inline void SparseMatrix::vmult_add (VectorBase &dst,