From 150bba5febb6a1dae8f9eaa7ce4da64bb88e3376 Mon Sep 17 00:00:00 2001 From: Marco Feder Date: Thu, 6 Jul 2023 00:50:40 +0200 Subject: [PATCH] Unify 2D and 3D implementations --- source/grid/grid_tools.cc | 45 +++++++++++---------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 43185a32f0..c2b37a345e 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -5941,7 +5941,7 @@ namespace GridTools } #else - + (void)tolerance; auto fill_ranks_and_indices = [&ranks_and_indices]( const std::vector & offsets, @@ -5954,46 +5954,25 @@ namespace GridTools unsigned int idx = (global_bboxes.size() == 1) ? 0 : Utilities::MPI::this_mpi_process(comm); - // size of global_bboxes>1 - if constexpr (spacedim == 2) - { - // Create query bounding boxes out of entities - std::vector> query_bounding_boxes; - for (const auto &entity : entities) - query_bounding_boxes.push_back( - BoundingBox<2>(entity).create_extended(tolerance)); - ArborXWrappers::BoundingBoxIntersectPredicate bb_intersect( - query_bounding_boxes); - ArborXWrappers::DistributedTree distributed_tree(comm, - global_bboxes[idx]); + ArborXWrappers::DistributedTree distributed_tree(comm, + global_bboxes[idx]); + + if constexpr (std::is_same>::value) + { + ArborXWrappers::PointIntersectPredicate bb_intersect(entities); const auto &[indices_ranks, offsets] = distributed_tree.query(bb_intersect); fill_ranks_and_indices(offsets, indices_ranks); } - else if constexpr (spacedim == 3) + else if constexpr (std::is_same>::value) { - ArborXWrappers::DistributedTree distributed_tree(comm, - global_bboxes[idx]); + ArborXWrappers::BoundingBoxIntersectPredicate bb_intersect(entities); - if constexpr (std::is_same>::value) - { - ArborXWrappers::PointIntersectPredicate bb_intersect(entities); - - const auto &[indices_ranks, offsets] = - distributed_tree.query(bb_intersect); - fill_ranks_and_indices(offsets, indices_ranks); - } - else if constexpr (std::is_same>::value) - { - ArborXWrappers::BoundingBoxIntersectPredicate bb_intersect( - entities); - - const auto &[indices_ranks, offsets] = - distributed_tree.query(bb_intersect); - fill_ranks_and_indices(offsets, indices_ranks); - } + const auto &[indices_ranks, offsets] = + distributed_tree.query(bb_intersect); + fill_ranks_and_indices(offsets, indices_ranks); } #endif -- 2.39.5