From f11759ad4875f828f4edaced8751acf44b74c8e8 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Thu, 13 Oct 2016 10:39:48 +0200 Subject: [PATCH] add a quick test for umfpack --- tests/quick_tests/CMakeLists.txt | 5 ++ tests/quick_tests/umfpack.cc | 121 +++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 tests/quick_tests/umfpack.cc diff --git a/tests/quick_tests/CMakeLists.txt b/tests/quick_tests/CMakeLists.txt index c6ecfc44dc..6338fa0df9 100644 --- a/tests/quick_tests/CMakeLists.txt +++ b/tests/quick_tests/CMakeLists.txt @@ -126,6 +126,11 @@ IF (DEAL_II_WITH_LAPACK) make_quicktest("lapack" ${_mybuild} "") ENDIF() +# Test Umfpack +IF (DEAL_II_WITH_UMFPACK) + make_quicktest("umfpack" ${_mybuild} "") +ENDIF() + # A custom test target: diff --git a/tests/quick_tests/umfpack.cc b/tests/quick_tests/umfpack.cc new file mode 100644 index 0000000000..3ba1112943 --- /dev/null +++ b/tests/quick_tests/umfpack.cc @@ -0,0 +1,121 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2016 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. +// +// --------------------------------------------------------------------- + + +// copy-paste from umfpack/umfpack_01 for dim==2 +// test the umfpack sparse direct solver on a mass matrix. +// test of the transpose as well + +#include "../tests.h" +#include +#include +#include + +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + + +template +void test (bool transpose = false) +{ + deallog << dim << 'd' << std::endl; + + Triangulation tria; + GridGenerator::hyper_cube (tria,0,1); + tria.refine_global (1); + + // destroy the uniformity of the matrix by + // refining one cell + tria.begin_active()->set_refine_flag (); + tria.execute_coarsening_and_refinement (); + tria.refine_global(8-2*dim); + + FE_Q fe (1); + DoFHandler dof_handler (tria); + dof_handler.distribute_dofs (fe); + + deallog << "Number of dofs = " << dof_handler.n_dofs() << std::endl; + + SparsityPattern sparsity_pattern; + sparsity_pattern.reinit (dof_handler.n_dofs(), + dof_handler.n_dofs(), + dof_handler.max_couplings_between_dofs()); + DoFTools::make_sparsity_pattern (dof_handler, sparsity_pattern); + sparsity_pattern.compress (); + + SparseMatrix B; + B.reinit (sparsity_pattern); + + QGauss qr (2); + MatrixTools::create_mass_matrix (dof_handler, qr, B); + + // for a number of different solution + // vectors, make up a matching rhs vector + // and check what the UMFPACK solver finds + for (unsigned int i=0; i<3; ++i) + { + Vector solution (dof_handler.n_dofs()); + Vector x (dof_handler.n_dofs()); + Vector b (dof_handler.n_dofs()); + + for (unsigned int j=0; j (); + test<2> (/*transpose =*/ true); +} -- 2.39.5