]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
One more test.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 10 Feb 2013 04:57:00 +0000 (04:57 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 10 Feb 2013 04:57:00 +0000 (04:57 +0000)
git-svn-id: https://svn.dealii.org/trunk@28303 0785d39b-7218-0410-832d-ea1e28bc413d

tests/trilinos/sparse_matrix_07_rectangle.cc [new file with mode: 0644]
tests/trilinos/sparse_matrix_07_rectangle/cmp/generic [new file with mode: 0644]

diff --git a/tests/trilinos/sparse_matrix_07_rectangle.cc b/tests/trilinos/sparse_matrix_07_rectangle.cc
new file mode 100644 (file)
index 0000000..a873b39
--- /dev/null
@@ -0,0 +1,69 @@
+//-----------------  trilinos_sparse_matrix_01.cc  -------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2011, 2013 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//-----------------  trilinos_sparse_matrix_01.cc  -------------------------
+
+
+// test TrilinosWrappers::SparseMatrix::reinit with a dealii::SparseMatrix
+// with a separate sparsity pattern that is partly subset and partly superset
+
+#include "../tests.h"
+#include <deal.II/base/utilities.h>
+#include <deal.II/lac/trilinos_sparse_matrix.h>
+#include <deal.II/lac/trilinos_sparsity_pattern.h>
+#include <deal.II/lac/sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+int main (int argc,char **argv)
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv);
+
+  std::ofstream logfile("sparse_matrix_07_rectangle/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  SparsityPattern sparsity (4,5,5);
+  sparsity.add (1,2);
+  sparsity.add (2,3);
+  sparsity.add (3,4);
+  sparsity.add (0,4);
+  sparsity.compress();
+  SparseMatrix<double> matrix(sparsity);
+  {
+    double value = 1;
+    for (SparseMatrix<double>::iterator p=matrix.begin();
+        p != matrix.end(); ++p, ++value)
+      p->value() = value;
+  }
+  deallog << "Original:" << std::endl;
+  matrix.print_formatted (deallog.get_file_stream());
+
+  // create a separate sparsity pattern to use
+  SparsityPattern xsparsity (4,5,5);
+  xsparsity.add (1,2);
+  xsparsity.add (2,3);
+  xsparsity.add (2,4);
+  xsparsity.add (2,1);
+  xsparsity.compress();
+
+
+  // now copy everything into a Trilinos matrix
+  Epetra_Map rowmap(4,4,0,Utilities::Trilinos::comm_world());
+  Epetra_Map colmap(5,5,0,Utilities::Trilinos::comm_world());
+  TrilinosWrappers::SparseMatrix tmatrix;
+  tmatrix.reinit (rowmap, colmap, matrix, 0, true, &xsparsity);
+
+  deallog << "Copy structure only:" << std::endl;
+  tmatrix.print (deallog.get_file_stream());
+}
diff --git a/tests/trilinos/sparse_matrix_07_rectangle/cmp/generic b/tests/trilinos/sparse_matrix_07_rectangle/cmp/generic
new file mode 100644 (file)
index 0000000..1b29f98
--- /dev/null
@@ -0,0 +1,11 @@
+
+DEAL::Original:
+                                            1.000e+00  
+                      2.000e+00                        
+                                 3.000e+00             
+                                            4.000e+00  
+DEAL::Copy structure only:
+(1,2) 2.00000
+(2,1) 0.00000
+(2,3) 3.00000
+(2,4) 0.00000

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.