]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Matrix-vector product with deal.II vectors and Trilinos matrix are can be readily...
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 17 Dec 2012 09:22:26 +0000 (09:22 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 17 Dec 2012 09:22:26 +0000 (09:22 +0000)
git-svn-id: https://svn.dealii.org/trunk@27825 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/trilinos_sparse_matrix.h

index 57f9da6ce74e0f8abe2690f5e8f2620f6cadf32d..d5e86a50f6e9f06b3435d7295d3633e525cd843c 100644 (file)
@@ -1676,6 +1676,14 @@ namespace TrilinosWrappers
     void vmult (parallel::distributed::Vector<TrilinosScalar>       &dst,
                 const parallel::distributed::Vector<TrilinosScalar> &src) const;
 
+    /**
+     * Same as before, but working with
+     * deal.II's own vector
+     * class.
+     */
+    void vmult (dealii::Vector<TrilinosScalar>       &dst,
+                const dealii::Vector<TrilinosScalar> &src) const;
+
     /**
      * Matrix-vector multiplication:
      * let <i>dst =
@@ -1719,6 +1727,14 @@ namespace TrilinosWrappers
     void Tvmult (parallel::distributed::Vector<TrilinosScalar>       &dst,
                  const parallel::distributed::Vector<TrilinosScalar> &src) const;
 
+    /**
+     * Same as before, but working with
+     * deal.II's own vector
+     * class.
+     */
+    void Tvmult (dealii::Vector<TrilinosScalar>       &dst,
+                 const dealii::Vector<TrilinosScalar> &src) const;
+
     /**
      * Adding Matrix-vector
      * multiplication. Add
@@ -3271,6 +3287,30 @@ namespace TrilinosWrappers
 
 
 
+  inline
+  void
+  SparseMatrix::vmult (dealii::Vector<TrilinosScalar>       &dst,
+                       const dealii::Vector<TrilinosScalar> &src) const
+  {
+    Assert (&src != &dst, ExcSourceEqualsDestination());
+    Assert (matrix->Filled(), ExcMatrixNotCompressed());
+
+    AssertDimension (static_cast<unsigned int>(matrix->DomainMap().NumMyElements()),
+                     static_cast<unsigned int>(matrix->DomainMap().NumGlobalElements()));
+    AssertDimension (dst.size(), static_cast<unsigned int>(matrix->RangeMap().NumMyElements()));
+    AssertDimension (src.size(), static_cast<unsigned int>(matrix->DomainMap().NumMyElements()));
+
+    Epetra_Vector tril_dst (View, matrix->RangeMap(), dst.begin());
+    Epetra_Vector tril_src (View, matrix->DomainMap(),
+                            const_cast<double *>(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<TrilinosScalar>      &dst,
+                        const dealii::Vector<TrilinosScalar> &src) const
+  {
+    Assert (&src != &dst, ExcSourceEqualsDestination());
+    Assert (matrix->Filled(), ExcMatrixNotCompressed());
+
+    AssertDimension (static_cast<unsigned int>(matrix->DomainMap().NumMyElements()),
+                     static_cast<unsigned int>(matrix->DomainMap().NumGlobalElements()));
+    AssertDimension (dst.size(), static_cast<unsigned int>(matrix->DomainMap().NumMyElements()));
+    AssertDimension (src.size(), static_cast<unsigned int>(matrix->RangeMap().NumMyElements()));
+
+    Epetra_Vector tril_dst (View, matrix->DomainMap(), dst.begin());
+    Epetra_Vector tril_src (View, matrix->RangeMap(),
+                            const_cast<double *>(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,

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.