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

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

index a6912fcbd51ffaa37d15bd9075e9f63622659d1f..4155942dc4c0cb22f9d5c29e72ce67a920880f00 100644 (file)
@@ -25,7 +25,7 @@ tests_x = vector-vector \
        tridiagonal_matrix tridiagonal_matrix_sym \
        sparsity_pattern sparse_matrices matrices \
        block_sparsity_pattern_01 \
-       block_vector block_vector_* block_matrices \
+       block_indices block_vector block_vector_* block_matrices \
        matrix_lib matrix_out pointer_matrix pointer_matrix_vector \
        solver eigen \
        sparse_ilu sparse_ilu_t lapack_fill block_minres \
diff --git a/tests/lac/block_indices.cc b/tests/lac/block_indices.cc
new file mode 100644 (file)
index 0000000..e907b5c
--- /dev/null
@@ -0,0 +1,74 @@
+//----------------------------------------------------------------------
+//    $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 if block indices are handled properly
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/block_indices.h>
+
+#include <fstream>
+
+
+void test (const BlockIndices& idx)
+{
+  const unsigned int n = idx.size();
+  deallog << "blocks " << idx.size() << std::endl
+         << "elements " << idx.total_size() << std::endl
+         << "block sizes ";
+  for (unsigned i=0;i<n;++i)
+    deallog << '\t' << idx.block_size(i);
+  deallog << std::endl << "Block start ";
+  for (unsigned i=0;i<n;++i)
+    deallog << '\t' << idx.block_start(i);
+
+  deallog << std::endl;
+  
+  for (unsigned int i=0;i<idx.total_size();++i)
+    {
+      const unsigned int b = idx.global_to_local(i).first;
+      const unsigned int j = idx.global_to_local(i).second;
+      deallog << ' '<< i << ':' << b << ':' << j;
+    }
+  
+  deallog << std::endl;
+
+  for (unsigned int b=0;b<n;++b)
+    for (unsigned int j=0;j<idx.block_size(b);++j)
+      {
+       const unsigned int i = idx.local_to_global(b,j);
+       deallog << ' '<< i << ':' << b << ':' << j;
+      }
+  
+  deallog << std::endl;
+}
+
+
+int main()
+{
+  std::ofstream logfile("block_indices/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  
+  BlockIndices bi1(3);
+  test(bi1);
+  bi1.reinit(3,4);
+  test(bi1);
+  
+  std::vector<unsigned int> v(4);
+  for (unsigned int i=0;i<v.size();++i)
+    v[i] = 4-i;
+  
+  BlockIndices bi2(v);
+  test(bi2);
+}
diff --git a/tests/lac/block_indices/cmp/generic b/tests/lac/block_indices/cmp/generic
new file mode 100644 (file)
index 0000000..6cab4b8
--- /dev/null
@@ -0,0 +1,19 @@
+
+DEAL::blocks 3
+DEAL::elements 0
+DEAL::block sizes      0       0       0
+DEAL::Block start      0       0       0
+DEAL::
+DEAL::
+DEAL::blocks 3
+DEAL::elements 12
+DEAL::block sizes      4       4       4
+DEAL::Block start      0       4       8
+DEAL:: 0:0:0 1:0:1 2:0:2 3:0:3 4:1:0 5:1:1 6:1:2 7:1:3 8:2:0 9:2:1 10:2:2 11:2:3
+DEAL:: 0:0:0 1:0:1 2:0:2 3:0:3 4:1:0 5:1:1 6:1:2 7:1:3 8:2:0 9:2:1 10:2:2 11:2:3
+DEAL::blocks 4
+DEAL::elements 10
+DEAL::block sizes      4       3       2       1
+DEAL::Block start      0       4       7       9
+DEAL:: 0:0:0 1:0:1 2:0:2 3:0:3 4:1:0 5:1:1 6:1:2 7:2:0 8:2:1 9:3:0
+DEAL:: 0:0:0 1:0:1 2:0:2 3:0:3 4:1:0 5:1:1 6:1:2 7:2:0 8:2:1 9:3:0

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.