* STL's @p{vector<>::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
ivector[1] = 0;
ivector[2] = 1;
ivector[3] = 2;
+
+ const std::vector<unsigned int> vector_indices(ivector);
BlockIndices i1(ivector);
BlockIndices i2 = i1;
deallog.pop();
- // initialization by an iterator
- // range
- deallog.push ("Initialization from iterators");
- double array[] = { 0, 1, 2, 3, 4, 5 };
- BlockVector<double> v1(ivector, &array[0], &array[6]);
- for (unsigned int i=0; i<v1.size(); ++i)
- deallog << v1(i) << ' ';
- deallog << std::endl;
-
- // same test, but do not initialize
- // from double*'s, but from
- // std::list iterators.
- std::list<double> l(&array[0], &array[6]);
- BlockVector<double> v2(ivector, l.begin(), l.end());
- for (unsigned int i=0; i<v2.size(); ++i)
- deallog << v2(i) << ' ';
- deallog << std::endl;
- deallog.pop ();
-
-
i3.reinit(ivector);
deallog.push("global->local");
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<double> v1(vector_indices, &array[0], &array[6]);
+ for (unsigned int i=0; i<v1.size(); ++i)
+ deallog << v1(i) << ' ';
+ deallog << std::endl;
+
+ // same test, but do not initialize
+ // from double*'s, but from
+ // std::list iterators.
+ std::list<double> l(&array[0], &array[6]);
+ BlockVector<double> v2(vector_indices, l.begin(), l.end());
+ for (unsigned int i=0; i<v2.n_blocks(); ++i)
+ for (unsigned int j=0;j<v2.block(i).size();++j)
+ deallog << i << '\t' << j << '\t' <<v2.block(i)(j) << std::endl;
+
+ deallog.pop();
+ deallog.push("reinit block");
+ v2.block(1).reinit(5);
+ v2.collect_sizes();
+ for (unsigned int i=0; i<v2.size(); ++i)
+ deallog << v2(i) << ' ';
+ deallog << std::endl;
+
+ deallog.pop ();
+ deallog.pop ();
}
-DEAL:BlockIndices:Initialization from iterators::0.000 1.000 2.000 3.000 4.000 5.000
-DEAL:BlockIndices:Initialization from iterators::0.000 1.000 2.000 3.000 4.000 5.000
DEAL:BlockIndices:global->local::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
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