--- /dev/null
+// ---------------------------------------------------------------------
+// $Id: solver_real_01.cc
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// test the PETSc Richardson solver
+
+// Note: This is (almost) a clone of the tests/petsc/solver_01.cc
+
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/petsc_solver.h>
+#include <deal.II/lac/petsc_precondition.h>
+#include <deal.II/lac/vector_memory.h>
+#include <typeinfo>
+
+template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
+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;
+ // it needs to be expected for the
+ // richardson solver that we end up
+ // here, so don't abort
+ }
+
+ deallog << "Solver stopped after " << solver.control().last_step()
+ << " iterations" << std::endl;
+}
+
+
+int main(int argc, char **argv)
+{
+ std::ofstream logfile("solver_real_01/output");
+ deallog.attach(logfile);
+ deallog << std::setprecision(4);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+ {
+ 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);
+ PETScWrappers::SparseMatrix A(dim, dim, 5);
+ testproblem.five_point(A);
+
+ PETScWrappers::Vector f(dim);
+ PETScWrappers::Vector u(dim);
+ f = 1.;
+ A.compress (VectorOperation::add);
+ f.compress (VectorOperation::add);
+ u.compress (VectorOperation::add);
+
+ PETScWrappers::SolverRichardson solver(control);
+ PETScWrappers::PreconditionJacobi preconditioner(A);
+ check_solve (solver, A,u,f, preconditioner);
+ }
+
+}
+
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers16SolverRichardsonE
+DEAL::Starting value 7.750
+DEAL::Failure step 100 value 4.004
+DEAL::Iterative method reported convergence failure in step 100 with residual 4.00437
+DEAL::Solver stopped after 100 iterations
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id: solver_real_02.cc
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// test the PETSc Chebychev solver
+
+// Note: This is (almost) a clone of the tests/petsc/solver_02.cc
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/petsc_solver.h>
+#include <deal.II/lac/petsc_precondition.h>
+#include <deal.II/lac/vector_memory.h>
+#include <typeinfo>
+
+template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
+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;
+ // just like for Richardson: we end up
+ // here normally for this solver
+ }
+
+ deallog << "Solver stopped after " << solver.control().last_step()
+ << " iterations" << std::endl;
+}
+
+
+int main(int argc, char **argv)
+{
+ std::ofstream logfile("solver_real_02/output");
+ deallog.attach(logfile);
+ deallog << std::setprecision(4);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+ {
+ 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);
+ PETScWrappers::SparseMatrix A(dim, dim, 5);
+ testproblem.five_point(A);
+
+ PETScWrappers::Vector f(dim);
+ PETScWrappers::Vector u(dim);
+ f = 1.;
+ A.compress (VectorOperation::add);
+ f.compress (VectorOperation::add);
+ u.compress (VectorOperation::add);
+
+ PETScWrappers::SolverChebychev solver(control);
+ PETScWrappers::PreconditionJacobi preconditioner(A);
+ check_solve (solver, A,u,f, preconditioner);
+ }
+
+}
+
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers15SolverChebychevE
+DEAL::Starting value 7.551
+DEAL::Failure step 100 value 2.942
+DEAL::Iterative method reported convergence failure in step 100 with residual 2.94179
+DEAL::Solver stopped after 100 iterations
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id: solver_real_03.cc
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// test the PETSc CG solver
+
+// Note: This is (almost) a clone of the tests/petsc/solver_03.cc
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/petsc_solver.h>
+#include <deal.II/lac/petsc_precondition.h>
+#include <deal.II/lac/vector_memory.h>
+#include <typeinfo>
+
+template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
+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)
+{
+ std::ofstream logfile("solver_real_03/output");
+ deallog.attach(logfile);
+ deallog << std::setprecision(4);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+ {
+ 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);
+ PETScWrappers::SparseMatrix A(dim, dim, 5);
+ testproblem.five_point(A);
+
+ PETScWrappers::Vector f(dim);
+ PETScWrappers::Vector u(dim);
+ f = 1.;
+ A.compress (VectorOperation::add);
+ f.compress (VectorOperation::add);
+ u.compress (VectorOperation::add);
+
+ PETScWrappers::SolverCG solver(control);
+ PETScWrappers::PreconditionJacobi preconditioner(A);
+ check_solve (solver, A,u,f, preconditioner);
+ }
+
+}
+
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers8SolverCGE
+DEAL::Starting value 7.750
+DEAL::Convergence step 41 value 0.0006730
+DEAL::Solver stopped after 41 iterations
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id: solver_03_mf.cc 30045 2013-07-18 19:18:00Z maier $
+//
+// Copyright (C) 2004 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// test the PETSc CG solver with PETSc MatrixFree class
+
+// Note: This is (almost) a clone of the tests/petsc/solver_03_mf.cc
+
+#include "../tests.h"
+#include "../petsc/petsc_mf_testmatrix.h" // It is tempting to copy
+ // ../petsc/petsc_mf_testmatrix.h
+ // into this directory and
+ // play with it, but, by
+ // using *that* file
+ // directly is itself a test
+ // of syntax compatibility
+ // between petsc-scalar=real
+ // and petsc-scalar=complex.
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/petsc_solver.h>
+#include <deal.II/lac/petsc_precondition.h>
+#include <deal.II/lac/vector_memory.h>
+#include <typeinfo>
+
+template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
+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)
+ {
+ std::cout << e.what() << std::endl;
+ deallog << e.what() << std::endl;
+ abort ();
+ }
+
+ deallog << "Solver stopped after " << solver.control().last_step()
+ << " iterations" << std::endl;
+}
+
+
+int main(int argc, char **argv)
+{
+ std::ofstream logfile("solver_real_03_mf/output");
+ deallog.attach(logfile);
+ deallog << std::setprecision(4);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+ {
+ 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;
+
+ PetscFDMatrix A(size, dim);
+
+ PETScWrappers::Vector f(dim);
+ PETScWrappers::Vector u(dim);
+ f = 1.;
+ A.compress (VectorOperation::add);
+ f.compress (VectorOperation::add);
+ u.compress (VectorOperation::add);
+
+ PETScWrappers::SolverCG solver(control);
+ PETScWrappers::PreconditionNone preconditioner(A);
+ check_solve (solver, A,u,f, preconditioner);
+ }
+
+}
+
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers8SolverCGE
+DEAL::Starting value 31.00
+DEAL::Convergence step 43 value 0.0008189
+DEAL::Solver stopped after 43 iterations
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id: solver_real_04.cc
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// test the PETSc BiCG solver
+
+// Note: This is (almost) a clone of the tests/petsc/solver_03.cc
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/petsc_solver.h>
+#include <deal.II/lac/petsc_precondition.h>
+#include <deal.II/lac/vector_memory.h>
+#include <typeinfo>
+
+template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
+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)
+{
+ std::ofstream logfile("solver_real_04/output");
+ deallog.attach(logfile);
+ deallog << std::setprecision(4);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+ {
+ 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);
+ PETScWrappers::SparseMatrix A(dim, dim, 5);
+ testproblem.five_point(A);
+
+ PETScWrappers::Vector f(dim);
+ PETScWrappers::Vector u(dim);
+ f = 1.;
+ A.compress (VectorOperation::add);
+ f.compress (VectorOperation::add);
+ u.compress (VectorOperation::add);
+
+ PETScWrappers::SolverBiCG solver(control);
+ PETScWrappers::PreconditionJacobi preconditioner(A);
+ check_solve (solver, A,u,f, preconditioner);
+ }
+
+}
+
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers10SolverBiCGE
+DEAL::Starting value 7.750
+DEAL::Convergence step 41 value 0.0006730
+DEAL::Solver stopped after 41 iterations