From ce543801819bcc1b133628b7e82cc98506096017 Mon Sep 17 00:00:00 2001 From: heister Date: Mon, 25 Nov 2013 16:12:38 +0000 Subject: [PATCH] add missing instantiation for mumps, add tests, leave some comments git-svn-id: https://svn.dealii.org/trunk@31796 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/mumps/mumps_01.cc | 43 ++++++++++--- tests/mumps/mumps_01.output | 60 ++++++------------ tests/mumps/mumps_02.cc | 122 ++++++++++++++++++++++++++++++++++++ tests/mumps/mumps_02.output | 25 ++++++++ 4 files changed, 199 insertions(+), 51 deletions(-) create mode 100644 tests/mumps/mumps_02.cc create mode 100644 tests/mumps/mumps_02.output diff --git a/tests/mumps/mumps_01.cc b/tests/mumps/mumps_01.cc index fdb70ad01d..270f1995f0 100644 --- a/tests/mumps/mumps_01.cc +++ b/tests/mumps/mumps_01.cc @@ -16,8 +16,7 @@ // test the mumps sparse direct solver on a mass matrix -// - check solving multiple times with one factorization -// - check two ways to initialize matrix +// - check several ways to solve #include "../tests.h" #include @@ -44,6 +43,30 @@ #include +void solve_and_check(const SparseMatrix & M, + const Vector & rhs, + const Vector & solution) +{ + { + SparseDirectMUMPS solver; + solver.initialize (M); + Vector dst(rhs.size()); + solver.vmult(dst, rhs); + dst -= solution; + Assert(dst.l2_norm() < 1e-9, ExcInternalError()); + } + { + SparseDirectMUMPS solver; + solver.initialize (M, rhs); + Vector dst(rhs.size()); + solver.solve(dst); + dst -= solution; + Assert(dst.l2_norm() < 1e-9, ExcInternalError()); + } +} + + + template void test () { @@ -96,8 +119,7 @@ void test () B.vmult (b, solution); - x = b; - Binv.solve (x); + Binv.vmult (x,b); x -= solution; deallog << "relative norm distance = " @@ -108,17 +130,20 @@ void test () << std::endl; Assert (x.l2_norm() / solution.l2_norm() < 1e-8, ExcInternalError()); + + + //also check solving in different ways: + solve_and_check(B, b, solution); } } -int main () +int main (int argc, char **argv) { - std::ofstream logfile("output"); - deallog.attach(logfile); - deallog.depth_console(0); - deallog.threshold_double(1.e-9); + Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv); + initlog(); + test<1> (); test<2> (); test<3> (); diff --git a/tests/mumps/mumps_01.output b/tests/mumps/mumps_01.output index 5cbb5f8764..bb98ce4852 100644 --- a/tests/mumps/mumps_01.output +++ b/tests/mumps/mumps_01.output @@ -1,49 +1,25 @@ DEAL::1d DEAL::Number of dofs = 193 -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 3084.00 -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 7709.99 -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 15420.0 +DEAL::relative norm distance = 2.06357e-16 +DEAL::absolute norms = 6.36406e-13 3084.00 +DEAL::relative norm distance = 2.28670e-16 +DEAL::absolute norms = 1.76304e-12 7709.99 +DEAL::relative norm distance = 2.28670e-16 +DEAL::absolute norms = 3.52609e-12 15420.0 DEAL::2d DEAL::Number of dofs = 1889 -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 94764.3 -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 236911. -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 473822. +DEAL::relative norm distance = 5.07512e-16 +DEAL::absolute norms = 4.80941e-11 94764.3 +DEAL::relative norm distance = 5.30372e-16 +DEAL::absolute norms = 1.25651e-10 236911. +DEAL::relative norm distance = 5.30372e-16 +DEAL::absolute norms = 2.51302e-10 473822. DEAL::3d DEAL::Number of dofs = 1333 -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 56165.6 -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 140414. -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 280828. -DEAL::1d -DEAL::Number of dofs = 193 -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 3084.00 -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 7709.99 -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 15420.0 -DEAL::2d -DEAL::Number of dofs = 1889 -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 94764.3 -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 236911. -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 473822. -DEAL::3d -DEAL::Number of dofs = 1333 -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 56165.6 -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 140414. -DEAL::relative norm distance = 0 -DEAL::absolute norms = 0 280828. +DEAL::relative norm distance = 1.33240e-15 +DEAL::absolute norms = 7.48349e-11 56165.6 +DEAL::relative norm distance = 1.27330e-15 +DEAL::absolute norms = 1.78789e-10 140414. +DEAL::relative norm distance = 1.27330e-15 +DEAL::absolute norms = 3.57579e-10 280828. diff --git a/tests/mumps/mumps_02.cc b/tests/mumps/mumps_02.cc new file mode 100644 index 0000000000..91e53d69fa --- /dev/null +++ b/tests/mumps/mumps_02.cc @@ -0,0 +1,122 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2002 - 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 mumps sparse direct solver on a mass matrix + +#include "../tests.h" +#include +#include +#include + +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + + +template +void test () +{ + 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 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> (); + test<3> (); +} diff --git a/tests/mumps/mumps_02.output b/tests/mumps/mumps_02.output new file mode 100644 index 0000000000..8df3f884c1 --- /dev/null +++ b/tests/mumps/mumps_02.output @@ -0,0 +1,25 @@ + +DEAL::1d +DEAL::Number of dofs = 193 +DEAL::relative norm distance = 0 +DEAL::absolute norms = 0 3084.00 +DEAL::relative norm distance = 0 +DEAL::absolute norms = 0 7709.99 +DEAL::relative norm distance = 0 +DEAL::absolute norms = 0 15420.0 +DEAL::2d +DEAL::Number of dofs = 1889 +DEAL::relative norm distance = 0 +DEAL::absolute norms = 0 94764.3 +DEAL::relative norm distance = 0 +DEAL::absolute norms = 0 236911. +DEAL::relative norm distance = 0 +DEAL::absolute norms = 0 473822. +DEAL::3d +DEAL::Number of dofs = 1333 +DEAL::relative norm distance = 0 +DEAL::absolute norms = 0 56165.6 +DEAL::relative norm distance = 0 +DEAL::absolute norms = 0 140414. +DEAL::relative norm distance = 0 +DEAL::absolute norms = 0 280828. -- 2.39.5