Reference documentation for deal.II version 9.6.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
distributed_tree.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2022 - 2024 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_arborx_distributed_tree_h
16#define dealii_arborx_distributed_tree_h
17
18#include <deal.II/base/config.h>
19
20#if defined(DEAL_II_ARBORX_WITH_MPI) && defined(DEAL_II_WITH_MPI)
22
23# include <ArborX_DistributedTree.hpp>
24# include <Kokkos_Core.hpp>
25
27
28namespace ArborXWrappers
29{
38 {
39 public:
44 template <int dim, typename Number>
46 const MPI_Comm comm,
47 const std::vector<BoundingBox<dim, Number>> &bounding_boxes);
48
53 template <int dim, typename Number>
55 const std::vector<Point<dim, Number>> &points);
56
69 template <typename QueryType>
70 std::pair<std::vector<std::pair<int, int>>, std::vector<int>>
71 query(const QueryType &queries);
72
73 private:
77 ArborX::DistributedTree<Kokkos::HostSpace> distributed_tree;
78 };
79
80
81
82 template <int dim, typename Number>
84 const MPI_Comm comm,
85 const std::vector<BoundingBox<dim, Number>> &bounding_boxes)
86 : distributed_tree(comm,
87 Kokkos::DefaultHostExecutionSpace{},
88 bounding_boxes)
89 {}
90
91
92
93 template <int dim, typename Number>
95 const MPI_Comm comm,
96 const std::vector<Point<dim, Number>> &points)
97 : distributed_tree(comm, Kokkos::DefaultHostExecutionSpace{}, points)
98 {}
99
100
101
102 template <typename QueryType>
103 std::pair<std::vector<std::pair<int, int>>, std::vector<int>>
104 DistributedTree::query(const QueryType &queries)
105 {
106 Kokkos::View<int *, Kokkos::HostSpace> offsets("offsets", 0);
107 Kokkos::View<Kokkos::pair<int, int> *, Kokkos::HostSpace> indices_ranks(
108 "indices_ranks", 0);
109 distributed_tree.query(Kokkos::DefaultHostExecutionSpace{},
110 queries,
111 indices_ranks,
112 offsets);
113
114 std::vector<std::pair<int, int>> indices_ranks_vector;
115 for (unsigned int i = 0; i < indices_ranks.extent(0); ++i)
116 {
117 indices_ranks_vector.emplace_back(indices_ranks(i).first,
118 indices_ranks(i).second);
119 }
120
121 std::vector<int> offsets_vector;
122 offsets_vector.insert(offsets_vector.begin(),
123 offsets.data(),
124 offsets.data() + offsets.extent(0));
125
126 return {indices_ranks_vector, offsets_vector};
127 }
128} // namespace ArborXWrappers
129
131
132#endif
133#endif
ArborX::DistributedTree< Kokkos::HostSpace > distributed_tree
std::pair< std::vector< std::pair< int, int > >, std::vector< int > > query(const QueryType &queries)
DistributedTree(const MPI_Comm comm, const std::vector< BoundingBox< dim, Number > > &bounding_boxes)
Definition point.h:111
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:503
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:504
Point< 2 > second
Definition grid_out.cc:4624
Point< 2 > first
Definition grid_out.cc:4623
*braid_SplitCommworld & comm