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 \
--- /dev/null
+//----------------------------------------------------------------------
+// $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);
+}
--- /dev/null
+
+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