]> https://gitweb.dealii.org/ - dealii.git/commitdiff
initialization with row_length vector from DoFTools
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Thu, 30 Mar 2006 20:57:45 +0000 (20:57 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Thu, 30 Mar 2006 20:57:45 +0000 (20:57 +0000)
git-svn-id: https://svn.dealii.org/trunk@12782 0785d39b-7218-0410-832d-ea1e28bc413d

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

index f725f685707c82cdf46d851cba72b6e29cee7390..1a4613068e35ee095524a6e958a2fdc96c7f6348 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors
+//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -103,7 +103,7 @@ class BlockSparsityPatternBase : public Subscriptor
                                      */
     BlockSparsityPatternBase (const unsigned int n_block_rows,
                              const unsigned int n_block_columns);
-
+    
                                     /**
                                      * Copy constructor. This
                                      * constructor is only allowed to
@@ -437,6 +437,26 @@ class BlockSparsityPattern : public BlockSparsityPatternBase<SparsityPattern>
     BlockSparsityPattern (const unsigned int n_rows,
                          const unsigned int n_columns);
 
+                                    /**
+                                     * Forwarding to
+                                     * BlockSparsityPatternBase::reinit().
+                                     */
+    void reinit (const unsigned int n_block_rows,
+                const unsigned int n_block_columns);
+    
+                                    /**
+                                     * Initialize the pattern with
+                                     * two BlockIndices for the block
+                                     * structures of matrix rows and
+                                     * columns as well as a row
+                                     * length vector in the format
+                                     * produced by DoFTools.
+                                     */
+    void reinit (const BlockIndices& row_indices,
+                const BlockIndices& col_indices,
+                const std::vector<std::vector<unsigned int> >& row_lengths);
+    
+
                                     /**
                                      * Return whether the structure
                                      * is compressed or not,
@@ -613,4 +633,16 @@ BlockSparsityPatternBase<SparsityPatternBase>::n_block_rows () const
   return rows;
 }
 
+
+inline
+void
+BlockSparsityPattern::reinit (
+  const unsigned int n_block_rows,
+  const unsigned int n_block_columns)
+{
+  BlockSparsityPatternBase<SparsityPattern>::reinit (
+    n_block_rows, n_block_columns);
+}
+
+
 #endif
index 31fd7dff6b63e55927dbfdef8bd5cdca936e096e..1d0e76e8e41c479b3d928079d060e323aaac816e 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors
+//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -11,6 +11,7 @@
 //
 //---------------------------------------------------------------------------
 
+#include <base/vector_slice.h>
 #include <base/memory_consumption.h>
 #include <lac/block_sparsity_pattern.h>
 
@@ -244,7 +245,7 @@ BlockSparsityPatternBase<SparsityPatternBase>::print(std::ostream& out) const
   unsigned int k=0;
   for (unsigned int ib=0;ib<n_block_rows();++ib)
     {
-      for (unsigned int i=0;i<block(ib,ib).n_rows();++i)
+      for (unsigned int i=0;i<block(ib,0).n_rows();++i)
        {
          out << '[' << i+k;
          unsigned int l=0;
@@ -258,7 +259,7 @@ BlockSparsityPatternBase<SparsityPatternBase>::print(std::ostream& out) const
            }
          out << ']' << std::endl;
        }
-      k += block(ib,ib).n_rows();
+      k += block(ib,0).n_rows();
     }
 }
 
@@ -297,7 +298,31 @@ BlockSparsityPattern::BlockSparsityPattern (const unsigned int n_rows,
 {}
 
 
+void
+BlockSparsityPattern::reinit(
+  const BlockIndices& rows,
+  const BlockIndices& cols,
+  const std::vector<std::vector<unsigned int> >& row_lengths)
+{
+  this->reinit(rows.size(), cols.size());
+  for (unsigned int j=0;j<cols.size();++j)
+    for (unsigned int i=0;i<rows.size();++i)
+      {
+       const unsigned int start = rows.local_to_global(i, 0);
+       const unsigned int length = rows.block_size(i);
+       
+       VectorSlice<const std::vector<unsigned int> >
+         block_rows(row_lengths[j], start, length);
+       block(i,j).reinit(rows.block_size(i),
+                         cols.block_size(j),
+                         block_rows);
+      }
+  this->collect_sizes();
+  Assert (this->row_indices == rows, ExcInternalError());
+  Assert (this->column_indices == cols, ExcInternalError());  
+}
 
+    
 bool
 BlockSparsityPattern::is_compressed () const
 {

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.