]> https://gitweb.dealii.org/ - dealii.git/commitdiff
test for new reinit of BlockSparsityPattern
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Thu, 30 Mar 2006 20:58:43 +0000 (20:58 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Thu, 30 Mar 2006 20:58:43 +0000 (20:58 +0000)
git-svn-id: https://svn.dealii.org/trunk@12783 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 370f5f4fe708e9e299e9e40a798427b166ce95b6..beaca1e4f3ea62394e59df268c3aa64e8bd78cb0 100644 (file)
@@ -23,6 +23,7 @@ default: run-tests
 tests_x = vector-vector \
        full_matrix householder tridiagonal_matrix \
        sparsity_pattern sparse_matrices matrices \
+       block_sparsity_pattern_01 \
        block_vector block_vector_iterator block_matrices \
        matrix_lib matrix_out \
        solver eigen \
diff --git a/tests/lac/block_sparsity_pattern_01.cc b/tests/lac/block_sparsity_pattern_01.cc
new file mode 100644 (file)
index 0000000..b46cdfc
--- /dev/null
@@ -0,0 +1,77 @@
+//----------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2006 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 reinit(BlockIndices...)
+
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/block_sparsity_pattern.h>
+
+#include <fstream>
+
+int main()
+{
+  std::ofstream logfile("block_sparsity_pattern_01/output");
+  logfile.setf(std::ios::fixed);
+  logfile.precision(2);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  BlockSparsityPattern sparsity;
+  std::vector<unsigned int> row_blocks(4);
+  row_blocks[0] = 4;
+  row_blocks[1] = 5;
+  row_blocks[2] = 1;
+  row_blocks[3] = 4;
+  std::vector<unsigned int> col_blocks(3);
+  col_blocks[0] = 2;
+  col_blocks[1] = 3;
+  col_blocks[2] = 2;
+  BlockIndices rows(row_blocks);
+  BlockIndices cols(col_blocks);
+
+  std::vector<std::vector<unsigned int> >
+    row_length(cols.size(),
+              std::vector<unsigned int>(rows.total_size()));
+  for (unsigned int jb=0;jb<row_length.size();++jb)
+      for (unsigned int i=0;i<row_length[jb].size();++i)
+       {
+         const unsigned int d = col_blocks[jb]-1;
+         row_length[jb][i] = (i+1) % d +1;
+       }
+  
+  for (unsigned int j=0;j<row_length.size();++j)
+    {
+      for (unsigned int i=0;i<row_length[j].size();++i)
+       deallog << ' ' << row_length[j][i];
+      deallog << std::endl;
+    }
+  
+  sparsity.reinit(rows, cols, row_length);
+
+  for (unsigned int ib = 0;ib<rows.size();++ib)
+    for (unsigned int i=0;i<rows.block_size(ib);++i)
+      {
+       const unsigned int ii = rows.local_to_global(ib,i);
+       for (unsigned int jb = 0;jb<cols.size();++jb)
+         for (unsigned int j=0;j<row_length[jb][ii];++j)
+           sparsity.add(ii, cols.local_to_global(jb,j));
+      }
+  
+  sparsity.print(logfile);
+  
+  return 0;
+}
diff --git a/tests/lac/block_sparsity_pattern_01/cmp/generic b/tests/lac/block_sparsity_pattern_01/cmp/generic
new file mode 100644 (file)
index 0000000..a1c28d5
--- /dev/null
@@ -0,0 +1,18 @@
+JobId unknown Thu Mar 30 22:53:04 2006
+DEAL:: 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+DEAL:: 2 1 2 1 2 1 2 1 2 1 2 1 2 1
+DEAL:: 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+[0,0,2,3,5]
+[1,0,2,5]
+[2,0,2,3,5]
+[3,0,2,5]
+[4,0,2,3,5]
+[5,0,2,5]
+[6,0,2,3,5]
+[7,0,2,5]
+[8,0,2,3,5]
+[9,0,2,5]
+[10,0,2,3,5]
+[11,0,2,5]
+[12,0,2,3,5]
+[13,0,2,5]

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.