std::vector<BoundingBox<dim>> boxes;
- const unsigned int target_level =
- std::min<unsigned int>(level, rtv.depth() - 1);
- // There should always be at least one level.
- Assert(target_level >= 0, ExcInternalError());
-
- ExtractLevelVisitor<typename RtreeView::value_type,
- typename RtreeView::options_type,
- typename RtreeView::translator_type,
- typename RtreeView::box_type,
- typename RtreeView::allocators_type>
- extract_level_visitor(rtv.translator(), target_level, boxes);
- rtv.apply_visitor(extract_level_visitor);
+ if (rtv.depth() == 0)
+ {
+ // The below algorithm does not work for `rtv.depth()==0`, which might
+ // happen if the number entries in the tree is too small.
+ // In this case, simply return a single bounding box.
+ boxes.resize(1);
+ boost::geometry::convert(tree.bounds(), boxes[0]);
+ }
+ else
+ {
+ const unsigned int target_level =
+ std::min<unsigned int>(level, rtv.depth() - 1);
+
+ ExtractLevelVisitor<typename RtreeView::value_type,
+ typename RtreeView::options_type,
+ typename RtreeView::translator_type,
+ typename RtreeView::box_type,
+ typename RtreeView::allocators_type>
+ extract_level_visitor(rtv.translator(), target_level, boxes);
+ rtv.apply_visitor(extract_level_visitor);
+ }
+
return boxes;
}
return str.str();
}
-
-int
-main(int argc, char **argv)
+void
+test(const unsigned int n_refinements)
{
- auto mpi_init = Utilities::MPI::MPI_InitFinalize(argc, argv);
- MPILogInitAll log;
-
parallel::distributed::Triangulation<2> tria(MPI_COMM_WORLD);
GridGenerator::hyper_ball(tria);
- tria.refine_global(3);
+ tria.refine_global(n_refinements);
std::vector<BoundingBox<2>> all_boxes(tria.n_locally_owned_active_cells());
unsigned int i = 0;
const auto tree = pack_rtree(all_boxes);
const auto boxes = extract_rtree_level(tree, 0);
+ deallog << "Refinements: " << n_refinements << std::endl;
deallog << "LEVEL 0: N boxes: " << boxes.size() << std::endl;
for (const auto &b : boxes)
deallog << print(b) << std::endl;
// for (const auto &b : all_boxes)
// all << print(b);
}
+
+
+int
+main(int argc, char **argv)
+{
+ auto mpi_init = Utilities::MPI::MPI_InitFinalize(argc, argv);
+ MPILogInitAll log;
+
+ for (unsigned int i = 0; i <= 3; ++i)
+ test(i);
+}
+DEAL:0::Refinements: 0
+DEAL:0::LEVEL 0: N boxes: 1
+DEAL:0::-0.707107 -0.707107
+0.707107 -0.707107
+0.707107 -0.292893
+-0.707107 -0.292893
+-0.707107 -0.707107
+
+DEAL:0::Refinements: 1
+DEAL:0::LEVEL 0: N boxes: 1
+DEAL:0::-1 -1
+0.707107 -1
+0.707107 0.707107
+-1 0.707107
+-1 -1
+
+DEAL:0::Refinements: 2
+DEAL:0::LEVEL 0: N boxes: 2
+DEAL:0::-1 -0.92388
+-0.146447 -0.92388
+-0.146447 0.707107
+-1 0.707107
+-1 -0.92388
+
+DEAL:0::-0.382683 -1
+0.707107 -1
+0.707107 -0.292893
+-0.382683 -0.292893
+-0.382683 -1
+
+DEAL:0::Refinements: 3
DEAL:0::LEVEL 0: N boxes: 7
DEAL:0::-0.92388 -0.92388
-0.297335 -0.92388
-4.16334e-17 -0.558058
+DEAL:1::Refinements: 0
+DEAL:1::LEVEL 0: N boxes: 1
+DEAL:1::-0.707107 -0.707107
+0.292893 -0.707107
+0.292893 0.707107
+-0.707107 0.707107
+-0.707107 -0.707107
+
+DEAL:1::Refinements: 1
+DEAL:1::LEVEL 0: N boxes: 1
+DEAL:1::-0.292893 -0.292893
+0.292893 -0.292893
+0.292893 0.292893
+-0.292893 0.292893
+-0.292893 -0.292893
+
+DEAL:1::Refinements: 2
+DEAL:1::LEVEL 0: N boxes: 2
+DEAL:1::-0.646447 -0.292893
+0.146447 -0.292893
+0.146447 0.5
+-0.646447 0.5
+-0.646447 -0.292893
+
+DEAL:1::0.146447 -0.707107
+1 -0.707107
+1 0.292893
+0.146447 0.292893
+0.146447 -0.707107
+
+DEAL:1::Refinements: 3
DEAL:1::LEVEL 0: N boxes: 7
DEAL:1::-0.292893 -0.292893
0 -0.292893
0.5 -0.707107
DEAL:1::-0.0732233 -0.0732233
-0.292893 -0.0732233
-0.292893 0.292893
+0.21967 -0.0732233
+0.21967 0.292893
-0.0732233 0.292893
-0.0732233 -0.0732233
-DEAL:1::0.21967 -0.0732233
-1 -0.0732233
+DEAL:1::0.21967 -1.11022e-16
+1 -1.11022e-16
1 0.382683
0.21967 0.382683
-0.21967 -0.0732233
+0.21967 -1.11022e-16
+DEAL:2::Refinements: 0
+DEAL:2::LEVEL 0: N boxes: 1
+DEAL:2::-0.707107 -0.707107
+0.707107 -0.707107
+0.707107 0.707107
+-0.707107 0.707107
+-0.707107 -0.707107
+
+DEAL:2::Refinements: 1
+DEAL:2::LEVEL 0: N boxes: 1
+DEAL:2::-0.707107 -0.707107
+1 -0.707107
+1 1
+-0.707107 1
+-0.707107 -0.707107
+
+DEAL:2::Refinements: 2
+DEAL:2::LEVEL 0: N boxes: 2
+DEAL:2::-0.707107 -0.396447
+0.5 -0.396447
+0.5 1
+-0.707107 1
+-0.707107 -0.396447
+
+DEAL:2::0.25 -0.5
+1 -0.5
+1 0.92388
+0.25 0.92388
+0.25 -0.5
+
+DEAL:2::Refinements: 3
DEAL:2::LEVEL 0: N boxes: 7
DEAL:2::-0.448223 0.292893
0.297335 0.292893