]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
add another convenient reinit function
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 14 Feb 2007 00:31:09 +0000 (00:31 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 14 Feb 2007 00:31:09 +0000 (00:31 +0000)
git-svn-id: https://svn.dealii.org/trunk@14471 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/block_sparsity_pattern.h
deal.II/lac/source/block_sparsity_pattern.cc

index b582e58c482d239b6b5cd82998526125a913269f..3f44fec7ae00671680bb38fc37b4db750d4806fd 100644 (file)
@@ -152,7 +152,7 @@ class BlockSparsityPatternBase : public Subscriptor
                                      */
     void reinit (const unsigned int n_block_rows,
                 const unsigned int n_block_columns);
-    
+
                                     /**
                                      * Copy operator. For this the
                                      * same holds as for the copy
@@ -534,7 +534,7 @@ class BlockSparsityPattern : public BlockSparsityPatternBase<SparsityPattern>
  *
  * @until copy
  *
- * @author Wolfgang Bangerth, 2000, 2001, example by Guido Kanschat, 2006
+ * @author Wolfgang Bangerth, 2000, 2001, Guido Kanschat, 2006, 2007
  */
 class CompressedBlockSparsityPattern : public BlockSparsityPatternBase<CompressedSparsityPattern>
 {
@@ -577,6 +577,30 @@ class CompressedBlockSparsityPattern : public BlockSparsityPatternBase<Compresse
     CompressedBlockSparsityPattern (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 matrix will have as many
+                                     * block rows and columns as
+                                     * there are entries in the two
+                                     * arguments. The block at
+                                     * position (<i>i,j</i>) will
+                                     * have the dimensions
+                                     * <tt>row_block_sizes[i]</tt>
+                                     * times <tt>col_block_sizes[j]</tt>.
+                                     */
+    void reinit (const std::vector< unsigned int > &row_block_sizes,
+                const std::vector< unsigned int > &col_block_sizes);
+
+                                    /**
+                                     * Allow the use of the reinit
+                                     * functions of the base class as
+                                     * well.
+                                     */
+    BlockSparsityPatternBase<CompressedSparsityPattern>::reinit;
 };
 
 
index 7ce640d011b3a8533d219181a5e7739e26897d3d..68fec80527ca66799680f3db323f1305864d838f 100644 (file)
@@ -97,7 +97,6 @@ reinit (const unsigned int n_block_rows,
 }
 
 
-
 template <class SparsityPatternBase>
 BlockSparsityPatternBase<SparsityPatternBase> &
 BlockSparsityPatternBase<SparsityPatternBase>::
@@ -401,6 +400,21 @@ CompressedBlockSparsityPattern (const std::vector<unsigned int>& row_indices,
 }
 
 
+void
+CompressedBlockSparsityPattern::reinit (
+  const std::vector< unsigned int > &row_block_sizes,
+  const std::vector< unsigned int > &col_block_sizes)
+{
+  this->reinit(row_block_sizes.size(), col_block_sizes.size());
+  for (unsigned int i=0;i<row_block_sizes.size();++i)
+    for (unsigned int j=0;j<col_block_sizes.size();++j)
+      this->block(i,j).reinit(row_block_sizes[i],col_block_sizes[j]);
+  this->collect_sizes();  
+}
+
+
+
+
 // Remark: The explicit instantiations for "BlockSparsityPatternBase" were moved
 // to the top of this source file. The reason is a slightly buggy version
 // of the Apple gcc v.3.3.

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.