Reference documentation for deal.II version 9.5.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// Copyright (C) 2022 - 2023 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_arborx_distributed_tree_h
17#define dealii_arborx_distributed_tree_h
18
19#include <deal.II/base/config.h>
20
21#if defined(DEAL_II_ARBORX_WITH_MPI) && defined(DEAL_II_WITH_MPI)
23
24# include <ArborX_DistributedTree.hpp>
25# include <Kokkos_Core.hpp>
26
28
29namespace ArborXWrappers
30{
39 {
40 public:
45 template <int dim, typename Number>
47 const MPI_Comm comm,
48 const std::vector<BoundingBox<dim, Number>> &bounding_boxes);
49
54 template <int dim, typename Number>
56 const std::vector<Point<dim, Number>> &points);
57
70 template <typename QueryType>
71 std::pair<std::vector<std::pair<int, int>>, std::vector<int>>
72 query(const QueryType &queries);
73
74 private:
78 ArborX::DistributedTree<Kokkos::HostSpace> distributed_tree;
79 };
80
81
82
83 template <int dim, typename Number>
85 const MPI_Comm comm,
86 const std::vector<BoundingBox<dim, Number>> &bounding_boxes)
87 : distributed_tree(comm,
88 Kokkos::DefaultHostExecutionSpace{},
89 bounding_boxes)
90 {}
91
92
93
94 template <int dim, typename Number>
96 const MPI_Comm comm,
97 const std::vector<Point<dim, Number>> &points)
98 : distributed_tree(comm, Kokkos::DefaultHostExecutionSpace{}, points)
99 {}
100
101
102
103 template <typename QueryType>
104 std::pair<std::vector<std::pair<int, int>>, std::vector<int>>
105 DistributedTree::query(const QueryType &queries)
106 {
107 Kokkos::View<int *, Kokkos::HostSpace> offsets("offsets", 0);
108 Kokkos::View<Kokkos::pair<int, int> *, Kokkos::HostSpace> indices_ranks(
109 "indices_ranks", 0);
110 distributed_tree.query(Kokkos::DefaultHostExecutionSpace{},
111 queries,
112 indices_ranks,
113 offsets);
114
115 std::vector<std::pair<int, int>> indices_ranks_vector;
116 for (unsigned int i = 0; i < indices_ranks.extent(0); ++i)
117 {
118 indices_ranks_vector.emplace_back(indices_ranks(i).first,
119 indices_ranks(i).second);
120 }
121
122 std::vector<int> offsets_vector;
123 offsets_vector.insert(offsets_vector.begin(),
124 offsets.data(),
125 offsets.data() + offsets.extent(0));
126
127 return {indices_ranks_vector, offsets_vector};
128 }
129} // namespace ArborXWrappers
130
132
133#endif
134#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:112
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
Point< 2 > second
Definition grid_out.cc:4616
Point< 2 > first
Definition grid_out.cc:4615
const MPI_Comm comm