From b798e893deeae01aad1f1a3539ddcbfc9a92cc35 Mon Sep 17 00:00:00 2001 From: kanschat Date: Mon, 15 Aug 2011 09:51:24 +0000 Subject: [PATCH] add push_back() fix bug in reinit git-svn-id: https://svn.dealii.org/trunk@24066 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/lac/block_indices.h | 33 ++++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/deal.II/include/deal.II/lac/block_indices.h b/deal.II/include/deal.II/lac/block_indices.h index 3a4720d1c6..5f004b9215 100644 --- a/deal.II/include/deal.II/lac/block_indices.h +++ b/deal.II/include/deal.II/lac/block_indices.h @@ -53,10 +53,9 @@ class BlockIndices : public Subscriptor /** * Default * constructor. Initialize for - * @p n_blocks blocks and set - * all block sizes to zero. + * zero blocks. */ - BlockIndices (/*const unsigned int n_blocks = 0*/); + BlockIndices (); /** * Constructor. Initialize the @@ -90,7 +89,14 @@ class BlockIndices : public Subscriptor * of block @p i is set to * n[i]. */ - inline void reinit (const std::vector &n); + void reinit (const std::vector &n); + + /** + * Add another block of given + * size to the end of the block + * structure. + */ + void push_back(const unsigned int size); /** * @name Size information @@ -109,7 +115,7 @@ class BlockIndices : public Subscriptor * of the vector space of the * block vector. */ - inline unsigned int total_size () const; + unsigned int total_size () const; /** * The size of the @p ith block. @@ -205,7 +211,8 @@ class BlockIndices : public Subscriptor /** - * Output operator for BlockIndices + * Operator for logging BlockIndices. Writes the number of blocks, the + * size of each block and the total size of the index field. * * @ref BlockIndices * @author Guido Kanschat @@ -217,11 +224,13 @@ operator << (LogStream& s, const BlockIndices& bi) { const unsigned int n = bi.size(); s << n << ":["; + // Write first size without leading space if (n>0) s << bi.block_size(0); + // Write all other sizes for (unsigned int i=1;i" << bi.total_size(); return s; } @@ -317,7 +326,7 @@ BlockIndices::reinit (const unsigned int nb, const unsigned int block_size) { n_blocks = nb; - start_indices.resize(nb); + start_indices.resize(n_blocks+1); for (unsigned int i=0; i<=n_blocks; ++i) start_indices[i] = i * block_size; } @@ -372,6 +381,14 @@ BlockIndices::BlockIndices (const std::vector &n) } +inline +void +BlockIndices::push_back(const unsigned int sz) +{ + start_indices.push_back(start_indices[n_blocks]+sz); + ++n_blocks; + AssertDimension(start_indices.size(), n_blocks+1); +} inline -- 2.39.5