From 4a7e049c9876d874ea5ac2810597595865ccaba7 Mon Sep 17 00:00:00 2001 From: guido Date: Thu, 4 Jul 2002 14:07:13 +0000 Subject: [PATCH] debug option for matrices git-svn-id: https://svn.dealii.org/trunk@6221 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/block_matrix_array.h | 1 + deal.II/lac/include/lac/schur_matrix.h | 54 ++++++++++++++++++- .../lac/include/lac/sparse_matrix.templates.h | 3 +- 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/deal.II/lac/include/lac/block_matrix_array.h b/deal.II/lac/include/lac/block_matrix_array.h index 3c06b23314..d842431db8 100644 --- a/deal.II/lac/include/lac/block_matrix_array.h +++ b/deal.II/lac/include/lac/block_matrix_array.h @@ -537,6 +537,7 @@ BlockMatrixArray::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; diff --git a/deal.II/lac/include/lac/schur_matrix.h b/deal.II/lac/include/lac/schur_matrix.h index c2493ab654..11e67e0aad 100644 --- a/deal.II/lac/include/lac/schur_matrix.h +++ b/deal.II/lac/include/lac/schur_matrix.h @@ -156,6 +156,16 @@ class SchurMatrix : void postprocess (BlockVector& dst, const BlockVector& src, const BlockVector& 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 signature; + + /** + * Switch for debugging information. + */ + unsigned int debug; }; template @@ -203,29 +218,54 @@ SchurMatrix const std::vector& signature) : Ainv(&Ainv), B(&B), Dt(&Dt), C(&C), mem(mem), - signature(signature) + signature(signature), + debug(0) { } +template +void +SchurMatrix +::debug_level(unsigned int l) +{ + debug = l; +} + + template void SchurMatrix ::vmult(BlockVector& dst, const BlockVector& 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* 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* 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 ExcDimensionMismatch(dst.n_blocks(), B->n_block_rows())); deallog.push("Schur-prepare"); + if (debug > 0) + deallog << "src:" << src.l2_norm() << std::endl; BlockVector* 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 ExcDimensionMismatch(src.n_blocks(), B->n_block_rows())); deallog.push("Schur-post"); + if (debug > 0) + deallog << "src:" << src.l2_norm() << std::endl; BlockVector* 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(); } diff --git a/deal.II/lac/include/lac/sparse_matrix.templates.h b/deal.II/lac/include/lac/sparse_matrix.templates.h index 1bcd1e3a60..d227e6c843 100644 --- a/deal.II/lac/include/lac/sparse_matrix.templates.h +++ b/deal.II/lac/include/lac/sparse_matrix.templates.h @@ -278,7 +278,8 @@ SparseMatrix::add_scaled (const number factor, template template void -SparseMatrix::vmult (Vector& dst, const Vector& src) const +SparseMatrix::vmult (Vector& dst, + const Vector& src) const { Assert (cols != 0, ExcMatrixNotInitialized()); Assert (val != 0, ExcMatrixNotInitialized()); -- 2.39.5