############################################################
-tests_x = tridiagonal_ev1 full_matrix
+tests_x = tridiagonal_ev1 solver_cg full_matrix
# from above list of regular expressions, generate the real set of
--- /dev/null
+//----------------------------------------------------------------------
+// $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.
+//
+//----------------------------------------------------------------------
+
+// Check eigenvalue capabilities of SolverCG
+
+#include "../tests.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include "../lac/testmatrix.h"
+#include <base/logstream.h>
+#include <lac/sparse_matrix.h>
+#include <lac/sparse_matrix.templates.h>
+#include <lac/vector.h>
+#include <lac/vector_memory.h>
+#include <lac/solver_control.h>
+#include <lac/solver_cg.h>
+#include <lac/precondition.h>
+
+template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
+void
+check_solve( SOLVER& solver, const MATRIX& A,
+ VECTOR& u, VECTOR& f, const PRECONDITION& P)
+{
+ u = 0.;
+ f = 1.;
+ try
+ {
+ solver.solve(A,u,f,P);
+ }
+ catch (std::exception& e)
+ {
+ deallog << e.what() << std::endl;
+ }
+}
+
+template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
+void
+check_Tsolve(SOLVER& solver, const MATRIX& A,
+ VECTOR& u, VECTOR& f, const PRECONDITION& P)
+{
+ u = 0.;
+ f = 1.;
+ try
+ {
+ solver.Tsolve(A,u,f,P);
+ }
+ catch (std::exception& e)
+ {
+ deallog << e.what() << std::endl;
+ }
+}
+
+int main()
+{
+ std::ofstream logfile("solver_cg/output");
+// logfile.setf(std::ios::fixed);
+ logfile.precision(4);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ GrowingVectorMemory<> mem;
+ SolverControl control(100, 1.e-3);
+ SolverControl verbose_control(100, 1.e-3, true);
+ SolverCG<>::AdditionalData data(false, true, true, true);
+ SolverCG<> cg(control, mem, data);
+
+ for (unsigned int size=4; size <= 30; size *= 3)
+ {
+ 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);
+
+ PreconditionIdentity prec_no;
+ PreconditionRichardson prec_richardson;
+ prec_richardson.initialize(0.6);
+ PreconditionSSOR<> prec_ssor;
+ prec_ssor.initialize(A, 1.2);
+
+ std::vector<unsigned int> permutation(dim);
+ std::vector<unsigned int> inverse_permutation(dim);
+
+ Vector<double> f(dim);
+ Vector<double> u(dim);
+ Vector<double> res(dim);
+
+ f = 1.;
+ u = 1.;
+
+ try
+ {
+ deallog.push("no-fail");
+ control.set_max_steps(10);
+ check_solve(cg,A,u,f,prec_no);
+ control.set_max_steps(100);
+ deallog.pop();
+
+ deallog.push("no");
+ check_solve(cg,A,u,f,prec_no);
+ deallog.pop();
+
+ deallog.push("rich");
+ check_solve(cg,A,u,f,prec_richardson);
+ deallog.pop();
+
+ deallog.push("ssor");
+ check_solve(cg,A,u,f,prec_ssor);
+ deallog.pop();
+ }
+ catch (std::exception& e)
+ {
+ std::cerr << "Exception: " << e.what() << std::endl;
+ }
+ }
+}
+
--- /dev/null
+
+DEAL::Size 4 Unknowns 9
+DEAL:no-fail:cg::Starting value 3.000
+DEAL:no-fail:cg::Condition number estimate: 1.000
+DEAL:no-fail:cg::Condition number estimate: 3.535
+DEAL:no-fail:cg::Convergence step 3 value 0
+DEAL:no-fail:cg:: 1.176 4.157
+DEAL:no:cg::Starting value 3.000
+DEAL:no:cg::Condition number estimate: 1.000
+DEAL:no:cg::Condition number estimate: 3.535
+DEAL:no:cg::Convergence step 3 value 0
+DEAL:no:cg:: 1.176 4.157
+DEAL:rich:cg::Starting value 3.000
+DEAL:rich:cg::Condition number estimate: 1.000
+DEAL:rich:cg::Condition number estimate: 3.535
+DEAL:rich:cg::Convergence step 3 value 0
+DEAL:rich:cg:: 0.7056 2.494
+DEAL:ssor:cg::Starting value 3.000
+DEAL:ssor:cg::Condition number estimate: 1.000
+DEAL:ssor:cg::Condition number estimate: 1.384
+DEAL:ssor:cg::Condition number estimate: 1.421
+DEAL:ssor:cg::Convergence step 4 value 6.018e-05
+DEAL:ssor:cg:: 0.5858 0.6810 0.8324
+DEAL::Size 12 Unknowns 121
+DEAL:no-fail:cg::Starting value 11.00
+DEAL:no-fail:cg::Condition number estimate: 1.000
+DEAL:no-fail:cg::Condition number estimate: 11.01
+DEAL:no-fail:cg::Condition number estimate: 21.10
+DEAL:no-fail:cg::Condition number estimate: 33.11
+DEAL:no-fail:cg::Condition number estimate: 43.25
+DEAL:no-fail:cg::Condition number estimate: 48.52
+DEAL:no-fail:cg::Condition number estimate: 51.74
+DEAL:no-fail:cg::Condition number estimate: 53.54
+DEAL:no-fail:cg::Condition number estimate: 54.75
+DEAL:no-fail:cg::Failure step 10 value 0.1496
+DEAL:no-fail:cg:: 0.1363 0.6565 1.499 2.357 3.131 3.994 5.392 6.576 7.464
+DEAL:no-fail::Iterative method reported convergence failure in step 10 with residual 0.149566
+DEAL:no:cg::Starting value 11.00
+DEAL:no:cg::Condition number estimate: 1.000
+DEAL:no:cg::Condition number estimate: 11.01
+DEAL:no:cg::Condition number estimate: 21.10
+DEAL:no:cg::Condition number estimate: 33.11
+DEAL:no:cg::Condition number estimate: 43.25
+DEAL:no:cg::Condition number estimate: 48.52
+DEAL:no:cg::Condition number estimate: 51.74
+DEAL:no:cg::Condition number estimate: 53.54
+DEAL:no:cg::Condition number estimate: 54.75
+DEAL:no:cg::Condition number estimate: 56.00
+DEAL:no:cg::Condition number estimate: 56.76
+DEAL:no:cg::Condition number estimate: 57.32
+DEAL:no:cg::Condition number estimate: 57.64
+DEAL:no:cg::Condition number estimate: 57.68
+DEAL:no:cg::Convergence step 15 value 0.0005794
+DEAL:no:cg:: 0.1363 0.6539 1.173 1.552 2.119 2.616 3.388 3.933 4.821 5.350 6.003 6.785 7.337 7.862
+DEAL:rich:cg::Starting value 11.00
+DEAL:rich:cg::Condition number estimate: 1.000
+DEAL:rich:cg::Condition number estimate: 11.01
+DEAL:rich:cg::Condition number estimate: 21.10
+DEAL:rich:cg::Condition number estimate: 33.11
+DEAL:rich:cg::Condition number estimate: 43.25
+DEAL:rich:cg::Condition number estimate: 48.52
+DEAL:rich:cg::Condition number estimate: 51.74
+DEAL:rich:cg::Condition number estimate: 53.54
+DEAL:rich:cg::Condition number estimate: 54.75
+DEAL:rich:cg::Condition number estimate: 56.00
+DEAL:rich:cg::Condition number estimate: 56.76
+DEAL:rich:cg::Condition number estimate: 57.32
+DEAL:rich:cg::Condition number estimate: 57.64
+DEAL:rich:cg::Condition number estimate: 57.68
+DEAL:rich:cg::Convergence step 15 value 0.0005794
+DEAL:rich:cg:: 0.08178 0.3924 0.7039 0.9313 1.271 1.569 2.033 2.360 2.893 3.210 3.602 4.071 4.402 4.717
+DEAL:ssor:cg::Starting value 11.00
+DEAL:ssor:cg::Condition number estimate: 1.000
+DEAL:ssor:cg::Condition number estimate: 4.354
+DEAL:ssor:cg::Condition number estimate: 5.511
+DEAL:ssor:cg::Condition number estimate: 5.673
+DEAL:ssor:cg::Condition number estimate: 5.706
+DEAL:ssor:cg::Condition number estimate: 5.715
+DEAL:ssor:cg::Condition number estimate: 5.718
+DEAL:ssor:cg::Convergence step 8 value 0.0005816
+DEAL:ssor:cg:: 0.1457 0.3791 0.4599 0.5650 0.6652 0.7548 0.8330
+DEAL::GrowingVectorMemory:Overall allocated vectors: 32
+DEAL::GrowingVectorMemory:Maximum allocated vectors: 4
--- /dev/null
+
+DEAL::Size 4 Unknowns 9
+DEAL::SOR-diff:0.000
+DEAL:no-fail:cg::Starting value 3.000
+DEAL:no-fail:cg::Convergence step 3 value 4.807e-17
+DEAL:no-fail:Bicgstab::Starting value 3.000
+DEAL:no-fail:Bicgstab::Convergence step 3 value 9.679e-16
+DEAL:no-fail:GMRES::Starting value 3.000
+DEAL:no-fail:GMRES::Convergence step 3 value 3.701e-17
+DEAL:no-fail:GMRES::Starting value 3.000
+DEAL:no-fail:GMRES::Convergence step 3 value 3.701e-17
+DEAL:no-fail:QMRS::Starting value 3.000
+DEAL:no-fail:QMRS::Convergence step 3 value 9.615e-17
+DEAL:no:cg::Starting value 3.000
+DEAL:no:cg::Convergence step 3 value 4.807e-17
+DEAL:no:Bicgstab::Starting value 3.000
+DEAL:no:Bicgstab::Convergence step 3 value 9.679e-16
+DEAL:no:GMRES::Starting value 3.000
+DEAL:no:GMRES::Convergence step 3 value 3.701e-17
+DEAL:no:GMRES::Starting value 3.000
+DEAL:no:GMRES::Convergence step 3 value 3.701e-17
+DEAL:no:QMRS::Starting value 3.000
+DEAL:no:QMRS::Convergence step 3 value 9.615e-17
+DEAL:ssor:RichardsonT::Starting value 3.000
+DEAL:ssor:RichardsonT::Convergence step 10 value 0.0004418
+DEAL:ssor:Richardson::Starting value 3.000
+DEAL:ssor:Richardson::Convergence step 10 value 0.0004418
+DEAL:ssor:cg::Starting value 3.000
+DEAL:ssor:cg::Convergence step 4 value 6.018e-05
+DEAL:ssor:Bicgstab::Starting value 3.000
+DEAL:ssor:Bicgstab::Convergence step 2 value 0.0003670
+DEAL:ssor:GMRES::Starting value 1.600
+DEAL:ssor:GMRES::Convergence step 3 value 0.0002978
+DEAL:ssor:GMRES::Starting value 1.600
+DEAL:ssor:GMRES::Convergence step 3 value 0.0002978
+DEAL:ssor:QMRS::Starting value 3.000
+DEAL:ssor:QMRS::Convergence step 4 value 0.0001345
+DEAL:sor:RichardsonT::Starting value 3.000
+DEAL:sor:RichardsonT::Convergence step 7 value 0.0004339
+DEAL:sor:Richardson::Starting value 3.000
+DEAL:sor:Richardson::Convergence step 7 value 0.0004339
+DEAL:sor:cg::Starting value 3.000
+DEAL:sor:cg::Failure step 100 value 0.2585
+DEAL:sor::Iterative method reported convergence failure in step 100 with residual 0.258509
+DEAL:sor:Bicgstab::Starting value 3.000
+DEAL:sor:Bicgstab::Convergence step 5 value 1.443e-15
+DEAL:sor:GMRES::Starting value 1.462
+DEAL:sor:GMRES::Convergence step 5 value 2.665e-18
+DEAL:sor:GMRES::Starting value 1.462
+DEAL:sor:GMRES::Convergence step 5 value 2.665e-18
+DEAL:psor:RichardsonT::Starting value 3.000
+DEAL:psor:RichardsonT::Convergence step 8 value 0.0004237
+DEAL:psor:Richardson::Starting value 3.000
+DEAL:psor:Richardson::Convergence step 8 value 0.0004237
+DEAL:psor:cg::Starting value 3.000
+DEAL:psor:cg::Failure step 100 value 0.1024
+DEAL:psor::Iterative method reported convergence failure in step 100 with residual 0.102391
+DEAL:psor:Bicgstab::Starting value 3.000
+DEAL:psor:Bicgstab::Convergence step 4 value 0.0001279
+DEAL:psor:GMRES::Starting value 1.467
+DEAL:psor:GMRES::Convergence step 5 value 0.0006649
+DEAL:psor:GMRES::Starting value 1.467
+DEAL:psor:GMRES::Convergence step 5 value 0.0006649
+DEAL::Size 12 Unknowns 121
+DEAL::SOR-diff:0.000
+DEAL:no-fail:cg::Starting value 11.00
+DEAL:no-fail:cg::Failure step 10 value 0.1496
+DEAL:no-fail::Iterative method reported convergence failure in step 10 with residual 0.149566
+DEAL:no-fail:Bicgstab::Starting value 11.00
+DEAL:no-fail:Bicgstab::Failure step 10 value 0.001961
+DEAL:no-fail::Iterative method reported convergence failure in step 10 with residual 0.00196051
+DEAL:no-fail:GMRES::Starting value 11.00
+DEAL:no-fail:GMRES::Failure step 10 value 0.8414
+DEAL:no-fail::Iterative method reported convergence failure in step 10 with residual 0.841354
+DEAL:no-fail:GMRES::Starting value 11.00
+DEAL:no-fail:GMRES::Failure step 10 value 0.8414
+DEAL:no-fail::Iterative method reported convergence failure in step 10 with residual 0.841354
+DEAL:no-fail:QMRS::Starting value 11.00
+DEAL:no-fail:QMRS::Failure step 10 value 0.4215
+DEAL:no-fail::Iterative method reported convergence failure in step 10 with residual 0.421504
+DEAL:no:cg::Starting value 11.00
+DEAL:no:cg::Convergence step 15 value 0.0005794
+DEAL:no:Bicgstab::Starting value 11.00
+DEAL:no:Bicgstab::Convergence step 11 value 0.0003990
+DEAL:no:GMRES::Starting value 11.00
+DEAL:no:GMRES::Convergence step 43 value 0.0009788
+DEAL:no:GMRES::Starting value 11.00
+DEAL:no:GMRES::Convergence step 43 value 0.0009788
+DEAL:no:QMRS::Starting value 11.00
+DEAL:no:QMRS::Convergence step 16 value 0.0002583
+DEAL:ssor:RichardsonT::Starting value 11.00
+DEAL:ssor:RichardsonT::Convergence step 59 value 0.0008892
+DEAL:ssor:Richardson::Starting value 11.00
+DEAL:ssor:Richardson::Convergence step 59 value 0.0008892
+DEAL:ssor:cg::Starting value 11.00
+DEAL:ssor:cg::Convergence step 8 value 0.0005816
+DEAL:ssor:Bicgstab::Starting value 11.00
+DEAL:ssor:Bicgstab::Convergence step 5 value 9.315e-05
+DEAL:ssor:GMRES::Starting value 11.05
+DEAL:ssor:GMRES::Convergence step 7 value 0.0006838
+DEAL:ssor:GMRES::Starting value 11.05
+DEAL:ssor:GMRES::Convergence step 7 value 0.0006838
+DEAL:ssor:QMRS::Starting value 11.00
+DEAL:ssor:QMRS::Convergence step 9 value 0.0004140
+DEAL:sor:RichardsonT::Starting value 11.00
+DEAL:sor:RichardsonT::Convergence step 88 value 0.0009636
+DEAL:sor:Richardson::Starting value 11.00
+DEAL:sor:Richardson::Convergence step 88 value 0.0009636
+DEAL:sor:cg::Starting value 11.00
+DEAL:sor:cg::Failure step 100 value 5.643
+DEAL:sor::Iterative method reported convergence failure in step 100 with residual 5.64329
+DEAL:sor:Bicgstab::Starting value 11.00
+DEAL:sor:Bicgstab::Convergence step 14 value 0.0009987
+DEAL:sor:GMRES::Starting value 7.322
+DEAL:sor:GMRES::Convergence step 23 value 0.0006981
+DEAL:sor:GMRES::Starting value 7.322
+DEAL:sor:GMRES::Convergence step 23 value 0.0006981
+DEAL:psor:RichardsonT::Starting value 11.00
+DEAL:psor:RichardsonT::Convergence step 89 value 0.0009736
+DEAL:psor:Richardson::Starting value 11.00
+DEAL:psor:Richardson::Convergence step 89 value 0.0009736
+DEAL:psor:cg::Starting value 11.00
+DEAL:psor:cg::Failure step 100 value 2.935
+DEAL:psor::Iterative method reported convergence failure in step 100 with residual 2.93488
+DEAL:psor:Bicgstab::Starting value 11.00
+DEAL:psor:Bicgstab::Convergence step 11 value 0.0001588
+DEAL:psor:GMRES::Starting value 7.345
+DEAL:psor:GMRES::Convergence step 20 value 0.0008491
+DEAL:psor:GMRES::Starting value 7.345
+DEAL:psor:GMRES::Convergence step 20 value 0.0008491
+DEAL::GrowingVectorMemory:Overall allocated vectors: 312
+DEAL::GrowingVectorMemory:Maximum allocated vectors: 8