]> https://gitweb.dealii.org/ - dealii.git/commitdiff
New tests.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 26 Feb 2004 17:02:06 +0000 (17:02 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 26 Feb 2004 17:02:06 +0000 (17:02 +0000)
git-svn-id: https://svn.dealii.org/trunk@8568 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/petsc_solver_01.cc [new file with mode: 0644]
tests/bits/petsc_solver_02.cc [new file with mode: 0644]
tests/bits/petsc_solver_03.cc [new file with mode: 0644]
tests/bits/petsc_solver_04.cc [new file with mode: 0644]
tests/bits/petsc_solver_05.cc [new file with mode: 0644]
tests/bits/petsc_solver_06.cc [new file with mode: 0644]
tests/bits/petsc_solver_07.cc [new file with mode: 0644]
tests/bits/petsc_solver_08.cc [new file with mode: 0644]
tests/bits/petsc_solver_09.cc [new file with mode: 0644]
tests/bits/petsc_solver_10.cc [new file with mode: 0644]
tests/bits/petsc_solver_11.cc [new file with mode: 0644]

diff --git a/tests/bits/petsc_solver_01.cc b/tests/bits/petsc_solver_01.cc
new file mode 100644 (file)
index 0000000..a2ce353
--- /dev/null
@@ -0,0 +1,89 @@
+//----------------------------  petsc_solver_01.cc  ---------------------------
+//    $Id$
+//    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_solver_01.cc  ---------------------------
+
+// test the PETSc Richardson solver
+
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <base/logstream.h>
+#include <lac/petsc_sparse_matrix.h>
+#include <lac/petsc_vector.h>
+#include <lac/petsc_solver.h>
+#include <lac/petsc_precondition.h>
+#include <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)
+{
+  PetscInitialize(&argc,&argv,0,0);
+  {
+    std::ofstream logfile("petsc_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 ();
+
+    petsc_wrappers::SolverRichardson solver(control);
+    petsc_wrappers::PreconditionJacobi preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/bits/petsc_solver_02.cc b/tests/bits/petsc_solver_02.cc
new file mode 100644 (file)
index 0000000..4a846ee
--- /dev/null
@@ -0,0 +1,89 @@
+//----------------------------  petsc_solver_02.cc  ---------------------------
+//    $Id$
+//    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_solver_02.cc  ---------------------------
+
+// test the PETSc Chebychev solver
+
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <base/logstream.h>
+#include <lac/petsc_sparse_matrix.h>
+#include <lac/petsc_vector.h>
+#include <lac/petsc_solver.h>
+#include <lac/petsc_precondition.h>
+#include <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)
+{
+  PetscInitialize(&argc,&argv,0,0);
+  {
+    std::ofstream logfile("petsc_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 ();
+
+    petsc_wrappers::SolverChebychev solver(control);
+    petsc_wrappers::PreconditionJacobi preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/bits/petsc_solver_03.cc b/tests/bits/petsc_solver_03.cc
new file mode 100644 (file)
index 0000000..fd2bbab
--- /dev/null
@@ -0,0 +1,89 @@
+//----------------------------  petsc_solver_03.cc  ---------------------------
+//    $Id$
+//    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_solver_03.cc  ---------------------------
+
+// test the PETSc CG solver
+
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <base/logstream.h>
+#include <lac/petsc_sparse_matrix.h>
+#include <lac/petsc_vector.h>
+#include <lac/petsc_solver.h>
+#include <lac/petsc_precondition.h>
+#include <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)
+{
+  PetscInitialize(&argc,&argv,0,0);
+  {
+    std::ofstream logfile("petsc_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 ();
+
+    petsc_wrappers::SolverCG solver(control);
+    petsc_wrappers::PreconditionJacobi preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/bits/petsc_solver_04.cc b/tests/bits/petsc_solver_04.cc
new file mode 100644 (file)
index 0000000..39a02f0
--- /dev/null
@@ -0,0 +1,89 @@
+//----------------------------  petsc_solver_04.cc  ---------------------------
+//    $Id$
+//    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_solver_04.cc  ---------------------------
+
+// test the PETSc BiCG solver
+
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <base/logstream.h>
+#include <lac/petsc_sparse_matrix.h>
+#include <lac/petsc_vector.h>
+#include <lac/petsc_solver.h>
+#include <lac/petsc_precondition.h>
+#include <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)
+{
+  PetscInitialize(&argc,&argv,0,0);
+  {
+    std::ofstream logfile("petsc_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 ();
+
+    petsc_wrappers::SolverBiCG solver(control);
+    petsc_wrappers::PreconditionJacobi preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/bits/petsc_solver_05.cc b/tests/bits/petsc_solver_05.cc
new file mode 100644 (file)
index 0000000..0d06e80
--- /dev/null
@@ -0,0 +1,89 @@
+//----------------------------  petsc_solver_05.cc  ---------------------------
+//    $Id$
+//    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_solver_05.cc  ---------------------------
+
+// test the PETSc GMRES solver
+
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <base/logstream.h>
+#include <lac/petsc_sparse_matrix.h>
+#include <lac/petsc_vector.h>
+#include <lac/petsc_solver.h>
+#include <lac/petsc_precondition.h>
+#include <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)
+{
+  PetscInitialize(&argc,&argv,0,0);
+  {
+    std::ofstream logfile("petsc_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 ();
+
+    petsc_wrappers::SolverGMRES solver(control);
+    petsc_wrappers::PreconditionJacobi preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/bits/petsc_solver_06.cc b/tests/bits/petsc_solver_06.cc
new file mode 100644 (file)
index 0000000..d97006e
--- /dev/null
@@ -0,0 +1,89 @@
+//----------------------------  petsc_solver_06.cc  ---------------------------
+//    $Id$
+//    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_solver_06.cc  ---------------------------
+
+// test the PETSc Bicgstab solver
+
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <base/logstream.h>
+#include <lac/petsc_sparse_matrix.h>
+#include <lac/petsc_vector.h>
+#include <lac/petsc_solver.h>
+#include <lac/petsc_precondition.h>
+#include <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)
+{
+  PetscInitialize(&argc,&argv,0,0);
+  {
+    std::ofstream logfile("petsc_solver_06.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 ();
+
+    petsc_wrappers::SolverBicgstab solver(control);
+    petsc_wrappers::PreconditionJacobi preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/bits/petsc_solver_07.cc b/tests/bits/petsc_solver_07.cc
new file mode 100644 (file)
index 0000000..936259a
--- /dev/null
@@ -0,0 +1,89 @@
+//----------------------------  petsc_solver_07.cc  ---------------------------
+//    $Id$
+//    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_solver_07.cc  ---------------------------
+
+// test the PETSc CGS solver
+
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <base/logstream.h>
+#include <lac/petsc_sparse_matrix.h>
+#include <lac/petsc_vector.h>
+#include <lac/petsc_solver.h>
+#include <lac/petsc_precondition.h>
+#include <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)
+{
+  PetscInitialize(&argc,&argv,0,0);
+  {
+    std::ofstream logfile("petsc_solver_07.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 ();
+
+    petsc_wrappers::SolverCGS solver(control);
+    petsc_wrappers::PreconditionJacobi preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/bits/petsc_solver_08.cc b/tests/bits/petsc_solver_08.cc
new file mode 100644 (file)
index 0000000..9eb6354
--- /dev/null
@@ -0,0 +1,89 @@
+//----------------------------  petsc_solver_08.cc  ---------------------------
+//    $Id$
+//    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_solver_08.cc  ---------------------------
+
+// test the PETSc TFQMR solver
+
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <base/logstream.h>
+#include <lac/petsc_sparse_matrix.h>
+#include <lac/petsc_vector.h>
+#include <lac/petsc_solver.h>
+#include <lac/petsc_precondition.h>
+#include <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)
+{
+  PetscInitialize(&argc,&argv,0,0);
+  {
+    std::ofstream logfile("petsc_solver_08.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 ();
+
+    petsc_wrappers::SolverTFQMR solver(control);
+    petsc_wrappers::PreconditionJacobi preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/bits/petsc_solver_09.cc b/tests/bits/petsc_solver_09.cc
new file mode 100644 (file)
index 0000000..a4953b1
--- /dev/null
@@ -0,0 +1,89 @@
+//----------------------------  petsc_solver_09.cc  ---------------------------
+//    $Id$
+//    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_solver_09.cc  ---------------------------
+
+// test the PETSc TCQMR solver
+
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <base/logstream.h>
+#include <lac/petsc_sparse_matrix.h>
+#include <lac/petsc_vector.h>
+#include <lac/petsc_solver.h>
+#include <lac/petsc_precondition.h>
+#include <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)
+{
+  PetscInitialize(&argc,&argv,0,0);
+  {
+    std::ofstream logfile("petsc_solver_09.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 ();
+
+    petsc_wrappers::SolverTCQMR solver(control);
+    petsc_wrappers::PreconditionJacobi preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/bits/petsc_solver_10.cc b/tests/bits/petsc_solver_10.cc
new file mode 100644 (file)
index 0000000..7d65a41
--- /dev/null
@@ -0,0 +1,89 @@
+//----------------------------  petsc_solver_10.cc  ---------------------------
+//    $Id$
+//    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_solver_10.cc  ---------------------------
+
+// test the PETSc CR solver
+
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <base/logstream.h>
+#include <lac/petsc_sparse_matrix.h>
+#include <lac/petsc_vector.h>
+#include <lac/petsc_solver.h>
+#include <lac/petsc_precondition.h>
+#include <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)
+{
+  PetscInitialize(&argc,&argv,0,0);
+  {
+    std::ofstream logfile("petsc_solver_10.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 ();
+
+    petsc_wrappers::SolverCR solver(control);
+    petsc_wrappers::PreconditionJacobi preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/bits/petsc_solver_11.cc b/tests/bits/petsc_solver_11.cc
new file mode 100644 (file)
index 0000000..e5680d0
--- /dev/null
@@ -0,0 +1,89 @@
+//----------------------------  petsc_solver_11.cc  ---------------------------
+//    $Id$
+//    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_solver_11.cc  ---------------------------
+
+// test the PETSc LSQR solver
+
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <base/logstream.h>
+#include <lac/petsc_sparse_matrix.h>
+#include <lac/petsc_vector.h>
+#include <lac/petsc_solver.h>
+#include <lac/petsc_precondition.h>
+#include <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)
+{
+  PetscInitialize(&argc,&argv,0,0);
+  {
+    std::ofstream logfile("petsc_solver_11.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 ();
+
+    petsc_wrappers::SolverLSQR solver(control);
+    petsc_wrappers::PreconditionJacobi preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+

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.