From ac4536304591f9a0d14487fc396b0ab8b1995b66 Mon Sep 17 00:00:00 2001 From: guido Date: Tue, 17 Sep 2002 21:43:12 +0000 Subject: [PATCH] new function BlockVector::collect_sizes git-svn-id: https://svn.dealii.org/trunk@6447 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/2002/c-3-4.html | 8 +++ deal.II/lac/include/lac/block_vector.h | 13 +++++ .../lac/include/lac/block_vector.templates.h | 12 +++++ tests/lac/block_vector.cc | 53 ++++++++++++------- tests/lac/block_vector.checked | 10 +++- 5 files changed, 74 insertions(+), 22 deletions(-) diff --git a/deal.II/doc/news/2002/c-3-4.html b/deal.II/doc/news/2002/c-3-4.html index 0c665b7ea0..c85c213373 100644 --- a/deal.II/doc/news/2002/c-3-4.html +++ b/deal.II/doc/news/2002/c-3-4.html @@ -234,6 +234,14 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

lac

    +
  1. New: class BlockVector has a + function collect_sizes(), very much as + BlockSparsityPattern. This allows + updating internal structures after blocks have been resized. +
    + (GK 2002/09/17) +

    +
  2. New: class SparseMatrix has an STL-conforming const_iterator and functions begin() and ::clear} function. */ void clear (); + + /** + * Update internal structures + * after resizing + * vectors. Whenever you reinited + * a block of a block vector, the + * internal data structures are + * corrupted. Therefore, you + * should call this function + * after al blocks got their new + * size. + */ + void collect_sizes (); /** * Swap the contents of this diff --git a/deal.II/lac/include/lac/block_vector.templates.h b/deal.II/lac/include/lac/block_vector.templates.h index 15762fcbc5..930c93e33b 100644 --- a/deal.II/lac/include/lac/block_vector.templates.h +++ b/deal.II/lac/include/lac/block_vector.templates.h @@ -110,6 +110,18 @@ void BlockVector::reinit (const BlockVector& v, } +template +void +BlockVector::collect_sizes () +{ + std::vector sizes (num_blocks); + + for (unsigned int i=0; i BlockVector::~BlockVector () diff --git a/tests/lac/block_vector.cc b/tests/lac/block_vector.cc index 24930da8a1..4cf9753027 100644 --- a/tests/lac/block_vector.cc +++ b/tests/lac/block_vector.cc @@ -30,6 +30,8 @@ void test () ivector[1] = 0; ivector[2] = 1; ivector[3] = 2; + + const std::vector vector_indices(ivector); BlockIndices i1(ivector); BlockIndices i2 = i1; @@ -46,26 +48,6 @@ void test () deallog.pop(); - // initialization by an iterator - // range - deallog.push ("Initialization from iterators"); - double array[] = { 0, 1, 2, 3, 4, 5 }; - BlockVector v1(ivector, &array[0], &array[6]); - for (unsigned int i=0; i l(&array[0], &array[6]); - BlockVector v2(ivector, l.begin(), l.end()); - for (unsigned int i=0; ilocal"); @@ -129,6 +111,37 @@ void test () unsigned int i = i1.global_to_local(3).first; i = i1.local_to_global(1,2); i = i1.local_to_global(2,0); + + deallog.pop (); + deallog.push("BlockVector"); + // initialization by an iterator + // range + deallog.push ("Constructor with iterators"); + double array[] = { 0, 1, 2, 3, 4, 5 }; + BlockVector v1(vector_indices, &array[0], &array[6]); + for (unsigned int i=0; i l(&array[0], &array[6]); + BlockVector v2(vector_indices, l.begin(), l.end()); + for (unsigned int i=0; ilocal::0 0 0 0 0 0 0 DEAL:BlockIndices:global->local::1 0 1 0 1 0 1 DEAL:BlockIndices:global->local::2 0 2 0 2 0 2 @@ -40,3 +38,11 @@ Additional Information: Index 3 is not in [0,3[ -------------------------------------------------------- ******** More assertions fail but messages are suppressed! ******** +DEAL:BlockVector:Constructor with iterators::0.000 1.000 2.000 3.000 4.000 5.000 +DEAL:BlockVector:Constructor with iterators::0 0 0.000 +DEAL:BlockVector:Constructor with iterators::0 1 1.000 +DEAL:BlockVector:Constructor with iterators::0 2 2.000 +DEAL:BlockVector:Constructor with iterators::2 0 3.000 +DEAL:BlockVector:Constructor with iterators::3 0 4.000 +DEAL:BlockVector:Constructor with iterators::3 1 5.000 +DEAL:BlockVector:reinit block::0.000 1.000 2.000 0.000 0.000 0.000 0.000 0.000 3.000 4.000 5.000 -- 2.39.5