]> https://gitweb.dealii.org/ - dealii.git/commitdiff
test FilteredMatrix
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Tue, 30 Oct 2007 20:23:41 +0000 (20:23 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Tue, 30 Oct 2007 20:23:41 +0000 (20:23 +0000)
git-svn-id: https://svn.dealii.org/trunk@15398 0785d39b-7218-0410-832d-ea1e28bc413d

tests/lac/Makefile
tests/lac/filtered_matrix.cc [new file with mode: 0644]
tests/lac/filtered_matrix/cmp/generic [new file with mode: 0644]

index 4155942dc4c0cb22f9d5c29e72ce67a920880f00..cc6a7ae70c76dee679649284a7f47f917332f497 100644 (file)
@@ -27,7 +27,7 @@ tests_x = vector-vector \
        block_sparsity_pattern_01 \
        block_indices block_vector block_vector_* block_matrices \
        matrix_lib matrix_out pointer_matrix pointer_matrix_vector \
-       solver eigen \
+       solver eigen filtered_matrix \
        sparse_ilu sparse_ilu_t lapack_fill block_minres \
        identity_matrix* trace \
        print_formatted_* \
diff --git a/tests/lac/filtered_matrix.cc b/tests/lac/filtered_matrix.cc
new file mode 100644 (file)
index 0000000..dfb64b5
--- /dev/null
@@ -0,0 +1,102 @@
+//----------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2007 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.
+//
+//----------------------------------------------------------------------
+
+// Test properties of FilteredMatrix and iterators
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/filtered_matrix.h>
+#include <lac/matrix_lib.h>
+#include <lac/precondition.h>
+#include <lac/vector.h>
+
+#include <fstream>
+
+
+template<class VECTOR>
+void test (const FilteredMatrix<VECTOR>& M)
+{
+  deallog << "Iterator";
+  
+  unsigned int max = 0;
+  for (typename FilteredMatrix<VECTOR>::const_iterator i= M.begin();
+       i != M.end();++i)
+    {
+      Assert(i->row() == i->column(), ExcInternalError());
+      deallog << ' ' << i->row() << ':' << i->value();
+      max = i->row();
+    }
+  VECTOR v(max+1);
+  VECTOR w(max+1);
+  
+  for (unsigned int i=0;i<v.size();++i)
+    v(i) = 31+i;
+
+  deallog << std::endl << "vmult ";
+
+  w = 0.;
+  M.vmult(w,v);
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << w(i);
+  
+  deallog << std::endl << "Tvmult";
+  
+  w = 0.;
+  M.Tvmult(w,v);
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << w(i);
+  
+  deallog << std::endl << "vmult_add";
+  
+  M.vmult_add(w,v);
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << w(i);
+
+  deallog << std::endl << "boundary";
+  
+  M.apply_constraints(w, true);
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << w(i);
+
+  deallog << std::endl << "boundary";
+  
+  M.apply_constraints(w, false);
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << w(i);
+  
+  deallog << std::endl;
+}
+
+
+
+int main()
+{
+  std::ofstream logfile("filtered_matrix/output");
+  deallog.attach(logfile);
+  deallog.depth_console(10);
+  
+  PreconditionIdentity identity;
+  ScaledMatrix<Vector<double> > s(identity, 3.);
+  
+  FilteredMatrix<Vector<double> > f;
+  f.initialize(s, false);
+  test(f);
+
+  for (unsigned int i=0;i<5;++i)
+    f.add_constraint(i*i,i/2.);
+  test(f);
+  
+  f.initialize(s, true);
+  test(f);
+  
+}
diff --git a/tests/lac/filtered_matrix/cmp/generic b/tests/lac/filtered_matrix/cmp/generic
new file mode 100644 (file)
index 0000000..cf24a40
--- /dev/null
@@ -0,0 +1,19 @@
+
+DEAL::Iterator
+DEAL::vmult  93.0000
+DEAL::Tvmult 93.0000
+DEAL::vmult_add 186.000
+DEAL::boundary 186.000
+DEAL::boundary 186.000
+DEAL::Iterator 0:0 1:0.500000 4:1.00000 9:1.50000 16:2.00000
+DEAL::vmult  31.0000 32.0000 99.0000 102.000 35.0000 108.000 111.000 114.000 117.000 40.0000 123.000 126.000 129.000 132.000 135.000 138.000 47.0000
+DEAL::Tvmult 31.0000 32.0000 99.0000 102.000 35.0000 108.000 111.000 114.000 117.000 40.0000 123.000 126.000 129.000 132.000 135.000 138.000 47.0000
+DEAL::vmult_add 31.0000 32.0000 198.000 204.000 35.0000 216.000 222.000 228.000 234.000 40.0000 246.000 252.000 258.000 264.000 270.000 276.000 47.0000
+DEAL::boundary 0 0.500000 198.000 204.000 1.00000 216.000 222.000 228.000 234.000 1.50000 246.000 252.000 258.000 264.000 270.000 276.000 2.00000
+DEAL::boundary 0 0.500000 198.000 204.000 1.00000 216.000 222.000 228.000 234.000 1.50000 246.000 252.000 258.000 264.000 270.000 276.000 2.00000
+DEAL::Iterator 0:0 1:0.500000 4:1.00000 9:1.50000 16:2.00000
+DEAL::vmult  31.0000 32.0000 99.0000 102.000 35.0000 108.000 111.000 114.000 117.000 40.0000 123.000 126.000 129.000 132.000 135.000 138.000 47.0000
+DEAL::Tvmult 31.0000 32.0000 99.0000 102.000 35.0000 108.000 111.000 114.000 117.000 40.0000 123.000 126.000 129.000 132.000 135.000 138.000 47.0000
+DEAL::vmult_add 31.0000 32.0000 198.000 204.000 35.0000 216.000 222.000 228.000 234.000 40.0000 246.000 252.000 258.000 264.000 270.000 276.000 47.0000
+DEAL::boundary 0 0.500000 198.000 204.000 1.00000 216.000 222.000 228.000 234.000 1.50000 246.000 252.000 258.000 264.000 270.000 276.000 2.00000
+DEAL::boundary 0 0.500000 198.000 204.000 1.00000 216.000 222.000 228.000 234.000 1.50000 246.000 252.000 258.000 264.000 270.000 276.000 2.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.