]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
default constructors added to BlockMatrixArray and BlockTrianglePrecondition
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 21 Apr 2005 09:32:43 +0000 (09:32 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 21 Apr 2005 09:32:43 +0000 (09:32 +0000)
git-svn-id: https://svn.dealii.org/trunk@10554 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 241f242e7e9d3d82a117f94c81f6177b7f5aaffb..f9702a6899fad52d140c68ee65aa66167ac89fce 100644 (file)
@@ -126,6 +126,14 @@ template <typename number = double>
 class BlockMatrixArray : public Subscriptor
 {
   public:
+                                    /**
+                                     * Default constructor creating a
+                                     * useless object. initialize()
+                                     * must be called before using
+                                     * it.
+                                     */
+    BlockMatrixArray ();
+    
                                     /**
                                      * Constructor fixing the
                                      * dimensions.
@@ -134,6 +142,17 @@ class BlockMatrixArray : public Subscriptor
                      const unsigned int n_block_cols,
                      VectorMemory<Vector<number> >& mem);
 
+                                    /**
+                                     * Initialize object
+                                     * completely. This is the
+                                     * function to call for an object
+                                     * created by the default
+                                     * constructor.
+                                     */
+    void initialize (const unsigned int n_block_rows,
+                    const unsigned int n_block_cols,
+                    VectorMemory<Vector<number> >& mem);
+    
                                     /**
                                      * Adjust the matrix to a new
                                      * size and delete all blocks.
@@ -415,15 +434,42 @@ class BlockTrianglePrecondition
   : private BlockMatrixArray<number>
 {
   public:
+                                    /**
+                                     * Default constructor creating a
+                                     * useless object. initialize()
+                                     * must be called before using
+                                     * it.
+                                     */
+    BlockTrianglePrecondition ();
+    
                                     /**
                                      * Constructor. This matrix must be
                                      * block-quadratic. The additional
                                      * parameter allows for backward
                                      * insertion instead of forward.
                                      */
-    BlockTrianglePrecondition(unsigned int block_rows,
-                             VectorMemory<Vector<number> >& mem,
-                             bool backward = false);
+    BlockTrianglePrecondition (unsigned int n_block_rows,
+                              VectorMemory<Vector<number> >& mem,
+                              bool backward = false);
+    
+                                    /**
+                                     * Initialize object
+                                     * completely. This is the
+                                     * function to call for an object
+                                     * created by the default
+                                     * constructor.
+                                     */
+    void initialize (const unsigned int n_block_rows,
+                    VectorMemory<Vector<number> >& mem,
+                    bool backward = false);
+    
+                                    /**
+                                     * Resize preconditioner to a new
+                                     * size and clear all blocks.
+                                     */
+    void reinit(const unsigned int n_block_rows);
+    
+    
                                     /**
                                      * Enter a block. This calls
                                      * BlockMatrixArray::enter(). Remember
@@ -437,12 +483,6 @@ class BlockTrianglePrecondition
                const unsigned int col,
                const double       prefix = 1.,
                const bool         transpose = false);
-    
-                                    /**
-                                     * Resize preconditioner to a new
-                                     * size and clear all blocks.
-                                     */
-    void reinit(const unsigned int n_block_rows);
 
                                      /**
                                      * Preconditioning.
@@ -544,6 +584,7 @@ BlockMatrixArray<number>::enter (const MATRIX& matrix,
                                 unsigned row, unsigned int col,
                                 double prefix, bool transpose)
 {
+  Assert (mem != 0, ExcNotInitialized());
   Assert(row<n_block_rows(), ExcIndexRange(row, 0, n_block_rows()));
   Assert(col<n_block_cols(), ExcIndexRange(col, 0, n_block_cols()));
   entries.push_back(Entry(matrix, row, col, prefix, transpose));
@@ -567,6 +608,7 @@ inline
 void
 BlockMatrixArray<number>::print_latex (STREAM& out) const
 {
+  Assert (mem != 0, ExcNotInitialized());
   out << "\\begin{array}{"
       << std::string(n_block_cols(), 'c')
       << "}" << std::endl;
index 3312fa283f46802e131d6fe7cac6f0317babc0b2..734758e295c4f12e36a7caa4fe68d4b283339916 100644 (file)
@@ -40,6 +40,15 @@ BlockMatrixArray<number>::Entry::~Entry ()
 
 
 
+template <typename number>
+BlockMatrixArray<number>::BlockMatrixArray ()
+               : block_rows (0),
+                 block_cols (0),
+                 mem(0, typeid(*this).name())
+{}
+
+
+
 template <typename number>
 BlockMatrixArray<number>::BlockMatrixArray (
   const unsigned int n_block_rows,
@@ -51,6 +60,20 @@ BlockMatrixArray<number>::BlockMatrixArray (
 {}
 
 
+template <typename number>
+void
+BlockMatrixArray<number>::initialize (
+  const unsigned int n_block_rows,
+  const unsigned int n_block_cols,
+  VectorMemory<Vector<number> >& memory)
+{
+  block_rows = n_block_rows;
+  block_cols = n_block_cols;
+  mem = &memory;
+}
+
+
+
 
 template <typename number>
 void
@@ -58,6 +81,7 @@ BlockMatrixArray<number>::reinit (
   const unsigned int n_block_rows,
   const unsigned int n_block_cols)
 {
+  Assert (mem != 0, ExcNotInitialized());
   clear();
   block_rows = n_block_rows;
   block_cols = n_block_cols;
@@ -78,6 +102,8 @@ void
 BlockMatrixArray<number>::vmult_add (BlockVector<number>& dst,
                                     const BlockVector<number>& src) const
 {
+  Assert (mem != 0, ExcNotInitialized());
+  
   Assert (dst.n_blocks() == block_rows,
          ExcDimensionMismatch(dst.n_blocks(), block_rows));
   Assert (src.n_blocks() == block_cols,
@@ -121,6 +147,7 @@ void
 BlockMatrixArray<number>::Tvmult_add (BlockVector<number>& dst,
                                      const BlockVector<number>& src) const
 {
+  Assert (mem != 0, ExcNotInitialized());
   Assert (dst.n_blocks() == block_cols,
          ExcDimensionMismatch(dst.n_blocks(), block_cols));
   Assert (src.n_blocks() == block_rows,
@@ -164,6 +191,7 @@ BlockMatrixArray<number>::matrix_scalar_product (
   const BlockVector<number>& u,
   const BlockVector<number>& v) const
 {
+  Assert (mem != 0, ExcNotInitialized());
   Assert (u.n_blocks() == block_rows,
          ExcDimensionMismatch(u.n_blocks(), block_rows));
   Assert (v.n_blocks() == block_cols,
@@ -228,6 +256,13 @@ BlockMatrixArray<number>::n_block_cols () const
 
 //---------------------------------------------------------------------------
 
+template <typename number>
+BlockTrianglePrecondition<number>::BlockTrianglePrecondition()
+               : BlockMatrixArray<number> (),
+                 backward(false)
+{}
+
+
 template <typename number>
 BlockTrianglePrecondition<number>::BlockTrianglePrecondition(
   unsigned int block_rows,
@@ -239,6 +274,18 @@ BlockTrianglePrecondition<number>::BlockTrianglePrecondition(
 {}
 
 
+template <typename number>
+void
+BlockTrianglePrecondition<number>::initialize(
+  unsigned int n_block_rows,
+  VectorMemory<Vector<number> >& memory,
+  bool backward)
+{
+  BlockMatrixArray<number>::initialize(n_block_rows, n_block_rows, memory);
+  backward = backward;
+}
+
+
 template <typename number>
 void
 BlockTrianglePrecondition<number>::reinit (
@@ -247,6 +294,7 @@ BlockTrianglePrecondition<number>::reinit (
   BlockMatrixArray<number>::reinit(n,n);
 }
 
+
 template <typename number>
 void
 BlockTrianglePrecondition<number>::do_row (

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.