]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Tests: Fix petsc/solver_11 to test for convergence 2817/head
authorMatthias Maier <tamiko@43-1.org>
Tue, 12 Jul 2016 16:37:34 +0000 (11:37 -0500)
committerMatthias Maier <tamiko@43-1.org>
Tue, 12 Jul 2016 16:37:53 +0000 (11:37 -0500)
tests/petsc/solver_11.cc
tests/petsc/solver_11.output

index b3e24b7e25217da7c1232d1837b235a859c834c2..fe03ac48f7a9da9816de3e351f3400c6ce2be0b5 100644 (file)
@@ -1,6 +1,6 @@
 // ---------------------------------------------------------------------
 //
-// Copyright (C) 2004 - 2015 by the deal.II authors
+// Copyright (C) 2004 - 2016 by the deal.II authors
 //
 // This file is part of the deal.II library.
 //
 //
 // ---------------------------------------------------------------------
 
-
 // test the PETSc LSQR 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<typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-void
-check_solve(SolverType          &solver,
-            const SolverControl &solver_control,
-            const MatrixType    &A,
-            VectorType          &u,
-            VectorType          &f,
-            const PRECONDITION  &P)
-{
-  deallog << "Solver type: " << typeid(solver).name() << std::endl;
-
-  u = 0.;
-  f = 1.;
-  try
-    {
-      deallog.depth_file(0);
-      solver.solve(A,u,f,P);
-      deallog.depth_file(3);
-    }
-  catch (dealii::SolverControl::NoConvergence &e)
-    {
-      // just like for Richardson: expect to
-      // get here, don't abort the program
-      deallog.depth_file(3);
-      deallog << "Catched exception dealii::SolverControl::NoConvergence" << std::endl;
-    }
-
-  deallog << "Solver stopped after " << solver_control.last_step()
-          << " iterations" << std::endl;
-}
-
 
 int main(int argc, char **argv)
 {
-  std::ofstream logfile("output");
-  deallog.attach(logfile);
-  deallog << std::setprecision(4);
-  deallog.threshold_double(1.e-10);
+  initlog();
 
   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);
 
@@ -86,12 +42,20 @@ int main(int argc, char **argv)
 
     PETScWrappers::Vector  f(dim);
     PETScWrappers::Vector  u(dim);
+
     f = 1.;
+    u = 0.;
+
     A.compress (VectorOperation::insert);
+    f.compress (VectorOperation::insert);
+    u.compress (VectorOperation::insert);
 
+    SolverControl control(200, 1.e-8);
     PETScWrappers::SolverLSQR solver(control);
     PETScWrappers::PreconditionJacobi preconditioner(A);
-    check_solve (solver, control, A,u,f, preconditioner);
-  }
 
+    check_solver_within_range(
+      solver.solve(A,u,f, preconditioner),
+      control.last_step(), 171, 175);
+  }
 }
index b00603808b8dd69903a63538c7349cd5129b90a0..619295c5d7edc3fb53341a948a56a70e0216e87b 100644 (file)
@@ -1,5 +1,3 @@
 
 DEAL::Size 32 Unknowns 961
-DEAL::Solver type: N6dealii13PETScWrappers10SolverLSQRE
-DEAL::Catched exception dealii::SolverControl::NoConvergence
-DEAL::Solver stopped after 100 iterations
+DEAL::Solver stopped within 171 - 175 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.