From: wolf Date: Wed, 25 Feb 2004 21:28:41 +0000 (+0000) Subject: Check the solvers we have. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c2aefc711921ca4396de7ea9e3aa709110c7c48;p=dealii-svn.git Check the solvers we have. git-svn-id: https://svn.dealii.org/trunk@8547 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/bits/Makefile b/tests/bits/Makefile index 5492e761d5..5199180e4f 100644 --- a/tests/bits/Makefile +++ b/tests/bits/Makefile @@ -49,7 +49,8 @@ tests_x = anna_? \ find_cell_* \ sparse_matrix_* \ full_matrix_vector_* \ - solver_selector + solver_selector \ + deal_solver_* ifeq ($(USE_CONTRIB_PETSC),yes) tests_x += vector_* petsc_* diff --git a/tests/bits/deal_solver_01.cc b/tests/bits/deal_solver_01.cc new file mode 100644 index 0000000000..35e9b1e0bf --- /dev/null +++ b/tests/bits/deal_solver_01.cc @@ -0,0 +1,92 @@ +//---------------------------- deal_solver_01.cc --------------------------- +// deal_solver_01.cc,v 1.33 2003/05/30 19:19:16 guido Exp +// Version: +// +// Copyright (C) 2004 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. +// +//---------------------------- deal_solver_01.cc --------------------------- + +// test the CG solver + + +#include "../tests.h" +#include "../lac/testmatrix.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +void +check_solve( SOLVER& solver, const MATRIX& A, + VECTOR& u, VECTOR& f, const PRECONDITION& P) +{ + deallog << "Solver type: " << typeid(solver).name() << std::endl; + + u = 0.; + f = 1.; + try + { + solver.solve(A,u,f,P); + } + catch (std::exception& e) + { + deallog << e.what() << std::endl; + abort (); + } + + deallog << "Solver stopped after " << solver.control().last_step() + << " iterations" << std::endl; +} + + +int main() +{ + std::ofstream logfile("deal_solver_01.output"); + logfile.precision(4); + deallog.attach(logfile); + deallog.depth_console(0); + + GrowingVectorMemory<> mem; + SolverControl control(100, 1.e-3); + + const unsigned int size = 32; + 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 A(structure); + testproblem.five_point(A); + + Vector f(dim); + Vector u(dim); + f = 1.; + + SolverCG<> solver(control, mem); + PreconditionIdentity preconditioner; + check_solve (solver, A,u,f, preconditioner); +} + diff --git a/tests/bits/deal_solver_02.cc b/tests/bits/deal_solver_02.cc new file mode 100644 index 0000000000..8685f62f7f --- /dev/null +++ b/tests/bits/deal_solver_02.cc @@ -0,0 +1,94 @@ + +//---------------------------- deal_solver_02.cc --------------------------- +// deal_solver_02.cc,v 1.33 2003/05/30 19:19:16 guido Exp +// Version: +// +// Copyright (C) 2004 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. +// +//---------------------------- deal_solver_02.cc --------------------------- + +// test the BiCGStab solver + + + +#include "../tests.h" +#include "../lac/testmatrix.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +void +check_solve( SOLVER& solver, const MATRIX& A, + VECTOR& u, VECTOR& f, const PRECONDITION& P) +{ + deallog << "Solver type: " << typeid(solver).name() << std::endl; + + u = 0.; + f = 1.; + try + { + solver.solve(A,u,f,P); + } + catch (std::exception& e) + { + deallog << e.what() << std::endl; + abort (); + } + + deallog << "Solver stopped after " << solver.control().last_step() + << " iterations" << std::endl; +} + + +int main() +{ + std::ofstream logfile("deal_solver_02.output"); + logfile.precision(4); + deallog.attach(logfile); + deallog.depth_console(0); + + GrowingVectorMemory<> mem; + SolverControl control(100, 1.e-3); + + const unsigned int size = 32; + 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 A(structure); + testproblem.five_point(A); + + Vector f(dim); + Vector u(dim); + f = 1.; + + SolverBicgstab<> solver(control, mem); + PreconditionIdentity preconditioner; + check_solve (solver, A,u,f, preconditioner); +} + diff --git a/tests/bits/deal_solver_03.cc b/tests/bits/deal_solver_03.cc new file mode 100644 index 0000000000..82b81b3f8a --- /dev/null +++ b/tests/bits/deal_solver_03.cc @@ -0,0 +1,94 @@ + +//---------------------------- deal_solver_03.cc --------------------------- +// deal_solver_03.cc,v 1.33 2003/05/30 19:19:16 guido Exp +// Version: +// +// Copyright (C) 2004 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. +// +//---------------------------- deal_solver_03.cc --------------------------- + +// test the GMRES solver + + + +#include "../tests.h" +#include "../lac/testmatrix.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +void +check_solve( SOLVER& solver, const MATRIX& A, + VECTOR& u, VECTOR& f, const PRECONDITION& P) +{ + deallog << "Solver type: " << typeid(solver).name() << std::endl; + + u = 0.; + f = 1.; + try + { + solver.solve(A,u,f,P); + } + catch (std::exception& e) + { + deallog << e.what() << std::endl; + abort (); + } + + deallog << "Solver stopped after " << solver.control().last_step() + << " iterations" << std::endl; +} + + +int main() +{ + std::ofstream logfile("deal_solver_03.output"); + logfile.precision(4); + deallog.attach(logfile); + deallog.depth_console(0); + + GrowingVectorMemory<> mem; + SolverControl control(100, 1.e-3); + + const unsigned int size = 32; + 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 A(structure); + testproblem.five_point(A); + + Vector f(dim); + Vector u(dim); + f = 1.; + + SolverGMRES<> solver(control, mem); + PreconditionIdentity preconditioner; + check_solve (solver, A,u,f, preconditioner); +} + diff --git a/tests/bits/deal_solver_04.cc b/tests/bits/deal_solver_04.cc new file mode 100644 index 0000000000..9d6c5f71d2 --- /dev/null +++ b/tests/bits/deal_solver_04.cc @@ -0,0 +1,94 @@ + +//---------------------------- deal_solver_04.cc --------------------------- +// deal_solver_04.cc,v 1.33 2003/05/30 19:19:16 guido Exp +// Version: +// +// Copyright (C) 2004 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. +// +//---------------------------- deal_solver_04.cc --------------------------- + +// test the MINRES solver + + +#include "../tests.h" +#include "../lac/testmatrix.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +void +check_solve( SOLVER& solver, const MATRIX& A, + VECTOR& u, VECTOR& f, const PRECONDITION& P) +{ + deallog << "Solver type: " << typeid(solver).name() << std::endl; + + u = 0.; + f = 1.; + try + { + solver.solve(A,u,f,P); + } + catch (std::exception& e) + { + deallog << e.what() << std::endl; + abort (); + } + + deallog << "Solver stopped after " << solver.control().last_step() + << " iterations" << std::endl; +} + + +int main() +{ + std::ofstream logfile("deal_solver_04.output"); + logfile.precision(4); + deallog.attach(logfile); + deallog.depth_console(0); + + GrowingVectorMemory<> mem; + SolverControl control(100, 1.e-3); + + const unsigned int size = 32; + 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 A(structure); + testproblem.five_point(A); + + Vector f(dim); + Vector u(dim); + f = 1.; + + SolverMinRes<> solver(control, mem); + PreconditionIdentity preconditioner; + check_solve (solver, A,u,f, preconditioner); +} + diff --git a/tests/bits/deal_solver_05.cc b/tests/bits/deal_solver_05.cc new file mode 100644 index 0000000000..4d74120844 --- /dev/null +++ b/tests/bits/deal_solver_05.cc @@ -0,0 +1,93 @@ + +//---------------------------- deal_solver_05.cc --------------------------- +// deal_solver_05.cc,v 1.33 2003/05/30 19:19:16 guido Exp +// Version: +// +// Copyright (C) 2004 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. +// +//---------------------------- deal_solver_05.cc --------------------------- + +// test the QMRS solver + + +#include "../tests.h" +#include "../lac/testmatrix.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +void +check_solve( SOLVER& solver, const MATRIX& A, + VECTOR& u, VECTOR& f, const PRECONDITION& P) +{ + deallog << "Solver type: " << typeid(solver).name() << std::endl; + + u = 0.; + f = 1.; + try + { + solver.solve(A,u,f,P); + } + catch (std::exception& e) + { + deallog << e.what() << std::endl; + abort (); + } + + deallog << "Solver stopped after " << solver.control().last_step() + << " iterations" << std::endl; +} + + +int main() +{ + std::ofstream logfile("deal_solver_05.output"); + logfile.precision(4); + deallog.attach(logfile); + deallog.depth_console(0); + + GrowingVectorMemory<> mem; + SolverControl control(100, 1.e-3); + + const unsigned int size = 32; + 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 A(structure); + testproblem.five_point(A); + + Vector f(dim); + Vector u(dim); + f = 1.; + + SolverQMRS<> solver(control, mem); + PreconditionIdentity preconditioner; + check_solve (solver, A,u,f, preconditioner); +} + diff --git a/tests/bits/deal_solver_06.cc b/tests/bits/deal_solver_06.cc new file mode 100644 index 0000000000..f39e04ac4f --- /dev/null +++ b/tests/bits/deal_solver_06.cc @@ -0,0 +1,92 @@ + +//---------------------------- deal_solver_06.cc --------------------------- +// deal_solver_06.cc,v 1.33 2003/05/30 19:19:16 guido Exp +// Version: +// +// Copyright (C) 2004 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. +// +//---------------------------- deal_solver_06.cc --------------------------- + +// test the Richardson solver + + +#include "../tests.h" +#include "../lac/testmatrix.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +void +check_solve( SOLVER& solver, const MATRIX& A, + VECTOR& u, VECTOR& f, const PRECONDITION& P) +{ + deallog << "Solver type: " << typeid(solver).name() << std::endl; + + u = 0.; + f = 1.; + try + { + solver.solve(A,u,f,P); + } + catch (std::exception& e) + { + deallog << e.what() << std::endl; + } + + deallog << "Solver stopped after " << solver.control().last_step() + << " iterations" << std::endl; +} + + +int main() +{ + std::ofstream logfile("deal_solver_06.output"); + logfile.precision(4); + deallog.attach(logfile); + deallog.depth_console(0); + + GrowingVectorMemory<> mem; + + const unsigned int size = 32; + unsigned int dim = (size-1)*(size-1); + SolverControl control(10000, 1.e-3); + + 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 A(structure); + testproblem.five_point(A); + + Vector f(dim); + Vector u(dim); + f = 1.; + + SolverRichardson<> solver(control, mem); + PreconditionIdentity preconditioner; + check_solve (solver, A,u,f, preconditioner); +} + diff --git a/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_01.output b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_01.output new file mode 100644 index 0000000000..d16f870c36 --- /dev/null +++ b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_01.output @@ -0,0 +1,8 @@ + +DEAL::Size 32 Unknowns 961 +DEAL::Solver type: 8SolverCGI6VectorIdEE +DEAL:cg::Starting value 31.00 +DEAL:cg::Convergence step 43 value 0.0008189 +DEAL::Solver stopped after 43 iterations +DEAL::GrowingVectorMemory:Overall allocated vectors: 4 +DEAL::GrowingVectorMemory:Maximum allocated vectors: 4 diff --git a/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_02.output b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_02.output new file mode 100644 index 0000000000..1725efa3c7 --- /dev/null +++ b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_02.output @@ -0,0 +1,8 @@ + +DEAL::Size 32 Unknowns 961 +DEAL::Solver type: 14SolverBicgstabI6VectorIdEE +DEAL:Bicgstab::Starting value 31.00 +DEAL:Bicgstab::Convergence step 35 value 0.0004803 +DEAL::Solver stopped after 35 iterations +DEAL::GrowingVectorMemory:Overall allocated vectors: 8 +DEAL::GrowingVectorMemory:Maximum allocated vectors: 8 diff --git a/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_03.output b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_03.output new file mode 100644 index 0000000000..85a7f46bb8 --- /dev/null +++ b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_03.output @@ -0,0 +1,8 @@ + +DEAL::Size 32 Unknowns 961 +DEAL::Solver type: 11SolverGMRESI6VectorIdEE +DEAL:GMRES::Starting value 31.00 +DEAL:GMRES::Convergence step 75 value 0.0008096 +DEAL::Solver stopped after 75 iterations +DEAL::GrowingVectorMemory:Overall allocated vectors: 30 +DEAL::GrowingVectorMemory:Maximum allocated vectors: 30 diff --git a/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_04.output b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_04.output new file mode 100644 index 0000000000..2515ebf564 --- /dev/null +++ b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_04.output @@ -0,0 +1,8 @@ + +DEAL::Size 32 Unknowns 961 +DEAL::Solver type: 12SolverMinResI6VectorIdEE +DEAL:minres::Starting value 31.00 +DEAL:minres::Convergence step 43 value 0.0006916 +DEAL::Solver stopped after 43 iterations +DEAL::GrowingVectorMemory:Overall allocated vectors: 7 +DEAL::GrowingVectorMemory:Maximum allocated vectors: 7 diff --git a/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_05.output b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_05.output new file mode 100644 index 0000000000..0d62be6568 --- /dev/null +++ b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_05.output @@ -0,0 +1,8 @@ + +DEAL::Size 32 Unknowns 961 +DEAL::Solver type: 10SolverQMRSI6VectorIdEE +DEAL:QMRS::Starting value 31.00 +DEAL:QMRS::Convergence step 46 value 0.0009063 +DEAL::Solver stopped after 46 iterations +DEAL::GrowingVectorMemory:Overall allocated vectors: 5 +DEAL::GrowingVectorMemory:Maximum allocated vectors: 5 diff --git a/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_06.output b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_06.output new file mode 100644 index 0000000000..da5a8b79e9 --- /dev/null +++ b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/deal_solver_06.output @@ -0,0 +1,9 @@ + +DEAL::Size 32 Unknowns 961 +DEAL::Solver type: 16SolverRichardsonI6VectorIdEE +DEAL:Richardson::Starting value 31.00 +DEAL:Richardson::Failure step 374 value nan +DEAL::Iterative method reported convergence failure in step 374 with residual nan +DEAL::Solver stopped after 374 iterations +DEAL::GrowingVectorMemory:Overall allocated vectors: 2 +DEAL::GrowingVectorMemory:Maximum allocated vectors: 2