From: guido Date: Thu, 9 Nov 2000 18:00:50 +0000 (+0000) Subject: BlockVector support for homogeneous blocks X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f117e99a4b38d8390439726630fe736bf3058bb;p=dealii-svn.git BlockVector support for homogeneous blocks git-svn-id: https://svn.dealii.org/trunk@3475 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/block_indices.h b/deal.II/lac/include/lac/block_indices.h index 81b00ed107..2baeaff2ff 100644 --- a/deal.II/lac/include/lac/block_indices.h +++ b/deal.II/lac/include/lac/block_indices.h @@ -37,7 +37,7 @@ class BlockIndices * @p{n_blocks} blocks and set * all block sizes to zero. */ - BlockIndices (const unsigned int n_blocks); + BlockIndices (const unsigned int n_blocks = 0); /** * Constructor. Initialize the diff --git a/deal.II/lac/include/lac/block_vector.h b/deal.II/lac/include/lac/block_vector.h index 861cedbfc5..48c91d767e 100644 --- a/deal.II/lac/include/lac/block_vector.h +++ b/deal.II/lac/include/lac/block_vector.h @@ -25,7 +25,9 @@ * Several vectors of data. * * The BlockVector is a collection of normal LAC-@p{Vector}s. Each of - * the vectors inside can have a different size. + * the vectors inside can have a different size. The special case of a + * block vector with constant block size is supported by constructor + * and reinit functions. * * The functionality of @p{BlockVector} includes everything a @p{Vector} * can do, plus the access to a single @p{Vector} inside the @@ -43,7 +45,7 @@ * corresponding ``.templates.h'' file and instantiate the respective * class yourself. * - * @author Guido Kanschat, 1999; Wolfgang Bangerth, 2000 + * @author Wolfgang Bangerth, Guido Kanschat, 1999, 2000 */ template class BlockVector @@ -69,9 +71,26 @@ class BlockVector typedef size_t size_type; /** - * Dummy-Constructor. Dimension=0 + * Constructor. There are three + * ways to use this + * constructor. First, without + * any arguments, it generates + * an objetct with no + * blocks. Given one argument, + * it initializes @p{num_blocks} + * blocks, but these blocks have + * size zero. The third variant + * finally initializes all + * blocks to the same size + * @p{block_size}. + * + * Confer the other constructor + * further down if you intend to + * use blocks of different + * sizes. */ - BlockVector (unsigned int num_blocks = 0); + BlockVector (unsigned int num_blocks = 0, + unsigned int block_size = 0); /** * Copy-Constructor. Dimension set to @@ -111,6 +130,18 @@ class BlockVector */ ~BlockVector (); + /** + * Reinitialize the BlockVector to + * contain @p{num_blocks} blocks of + * size @p{block_size} each. + * + * If @p{fast==false}, the vector + * is filled with zeros. + */ + void reinit (const unsigned int num_blocks, + const unsigned int block_size, + const bool fast = false); + /** * Reinitialize the BlockVector * such that it contains @@ -129,8 +160,8 @@ class BlockVector * has a potential to slow down a * program considerably. * - * On @p{fast==false}, the vector is filled by - * zeros. + * If @p{fast==false}, the vector + * is filled with zeros. */ void reinit (const vector &N, const bool fast=false); diff --git a/deal.II/lac/include/lac/block_vector.templates.h b/deal.II/lac/include/lac/block_vector.templates.h index e1a0ce6ac9..8af6af75d7 100644 --- a/deal.II/lac/include/lac/block_vector.templates.h +++ b/deal.II/lac/include/lac/block_vector.templates.h @@ -20,17 +20,16 @@ template -BlockVector::BlockVector (unsigned int num_blocks) - : components(num_blocks), - block_indices(num_blocks), - num_blocks(num_blocks) -{} +BlockVector::BlockVector (unsigned int n_blocks, + unsigned int block_size) +{ + reinit (n_blocks, block_size); +} template BlockVector::BlockVector (const vector &n) - : block_indices(num_blocks) { reinit (n, false); } @@ -65,6 +64,16 @@ BlockVector::BlockVector (const BlockVector& v) // } +template +void BlockVector::reinit (const unsigned int n_bl, + const unsigned int bl_sz, + const bool fast) +{ + vector n(n_bl, bl_sz); + reinit(n, fast); +} + + template void BlockVector::reinit (const vector &n, const bool fast)