]> https://gitweb.dealii.org/ - dealii.git/commitdiff
More tests.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 20 Nov 2012 03:03:55 +0000 (03:03 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 20 Nov 2012 03:03:55 +0000 (03:03 +0000)
git-svn-id: https://svn.dealii.org/trunk@27580 0785d39b-7218-0410-832d-ea1e28bc413d

14 files changed:
tests/petsc/solver_03_precondition_boomeramg.cc [new file with mode: 0644]
tests/petsc/solver_03_precondition_boomeramg/cmp/generic [new file with mode: 0644]
tests/petsc/solver_03_precondition_boomeramg_symmetric.cc [new file with mode: 0644]
tests/petsc/solver_03_precondition_boomeramg_symmetric/cmp/generic [new file with mode: 0644]
tests/petsc/solver_03_precondition_eisenstat.cc [new file with mode: 0644]
tests/petsc/solver_03_precondition_eisenstat/cmp/generic [new file with mode: 0644]
tests/petsc/solver_03_precondition_icc.cc [new file with mode: 0644]
tests/petsc/solver_03_precondition_icc/cmp/generic [new file with mode: 0644]
tests/petsc/solver_03_precondition_ilu.cc [new file with mode: 0644]
tests/petsc/solver_03_precondition_ilu/cmp/generic [new file with mode: 0644]
tests/petsc/solver_03_precondition_sor.cc [new file with mode: 0644]
tests/petsc/solver_03_precondition_sor/cmp/generic [new file with mode: 0644]
tests/petsc/solver_03_precondition_ssor.cc [new file with mode: 0644]
tests/petsc/solver_03_precondition_ssor/cmp/generic [new file with mode: 0644]

diff --git a/tests/petsc/solver_03_precondition_boomeramg.cc b/tests/petsc/solver_03_precondition_boomeramg.cc
new file mode 100644 (file)
index 0000000..65d9d1f
--- /dev/null
@@ -0,0 +1,91 @@
+//----------------------------  petsc_solver_03_precondition_boomeramg.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2004, 2005, 2010, 2012 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_precondition_boomeramg.cc  ---------------------------
+
+// test the PETSc CG solver with the PreconditionBoomerAMG
+// preconditioner
+
+
+#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_03_precondition_boomeramg/output");
+  deallog.attach(logfile);
+  deallog << std::setprecision(4);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  PetscInitialize(&argc,&argv,0,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);
+    PETScWrappers::SparseMatrix  A(dim, dim, 5);
+    testproblem.five_point(A);
+
+    PETScWrappers::Vector  f(dim);
+    PETScWrappers::Vector  u(dim);
+    f = 1.;
+    A.compress ();
+    f.compress ();
+    u.compress ();
+
+    PETScWrappers::SolverCG solver(control);
+    PETScWrappers::PreconditionBoomerAMG preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/petsc/solver_03_precondition_boomeramg/cmp/generic b/tests/petsc/solver_03_precondition_boomeramg/cmp/generic
new file mode 100644 (file)
index 0000000..cd0525a
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers8SolverCGE
+DEAL::Starting value 1315.
+DEAL::Convergence step 4 value 8.048e-05
+DEAL::Solver stopped after 4 iterations
diff --git a/tests/petsc/solver_03_precondition_boomeramg_symmetric.cc b/tests/petsc/solver_03_precondition_boomeramg_symmetric.cc
new file mode 100644 (file)
index 0000000..9b9441d
--- /dev/null
@@ -0,0 +1,92 @@
+//----------------------------  petsc_solver_03_precondition_boomeramg_symmetric.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2004, 2005, 2010, 2012 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_precondition_boomeramg_symmetric.cc  ---------------------------
+
+// test the PETSc CG solver with the PreconditionBoomerAMG
+// preconditioner. allow the preconditioner to exploit symmetry of the
+// matrix
+
+
+#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_03_precondition_boomeramg_symmetric/output");
+  deallog.attach(logfile);
+  deallog << std::setprecision(4);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  PetscInitialize(&argc,&argv,0,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);
+    PETScWrappers::SparseMatrix  A(dim, dim, 5);
+    testproblem.five_point(A);
+
+    PETScWrappers::Vector  f(dim);
+    PETScWrappers::Vector  u(dim);
+    f = 1.;
+    A.compress ();
+    f.compress ();
+    u.compress ();
+
+    PETScWrappers::SolverCG solver(control);
+    PETScWrappers::PreconditionBoomerAMG preconditioner(A, true);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/petsc/solver_03_precondition_boomeramg_symmetric/cmp/generic b/tests/petsc/solver_03_precondition_boomeramg_symmetric/cmp/generic
new file mode 100644 (file)
index 0000000..cd0525a
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers8SolverCGE
+DEAL::Starting value 1315.
+DEAL::Convergence step 4 value 8.048e-05
+DEAL::Solver stopped after 4 iterations
diff --git a/tests/petsc/solver_03_precondition_eisenstat.cc b/tests/petsc/solver_03_precondition_eisenstat.cc
new file mode 100644 (file)
index 0000000..087b43c
--- /dev/null
@@ -0,0 +1,90 @@
+//----------------------------  petsc_solver_03_precondition_eisenstat.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2004, 2005, 2010, 2012 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_precondition_eisenstat.cc  ---------------------------
+
+// test the PETSc CG solver
+
+
+#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_03_precondition_eisenstat/output");
+  deallog.attach(logfile);
+  deallog << std::setprecision(4);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  PetscInitialize(&argc,&argv,0,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);
+    PETScWrappers::SparseMatrix  A(dim, dim, 5);
+    testproblem.five_point(A);
+
+    PETScWrappers::Vector  f(dim);
+    PETScWrappers::Vector  u(dim);
+    f = 1.;
+    A.compress ();
+    f.compress ();
+    u.compress ();
+
+    PETScWrappers::SolverCG solver(control);
+    PETScWrappers::PreconditionEisenstat preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/petsc/solver_03_precondition_eisenstat/cmp/generic b/tests/petsc/solver_03_precondition_eisenstat/cmp/generic
new file mode 100644 (file)
index 0000000..1a56252
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers8SolverCGE
+DEAL::Starting value 60.26
+DEAL::Convergence step 20 value 0.0006908
+DEAL::Solver stopped after 20 iterations
diff --git a/tests/petsc/solver_03_precondition_icc.cc b/tests/petsc/solver_03_precondition_icc.cc
new file mode 100644 (file)
index 0000000..1fe7554
--- /dev/null
@@ -0,0 +1,90 @@
+//----------------------------  petsc_solver_03_precondition_icc.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2004, 2005, 2010, 2012 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_precondition_icc.cc  ---------------------------
+
+// test the PETSc CG solver
+
+
+#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_03_precondition_icc/output");
+  deallog.attach(logfile);
+  deallog << std::setprecision(4);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  PetscInitialize(&argc,&argv,0,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);
+    PETScWrappers::SparseMatrix  A(dim, dim, 5);
+    testproblem.five_point(A);
+
+    PETScWrappers::Vector  f(dim);
+    PETScWrappers::Vector  u(dim);
+    f = 1.;
+    A.compress ();
+    f.compress ();
+    u.compress ();
+
+    PETScWrappers::SolverCG solver(control);
+    PETScWrappers::PreconditionICC preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/petsc/solver_03_precondition_icc/cmp/generic b/tests/petsc/solver_03_precondition_icc/cmp/generic
new file mode 100644 (file)
index 0000000..3d30c3a
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers8SolverCGE
+DEAL::Starting value 48.96
+DEAL::Convergence step 17 value 0.0004044
+DEAL::Solver stopped after 17 iterations
diff --git a/tests/petsc/solver_03_precondition_ilu.cc b/tests/petsc/solver_03_precondition_ilu.cc
new file mode 100644 (file)
index 0000000..8912039
--- /dev/null
@@ -0,0 +1,90 @@
+//----------------------------  petsc_solver_03_precondition_ilu.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2004, 2005, 2010, 2012 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_precondition_ilu.cc  ---------------------------
+
+// test the PETSc CG solver
+
+
+#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_03_precondition_ilu/output");
+  deallog.attach(logfile);
+  deallog << std::setprecision(4);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  PetscInitialize(&argc,&argv,0,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);
+    PETScWrappers::SparseMatrix  A(dim, dim, 5);
+    testproblem.five_point(A);
+
+    PETScWrappers::Vector  f(dim);
+    PETScWrappers::Vector  u(dim);
+    f = 1.;
+    A.compress ();
+    f.compress ();
+    u.compress ();
+
+    PETScWrappers::SolverCG solver(control);
+    PETScWrappers::PreconditionILU preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/petsc/solver_03_precondition_ilu/cmp/generic b/tests/petsc/solver_03_precondition_ilu/cmp/generic
new file mode 100644 (file)
index 0000000..3d30c3a
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers8SolverCGE
+DEAL::Starting value 48.96
+DEAL::Convergence step 17 value 0.0004044
+DEAL::Solver stopped after 17 iterations
diff --git a/tests/petsc/solver_03_precondition_sor.cc b/tests/petsc/solver_03_precondition_sor.cc
new file mode 100644 (file)
index 0000000..3bdc29f
--- /dev/null
@@ -0,0 +1,90 @@
+//----------------------------  petsc_solver_03_precondition_sor.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2004, 2005, 2010, 2012 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_precondition_sor.cc  ---------------------------
+
+// test the PETSc CG solver
+
+
+#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_03_precondition_sor/output");
+  deallog.attach(logfile);
+  deallog << std::setprecision(4);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  PetscInitialize(&argc,&argv,0,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);
+    PETScWrappers::SparseMatrix  A(dim, dim, 5);
+    testproblem.five_point(A);
+
+    PETScWrappers::Vector  f(dim);
+    PETScWrappers::Vector  u(dim);
+    f = 1.;
+    A.compress ();
+    f.compress ();
+    u.compress ();
+
+    PETScWrappers::SolverCG solver(control);
+    PETScWrappers::PreconditionSOR preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/petsc/solver_03_precondition_sor/cmp/generic b/tests/petsc/solver_03_precondition_sor/cmp/generic
new file mode 100644 (file)
index 0000000..d086901
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers8SolverCGE
+DEAL::Starting value 29.45
+DEAL::Convergence step 19 value 0.0005731
+DEAL::Solver stopped after 19 iterations
diff --git a/tests/petsc/solver_03_precondition_ssor.cc b/tests/petsc/solver_03_precondition_ssor.cc
new file mode 100644 (file)
index 0000000..450f7a6
--- /dev/null
@@ -0,0 +1,90 @@
+//----------------------------  petsc_solver_03_precondition_ssor.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2004, 2005, 2010, 2012 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_precondition_ssor.cc  ---------------------------
+
+// test the PETSc CG solver
+
+
+#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_03_precondition_ssor/output");
+  deallog.attach(logfile);
+  deallog << std::setprecision(4);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  PetscInitialize(&argc,&argv,0,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);
+    PETScWrappers::SparseMatrix  A(dim, dim, 5);
+    testproblem.five_point(A);
+
+    PETScWrappers::Vector  f(dim);
+    PETScWrappers::Vector  u(dim);
+    f = 1.;
+    A.compress ();
+    f.compress ();
+    u.compress ();
+
+    PETScWrappers::SolverCG solver(control);
+    PETScWrappers::PreconditionSSOR preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/petsc/solver_03_precondition_ssor/cmp/generic b/tests/petsc/solver_03_precondition_ssor/cmp/generic
new file mode 100644 (file)
index 0000000..d086901
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers8SolverCGE
+DEAL::Starting value 29.45
+DEAL::Convergence step 19 value 0.0005731
+DEAL::Solver stopped after 19 iterations

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.