]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
test for correct size of permutation vector and add documentation
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 17 Jun 2011 21:35:44 +0000 (21:35 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 17 Jun 2011 21:35:44 +0000 (21:35 +0000)
git-svn-id: https://svn.dealii.org/trunk@23836 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/precondition_block.h
deal.II/include/deal.II/lac/precondition_block.templates.h

index cfe99c3fe419818dcacf9c3ea1c63339dfd47258..2a8f81116d76ef547047f38faea830a696e5b49e 100644 (file)
@@ -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<unsigned int>& permutation,
                         const std::vector<unsigned int>& inverse_permutation);
index 6916f5929e0f5099210b36272bcabbef0ab3c0f6..994ea111d9da6dd9e24583a6183f6d7f9e1a825b 100644 (file)
@@ -88,7 +88,12 @@ void PreconditionBlock<MATRIX,inverse_type>::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<MATRIX,inverse_type>::initialize (
   const std::vector<unsigned int>& 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 <class MATRIX, typename inverse_type>
@@ -539,6 +524,12 @@ void PreconditionBlock<MATRIX,inverse_type>::set_permutation (
   const std::vector<unsigned int>& 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<p.size();++k)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.