]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add initializers with BlockIndices
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Wed, 26 Aug 2009 18:09:32 +0000 (18:09 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Wed, 26 Aug 2009 18:09:32 +0000 (18:09 +0000)
git-svn-id: https://svn.dealii.org/trunk@19347 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/lac/include/lac/block_sparsity_pattern.h
deal.II/lac/include/lac/block_vector.h
deal.II/lac/include/lac/block_vector.templates.h
deal.II/lac/source/block_sparsity_pattern.cc

index f12740255a0f0652859aa594f7cb0541b5b97bf0..ef8290ba355964001de2d210b1843b451fc50f19 100644 (file)
@@ -296,6 +296,16 @@ inconvenience this causes.
 <h3>lac</h3>
 
 <ol>
+  <li><p> Improved: BlockVector and several of the block sparsity
+  patterns can now be initialized with BlockIndices
+  objects. Therefore, if an application needs such an object, it does
+  not have to store a vector of block sizes separately.
+  <br>
+  (GK 2009/08/26)
+  </p>
+  </li>
+  
   <li>
   <p>
   Fixed: Crash or strange behaviour (wrong matrix entries written) in
@@ -390,6 +400,14 @@ inconvenience this causes.
 <h3>deal.II</h3>
 
 <ol>
+
+  <li><p> FETools::compute_block_renumbering() can nor return block sizes instead of
+  start indices.
+  <br>
+  (GK 2009/08/26)
+  </p>
+  </li>
+  
   <li>
   <p>
   New: The function GridGenerator::truncated_cone() and the class ConeBoundary
index 6cf9e4f17e09c79b9434b01bf6e9c762324d4f0d..abb365c913ffccf350735001f3e4bc64b483b593 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by the deal.II authors
+//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -679,6 +679,15 @@ class BlockCompressedSparsityPattern : public BlockSparsityPatternBase<Compresse
     BlockCompressedSparsityPattern (const std::vector<unsigned int>& row_block_sizes,
                                    const std::vector<unsigned int>& col_block_sizes);
     
+                                    /**
+                                     * Initialize the pattern with
+                                     * two BlockIndices for the block
+                                     * structures of matrix rows and
+                                     * columns.
+                                     */
+    BlockCompressedSparsityPattern (const BlockIndices& row_indices,
+                                   const BlockIndices& col_indices);
+    
                                     /**
                                      * Resize the matrix to a tensor
                                      * product of matrices with
@@ -697,6 +706,18 @@ class BlockCompressedSparsityPattern : public BlockSparsityPatternBase<Compresse
     void reinit (const std::vector< unsigned int > &row_block_sizes,
                 const std::vector< unsigned int > &col_block_sizes);
 
+                                    /**
+                                     * Resize the matrix to a tensor
+                                     * product of matrices with
+                                     * dimensions defined by the
+                                     * arguments. The two
+                                     * BlockIndices objects must be
+                                     * initialized and the sparsity
+                                     * pattern will have the
+                                     * same block structure afterwards.
+                                     */
+    void reinit (const BlockIndices& row_indices, const BlockIndices& col_indices);
+    
                                     /**
                                      * Allow the use of the reinit
                                      * functions of the base class as
@@ -759,7 +780,7 @@ class BlockCompressedSetSparsityPattern : public BlockSparsityPatternBase<Compre
                                      * you assign them sizes.
                                      */
     BlockCompressedSetSparsityPattern (const unsigned int n_rows,
-                                   const unsigned int n_columns);
+                                      const unsigned int n_columns);
 
                                     /**
                                      * Initialize the pattern with
@@ -773,7 +794,16 @@ class BlockCompressedSetSparsityPattern : public BlockSparsityPatternBase<Compre
                                      * values.
                                      */
     BlockCompressedSetSparsityPattern (const std::vector<unsigned int>& row_block_sizes,
-                                   const std::vector<unsigned int>& col_block_sizes);
+                                      const std::vector<unsigned int>& col_block_sizes);
+    
+                                    /**
+                                     * Initialize the pattern with
+                                     * two BlockIndices for the block
+                                     * structures of matrix rows and
+                                     * columns.
+                                     */
+    BlockCompressedSetSparsityPattern (const BlockIndices& row_indices,
+                                      const BlockIndices& col_indices);
     
                                     /**
                                      * Resize the matrix to a tensor
@@ -793,6 +823,18 @@ class BlockCompressedSetSparsityPattern : public BlockSparsityPatternBase<Compre
     void reinit (const std::vector< unsigned int > &row_block_sizes,
                 const std::vector< unsigned int > &col_block_sizes);
 
+                                    /**
+                                     * Resize the matrix to a tensor
+                                     * product of matrices with
+                                     * dimensions defined by the
+                                     * arguments. The two
+                                     * BlockIndices objects must be
+                                     * initialized and the sparsity
+                                     * pattern will have the
+                                     * same block structure afterwards.
+                                     */
+    void reinit (const BlockIndices& row_indices, const BlockIndices& col_indices);
+    
                                     /**
                                      * Allow the use of the reinit
                                      * functions of the base class as
index 0d65b7607d5293200090fdd8654efede33de783c..0448ca191343c332737b3b26996959099d77904d 100644 (file)
@@ -160,6 +160,13 @@ class BlockVector : public BlockVectorBase<Vector<Number> >
                                       */
     BlockVector (const std::vector<unsigned int> &block_sizes);
 
+                                     /**
+                                      * Constructor. Initialize vector
+                                      * to the structure found in the
+                                      * BlockIndices argument.
+                                      */
+    BlockVector (const BlockIndices& block_indices);
+
                                     /**
                                      * Constructor. Set the number of
                                      * blocks to
@@ -285,6 +292,23 @@ class BlockVector : public BlockVectorBase<Vector<Number> >
                                      */ 
     void reinit (const std::vector<unsigned int> &N,
                 const bool                       fast=false);
+
+                                    /**
+                                     * Reinitialize the BlockVector
+                                     * to reflect the structure found
+                                     * in BlockIndices.
+                                     *
+                                     * If the number of blocks is the
+                                     * same as before this function
+                                     * was called, all vectors remain
+                                     * the same and reinit() is
+                                     * called for each vector.
+                                     *
+                                     * If <tt>fast==false</tt>, the vector
+                                     * is filled with zeros.
+                                     */
+    void reinit (const BlockIndices& block_indices,
+                const bool fast=false);
     
                                     /**
                                      * Change the dimension to that
index c5c7ae89c68a87a8ed2cef5ea0fab8cb488053b0..91aa68ba59bd1aa75ac3bc0d0a576aa49e592eb4 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
+//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -38,6 +38,13 @@ BlockVector<Number>::BlockVector (const std::vector<unsigned int> &n)
 }
 
 
+template <typename Number>
+BlockVector<Number>::BlockVector (const BlockIndices& n)
+{
+  reinit (n, false);
+}
+
+
 template <typename Number>
 BlockVector<Number>::BlockVector (const BlockVector<Number>& v)
                 :
@@ -104,6 +111,20 @@ void BlockVector<Number>::reinit (const std::vector<unsigned int> &n,
 }
 
 
+template <typename Number>
+void BlockVector<Number>::reinit (
+  const BlockIndices& n,
+  const bool fast)
+{
+  this->block_indices = n;
+  if (this->components.size() != this->n_blocks())
+    this->components.resize(this->n_blocks());
+  
+  for (unsigned int i=0; i<this->n_blocks(); ++i)
+    this->components[i].reinit(n.block_size(i), fast);
+}
+
+
 template <typename Number>
 template <typename Number2>
 void BlockVector<Number>::reinit (const BlockVector<Number2>& v,
index 67e84d312c4ebb072408c6b4477ccef8d49f2556..4ab9c469e701d9f2701132be26b31c05d4838b35 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
+//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -441,8 +441,9 @@ BlockCompressedSparsityPattern::BlockCompressedSparsityPattern ()
 
 
 BlockCompressedSparsityPattern::
-BlockCompressedSparsityPattern (const unsigned int n_rows,
-                               const unsigned int n_columns)
+BlockCompressedSparsityPattern (
+  const unsigned int n_rows,
+  const unsigned int n_columns)
                :
                BlockSparsityPatternBase<CompressedSparsityPattern>(n_rows,
                                                                    n_columns)
@@ -450,16 +451,20 @@ BlockCompressedSparsityPattern (const unsigned int n_rows,
 
 
 BlockCompressedSparsityPattern::
-BlockCompressedSparsityPattern (const std::vector<unsigned int>& row_indices,
-                               const std::vector<unsigned int>& col_indices)
-               :
-               BlockSparsityPatternBase<CompressedSparsityPattern>(row_indices.size(),
-                                                                   col_indices.size())
+BlockCompressedSparsityPattern (
+  const std::vector<unsigned int>& row_indices,
+  const std::vector<unsigned int>& col_indices)
 {
-  for (unsigned int i=0;i<row_indices.size();++i)
-    for (unsigned int j=0;j<col_indices.size();++j)
-      this->block(i,j).reinit(row_indices[i],col_indices[j]);
-  this->collect_sizes();
+  reinit(row_indices, col_indices);
+}
+
+
+BlockCompressedSparsityPattern::
+BlockCompressedSparsityPattern (
+  const BlockIndices& row_indices,
+  const BlockIndices& col_indices)
+{
+  reinit(row_indices, col_indices);
 }
 
 
@@ -477,31 +482,52 @@ BlockCompressedSparsityPattern::reinit (
 
 
 
+void
+BlockCompressedSparsityPattern::reinit (
+  const BlockIndices& row_indices,
+  const BlockIndices& col_indices)
+{
+  BlockSparsityPatternBase<CompressedSparsityPattern>::reinit(row_indices.size(),
+                                                             col_indices.size());
+  for (unsigned int i=0;i<row_indices.size();++i)
+    for (unsigned int j=0;j<col_indices.size();++j)
+      this->block(i,j).reinit(row_indices.block_size(i),
+                             col_indices.block_size(j));
+  this->collect_sizes();  
+}
+
+
+
 BlockCompressedSetSparsityPattern::BlockCompressedSetSparsityPattern ()
 {}
 
 
 
 BlockCompressedSetSparsityPattern::
-BlockCompressedSetSparsityPattern (const unsigned int n_rows,
-                               const unsigned int n_columns)
+BlockCompressedSetSparsityPattern (
+  const unsigned int n_rows,
+  const unsigned int n_columns)
                :
                BlockSparsityPatternBase<CompressedSetSparsityPattern>(n_rows,
-                                                                   n_columns)
+                                                                      n_columns)
 {}
 
 
 BlockCompressedSetSparsityPattern::
-BlockCompressedSetSparsityPattern (const std::vector<unsigned int>& row_indices,
-                               const std::vector<unsigned int>& col_indices)
-               :
-               BlockSparsityPatternBase<CompressedSetSparsityPattern>(row_indices.size(),
-                                                                   col_indices.size())
+BlockCompressedSetSparsityPattern (
+  const std::vector<unsigned int>& row_indices,
+  const std::vector<unsigned int>& col_indices)
 {
-  for (unsigned int i=0;i<row_indices.size();++i)
-    for (unsigned int j=0;j<col_indices.size();++j)
-      this->block(i,j).reinit(row_indices[i],col_indices[j]);
-  this->collect_sizes();
+  reinit(row_indices, col_indices);
+}
+
+
+BlockCompressedSetSparsityPattern::
+BlockCompressedSetSparsityPattern (
+  const BlockIndices& row_indices,
+  const BlockIndices& col_indices)
+{
+  reinit(row_indices, col_indices);
 }
 
 
@@ -519,6 +545,22 @@ BlockCompressedSetSparsityPattern::reinit (
 
 
 
+void
+BlockCompressedSetSparsityPattern::reinit (
+  const BlockIndices& row_indices,
+  const BlockIndices& col_indices)
+{
+  BlockSparsityPatternBase<CompressedSetSparsityPattern>::reinit(row_indices.size(),
+                                                                col_indices.size());
+  for (unsigned int i=0;i<row_indices.size();++i)
+    for (unsigned int j=0;j<col_indices.size();++j)
+      this->block(i,j).reinit(row_indices.block_size(i),
+                             col_indices.block_size(j));
+  this->collect_sizes();  
+}
+
+
+
 BlockCompressedSimpleSparsityPattern::BlockCompressedSimpleSparsityPattern ()
 {}
 

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.