I'm a bit confused then. The following tests three get_view() with
IndexSets : your example (slightly modified), the example from the doc
of get_view(), and then a slight modification of it. Your example
returns 0-based indices, but the one from the doc returns 11 as first
index, which is 1-based. The last example throws an error. Is it a
bug or am I missing something obvious?
My output is :
A :{[1,2], 5}
B :{[0,1], [4,9]}
View :{1, 3}
A :{[20,39]}
B :{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99}
View B:{[11,20]}
C :{22, 26}
--------------------------------------------------------
An error occurred in line <1816> of file </home/bawina/Code/dealii/include/deal.II/base/index_set.h> in function
void dealii::IndexSet::add_range(size_type, size_type)
The violated condition was:
(begin < index_space_size) || ((begin == index_space_size) && (end == index_space_size))
Additional information:
Index 22 is not in the half-open range [0,2).
Stacktrace:
-----------
#0 ./indexset: dealii::IndexSet::add_range(unsigned int, unsigned int)
#1 /usr/local/lib/libdeal_II.g.so.9.7.0-pre: dealii::IndexSet::get_view(dealii::IndexSet const&) const
#2 ./indexset: main
--------------------------------------------------------
(Edit: I accidentally replied to W. Bangerth only, not to the list.)
Thanks,
Arthur
{
IndexSet A(10);
A.add_index(1);
A.add_index(2);
A.add_index(5);
std::cout << "A :";
A.print(std::cout);
IndexSet B(10);
B.add_index(0);
B.add_index(1);
B.add_index(4);
B.add_index(5);
B.add_index(6);
B.add_index(7);
B.add_index(8);
B.add_index(9);
std::cout << "B :";
B.print(std::cout);
IndexSet view = A.get_view(B);
std::cout << "View :";
view.print(std::cout);
}
{
const unsigned int N = 100;
IndexSet A(N);
A.add_range(20, 40);
std::cout << "A :";
A.print(std::cout);
// Odd numbers in [0,N)
IndexSet B(N);
for (unsigned int i = 1; i < N; i += 2)
B.add_index(i);
std::cout << "B :";
B.print(std::cout);
{
IndexSet view = A.get_view(B);
std::cout << "View B:";
view.print(std::cout);
}
IndexSet C(N);
C.add_index(22);
C.add_index(26);
std::cout << "C :";
C.print(std::cout);
{
IndexSet view = A.get_view(C);
std::cout << "View C :";
view.print(std::cout);