]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Test the PETScWrappers::SparseDirectMumps interface.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 20 Nov 2012 15:31:31 +0000 (15:31 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 20 Nov 2012 15:31:31 +0000 (15:31 +0000)
git-svn-id: https://svn.dealii.org/trunk@27593 0785d39b-7218-0410-832d-ea1e28bc413d

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

diff --git a/tests/petsc/sparse_direct_mumps.cc b/tests/petsc/sparse_direct_mumps.cc
new file mode 100644 (file)
index 0000000..c368f0e
--- /dev/null
@@ -0,0 +1,94 @@
+//----------------------------  sparse_direct_mumps.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.
+//
+//----------------------------  sparse_direct_mumps.cc  ---------------------------
+
+// test the PETSc SparseDirectMumps 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("sparse_direct_mumps/output");
+  deallog.attach(logfile);
+  deallog << std::setprecision(4);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  PetscInitialize(&argc,&argv,0,0);
+  {
+    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);
+    u = 0.;
+    f = 1.;
+    A.compress ();
+    f.compress ();
+    u.compress ();
+
+    SolverControl cn;
+    PETScWrappers::SparseDirectMUMPS solver(cn);
+//    solver.set_symmetric_mode(true);
+    solver.solve(A,u,f);
+
+    PETScWrappers::Vector  tmp(dim);
+    deallog << "residual = " << A.residual (tmp, u, f)
+           << std::endl;
+  }
+  PetscFinalize ();
+}
+
diff --git a/tests/petsc/sparse_direct_mumps/cmp/generic b/tests/petsc/sparse_direct_mumps/cmp/generic
new file mode 100644 (file)
index 0000000..932860e
--- /dev/null
@@ -0,0 +1,4 @@
+
+DEAL::Size 32 Unknowns 961
+DEAL::Convergence step 1 value 0
+DEAL::residual = 0

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.