From: Martin Kronbichler Date: Fri, 28 Oct 2016 09:34:26 +0000 (+0200) Subject: Add test which uses zero rhs vector that needs alternative initialization X-Git-Tag: v8.5.0-rc1~520^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4c1264eab0905bea0d95ba3a9d7a521f70d5b95;p=dealii.git Add test which uses zero rhs vector that needs alternative initialization --- diff --git a/tests/lac/precondition_chebyshev_04.cc b/tests/lac/precondition_chebyshev_04.cc new file mode 100644 index 0000000000..03ccdb11c2 --- /dev/null +++ b/tests/lac/precondition_chebyshev_04.cc @@ -0,0 +1,135 @@ +// --------------------------------------------------------------------- +// +// 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_02 but checking that the Chebyshev +// initialization also works when the first vmult operation is done on a zero +// vector + + +#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), ref(size), zero(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; i