]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Introduce another reinit function to copy from a Epetra_CrsMatix.
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 14 Nov 2008 15:29:41 +0000 (15:29 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 14 Nov 2008 15:29:41 +0000 (15:29 +0000)
git-svn-id: https://svn.dealii.org/trunk@17582 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 98129b4a006eebe6bb1850db41ee314647893c9c..b04db9f9e8f1da45065190f92916d4f47d0ea514 100755 (executable)
@@ -670,6 +670,13 @@ namespace TrilinosWrappers
                   const ::dealii::SparseMatrix<double>  &dealii_sparse_matrix,
                   const double                           drop_tolerance=1e-13);
 
+                                       /**
+                                       * This reinit function takes as
+                                       * input a Trilinos Epetra_CrsMatrix
+                                       * and copies its content.
+                                       */
+      void reinit (const Epetra_CrsMatrix &input_matrix);
+
                                        /**
                                         * This operator assigns a scalar
                                         * to a matrix. Since this does
index d0bd56a5147102d56d70b5a1b454596d0b91e596..054c80a60ef9970ee94689695f7e9e086b4b4aa7 100755 (executable)
@@ -560,6 +560,39 @@ namespace TrilinosWrappers
 
 
 
+  void 
+  SparseMatrix::reinit (const Epetra_CrsMatrix &input_matrix)
+  {
+    matrix.reset();
+
+    Assert (input_matrix.Filled()==true,
+           ExcMessage("Input CrsMatrix has not called FillComplete()!"));
+
+    row_map = input_matrix.RangeMap();
+    col_map = input_matrix.DomainMap();
+
+    const Epetra_CrsGraph *graph = &input_matrix.Graph();
+
+    matrix = std::auto_ptr<Epetra_FECrsMatrix> 
+                      (new Epetra_FECrsMatrix(Copy, *graph, false));
+
+    matrix->FillComplete (col_map, row_map, true);
+
+    int length;
+    int *row_indices;
+    TrilinosScalar *values;
+    for (unsigned int row=0; row<m(); ++row)
+      if (row_map.MyGID(row))
+       {
+         const int local_row = row_map.LID(row);
+         input_matrix.ExtractMyRowView(local_row, length, values, row_indices);
+         matrix->ReplaceMyValues(local_row, length, values, row_indices);
+       }
+
+    compress();
+  }
+
+
   void
   SparseMatrix::clear ()
   {
@@ -1119,9 +1152,9 @@ namespace TrilinosWrappers
     if (matrix->Filled() == false)
       matrix->FillComplete(col_map, row_map, true);
 
-    Assert (src.vector->Map().SameAs(matrix->DomainMap()) == true,
+    Assert (src.vector->Map().SameAs(matrix->RangeMap()) == true,
            ExcMessage ("Column map of matrix does not fit with vector map!"));
-    Assert (dst.vector->Map().SameAs(matrix->RangeMap()) == true,
+    Assert (dst.vector->Map().SameAs(matrix->DomainMap()) == true,
            ExcMessage ("Row map of matrix does not fit with vector map!"));
 
     const int ierr = matrix->Multiply (true, *(src.vector), *(dst.vector));

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.