]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
BlockVector support for homogeneous blocks
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 9 Nov 2000 18:00:50 +0000 (18:00 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 9 Nov 2000 18:00:50 +0000 (18:00 +0000)
git-svn-id: https://svn.dealii.org/trunk@3475 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/block_indices.h
deal.II/lac/include/lac/block_vector.h
deal.II/lac/include/lac/block_vector.templates.h

index 81b00ed107eff4a5eb3041a1b211970435e795e7..2baeaff2ff206daf073535e1b9bea994747608dd 100644 (file)
@@ -37,7 +37,7 @@ class BlockIndices
                                      * @p{n_blocks} blocks and set
                                      * all block sizes to zero.
                                      */
-    BlockIndices (const unsigned int n_blocks);
+    BlockIndices (const unsigned int n_blocks = 0);
 
                                     /**
                                      * Constructor. Initialize the
index 861cedbfc5905806cdd6f9425c877674e0f0aed4..48c91d767e2e2a62c7bdf45ea1fcea41bae553d7 100644 (file)
@@ -25,7 +25,9 @@
  * Several vectors of data. 
  *
  * The BlockVector is a collection of normal LAC-@p{Vector}s. Each of
- * the vectors inside can have a different size.
+ * the vectors inside can have a different size. The special case of a
+ * block vector with constant block size is supported by constructor
+ * and reinit functions.
  *
  * The functionality of @p{BlockVector} includes everything a @p{Vector}
  * can do, plus the access to a single @p{Vector} inside the
@@ -43,7 +45,7 @@
  * corresponding ``.templates.h'' file and instantiate the respective
  * class yourself.
  *
- * @author Guido Kanschat, 1999; Wolfgang Bangerth, 2000
+ * @author Wolfgang Bangerth, Guido Kanschat, 1999, 2000
  */
 template <typename Number>
 class BlockVector
@@ -69,9 +71,26 @@ class BlockVector
     typedef size_t size_type;
 
                                     /**
-                                     *  Dummy-Constructor. Dimension=0
+                                     *  Constructor. There are three
+                                     *  ways to use this
+                                     *  constructor. First, without
+                                     *  any arguments, it generates
+                                     *  an objetct with no
+                                     *  blocks. Given one argument,
+                                     *  it initializes @p{num_blocks}
+                                     *  blocks, but these blocks have
+                                     *  size zero. The third variant
+                                     *  finally initializes all
+                                     *  blocks to the same size
+                                     *  @p{block_size}.
+                                     *
+                                     *  Confer the other constructor
+                                     *  further down if you intend to
+                                     *  use blocks of different
+                                     *  sizes.
                                      */
-    BlockVector (unsigned int num_blocks = 0);
+    BlockVector (unsigned int num_blocks = 0,
+                unsigned int block_size = 0);
     
                                     /**
                                      * Copy-Constructor. Dimension set to
@@ -111,6 +130,18 @@ class BlockVector
                                      */
     ~BlockVector ();
 
+                                  /**
+                                   * Reinitialize the BlockVector to
+                                   * contain @p{num_blocks} blocks of
+                                   * size @p{block_size} each.
+                                   *
+                                   * If @p{fast==false}, the vector
+                                   * is filled with zeros.
+                                   */
+  void reinit (const unsigned int num_blocks,
+              const unsigned int block_size,
+              const bool fast = false);
+  
                                     /**
                                      * Reinitialize the BlockVector
                                      * such that it contains
@@ -129,8 +160,8 @@ class BlockVector
                                      * has a potential to slow down a
                                      * program considerably.
                                      *
-                                     * On @p{fast==false}, the vector is filled by
-                                     * zeros.
+                                     * If @p{fast==false}, the vector
+                                     * is filled with zeros.
                                      */ 
     void reinit (const vector<unsigned int> &N,
                 const bool                  fast=false);
index e1a0ce6ac926203d28dcaccbed7101a2fd26dc8e..8af6af75d719593150a7fbf53675df17bb7585ba 100644 (file)
 
 
 template <typename Number>
-BlockVector<Number>::BlockVector (unsigned int num_blocks)
-  : components(num_blocks),
-    block_indices(num_blocks),
-    num_blocks(num_blocks)
-{}
+BlockVector<Number>::BlockVector (unsigned int n_blocks,
+                                 unsigned int block_size)
+{
+  reinit (n_blocks, block_size);
+}
 
 
 
 template <typename Number>
 BlockVector<Number>::BlockVector (const vector<unsigned int> &n)
-  : block_indices(num_blocks)
 {
   reinit (n, false);
 }
@@ -65,6 +64,16 @@ BlockVector<Number>::BlockVector (const BlockVector<Number>& v)
 // }
 
 
+template <typename Number>
+void BlockVector<Number>::reinit (const unsigned int n_bl,
+                                 const unsigned int bl_sz,
+                                 const bool                  fast)
+{
+  vector<unsigned int> n(n_bl, bl_sz);
+  reinit(n, fast);
+}
+
+
 template <typename Number>
 void BlockVector<Number>::reinit (const vector<unsigned int> &n,
                                  const bool                  fast)

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.