]> https://gitweb.dealii.org/ - dealii.git/commitdiff
move/add SolverSelector tests
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 2 Jul 2010 16:28:07 +0000 (16:28 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 2 Jul 2010 16:28:07 +0000 (16:28 +0000)
git-svn-id: https://svn.dealii.org/trunk@21446 0785d39b-7218-0410-832d-ea1e28bc413d

tests/lac/Makefile
tests/lac/solver_selector_00.cc [moved from tests/bits/solver_selector.cc with 88% similarity]
tests/lac/solver_selector_00/cmp/generic [moved from tests/bits/solver_selector/cmp/generic with 100% similarity]
tests/lac/solver_selector_01.cc [new file with mode: 0644]
tests/lac/solver_selector_01/cmp/generic [new file with mode: 0644]

index c5dace6c550ab54112f9111a549ecae94728c716..c9f8e3c3d8644d590a2853acaecc415683cef4ca 100644 (file)
@@ -47,7 +47,7 @@ tests_x = vector-vector vector_memory \
        matrix_out \
        pointer_matrix \
        pointer_matrix_vector \
-       solver \
+       solver solver_selector_* \
        eigen \
        filtered_matrix \
        sparse_ilu* \
similarity index 88%
rename from tests/bits/solver_selector.cc
rename to tests/lac/solver_selector_00.cc
index 6407bdf9c467123c9e0921550757a25be046b51d..f23a3f5f802408d8b8c340061333f47050e3419c 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$ 
 //
-//    Copyright (C) 2004, 2005, 2006 by the deal.II authors
+//    Copyright (C) 2004, 2005, 2006, 2010 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -24,7 +24,7 @@ template class SolverSelector<>;
 
 int main () 
 {  
-  std::ofstream logfile("solver_selector/output");
+  std::ofstream logfile("solver_selector_00/output");
   deallog.attach(logfile);
   deallog.depth_console(0);
   deallog.threshold_double(1.e-10);
diff --git a/tests/lac/solver_selector_01.cc b/tests/lac/solver_selector_01.cc
new file mode 100644 (file)
index 0000000..8ce9355
--- /dev/null
@@ -0,0 +1,95 @@
+//----------------------------------------------------------------------
+//    $Id$
+//
+//    Copyright (C) 2010 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.
+//
+//----------------------------------------------------------------------
+
+
+#include "../tests.h"
+#include "testmatrix.h"
+#include <base/logstream.h>
+#include <lac/sparse_matrix.h>
+#include <lac/vector.h>
+#include <lac/vector_memory.h>
+#include <lac/solver_selector.h>
+
+#include <fstream>
+
+template <class MATRIX, class VECTOR>
+void
+check(const MATRIX& A, const VECTOR& f)
+{
+  std::vector<std::string> names;
+  names.push_back("cg");
+  names.push_back("bicgstab");
+  names.push_back("gmres");
+  names.push_back("fgmres");
+
+  SolverSelector<VECTOR> solver;
+  PreconditionSSOR<SparseMatrix<double> > pre;
+  pre.initialize(A);
+  
+  VECTOR u;
+  u.reinit(f);
+  
+  std::vector<std::string>::const_iterator name;
+  for (name = names.begin(); name != names.end();++name)
+    {
+      solver.select(*name);
+      u = 0.;
+      solver.solve(A, u, f, pre);
+    }
+
+  ReductionControl cont1(100, 0., 1.e-4);
+  solver.control = cont1;
+  for (name = names.begin(); name != names.end();++name)
+    {
+      solver.select(*name);
+      u = 0.;
+      solver.solve(A, u, f, pre);
+    }
+  
+  SolverControl cont2(100, 1.e-7);
+  solver.control = cont2;
+  for (name = names.begin(); name != names.end();++name)
+    {
+      solver.select(*name);
+      u = 0.;
+      solver.solve(A, u, f, pre);
+    }
+  
+}
+
+
+int main()
+{
+  std::ofstream logfile("solver_selector_01/output");
+//  logfile.setf(std::ios::fixed);
+  deallog << std::setprecision(4);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  unsigned int size=37;
+  unsigned int dim = (size-1)*(size-1);
+  
+  deallog << "Size " << size << " Unknowns " << dim << std::endl;
+  
+                                  // Make matrix
+  FDMatrix testproblem(size, size);
+  SparsityPattern structure(dim, dim, 5);
+  testproblem.five_point_structure(structure);
+  structure.compress();
+  SparseMatrix<double>  A(structure);
+  testproblem.five_point(A);
+  Vector<double>  f(dim);
+  f = 1.;
+  
+  check(A, f);
+}
diff --git a/tests/lac/solver_selector_01/cmp/generic b/tests/lac/solver_selector_01/cmp/generic
new file mode 100644 (file)
index 0000000..983fde2
--- /dev/null
@@ -0,0 +1,26 @@
+
+DEAL::Size 37 Unknowns 1296
+DEAL:cg::Starting value 36.00
+DEAL:cg::Convergence step 14 value 0.2102
+DEAL:Bicgstab::Starting value 36.00
+DEAL:Bicgstab::Convergence step 5 value 0.2814
+DEAL:GMRES::Starting value 34.45
+DEAL:GMRES::Convergence step 13 value 0.1890
+DEAL:FGMRES::Starting value 36.00
+DEAL:FGMRES::Convergence step 13 value 0.2928
+DEAL:cg::Starting value 36.00
+DEAL:cg::Convergence step 21 value 0.003095
+DEAL:Bicgstab::Starting value 36.00
+DEAL:Bicgstab::Convergence step 10 value 0.003158
+DEAL:GMRES::Starting value 34.45
+DEAL:GMRES::Convergence step 21 value 0.001416
+DEAL:FGMRES::Starting value 36.00
+DEAL:FGMRES::Convergence step 21 value 0.002535
+DEAL:cg::Starting value 36.00
+DEAL:cg::Convergence step 39 value 7.335e-08
+DEAL:Bicgstab::Starting value 36.00
+DEAL:Bicgstab::Convergence step 27 value 1.148e-08
+DEAL:GMRES::Starting value 34.45
+DEAL:GMRES::Convergence step 39 value 6.627e-08
+DEAL:FGMRES::Starting value 36.00
+DEAL:FGMRES::Convergence step 39 value 7.890e-08

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.