From 09eafbdb4f097381c694711376c9b29b7b79473a Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 25 Feb 2004 22:28:07 +0000 Subject: [PATCH] New tests. git-svn-id: https://svn.dealii.org/trunk@8556 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/bits/petsc_deal_solver_01.cc | 95 +++++++++++++++++++++++++++++ tests/bits/petsc_deal_solver_02.cc | 97 ++++++++++++++++++++++++++++++ tests/bits/petsc_deal_solver_03.cc | 97 ++++++++++++++++++++++++++++++ tests/bits/petsc_deal_solver_04.cc | 96 +++++++++++++++++++++++++++++ tests/bits/petsc_deal_solver_05.cc | 95 +++++++++++++++++++++++++++++ tests/bits/petsc_deal_solver_06.cc | 94 +++++++++++++++++++++++++++++ 6 files changed, 574 insertions(+) create mode 100644 tests/bits/petsc_deal_solver_01.cc create mode 100644 tests/bits/petsc_deal_solver_02.cc create mode 100644 tests/bits/petsc_deal_solver_03.cc create mode 100644 tests/bits/petsc_deal_solver_04.cc create mode 100644 tests/bits/petsc_deal_solver_05.cc create mode 100644 tests/bits/petsc_deal_solver_06.cc diff --git a/tests/bits/petsc_deal_solver_01.cc b/tests/bits/petsc_deal_solver_01.cc new file mode 100644 index 0000000000..b0959af311 --- /dev/null +++ b/tests/bits/petsc_deal_solver_01.cc @@ -0,0 +1,95 @@ +//---------------------------- petsc_deal_solver_01.cc --------------------------- +// petsc_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. +// +//---------------------------- petsc_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 + +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(int argc, char **argv) +{ + PetscInitialize(&argc,&argv,0,0); + { + std::ofstream logfile("petsc_deal_solver_01.output"); + logfile.precision(4); + deallog.attach(logfile); + deallog.depth_console(0); + + 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); + petsc_wrappers::SparseMatrix A(dim, dim, 5); + testproblem.five_point(A); + + petsc_wrappers::Vector f(dim); + petsc_wrappers::Vector u(dim); + f = 1.; + A.compress (); + f.compress (); + u.compress (); + + GrowingVectorMemory mem; + SolverCG solver(control,mem); + PreconditionIdentity preconditioner; + check_solve (solver, A,u,f, preconditioner); + } + PetscFinalize (); +} + diff --git a/tests/bits/petsc_deal_solver_02.cc b/tests/bits/petsc_deal_solver_02.cc new file mode 100644 index 0000000000..6bd240bc48 --- /dev/null +++ b/tests/bits/petsc_deal_solver_02.cc @@ -0,0 +1,97 @@ +//---------------------------- petsc_deal_solver_02.cc --------------------------- +// petsc_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. +// +//---------------------------- petsc_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(int argc, char **argv) +{ + PetscInitialize(&argc,&argv,0,0); + { + std::ofstream logfile("petsc_deal_solver_02.output"); + logfile.precision(4); + deallog.attach(logfile); + deallog.depth_console(0); + + 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); + petsc_wrappers::SparseMatrix A(dim, dim, 5); + testproblem.five_point(A); + + petsc_wrappers::Vector f(dim); + petsc_wrappers::Vector u(dim); + f = 1.; + A.compress (); + f.compress (); + u.compress (); + + GrowingVectorMemory mem; + SolverBicgstab solver(control,mem); + PreconditionIdentity preconditioner; + check_solve (solver, A,u,f, preconditioner); + } + PetscFinalize (); +} + diff --git a/tests/bits/petsc_deal_solver_03.cc b/tests/bits/petsc_deal_solver_03.cc new file mode 100644 index 0000000000..2b83fba59e --- /dev/null +++ b/tests/bits/petsc_deal_solver_03.cc @@ -0,0 +1,97 @@ +//---------------------------- petsc_deal_solver_03.cc --------------------------- +// petsc_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. +// +//---------------------------- petsc_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(int argc, char **argv) +{ + PetscInitialize(&argc,&argv,0,0); + { + std::ofstream logfile("petsc_deal_solver_03.output"); + logfile.precision(4); + deallog.attach(logfile); + deallog.depth_console(0); + + 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); + petsc_wrappers::SparseMatrix A(dim, dim, 5); + testproblem.five_point(A); + + petsc_wrappers::Vector f(dim); + petsc_wrappers::Vector u(dim); + f = 1.; + A.compress (); + f.compress (); + u.compress (); + + GrowingVectorMemory mem; + SolverGMRES solver(control,mem); + PreconditionIdentity preconditioner; + check_solve (solver, A,u,f, preconditioner); + } + PetscFinalize (); +} + diff --git a/tests/bits/petsc_deal_solver_04.cc b/tests/bits/petsc_deal_solver_04.cc new file mode 100644 index 0000000000..a444caf5b5 --- /dev/null +++ b/tests/bits/petsc_deal_solver_04.cc @@ -0,0 +1,96 @@ +//---------------------------- petsc_deal_solver_04.cc --------------------------- +// petsc_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. +// +//---------------------------- petsc_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 + +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(int argc, char **argv) +{ + PetscInitialize(&argc,&argv,0,0); + { + std::ofstream logfile("petsc_deal_solver_04.output"); + logfile.precision(4); + deallog.attach(logfile); + deallog.depth_console(0); + + 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); + petsc_wrappers::SparseMatrix A(dim, dim, 5); + testproblem.five_point(A); + + petsc_wrappers::Vector f(dim); + petsc_wrappers::Vector u(dim); + f = 1.; + A.compress (); + f.compress (); + u.compress (); + + GrowingVectorMemory mem; + SolverMinRes solver(control,mem); + PreconditionIdentity preconditioner; + check_solve (solver, A,u,f, preconditioner); + } + PetscFinalize (); +} + diff --git a/tests/bits/petsc_deal_solver_05.cc b/tests/bits/petsc_deal_solver_05.cc new file mode 100644 index 0000000000..d49dee045c --- /dev/null +++ b/tests/bits/petsc_deal_solver_05.cc @@ -0,0 +1,95 @@ +//---------------------------- petsc_deal_solver_05.cc --------------------------- +// petsc_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. +// +//---------------------------- petsc_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 + +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(int argc, char **argv) +{ + PetscInitialize(&argc,&argv,0,0); + { + std::ofstream logfile("petsc_deal_solver_05.output"); + logfile.precision(4); + deallog.attach(logfile); + deallog.depth_console(0); + + 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); + petsc_wrappers::SparseMatrix A(dim, dim, 5); + testproblem.five_point(A); + + petsc_wrappers::Vector f(dim); + petsc_wrappers::Vector u(dim); + f = 1.; + A.compress (); + f.compress (); + u.compress (); + + GrowingVectorMemory mem; + SolverQMRS solver(control,mem); + PreconditionIdentity preconditioner; + check_solve (solver, A,u,f, preconditioner); + } + PetscFinalize (); +} + diff --git a/tests/bits/petsc_deal_solver_06.cc b/tests/bits/petsc_deal_solver_06.cc new file mode 100644 index 0000000000..1c61d4088e --- /dev/null +++ b/tests/bits/petsc_deal_solver_06.cc @@ -0,0 +1,94 @@ +//---------------------------- petsc_deal_solver_06.cc --------------------------- +// petsc_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. +// +//---------------------------- petsc_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 + +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(int argc, char **argv) +{ + PetscInitialize(&argc,&argv,0,0); + { + std::ofstream logfile("petsc_deal_solver_06.output"); + logfile.precision(4); + deallog.attach(logfile); + deallog.depth_console(0); + + + 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); + petsc_wrappers::SparseMatrix A(dim, dim, 5); + testproblem.five_point(A); + + petsc_wrappers::Vector f(dim); + petsc_wrappers::Vector u(dim); + f = 1.; + A.compress (); + f.compress (); + u.compress (); + + GrowingVectorMemory mem; + SolverRichardson solver(control,mem); + PreconditionIdentity preconditioner; + check_solve (solver, A,u,f, preconditioner); + } + PetscFinalize (); +} + -- 2.39.5