From: Martin Kronbichler Date: Thu, 27 Oct 2016 13:22:05 +0000 (+0200) Subject: Add new test for general (non-diagonal matrix) interface of Chebyshev X-Git-Tag: v8.5.0-rc1~520^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbbe5c15dff0cce08033b3c7294603f4253bb2fe;p=dealii.git Add new test for general (non-diagonal matrix) interface of Chebyshev --- diff --git a/tests/lac/precondition_chebyshev_02.cc b/tests/lac/precondition_chebyshev_02.cc new file mode 100644 index 0000000000..9fc63c140c --- /dev/null +++ b/tests/lac/precondition_chebyshev_02.cc @@ -0,0 +1,137 @@ +// --------------------------------------------------------------------- +// +// 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. +// +// --------------------------------------------------------------------- + + +// Similar to precondition_chebyshev_01 but using a separate preconditioner +// class for providing the inverse diagonal that goes through another code +// path in PreconditionChebyshev + + +#include "../tests.h" +#include +#include +#include +#include + +#include +#include +#include +#include + + +class DiagonalMatrixManual +{ +public: + DiagonalMatrixManual() {} + + void set_vector_one (const unsigned int size) + { + diagonal.reinit(size); + diagonal = 1; + } + + void reinit (const FullMatrix f) + { + diagonal.reinit(f.m()); + for (unsigned int i=0; i::size_type m() const + { + return diagonal.size(); + } + + void vmult(Vector &dst, const Vector &src) const + { + dst = src; + dst.scale(diagonal); + } + +private: + Vector diagonal; +}; + + +void +check() +{ + const unsigned int size = 10; + FullMatrix m(size,size); + for (unsigned int i=0; i in (size), out(size); + for (unsigned int i=0; i,Vector,DiagonalMatrixManual> prec; + PreconditionChebyshev,Vector,DiagonalMatrixManual>::AdditionalData + data; + data.smoothing_range = 2 * size; + data.degree = 3; + data.preconditioner.reset(new DiagonalMatrixManual()); + data.preconditioner->set_vector_one(size); + prec.initialize(m, data); + + deallog << "Exact inverse: "; + for (unsigned int i=0; ireinit(m); + data.smoothing_range = 2; + data.degree = 5; + prec.initialize(m, data); + + deallog << "Check vmult diag: "; + prec.vmult(out, in); + for (unsigned int i=0; i