From e1f8b8b29cb00fecf6f158ac871f59265a442e59 Mon Sep 17 00:00:00 2001 From: kanschat Date: Fri, 17 Jun 2011 21:35:44 +0000 Subject: [PATCH] test for correct size of permutation vector and add documentation git-svn-id: https://svn.dealii.org/trunk@23836 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/deal.II/lac/precondition_block.h | 51 ++++++++++++++++--- .../lac/precondition_block.templates.h | 35 +++++-------- 2 files changed, 58 insertions(+), 28 deletions(-) diff --git a/deal.II/include/deal.II/lac/precondition_block.h b/deal.II/include/deal.II/lac/precondition_block.h index cfe99c3fe4..2a8f81116d 100644 --- a/deal.II/include/deal.II/lac/precondition_block.h +++ b/deal.II/include/deal.II/lac/precondition_block.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -199,11 +199,50 @@ class PreconditionBlock const AdditionalData parameters); /** - * Set the permutation and its - * inverse. These vectors are - * copied into private data, so - * they can be reused or deleted - * after a call to this function. + * Set either the permutation of + * rows or the permutation of + * blocks, depending on the size + * of the vector. + * + * If the size of the permutation + * vectors is equal to the + * dimension of the linear + * system, it is assumed that + * rows are permuted + * individually. In this case, + * set_permutation() must be + * called before initialize(), + * since the diagonal blocks are + * built from the permuted + * entries of the matrix. + * + * If the size of the permutation + * vector is not equal to the + * dimension of the system, the + * diagonal blocks are computed + * from the unpermuted + * entries. Instead, the + * relaxation methods step() and + * Tstep() are executed applying + * the blocks in the order given + * by the permutation + * vector. They will throw an + * exception if length of this + * vector is not equal to the + * number of blocks. + * + * @note Permutation of blocks + * can only be applied to the + * relaxation operators step() + * and Tstep(), not to the + * preconditioning operators + * vmult() and Tvmult(). + * + * @note It is safe to call + * set_permutation() before + * initialize(), while the other + * order is only admissible for + * block permutation. */ void set_permutation(const std::vector& permutation, const std::vector& inverse_permutation); diff --git a/deal.II/include/deal.II/lac/precondition_block.templates.h b/deal.II/include/deal.II/lac/precondition_block.templates.h index 6916f5929e..994ea111d9 100644 --- a/deal.II/include/deal.II/lac/precondition_block.templates.h +++ b/deal.II/include/deal.II/lac/precondition_block.templates.h @@ -88,7 +88,12 @@ void PreconditionBlock::initialize ( parameters.inversion); if (parameters.invert_diagonal) - invert_diagblocks(); + { + if (permutation.size() == M.m()) + invert_permuted_diagblocks(permutation, inverse_permutation); + else + invert_diagblocks(); + } } @@ -99,28 +104,8 @@ void PreconditionBlock::initialize ( const std::vector& inverse_permutation, const AdditionalData parameters) { - const unsigned int bsize = parameters.block_size; - - clear(); - Assert (M.m() == M.n(), ExcNotQuadratic()); - A = &M; - Assert (bsize>0, ExcIndexRange(bsize, 1, M.m())); - Assert (A->m()%bsize==0, ExcWrongBlockSize(bsize, A->m())); - blocksize=bsize; - relaxation = parameters.relaxation; - const unsigned int nblocks = A->m()/bsize; - this->reinit(nblocks, blocksize, parameters.same_diagonal, - parameters.inversion); - set_permutation(permutation, inverse_permutation); - - if (parameters.invert_diagonal) - { - if (permutation.size() == M.m()) - invert_permuted_diagblocks(permutation, inverse_permutation); - else - invert_diagblocks(); - } + initialize(M, parameters); } template @@ -539,6 +524,12 @@ void PreconditionBlock::set_permutation ( const std::vector& i) { Assert (p.size() == i.size(), ExcDimensionMismatch(p.size(), i.size())); + + if (this->inverses_ready()) + { + AssertDimension(p.size(), this->size()); + } + permutation.resize(p.size()); inverse_permutation.resize(p.size()); for (unsigned int k=0;k