]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add a test
authorMatthias Maier <tamiko@43-1.org>
Sun, 12 Apr 2015 22:24:16 +0000 (00:24 +0200)
committerMatthias Maier <tamiko@43-1.org>
Sun, 19 Apr 2015 20:55:06 +0000 (22:55 +0200)
tests/lac/linear_operator_04.cc
tests/lac/linear_operator_08.cc [new file with mode: 0644]
tests/lac/linear_operator_08.with_cxx11=on.output [new file with mode: 0644]

index 6f7f12d1a205e807583d52593275f7f744d53d84..2a4e4f4216b829fdf072c7c47fff2059bd74d6f8 100644 (file)
@@ -15,6 +15,7 @@
 
 // Test that it is possible to instantiate a LinearOperator object for all
 // different kinds of Trilinos matrices and vectors
+// TODO: A bit more tests...
 
 #include "../tests.h"
 
diff --git a/tests/lac/linear_operator_08.cc b/tests/lac/linear_operator_08.cc
new file mode 100644 (file)
index 0000000..a03cd8f
--- /dev/null
@@ -0,0 +1,88 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2015 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+// Test non symmetric variants:
+
+#include "../tests.h"
+
+#include <deal.II/lac/block_sparse_matrix.h>
+#include <deal.II/lac/block_vector.h>
+#include <deal.II/lac/dynamic_sparsity_pattern.h>
+#include <deal.II/lac/linear_operator.h>
+#include <deal.II/lac/sparse_matrix.h>
+#include <deal.II/lac/vector.h>
+
+#define PRINTME(name, var) \
+  deallog << "Block vector: " name << ":" << std::endl; \
+  for (unsigned int i = 0; i < var.n_blocks(); ++i) \
+    deallog << "[block " << i << " ]  " << var.block(i);
+
+
+using namespace dealii;
+
+int main()
+{
+  initlog();
+  deallog << std::setprecision(10);
+
+  // SparseMatrix:
+  {
+    SparsityPattern sparsity_pattern (10, 5, 0);
+    sparsity_pattern.compress();
+
+    SparseMatrix<double> a (sparsity_pattern);
+
+    auto op_a = linop(a);
+
+    Vector<double> u;
+    op_a.reinit_domain_vector(u, false);
+    Vector<double> v;
+    op_a.reinit_range_vector(v, false);
+    op_a.vmult(v, u);
+    op_a.vmult_add(v, u);
+    op_a.Tvmult(u, v);
+    op_a.Tvmult_add(u, v);
+
+    deallog << "OK" << std::endl;
+  }
+
+  // BlockSparseMatrix:
+  {
+    BlockDynamicSparsityPattern dsp(5, 3);
+    for (unsigned int i = 0; i < 5; ++i)
+      for (unsigned int j = 0; j < 3; ++j)
+        dsp.block(i, j).reinit (10, 5);
+    dsp.collect_sizes ();
+
+    BlockSparsityPattern sparsity_pattern;
+    sparsity_pattern.copy_from(dsp);
+    sparsity_pattern.compress();
+
+    BlockSparseMatrix<double> a (sparsity_pattern);
+
+    auto op_a = linop<BlockVector<double>>(a);
+
+    BlockVector<double> u;
+    op_a.reinit_domain_vector(u, false);
+    BlockVector<double> v;
+    op_a.reinit_range_vector(v, false);
+    op_a.vmult(v, u);
+    op_a.vmult_add(v, u);
+    op_a.Tvmult(u, v);
+    op_a.Tvmult_add(u, v);
+    deallog << "OK" << std::endl;
+  }
+}
+
diff --git a/tests/lac/linear_operator_08.with_cxx11=on.output b/tests/lac/linear_operator_08.with_cxx11=on.output
new file mode 100644 (file)
index 0000000..8b3b075
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL::OK
+DEAL::OK

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.