]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
debug option for matrices
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 4 Jul 2002 14:07:13 +0000 (14:07 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 4 Jul 2002 14:07:13 +0000 (14:07 +0000)
git-svn-id: https://svn.dealii.org/trunk@6221 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/block_matrix_array.h
deal.II/lac/include/lac/schur_matrix.h
deal.II/lac/include/lac/sparse_matrix.templates.h

index 3c06b233149ee2e2fadaebfa8e13f4ccce43e1ae..d842431db872eea7a5d38ea6303d64b88e948017 100644 (file)
@@ -537,6 +537,7 @@ BlockMatrixArray<MATRIX>::print_latex (ostream& out) const
       if (m->prefix != 1.)
        stream << " " << m->prefix << 'x';
       stream << matrix_names.find(m->matrix)->second;
+      stream << '(' << m->matrix << ')';
       if (m->transpose)
        stream << "^T";
       stream << std::ends;
index c2493ab65475d1d3a6dd519667c30062456124dd..11e67e0aadf4aae5edce6c814ec8108483373d6f 100644 (file)
@@ -156,6 +156,16 @@ class SchurMatrix :
   void postprocess (BlockVector<double>& dst,
                    const BlockVector<double>& src,
                    const BlockVector<double>& rhs) const;
+
+                                  /**
+                                   * Select debugging information for
+                                   * log-file.  Debug level 1 is
+                                   * defined and writes the norm of
+                                   * every vector before and after
+                                   * each operation. Debug level 0
+                                   * turns off debugging information.
+                                   */
+  void debug_level(unsigned int l);
   private:
                                   /**
                                    * No copy constructor.
@@ -191,6 +201,11 @@ class SchurMatrix :
                                    * Optional signature of the @p{u}-vector.
                                    */
   std::vector<unsigned int> signature;
+  
+                                  /**
+                                   * Switch for debugging information.
+                                   */
+  unsigned int debug;
 };
 
 template <class MA_inverse, class MB, class MDt, class MC>
@@ -203,29 +218,54 @@ SchurMatrix<MA_inverse, MB, MDt, MC>
              const std::vector<unsigned int>& signature)
                : Ainv(&Ainv), B(&B), Dt(&Dt), C(&C),
                  mem(mem),
-                 signature(signature)
+               signature(signature),
+               debug(0)
 {
 }
 
 
+template <class MA_inverse, class MB, class MDt, class MC>
+void
+SchurMatrix<MA_inverse, MB, MDt, MC>
+::debug_level(unsigned int l)
+{
+  debug = l;
+}
+
+
 template <class MA_inverse, class MB, class MDt, class MC>
 void SchurMatrix<MA_inverse, MB, MDt, MC>
 ::vmult(BlockVector<double>& dst,
        const BlockVector<double>& src) const
 {
   deallog.push("Schur");
+  if (debug > 0)
+    deallog << "src:" << src.l2_norm() << std::endl;
+  
   C->vmult(dst, src);
+  if (debug > 0)
+    deallog << "C:" << dst.l2_norm() << std::endl;
+
   BlockVector<double>* h1 = mem.alloc();
   if (signature.size()>0)
     h1->reinit(signature);
   else
     h1->reinit(B->n_block_cols(), src.block(0).size());
   Dt->Tvmult(*h1,src);
+  if (debug > 0)
+    deallog << "Dt:" << h1->l2_norm() << std::endl;
+
   BlockVector<double>* h2 = mem.alloc();
   h2->reinit(*h1);
   Ainv->vmult(*h2, *h1);
+  if (debug > 0)
+    deallog << "Ainverse:" << h2->l2_norm() << std::endl;
+
   mem.free(h1);
   B->vmult_add(dst, *h2);
+  if (debug > 0)
+    deallog << "dst:" << dst.l2_norm() << std::endl;
+
   mem.free(h2);
   deallog.pop();
 }
@@ -255,13 +295,19 @@ void SchurMatrix<MA_inverse, MB, MDt, MC>
          ExcDimensionMismatch(dst.n_blocks(), B->n_block_rows()));
   
   deallog.push("Schur-prepare");
+  if (debug > 0)
+    deallog << "src:" << src.l2_norm() << std::endl;
   BlockVector<double>* h1 = mem.alloc();
   if (signature.size()>0)
     h1->reinit(signature);
   else
     h1->reinit(B->n_block_cols(), src.block(0).size());
   Ainv->vmult(*h1, src);
+  if (debug > 0)
+    deallog << "Ainverse:" << h1->l2_norm() << std::endl;
   B->vmult_add(dst, *h1);
+  if (debug > 0)
+    deallog << "dst:" << dst.l2_norm() << std::endl;
   mem.free(h1);
   deallog.pop();
 }
@@ -281,14 +327,20 @@ void SchurMatrix<MA_inverse, MB, MDt, MC>
          ExcDimensionMismatch(src.n_blocks(), B->n_block_rows()));
   
   deallog.push("Schur-post");
+  if (debug > 0)
+    deallog << "src:" << src.l2_norm() << std::endl;
   BlockVector<double>* h1 = mem.alloc();
   if (signature.size()>0)
     h1->reinit(signature);
   else
     h1->reinit(B->n_block_cols(), src.block(0).size());
   Dt->Tvmult(*h1, src);
+  if (debug > 0)
+    deallog << "Dt:" << h1->l2_norm() << std::endl;
   h1->sadd(-1.,rhs);
   Ainv->vmult(dst,*h1);
+  if (debug > 0)
+    deallog << "dst:" << dst.l2_norm() << std::endl;
   mem.free(h1);
   deallog.pop();
 }
index 1bcd1e3a60768a5f091b7c82a8dee0c83f4dbc64..d227e6c843cc52ff09bc1b2f0b7dd73b54ded027 100644 (file)
@@ -278,7 +278,8 @@ SparseMatrix<number>::add_scaled (const number factor,
 template <typename number>
 template <typename somenumber>
 void
-SparseMatrix<number>::vmult (Vector<somenumber>& dst, const Vector<somenumber>& src) const
+SparseMatrix<number>::vmult (Vector<somenumber>& dst,
+                            const Vector<somenumber>& src) const
 {
   Assert (cols != 0, ExcMatrixNotInitialized());
   Assert (val != 0, ExcMatrixNotInitialized());

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.