]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Clone five solver tests to verify that using petsc-scalar=complex does not affect...
authoryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 20 Oct 2013 14:29:03 +0000 (14:29 +0000)
committeryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 20 Oct 2013 14:29:03 +0000 (14:29 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_petscscalar_complex@31336 0785d39b-7218-0410-832d-ea1e28bc413d

tests/petsc_scalar_complex/solver_real_01.cc [new file with mode: 0644]
tests/petsc_scalar_complex/solver_real_01/cmp/generic [new file with mode: 0644]
tests/petsc_scalar_complex/solver_real_02.cc [new file with mode: 0644]
tests/petsc_scalar_complex/solver_real_02/cmp/generic [new file with mode: 0644]
tests/petsc_scalar_complex/solver_real_03.cc [new file with mode: 0644]
tests/petsc_scalar_complex/solver_real_03/cmp/generic [new file with mode: 0644]
tests/petsc_scalar_complex/solver_real_03_mf.cc [new file with mode: 0644]
tests/petsc_scalar_complex/solver_real_03_mf/cmp/generic [new file with mode: 0644]
tests/petsc_scalar_complex/solver_real_04.cc [new file with mode: 0644]
tests/petsc_scalar_complex/solver_real_04/cmp/generic [new file with mode: 0644]

diff --git a/tests/petsc_scalar_complex/solver_real_01.cc b/tests/petsc_scalar_complex/solver_real_01.cc
new file mode 100644 (file)
index 0000000..d794ff3
--- /dev/null
@@ -0,0 +1,98 @@
+// ---------------------------------------------------------------------
+// $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);
+  }
+
+}
+
diff --git a/tests/petsc_scalar_complex/solver_real_01/cmp/generic b/tests/petsc_scalar_complex/solver_real_01/cmp/generic
new file mode 100644 (file)
index 0000000..208bfd4
--- /dev/null
@@ -0,0 +1,7 @@
+
+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
diff --git a/tests/petsc_scalar_complex/solver_real_02.cc b/tests/petsc_scalar_complex/solver_real_02.cc
new file mode 100644 (file)
index 0000000..fce802f
--- /dev/null
@@ -0,0 +1,96 @@
+// ---------------------------------------------------------------------
+// $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);
+  }
+
+}
+
diff --git a/tests/petsc_scalar_complex/solver_real_02/cmp/generic b/tests/petsc_scalar_complex/solver_real_02/cmp/generic
new file mode 100644 (file)
index 0000000..47abf08
--- /dev/null
@@ -0,0 +1,7 @@
+
+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
diff --git a/tests/petsc_scalar_complex/solver_real_03.cc b/tests/petsc_scalar_complex/solver_real_03.cc
new file mode 100644 (file)
index 0000000..8a7e3b0
--- /dev/null
@@ -0,0 +1,95 @@
+// ---------------------------------------------------------------------
+// $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);
+  }
+
+}
+
diff --git a/tests/petsc_scalar_complex/solver_real_03/cmp/generic b/tests/petsc_scalar_complex/solver_real_03/cmp/generic
new file mode 100644 (file)
index 0000000..2237281
--- /dev/null
@@ -0,0 +1,6 @@
+
+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
diff --git a/tests/petsc_scalar_complex/solver_real_03_mf.cc b/tests/petsc_scalar_complex/solver_real_03_mf.cc
new file mode 100644 (file)
index 0000000..ad81622
--- /dev/null
@@ -0,0 +1,101 @@
+// ---------------------------------------------------------------------
+// $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);
+  }
+
+}
+
diff --git a/tests/petsc_scalar_complex/solver_real_03_mf/cmp/generic b/tests/petsc_scalar_complex/solver_real_03_mf/cmp/generic
new file mode 100644 (file)
index 0000000..bea3eb1
--- /dev/null
@@ -0,0 +1,6 @@
+
+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
diff --git a/tests/petsc_scalar_complex/solver_real_04.cc b/tests/petsc_scalar_complex/solver_real_04.cc
new file mode 100644 (file)
index 0000000..470697b
--- /dev/null
@@ -0,0 +1,95 @@
+// ---------------------------------------------------------------------
+// $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);
+  }
+
+}
+
diff --git a/tests/petsc_scalar_complex/solver_real_04/cmp/generic b/tests/petsc_scalar_complex/solver_real_04/cmp/generic
new file mode 100644 (file)
index 0000000..d69ef94
--- /dev/null
@@ -0,0 +1,6 @@
+
+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

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.