]> https://gitweb.dealii.org/ - dealii.git/commitdiff
test for PETScWrappers::SolverPreOnly.
authorTimo Heister <timo.heister@gmail.com>
Fri, 14 Jan 2011 20:40:07 +0000 (20:40 +0000)
committerTimo Heister <timo.heister@gmail.com>
Fri, 14 Jan 2011 20:40:07 +0000 (20:40 +0000)
git-svn-id: https://svn.dealii.org/trunk@23190 0785d39b-7218-0410-832d-ea1e28bc413d

tests/petsc/solver_12.cc [new file with mode: 0644]
tests/petsc/solver_12/cmp/generic [new file with mode: 0644]

diff --git a/tests/petsc/solver_12.cc b/tests/petsc/solver_12.cc
new file mode 100644 (file)
index 0000000..54ae848
--- /dev/null
@@ -0,0 +1,87 @@
+//----------------------------  petsc_solver_11.cc  ---------------------------
+//    $Id: solver_11.cc 20442 2010-01-25 10:46:00Z heister $
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004, 2005, 2010 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 PreOnly 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.;
+
+  solver.solve(A,u,f,P);
+
+  deallog << "Solver stopped after " << solver.control().last_step()
+          << " iterations" << std::endl;
+}
+
+
+int main(int argc, char **argv)
+{
+  std::ofstream logfile("solver_12/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::SolverPreOnly solver(control);
+    
+    PETScWrappers::PreconditionJacobi preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+
+                                    //run twice because this errored out at some point
+    check_solve (solver, A,u,f, preconditioner);
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/petsc/solver_12/cmp/generic b/tests/petsc/solver_12/cmp/generic
new file mode 100644 (file)
index 0000000..2a67dab
--- /dev/null
@@ -0,0 +1,7 @@
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers10SolverLSQRE
+DEAL::Starting value 31.00
+DEAL::Failure step 100 value 24.01
+DEAL::Iterative method reported convergence failure in step 100 with residual 24.0098
+DEAL::Solver stopped after 100 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.