From e33e46658e85f1ddee79fb0e263f9f7cceb520d3 Mon Sep 17 00:00:00 2001 From: Guido Kanschat Date: Sat, 3 Dec 2005 17:27:26 +0000 Subject: [PATCH] new test for BlockSmoother git-svn-id: https://svn.dealii.org/trunk@11807 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/multigrid/Makefile | 3 +- tests/multigrid/smoother_block.cc | 216 +++++++++++++++++++++ tests/multigrid/smoother_block/cmp/generic | 44 +++++ 3 files changed, 262 insertions(+), 1 deletion(-) create mode 100644 tests/multigrid/smoother_block.cc create mode 100644 tests/multigrid/smoother_block/cmp/generic diff --git a/tests/multigrid/Makefile b/tests/multigrid/Makefile index 8f69a242dc..e779f2cb60 100644 --- a/tests/multigrid/Makefile +++ b/tests/multigrid/Makefile @@ -21,7 +21,8 @@ default: run-tests ############################################################ -tests_x = cycles transfer transfer_select transfer_block +tests_x = cycles transfer transfer_select transfer_block \ + smoother_block # from above list of regular expressions, generate the real set of # tests diff --git a/tests/multigrid/smoother_block.cc b/tests/multigrid/smoother_block.cc new file mode 100644 index 0000000000..b18df2fce1 --- /dev/null +++ b/tests/multigrid/smoother_block.cc @@ -0,0 +1,216 @@ +//---------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2000 - 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. +// +//---------------------------------------------------------------------------- + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +template +class ScalingMatrix : public Subscriptor +{ + public: + /** + * Constructor setting the + * scaling factor. Default is + * constructing the identity + * matrix. + */ + ScalingMatrix(number scaling_factor = 1.); + /** + * Apply preconditioner. + */ + template + void vmult (VECTOR&, const VECTOR&) const; + + /** + * Apply transpose + * preconditioner. Since this is + * the identity, this function is + * the same as + * vmult(). + */ + template + void Tvmult (VECTOR&, const VECTOR&) const; + /** + * Apply preconditioner, adding to the previous value. + */ + template + void vmult_add (VECTOR&, const VECTOR&) const; + + /** + * Apply transpose + * preconditioner, adding. Since this is + * the identity, this function is + * the same as + * vmult_add(). + */ + template + void Tvmult_add (VECTOR&, const VECTOR&) const; + + private: + number factor; +}; + + +//----------------------------------------------------------------------// + +template +ScalingMatrix::ScalingMatrix(number factor) + : + factor(factor) +{} + + +template +template +inline void +ScalingMatrix::vmult (VECTOR &dst, const VECTOR &src) const +{ + dst.equ(factor, src); +} + +template +template +inline void +ScalingMatrix::Tvmult (VECTOR &dst, const VECTOR &src) const +{ + dst.equ(factor, src); +} + +template +template +inline void +ScalingMatrix::vmult_add (VECTOR &dst, const VECTOR &src) const +{ + dst.add(factor, src); +} + + + +template +template +inline void +ScalingMatrix::Tvmult_add (VECTOR &dst, const VECTOR &src) const +{ + dst.add(factor, src); +} + +//----------------------------------------------------------------------// + +template +void check_smoother(const MGLevelObject& m, + const MGLevelObject& r) +{ + GrowingVectorMemory > mem; + MGSmootherBlock smoother(mem); + + smoother.initialize(m, r); + + for (unsigned int l=m.get_minlevel(); l<= m.get_maxlevel();++l) + { + deallog << "Level " << l << std::endl; + + BlockVector& u = *mem.alloc(); + BlockVector& f = *mem.alloc(); + u.reinit(m[l].n_block_rows(), 3); + f.reinit(u); + for (unsigned int b=0;b s1(-1.); + ScalingMatrix s2(2.); + ScalingMatrix s8(8.); + + GrowingVectorMemory > mem; + MGLevelObject > A (2,4); + MGLevelObject > P(2,4); + + for (unsigned int l=A.get_minlevel(); l<= A.get_maxlevel();++l) + { + A[l].initialize(3, 3, mem); + P[l].initialize(3, mem); + for (unsigned int b=0;b