--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2010 - 2018 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+// test IndexSet::get_view(IndexSet) with a mask that is identical to
+// the one used in the _18 test just that it is given as an IndexSet
+// rather than a single range.
+
+#include <deal.II/base/index_set.h>
+
+#include <stdlib.h>
+
+#include "../tests.h"
+
+
+void
+test()
+{
+ IndexSet is1(100);
+
+ // randomly add 90 elements to each
+ // set, some of which may be
+ // repetitions of previous ones
+ for (unsigned int i = 0; i < 9 * is1.size() / 10; ++i)
+ is1.add_index(Testing::rand() % is1.size());
+
+ is1.compress();
+
+ IndexSet mask(100);
+ mask.add_range(20, 50);
+
+ const IndexSet is2 = is1.get_view(mask);
+ Assert(is2.size() == mask.n_elements(), ExcInternalError());
+
+ deallog << "Original index set: " << std::endl;
+ is1.print(deallog);
+ deallog << "View of index set between 20 and 50: " << std::endl;
+ is2.print(deallog);
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main()
+{
+ initlog();
+
+ test();
+}
--- /dev/null
+
+DEAL::Original index set:
+DEAL::{[2,3], 5, 8, 11, [13,15], 19, [21,27], [29,30], [34,37], 40, [42,43], [45,46], [49,51], 54, [56,59], [62,64], [67,70], [72,73], [76,78], [80,84], [86,88], [90,93], [95,96], [98,99]}
+DEAL::View of index set between 20 and 50:
+DEAL::{[1,7], [9,10], [14,17], 20, [22,23], [25,26], 29}
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2010 - 2018 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+// test IndexSet::get_view(IndexSet) with a mask that is not just a
+// single range.
+
+#include <deal.II/base/index_set.h>
+
+#include <stdlib.h>
+
+#include "../tests.h"
+
+
+void
+test()
+{
+ IndexSet is1(100);
+
+ // randomly add 90 elements to each
+ // set, some of which may be
+ // repetitions of previous ones
+ for (unsigned int i = 0; i < 9 * is1.size() / 10; ++i)
+ is1.add_index(Testing::rand() % is1.size());
+
+ IndexSet mask(100);
+ mask.add_range(20, 40);
+ mask.add_range(60, 80);
+ mask.compress();
+
+ const IndexSet is2 = is1.get_view(mask);
+ Assert(is2.size() == mask.n_elements(), ExcInternalError());
+
+ deallog << "Original index set: " << std::endl;
+ is1.print(deallog);
+ deallog << "Mask: " << std::endl;
+ mask.print(deallog);
+ deallog << "View of index set between 20-40 and 60-80: " << std::endl;
+ is2.print(deallog);
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main()
+{
+ initlog();
+
+ test();
+}
--- /dev/null
+
+DEAL::Original index set:
+DEAL::{[2,3], 5, 8, 11, [13,15], 19, [21,27], [29,30], [34,37], 40, [42,43], [45,46], [49,51], 54, [56,59], [62,64], [67,70], [72,73], [76,78], [80,84], [86,88], [90,93], [95,96], [98,99]}
+DEAL::Mask:
+DEAL::{[20,39], [60,79]}
+DEAL::View of index set between 20-40 and 60-80:
+DEAL::{[1,7], [9,10], [14,17], [22,24], [27,30], [32,33], [36,38]}
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2010 - 2018 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+// Test IndexSet::get_view(IndexSet) with a mask that is not just a
+// single range.
+//
+// This test is for the specific example given in the documentation of
+// the function we test.
+
+#include <deal.II/base/index_set.h>
+
+#include <stdlib.h>
+
+#include "../tests.h"
+
+
+void
+test()
+{
+ IndexSet is1(100);
+ is1.add_range(20, 40);
+ is1.compress();
+
+ IndexSet mask(100);
+ for (unsigned int i = 0; i < is1.size(); ++i)
+ if (i % 2 == 1)
+ mask.add_index(i);
+ mask.compress();
+
+ const IndexSet is2 = is1.get_view(mask);
+ Assert(is2.size() == mask.n_elements(), ExcInternalError());
+
+ deallog << "Original index set: " << std::endl;
+ is1.print(deallog);
+ deallog << "Mask: " << std::endl;
+ mask.print(deallog);
+ deallog << "View of index set among the odd numbers: " << std::endl;
+ is2.print(deallog);
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main()
+{
+ initlog();
+
+ test();
+}
--- /dev/null
+
+DEAL::Original index set:
+DEAL::{[20,39]}
+DEAL::Mask:
+DEAL::{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}
+DEAL::View of index set among the odd numbers:
+DEAL::{[11,20]}
+DEAL::OK