]> https://gitweb.dealii.org/ - dealii.git/commitdiff
a test that presently fails because minres is not equipped to deal with block systems
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 17 Feb 2006 00:00:54 +0000 (00:00 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 17 Feb 2006 00:00:54 +0000 (00:00 +0000)
git-svn-id: https://svn.dealii.org/trunk@12392 0785d39b-7218-0410-832d-ea1e28bc413d

tests/lac/Makefile
tests/lac/block_minres.cc [new file with mode: 0644]

index 3cae089c98bf0dc9e9c8ca5f5057563b70a7be8f..de443419923df314838fe773773d0962de748b24 100644 (file)
@@ -1,6 +1,6 @@
 ############################################################
 # $Id$
-# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors
+# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
 ############################################################
 
 ############################################################
@@ -26,7 +26,7 @@ tests_x = vector-vector \
        block_vector block_vector_iterator block_matrices \
        matrix_lib matrix_out \
        solver eigen \
-       sparse_ilu sparse_ilu_t lapack
+       sparse_ilu sparse_ilu_t lapack block_minres
 
 
 # from above list of regular expressions, generate the real set of
diff --git a/tests/lac/block_minres.cc b/tests/lac/block_minres.cc
new file mode 100644 (file)
index 0000000..ea0f9ea
--- /dev/null
@@ -0,0 +1,84 @@
+//----------------------------  block_matrices.cc  ---------------------------
+//    $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.
+//
+//----------------------------  block_matrices.cc  ---------------------------
+
+// MinRes can't deal with block systems at the time of writing this test
+
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/block_sparsity_pattern.h>
+#include <lac/block_sparse_matrix.h>
+#include <lac/block_vector.h>
+#include <lac/solver_control.h>
+#include <lac/solver_minres.h>
+#include <lac/precondition.h>
+#include <fstream>
+#include <iostream>
+
+
+int main()
+{
+  std::ofstream logfile("block_minres/output");
+  logfile.precision(2);
+  deallog.attach(logfile);
+
+
+                                  // assemble a 2x2 block identity
+                                  // matrix
+  BlockSparsityPattern block_structure(2,2);
+  block_structure.block(0,0).reinit (2,2,1);
+  block_structure.block(0,1).reinit (2,2,1);
+  block_structure.block(1,0).reinit (2,2,1);
+  block_structure.block(1,1).reinit (2,2,1);
+  block_structure.collect_sizes ();
+
+  block_structure.add (0,0);
+  block_structure.add (1,1);
+  block_structure.add (2,2);
+  block_structure.add (3,3);
+  block_structure.compress();
+
+  BlockSparseMatrix<double>  block_A(block_structure);
+  block_A.add(0,0,1);
+  block_A.add(1,1,1);
+  block_A.add(2,2,1);
+  block_A.add(3,3,1);
+
+                                  // block vector with 2 blocks of 2
+                                  // components each
+  BlockVector<double> a (2,2);
+  a(0) = 2;
+  a(1) = 3;
+  a(2) = 4;
+  a(3) = 5;
+  
+                                  // this should work (check that
+                                  // sizes of objects are all
+                                  // correct)
+  BlockVector<double> b (2,2);
+  block_A.vmult (b,a);
+
+                                  // and while at it also check
+                                  // whether the result was correct
+  Assert (b(0) == 2, ExcInternalError());
+  Assert (b(1) == 3, ExcInternalError());
+  Assert (b(2) == 4, ExcInternalError());
+  Assert (b(3) == 5, ExcInternalError());
+
+                                  // now solve with MinRes. This
+                                  // didn't work at one point
+  SolverControl  solver_control (1000, 1e-12);
+  SolverMinRes<BlockVector<double> > minres (solver_control);
+
+  minres.solve (block_A, b, a, PreconditionIdentity());
+}

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.