From c47d68c8c690307fc9342a545367a68bc6933d11 Mon Sep 17 00:00:00 2001 From: guido Date: Thu, 21 Apr 2005 09:32:43 +0000 Subject: [PATCH] default constructors added to BlockMatrixArray and BlockTrianglePrecondition git-svn-id: https://svn.dealii.org/trunk@10554 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/block_matrix_array.h | 60 +++++++++++++++++--- deal.II/lac/source/block_matrix_array.cc | 48 ++++++++++++++++ 2 files changed, 99 insertions(+), 9 deletions(-) diff --git a/deal.II/lac/include/lac/block_matrix_array.h b/deal.II/lac/include/lac/block_matrix_array.h index 241f242e7e..f9702a6899 100644 --- a/deal.II/lac/include/lac/block_matrix_array.h +++ b/deal.II/lac/include/lac/block_matrix_array.h @@ -126,6 +126,14 @@ template 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 >& 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 >& mem); + /** * Adjust the matrix to a new * size and delete all blocks. @@ -415,15 +434,42 @@ class BlockTrianglePrecondition : private BlockMatrixArray { 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 >& mem, - bool backward = false); + BlockTrianglePrecondition (unsigned int n_block_rows, + VectorMemory >& 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 >& 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::enter (const MATRIX& matrix, unsigned row, unsigned int col, double prefix, bool transpose) { + Assert (mem != 0, ExcNotInitialized()); Assert(row::print_latex (STREAM& out) const { + Assert (mem != 0, ExcNotInitialized()); out << "\\begin{array}{" << std::string(n_block_cols(), 'c') << "}" << std::endl; diff --git a/deal.II/lac/source/block_matrix_array.cc b/deal.II/lac/source/block_matrix_array.cc index 3312fa283f..734758e295 100644 --- a/deal.II/lac/source/block_matrix_array.cc +++ b/deal.II/lac/source/block_matrix_array.cc @@ -40,6 +40,15 @@ BlockMatrixArray::Entry::~Entry () +template +BlockMatrixArray::BlockMatrixArray () + : block_rows (0), + block_cols (0), + mem(0, typeid(*this).name()) +{} + + + template BlockMatrixArray::BlockMatrixArray ( const unsigned int n_block_rows, @@ -51,6 +60,20 @@ BlockMatrixArray::BlockMatrixArray ( {} +template +void +BlockMatrixArray::initialize ( + const unsigned int n_block_rows, + const unsigned int n_block_cols, + VectorMemory >& memory) +{ + block_rows = n_block_rows; + block_cols = n_block_cols; + mem = &memory; +} + + + template void @@ -58,6 +81,7 @@ BlockMatrixArray::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::vmult_add (BlockVector& dst, const BlockVector& 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::Tvmult_add (BlockVector& dst, const BlockVector& 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::matrix_scalar_product ( const BlockVector& u, const BlockVector& 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::n_block_cols () const //--------------------------------------------------------------------------- +template +BlockTrianglePrecondition::BlockTrianglePrecondition() + : BlockMatrixArray (), + backward(false) +{} + + template BlockTrianglePrecondition::BlockTrianglePrecondition( unsigned int block_rows, @@ -239,6 +274,18 @@ BlockTrianglePrecondition::BlockTrianglePrecondition( {} +template +void +BlockTrianglePrecondition::initialize( + unsigned int n_block_rows, + VectorMemory >& memory, + bool backward) +{ + BlockMatrixArray::initialize(n_block_rows, n_block_rows, memory); + backward = backward; +} + + template void BlockTrianglePrecondition::reinit ( @@ -247,6 +294,7 @@ BlockTrianglePrecondition::reinit ( BlockMatrixArray::reinit(n,n); } + template void BlockTrianglePrecondition::do_row ( -- 2.39.5