From: Martin Kronbichler Date: Thu, 27 Oct 2016 19:49:53 +0000 (+0200) Subject: Add another test X-Git-Tag: v8.5.0-rc1~520^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75f75ac860f4a5352e091fcb60c92009b82fdf20;p=dealii.git Add another test --- diff --git a/tests/lac/precondition_chebyshev_03.cc b/tests/lac/precondition_chebyshev_03.cc new file mode 100644 index 0000000000..8fed9b46cb --- /dev/null +++ b/tests/lac/precondition_chebyshev_03.cc @@ -0,0 +1,91 @@ +// --------------------------------------------------------------------- +// +// 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. +// +// --------------------------------------------------------------------- + + +// Test PreconditionChebyshev on more complex matrix and preconditioner + + +#include "../tests.h" +#include +#include +#include +#include +#include "../testmatrix.h" +#include + +#include +#include +#include +#include + + + +int main() +{ + std::ofstream logfile("output"); + deallog << std::fixed; + deallog << std::setprecision(2); + deallog.attach(logfile); + 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); + + PreconditionChebyshev, Vector, SparseILU > cheby; + PreconditionChebyshev, Vector, SparseILU >::AdditionalData cheby_data; + cheby_data.preconditioner.reset(new SparseILU()); + cheby_data.preconditioner->initialize(A); + cheby_data.degree = 10; + cheby_data.smoothing_range = 40; + cheby.initialize(A, cheby_data); + + Vector v(dim); + Vector tmp1(dim), tmp2(dim); + for (unsigned int i=0; i<3; ++i) + { + for (unsigned int j=0; jvmult (tmp2, tmp1); + tmp2 -= v; + const double ilu_residual = tmp2.l2_norm(); + + A.vmult (tmp1, v); + cheby.vmult (tmp2, tmp1); + tmp2 -= v; + const double cheby_residual = tmp2.l2_norm(); + + deallog << "Residual step i=" << i << ": " + << " ilu=" << ilu_residual + << ", cheby=" << cheby_residual + << std::endl; + } + } + + return 0; +} diff --git a/tests/lac/precondition_chebyshev_03.with_lapack=true.output b/tests/lac/precondition_chebyshev_03.with_lapack=true.output new file mode 100644 index 0000000000..96cdf4ba96 --- /dev/null +++ b/tests/lac/precondition_chebyshev_03.with_lapack=true.output @@ -0,0 +1,13 @@ + +DEAL::Size 4 Unknowns 9 +DEAL::Residual step i=0: ilu=0.33, cheby=0.08 +DEAL::Residual step i=1: ilu=0.36, cheby=0.08 +DEAL::Residual step i=2: ilu=0.17, cheby=0.05 +DEAL::Size 8 Unknowns 49 +DEAL::Residual step i=0: ilu=1.94, cheby=0.14 +DEAL::Residual step i=1: ilu=2.15, cheby=0.15 +DEAL::Residual step i=2: ilu=1.76, cheby=0.15 +DEAL::Size 16 Unknowns 225 +DEAL::Residual step i=0: ilu=6.15, cheby=0.38 +DEAL::Residual step i=1: ilu=6.25, cheby=0.40 +DEAL::Residual step i=2: ilu=5.65, cheby=0.37