Reference documentation for deal.II version 9.3.3
\(\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\}}\)
access_traits.cc
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2021 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
17
18#ifdef DEAL_II_WITH_ARBORX
19
21
22namespace ArborXWrappers
23{
24 // ------------------- PointPredicate ------------------- //
25 template <int dim, typename Number>
27 const std::vector<::Point<dim, Number>> &dim_points)
28 {
29 static_assert(dim != 1, "dim equal to one is not supported.");
30
31 const unsigned int size = dim_points.size();
32 points.reserve(size);
33 for (unsigned int i = 0; i < size; ++i)
34 {
35 points.emplace_back(static_cast<float>(dim_points[i][0]),
36 static_cast<float>(dim_points[i][1]),
37 dim == 2 ? 0.f :
38 static_cast<float>(dim_points[i][2]));
39 }
40 }
41
42
43
44 std::size_t
46 {
47 return points.size();
48 }
49
50
51
52 const ::Point<3, float> &
53 PointPredicate::get(unsigned int i) const
54 {
55 return points[i];
56 }
57
58
59
60 template <int dim, typename Number>
62 const std::vector<::Point<dim, Number>> &points)
63 : PointPredicate(points)
64 {}
65
66
67
68 template <int dim, typename Number>
70 const std::vector<::Point<dim, Number>> &points,
71 const unsigned int n_nearest_neighbors)
72 : PointPredicate(points)
73 , n_nearest_neighbors(n_nearest_neighbors)
74 {}
75
76
77
78 unsigned int
80 {
82 }
83
84 // ------------------- BoundingBoxPredicate ------------------- //
85 template <int dim, typename Number>
87 const std::vector<::BoundingBox<dim, Number>> &bb)
88 {
89 const unsigned int size = bb.size();
90 bounding_boxes.reserve(size);
91 ::Point<3, float> min_corner_arborx(0., 0., 0.);
92 ::Point<3, float> max_corner_arborx(0., 0., 0.);
93 for (unsigned int i = 0; i < size; ++i)
94 {
95 auto boundary_points = bb[i].get_boundary_points();
96 ::Point<dim, Number> min_corner = boundary_points.first;
97 ::Point<dim, Number> max_corner = boundary_points.second;
98 for (int d = 0; d < dim; ++d)
99 {
100 min_corner_arborx[d] = static_cast<float>(min_corner[d]);
101 max_corner_arborx[d] = static_cast<float>(max_corner[d]);
102 }
103 bounding_boxes.emplace_back(
104 std::make_pair(min_corner_arborx, max_corner_arborx));
105 }
106 }
107
108
109
110 std::size_t
112 {
113 return bounding_boxes.size();
114 }
115
116
117
118 const ::BoundingBox<3, float> &
119 BoundingBoxPredicate::get(unsigned int i) const
120 {
121 return bounding_boxes[i];
122 }
123
124
125
126 template <int dim, typename Number>
128 const std::vector<::BoundingBox<dim, Number>> &bounding_boxes)
129 : BoundingBoxPredicate(bounding_boxes)
130 {}
131
132
133
134 template <int dim, typename Number>
136 const std::vector<::BoundingBox<dim, Number>> &bounding_boxes,
137 const unsigned int n_nearest_neighbors)
138 : BoundingBoxPredicate(bounding_boxes)
139 , n_nearest_neighbors(n_nearest_neighbors)
140 {}
141
142
143
144 unsigned int
146 {
147 return n_nearest_neighbors;
148 }
149} // namespace ArborXWrappers
150
152
153namespace ArborX
154{
155 // ------------------- Point Primitives AccessTraits ------------------- //
156 template <int dim, typename Number>
157 std::size_t
158 AccessTraits<std::vector<::Point<dim, Number>>, PrimitivesTag>::size(
159 const std::vector<::Point<dim, Number>> &v)
160 {
161 return v.size();
162 }
163
164
165
166 template <int dim, typename Number>
167 Point
168 AccessTraits<std::vector<::Point<dim, Number>>, PrimitivesTag>::get(
169 const std::vector<::Point<dim, Number>> &v,
170 std::size_t i)
171 {
172 // ArborX assumes that the point coordinates use float and that the point
173 // is 3D
174 return {{static_cast<float>(v[i][0]),
175 static_cast<float>(v[i][1]),
176 dim == 2 ? 0 : static_cast<float>(v[i][2])}};
177 }
178
179
180
181 // ----------------- BoundingBox Primitives AccessTraits ----------------- //
182 template <int dim, typename Number>
183 std::size_t
184 AccessTraits<std::vector<::BoundingBox<dim, Number>>, PrimitivesTag>::
185 size(const std::vector<::BoundingBox<dim, Number>> &v)
186 {
187 return v.size();
188 }
189
190
191
192 template <int dim, typename Number>
193 Box
194 AccessTraits<std::vector<::BoundingBox<dim, Number>>, PrimitivesTag>::
195 get(const std::vector<::BoundingBox<dim, Number>> &v, std::size_t i)
196 {
197 const auto boundary_points = v[i].get_boundary_points();
198 const ::Point<dim, Number> min_corner = boundary_points.first;
199 const ::Point<dim, Number> max_corner = boundary_points.second;
200 // ArborX assumes that the bounding box coordinates use float and that the
201 // bounding box is 3D
202 return {{static_cast<float>(min_corner[0]),
203 static_cast<float>(min_corner[1]),
204 dim == 2 ? 0.f : static_cast<float>(min_corner[2])},
205 {static_cast<float>(max_corner[0]),
206 static_cast<float>(max_corner[1]),
207 dim == 2 ? 0.f : static_cast<float>(max_corner[2])}};
208 }
209} // namespace ArborX
210
211// ----------------------- Instantiations --------------------//
212# include "access_traits.inst"
213
214#endif
BoundingBoxIntersectPredicate(const std::vector<::BoundingBox< dim, Number > > &bounding_boxes)
BoundingBoxNearestPredicate(const std::vector<::BoundingBox< dim, Number > > &bounding_boxes, const unsigned int n_nearest_neighbors)
BoundingBoxPredicate(const std::vector<::BoundingBox< dim, Number > > &bounding_boxes)
std::vector<::BoundingBox< 3, float > > bounding_boxes
const ::BoundingBox< 3, float > & get(unsigned int i) const
PointIntersectPredicate(const std::vector<::Point< dim, Number > > &points)
unsigned int get_n_nearest_neighbors() const
PointNearestPredicate(const std::vector<::Point< dim, Number > > &points, const unsigned int n_nearest_neighbors)
std::vector<::Point< 3, float > > points
Definition: access_traits.h:57
PointPredicate(const std::vector<::Point< dim, Number > > &points)
const ::Point< 3, float > & get(unsigned int i) const
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:402
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)