From 962662363dc4827c57fa5dae17be2548d5487fb8 Mon Sep 17 00:00:00 2001 From: oliver Date: Thu, 15 Sep 2005 10:17:19 +0000 Subject: [PATCH] Added a test case for the Tvmult method of the SparseILU class. It is essentially the same code as sparse_ilu.cc with the difference that the Tvmult method is tested instead of the vmult method. git-svn-id: https://svn.dealii.org/trunk@11445 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/lac/Makefile | 2 +- tests/lac/sparse_ilu_t.cc | 125 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 tests/lac/sparse_ilu_t.cc diff --git a/tests/lac/Makefile b/tests/lac/Makefile index d1f09eba66..3cae089c98 100644 --- a/tests/lac/Makefile +++ b/tests/lac/Makefile @@ -26,7 +26,7 @@ tests_x = vector-vector \ block_vector block_vector_iterator block_matrices \ matrix_lib matrix_out \ solver eigen \ - sparse_ilu lapack + sparse_ilu sparse_ilu_t lapack # from above list of regular expressions, generate the real set of diff --git a/tests/lac/sparse_ilu_t.cc b/tests/lac/sparse_ilu_t.cc new file mode 100644 index 0000000000..61ece335b5 --- /dev/null +++ b/tests/lac/sparse_ilu_t.cc @@ -0,0 +1,125 @@ +//---------------------------- sparse_ilu_t.cc ------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2001, 2002, 2003, 2004, 2005 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_ilu_t.cc ------------------------- + + +// make sure that the SparseILU applied with infinite fill-in +// generates the exact inverse matrix + +#include "../tests.h" +#include +#include +#include +#include +#include +#include "testmatrix.h" +#include +#include +#include +#include + +//TODO:[WB] find test that is less sensitive to floating point accuracy + +int main() +{ + std::ofstream logfile("sparse_ilu_t.output"); + logfile.setf(std::ios::fixed); + logfile.precision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + + for (unsigned int size=4; size <= 16; size *= 2) + { + unsigned int dim = (size-1)*(size-1); + + deallog << "Size " << size << " Unknowns " << dim << std::endl; + + // Make matrix + FDMatrix testproblem(size, size); + SparsityPattern structure(dim, dim, 5); + testproblem.five_point_structure(structure); + structure.compress(); + SparseMatrix A(structure); + testproblem.five_point(A); + + + for (unsigned int test=0; test<2; ++test) + { + deallog << "Test " << test << std::endl; + + // generate sparse ILU. + // + // for test 1, test with + // full pattern. for test + // 2, test with same + // pattern as A + SparsityPattern ilu_pattern (dim, dim, + (test==0 ? dim : 5)); + switch (test) + { + case 0: + for (unsigned int i=0; i ilu (ilu_pattern); + ilu.decompose (A); + + // now for three test vectors v + // determine norm of + // (I-B'A')v, where B' is the ILU + // of A transposed. + // Since matrix is symmetric, + // likewise test for right + // preconditioner + Vector v(dim); + Vector tmp1(dim), tmp2(dim); + for (unsigned int i=0; i<3; ++i) + { + for (unsigned int j=0; j