| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2021 - 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_access_traits_h |
| 16 |
#define dealii_arborx_access_traits_h |
| 17 |
|
| 18 |
#include <deal.II/base/config.h> |
| 19 |
|
| 20 |
#ifdef DEAL_II_WITH_ARBORX |
| 21 |
# include <deal.II/base/bounding_box.h> |
| 22 |
|
| 23 |
# include <ArborX.hpp> |
| 24 |
|
| 25 |
# include <utility> |
| 26 |
|
| 27 |
|
| 28 |
DEAL_II_NAMESPACE_OPEN |
| 29 |
|
| 30 |
namespace ArborXWrappers |
| 31 |
{ |
| 32 |
# if ARBORX_VERSION_MAJOR < 2 |
| 33 |
/** |
| 34 |
* Base class for Point-based predicates providing basic functionality for |
| 35 |
* derived classes, not supposed to be used on its own. |
| 36 |
*/ |
| 37 |
class PointPredicate |
| 38 |
{ |
| 39 |
protected: |
| 40 |
/** |
| 41 |
* Constructor. @p points is a list of points used by the predicate. |
| 42 |
*/ |
| 43 |
template <int dim, typename Number> |
| 44 |
PointPredicate(const std::vector<dealii::Point<dim, Number>> &points); |
| 45 |
|
| 46 |
/** |
| 47 |
* The number of points stored in the structure. |
| 48 |
*/ |
| 49 |
std::size_t |
| 50 |
size() const; |
| 51 |
|
| 52 |
/** |
| 53 |
* Return the `i`th Point stored in the object. |
| 54 |
*/ |
| 55 |
const dealii::Point<3, float> & |
| 56 |
get(unsigned int i) const; |
| 57 |
|
| 58 |
private: |
| 59 |
std::vector<dealii::Point<3, float>> points; |
| 60 |
}; |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
/** |
| 65 |
* This class defines a predicate used by ArborXWrappers::BVH to determine |
| 66 |
* for given points which of the bounding boxes used to build the |
| 67 |
* ArborXWrappers::BVH intersect with them. |
| 68 |
* @note The class is not supposed to be used in a polymorphic context. |
| 69 |
*/ |
| 70 |
class PointIntersectPredicate : private PointPredicate |
| 71 |
{ |
| 72 |
public: |
| 73 |
/** |
| 74 |
* Constructor. @p points is a list of points which we are interested in |
| 75 |
* knowing if they intersect ArborXWrappers::BVH bounding boxes. |
| 76 |
*/ |
| 77 |
template <int dim, typename Number> |
| 78 |
PointIntersectPredicate( |
| 79 |
const std::vector<dealii::Point<dim, Number>> &points); |
| 80 |
|
| 81 |
// We need these since we inherit privately to avoid polymorphic use. |
| 82 |
using PointPredicate::get; |
| 83 |
using PointPredicate::size; |
| 84 |
}; |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
/** |
| 89 |
* This class defines a predicate used by ArborXWrappers::BVH to determine |
| 90 |
* for given points which are the nearest bounding boxes/points among the ones |
| 91 |
* used to build the ArborXWrappers::BVH. |
| 92 |
* @note The class is not supposed to be used in a polymorphic context. |
| 93 |
*/ |
| 94 |
class PointNearestPredicate : private PointPredicate |
| 95 |
{ |
| 96 |
public: |
| 97 |
/** |
| 98 |
* Constructor. @p points is a list of points for which we are interested in |
| 99 |
* the @p n_nearest_neighbors in the ArborXWrappers::BVH bounding |
| 100 |
* boxes/points. |
| 101 |
*/ |
| 102 |
template <int dim, typename Number> |
| 103 |
PointNearestPredicate(const std::vector<dealii::Point<dim, Number>> &points, |
| 104 |
const unsigned int n_nearest_neighbors); |
| 105 |
|
| 106 |
/** |
| 107 |
* Return the number of nearest neighbors we are looking for. |
| 108 |
*/ |
| 109 |
unsigned int |
| 110 |
get_n_nearest_neighbors() const; |
| 111 |
|
| 112 |
// We need these since we inherit privately to avoid polymorphic use. |
| 113 |
using PointPredicate::get; |
| 114 |
using PointPredicate::size; |
| 115 |
|
| 116 |
private: |
| 117 |
unsigned int n_nearest_neighbors; |
| 118 |
}; |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
/** |
| 123 |
* Base class for BoundingBox predicates providing basic functionality for |
| 124 |
* derived classes, not supposed to be used on its own. |
| 125 |
*/ |
| 126 |
class BoundingBoxPredicate |
| 127 |
{ |
| 128 |
protected: |
| 129 |
/** |
| 130 |
* Constructor. @p bounding_boxes is a list of bounding boxes used by the |
| 131 |
* predicate. |
| 132 |
*/ |
| 133 |
template <int dim, typename Number> |
| 134 |
BoundingBoxPredicate( |
| 135 |
const std::vector<dealii::BoundingBox<dim, Number>> &bounding_boxes); |
| 136 |
|
| 137 |
/** |
| 138 |
* The number of bounding boxes stored in the structure. |
| 139 |
*/ |
| 140 |
std::size_t |
| 141 |
size() const; |
| 142 |
|
| 143 |
/** |
| 144 |
* Return the `i`th BoundingBox stored in the object. |
| 145 |
*/ |
| 146 |
const dealii::BoundingBox<3, float> & |
| 147 |
get(unsigned int i) const; |
| 148 |
|
| 149 |
private: |
| 150 |
std::vector<dealii::BoundingBox<3, float>> bounding_boxes; |
| 151 |
}; |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
/** |
| 156 |
* This class is used by ArborXWrappers::BVH to determine for given bounding |
| 157 |
* boxes which of the bounding boxes used to build the ArborXWrappers::BVH |
| 158 |
* intersect with them. |
| 159 |
* @note The class is not supposed to be used in a polymorphic context. |
| 160 |
*/ |
| 161 |
class BoundingBoxIntersectPredicate : private BoundingBoxPredicate |
| 162 |
{ |
| 163 |
public: |
| 164 |
/** |
| 165 |
* Constructor. @p bounding_boxes is a list of bounding boxes which we are interested in |
| 166 |
* knowing if they intersect ArborXWrappers::BVH bounding boxes. |
| 167 |
*/ |
| 168 |
template <int dim, typename Number> |
| 169 |
BoundingBoxIntersectPredicate( |
| 170 |
const std::vector<dealii::BoundingBox<dim, Number>> &bounding_boxes); |
| 171 |
|
| 172 |
// We need these since we inherit privately to avoid polymorphic use. |
| 173 |
using BoundingBoxPredicate::get; |
| 174 |
using BoundingBoxPredicate::size; |
| 175 |
}; |
| 176 |
|
| 177 |
|
| 178 |
/** |
| 179 |
* This class is used by ArborXWrappers::BVH to determine for given bounding |
| 180 |
* boxes which are the nearest bounding boxes/points among the ones used to |
| 181 |
* build the ArborXWrappers::BVH. |
| 182 |
* @note The class is not supposed to be used in a polymorphic context. |
| 183 |
*/ |
| 184 |
class BoundingBoxNearestPredicate : private BoundingBoxPredicate |
| 185 |
{ |
| 186 |
public: |
| 187 |
/** |
| 188 |
* Constructor. @p bounding_boxes is a list of bounding boxes for which are interested in |
| 189 |
* knowing the @p n_nearest_neighbors nearest bounding boxes used to build the |
| 190 |
* ArborXWrappers::BVH. |
| 191 |
*/ |
| 192 |
template <int dim, typename Number> |
| 193 |
BoundingBoxNearestPredicate( |
| 194 |
const std::vector<dealii::BoundingBox<dim, Number>> &bounding_boxes, |
| 195 |
const unsigned int n_nearest_neighbors); |
| 196 |
|
| 197 |
/** |
| 198 |
* Return the number of nearest neighbors we are looking for. |
| 199 |
*/ |
| 200 |
unsigned int |
| 201 |
get_n_nearest_neighbors() const; |
| 202 |
|
| 203 |
// We need these since we inherit privately to avoid polymorphic use. |
| 204 |
using BoundingBoxPredicate::get; |
| 205 |
using BoundingBoxPredicate::size; |
| 206 |
|
| 207 |
private: |
| 208 |
unsigned int n_nearest_neighbors; |
| 209 |
}; |
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
/** |
| 214 |
* Base class for Sphere-based predicates providing basic functionality for |
| 215 |
* derived classes; not supposed to be used on its own. |
| 216 |
*/ |
| 217 |
class SpherePredicate |
| 218 |
{ |
| 219 |
protected: |
| 220 |
/** |
| 221 |
* Constructor. @p spheres is a list of spheres, i.e. a center and radius |
| 222 |
* pair, used by the predicate. |
| 223 |
*/ |
| 224 |
template <int dim, typename Number> |
| 225 |
SpherePredicate( |
| 226 |
const std::vector<std::pair<dealii::Point<dim, Number>, Number>> |
| 227 |
&spheres); |
| 228 |
|
| 229 |
/** |
| 230 |
* The number of spheres stored in the structure. |
| 231 |
*/ |
| 232 |
std::size_t |
| 233 |
size() const; |
| 234 |
|
| 235 |
/** |
| 236 |
* Return the `i`th sphere stored in the object. |
| 237 |
*/ |
| 238 |
const std::pair<dealii::Point<3, float>, float> & |
| 239 |
get(unsigned int) const; |
| 240 |
|
| 241 |
private: |
| 242 |
std::vector<std::pair<dealii::Point<3, float>, float>> spheres; |
| 243 |
}; |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
/** |
| 248 |
* This class defines a predicate used by ArborXWrappers::BVH to determine |
| 249 |
* for given spheres which of the bounding boxes used to build the |
| 250 |
* ArborXWrappers::BVH intersect with them. |
| 251 |
* @note The class is not supposed to be used in a polymorphic context. |
| 252 |
*/ |
| 253 |
class SphereIntersectPredicate : private SpherePredicate |
| 254 |
{ |
| 255 |
public: |
| 256 |
/** |
| 257 |
* Constructor. @p spheres is a list of spheres which we are interested in |
| 258 |
* knowing if they intersect ArborXWrappers::BVH bounding boxes. |
| 259 |
*/ |
| 260 |
template <int dim, typename Number> |
| 261 |
SphereIntersectPredicate( |
| 262 |
const std::vector<std::pair<dealii::Point<dim, Number>, Number>> |
| 263 |
&spheres); |
| 264 |
|
| 265 |
// We need these since we inherit privately to avoid polymorphic use. |
| 266 |
using SpherePredicate::get; |
| 267 |
using SpherePredicate::size; |
| 268 |
}; |
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
/** |
| 273 |
* This class defines a predicate used by ArborXWrappers::BVH to determine, |
| 274 |
* for the given spheres, which are the nearest bounding boxes/points among |
| 275 |
* the ones used to build the ArborXWrappers::BVH. |
| 276 |
* @note The class is not supposed to be used in a polymorphic context. |
| 277 |
*/ |
| 278 |
class SphereNearestPredicate : private SpherePredicate |
| 279 |
{ |
| 280 |
public: |
| 281 |
/** |
| 282 |
* Constructor. @p spheres is a list of spheres for which we are |
| 283 |
* interested in the @p n_nearest_neighbors in the ArborXWrappers::BVH |
| 284 |
* bounding boxes/points. |
| 285 |
*/ |
| 286 |
template <int dim, typename Number> |
| 287 |
SphereNearestPredicate( |
| 288 |
const std::vector<std::pair<dealii::Point<dim, Number>, Number>> &spheres, |
| 289 |
const unsigned int n_nearest_neighbors); |
| 290 |
|
| 291 |
/** |
| 292 |
* Return the number of nearest neighbors we are looking for. |
| 293 |
*/ |
| 294 |
unsigned int |
| 295 |
get_n_nearest_neighbors() const; |
| 296 |
|
| 297 |
// We need these since we inherit privately to avoid polymorphic use. |
| 298 |
using SpherePredicate::get; |
| 299 |
using SpherePredicate::size; |
| 300 |
|
| 301 |
private: |
| 302 |
unsigned int n_nearest_neighbors; |
| 303 |
}; |
| 304 |
# else |
| 305 |
namespace internal |
| 306 |
{ |
| 307 |
template <int dim, typename Number> |
| 308 |
ArborX::Point<dim, Number> |
| 309 |
to_arborx_point(const dealii::Point<dim, Number> &p) |
| 310 |
{ |
| 311 |
if constexpr (dim == 1) |
| 312 |
{ |
| 313 |
return {p[0]}; |
| 314 |
} |
| 315 |
|
| 316 |
if constexpr (dim == 2) |
| 317 |
{ |
| 318 |
return {p[0], p[1]}; |
| 319 |
} |
| 320 |
|
| 321 |
if constexpr (dim == 3) |
| 322 |
{ |
| 323 |
return {p[0], p[1], p[2]}; |
| 324 |
} |
| 325 |
} |
| 326 |
|
| 327 |
/** |
| 328 |
* This structure returns the ArborX object associated with the deal.II |
| 329 |
* object stored in a PairValueIndex. |
| 330 |
*/ |
| 331 |
struct IndexableGetter |
| 332 |
{ |
| 333 |
template <int dim, typename Number> |
| 334 |
ArborX::Point<dim, Number> |
| 335 |
operator()(const ArborX::PairValueIndex<dealii::Point<dim, Number>, |
| 336 |
unsigned int> &pair) const |
| 337 |
{ |
| 338 |
return to_arborx_point(pair.value); |
| 339 |
} |
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
template <int dim, typename Number> |
| 344 |
ArborX::Box<dim, Number> |
| 345 |
operator()(const ArborX::PairValueIndex<dealii::BoundingBox<dim, Number>, |
| 346 |
unsigned int> &pair) const |
| 347 |
{ |
| 348 |
const auto boundary_points = pair.value.get_boundary_points(); |
| 349 |
const dealii::Point<dim, Number> min_corner = boundary_points.first; |
| 350 |
const dealii::Point<dim, Number> max_corner = boundary_points.second; |
| 351 |
return {to_arborx_point(min_corner), to_arborx_point(max_corner)}; |
| 352 |
} |
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
template <int dim, typename Number> |
| 357 |
ArborX::Sphere<dim, Number> |
| 358 |
operator()(const ArborX::PairValueIndex< |
| 359 |
std::pair<dealii::Point<dim, Number>, Number>, |
| 360 |
unsigned int> &pair) const |
| 361 |
{ |
| 362 |
return {to_arborx_point(pair.value.first), pair.value.second}; |
| 363 |
} |
| 364 |
}; |
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
/** |
| 369 |
* Callback to extract the index of each primitive that satisfies a query. |
| 370 |
*/ |
| 371 |
struct ExtractIndex |
| 372 |
{ |
| 373 |
template <typename Query, typename Value, typename Output> |
| 374 |
KOKKOS_FUNCTION void |
| 375 |
operator()(const Query &, const Value &value, const Output &out) const |
| 376 |
{ |
| 377 |
out(value.index); |
| 378 |
} |
| 379 |
}; |
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
/** |
| 384 |
* Callback to extract the index and the rank of each primitive that |
| 385 |
* satisfies a query. |
| 386 |
*/ |
| 387 |
struct ExtractIndexRank |
| 388 |
{ |
| 389 |
unsigned int rank; |
| 390 |
|
| 391 |
template <typename Predicate, typename Value, typename Output> |
| 392 |
KOKKOS_FUNCTION void |
| 393 |
operator()(const Predicate &, |
| 394 |
const ArborX::PairValueIndex<Value> &value, |
| 395 |
const Output &out) const |
| 396 |
{ |
| 397 |
out({value.index, rank}); |
| 398 |
} |
| 399 |
}; |
| 400 |
} // namespace internal |
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
/** |
| 405 |
* This class defines a predicate used by ArborXWrappers::BVH to determine |
| 406 |
* for given points which of the primitives used to build the |
| 407 |
* ArborXWrappers::BVH intersect with them. |
| 408 |
*/ |
| 409 |
template <int dim, typename Number> |
| 410 |
class PointIntersectPredicate |
| 411 |
{ |
| 412 |
public: |
| 413 |
/** |
| 414 |
* Constructor. @p points is a list of points which we are interested in |
| 415 |
* knowing if they intersect ArborXWrappers::BVH primitives. |
| 416 |
*/ |
| 417 |
PointIntersectPredicate( |
| 418 |
const std::vector<dealii::Point<dim, Number>> &points); |
| 419 |
|
| 420 |
/** |
| 421 |
* The number of points stored in the structure. |
| 422 |
*/ |
| 423 |
std::size_t |
| 424 |
size() const; |
| 425 |
|
| 426 |
/** |
| 427 |
* Return the `i`th Point stored in the object. |
| 428 |
*/ |
| 429 |
const dealii::Point<dim, Number> & |
| 430 |
get(unsigned int i) const; |
| 431 |
|
| 432 |
/** |
| 433 |
* A flag that specifies if the predicate is nearest neighbors search. |
| 434 |
*/ |
| 435 |
static constexpr bool is_nearest = false; |
| 436 |
|
| 437 |
private: |
| 438 |
std::vector<dealii::Point<dim, Number>> points; |
| 439 |
}; |
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
/** |
| 444 |
* This class defines a predicate used by ArborXWrappers::BVH to determine |
| 445 |
* for given points which are the nearest primitives among the ones |
| 446 |
* used to build the ArborXWrappers::BVH. |
| 447 |
*/ |
| 448 |
template <int dim, typename Number> |
| 449 |
class PointNearestPredicate |
| 450 |
{ |
| 451 |
public: |
| 452 |
/** |
| 453 |
* Constructor. @p points is a list of points for which we are interested in |
| 454 |
* the @p n_nearest_neighbors in the ArborXWrappers::BVH primitives. |
| 455 |
*/ |
| 456 |
PointNearestPredicate(const std::vector<dealii::Point<dim, Number>> &points, |
| 457 |
const unsigned int n_nearest_neighbors); |
| 458 |
|
| 459 |
/** |
| 460 |
* Return the number of nearest neighbors we are looking for. |
| 461 |
*/ |
| 462 |
unsigned int |
| 463 |
get_n_nearest_neighbors() const; |
| 464 |
|
| 465 |
/** |
| 466 |
* The number of points stored in the structure. |
| 467 |
*/ |
| 468 |
std::size_t |
| 469 |
size() const; |
| 470 |
|
| 471 |
/** |
| 472 |
* Return the `i`th Point stored in the object. |
| 473 |
*/ |
| 474 |
const dealii::Point<dim, Number> & |
| 475 |
get(unsigned int i) const; |
| 476 |
|
| 477 |
|
| 478 |
/** |
| 479 |
* A flag that specifies if the predicate is nearest neighbors search. |
| 480 |
*/ |
| 481 |
static constexpr bool is_nearest = true; |
| 482 |
|
| 483 |
private: |
| 484 |
std::vector<dealii::Point<dim, Number>> points; |
| 485 |
unsigned int n_nearest_neighbors; |
| 486 |
}; |
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
/** |
| 491 |
* This class is used by ArborXWrappers::BVH to determine for given bounding |
| 492 |
* boxes which of the primitives used to build the ArborXWrappers::BVH |
| 493 |
* intersect with them. |
| 494 |
*/ |
| 495 |
template <int dim, typename Number> |
| 496 |
class BoundingBoxIntersectPredicate |
| 497 |
{ |
| 498 |
public: |
| 499 |
/** |
| 500 |
* Constructor. @p bounding_boxes is a list of bounding boxes which we are interested in |
| 501 |
* knowing if they intersect ArborXWrappers::BVH primitives. |
| 502 |
*/ |
| 503 |
BoundingBoxIntersectPredicate( |
| 504 |
const std::vector<dealii::BoundingBox<dim, Number>> &bounding_boxes); |
| 505 |
|
| 506 |
/** |
| 507 |
* The number of points stored in the structure. |
| 508 |
*/ |
| 509 |
std::size_t |
| 510 |
size() const; |
| 511 |
|
| 512 |
/** |
| 513 |
* Return the `i`th Point stored in the object. |
| 514 |
*/ |
| 515 |
const dealii::BoundingBox<dim, Number> & |
| 516 |
get(unsigned int i) const; |
| 517 |
|
| 518 |
/** |
| 519 |
* A flag that specifies if the predicate is nearest neighbors search. |
| 520 |
*/ |
| 521 |
static constexpr bool is_nearest = false; |
| 522 |
|
| 523 |
private: |
| 524 |
std::vector<dealii::BoundingBox<dim, Number>> bounding_boxes; |
| 525 |
}; |
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
/** |
| 530 |
* This class is used by ArborXWrappers::BVH to determine for given bounding |
| 531 |
* boxes which are the nearest primitives among the ones used to |
| 532 |
* build the ArborXWrappers::BVH. |
| 533 |
*/ |
| 534 |
template <int dim, typename Number> |
| 535 |
class BoundingBoxNearestPredicate |
| 536 |
{ |
| 537 |
public: |
| 538 |
/** |
| 539 |
* Constructor. @p bounding_boxes is a list of bounding boxes for which are interested in |
| 540 |
* knowing the @p n_nearest_neighbors nearest primitives used to build the |
| 541 |
* ArborXWrappers::BVH. |
| 542 |
*/ |
| 543 |
BoundingBoxNearestPredicate( |
| 544 |
const std::vector<dealii::BoundingBox<dim, Number>> &bounding_boxes, |
| 545 |
const unsigned int n_nearest_neighbors); |
| 546 |
|
| 547 |
/** |
| 548 |
* Return the number of nearest neighbors we are looking for. |
| 549 |
*/ |
| 550 |
unsigned int |
| 551 |
get_n_nearest_neighbors() const; |
| 552 |
|
| 553 |
/** |
| 554 |
* The number of points stored in the structure. |
| 555 |
*/ |
| 556 |
std::size_t |
| 557 |
size() const; |
| 558 |
|
| 559 |
/** |
| 560 |
* Return the `i`th Point stored in the object. |
| 561 |
*/ |
| 562 |
const dealii::BoundingBox<dim, Number> & |
| 563 |
get(unsigned int i) const; |
| 564 |
|
| 565 |
/** |
| 566 |
* A flag that specifies if the predicate is nearest neighbors search. |
| 567 |
*/ |
| 568 |
static constexpr bool is_nearest = true; |
| 569 |
|
| 570 |
private: |
| 571 |
std::vector<dealii::BoundingBox<dim, Number>> bounding_boxes; |
| 572 |
unsigned int n_nearest_neighbors; |
| 573 |
}; |
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
/** |
| 578 |
* This class defines a predicate used by ArborXWrappers::BVH to determine |
| 579 |
* for given spheres which of the primitives used to build the |
| 580 |
* ArborXWrappers::BVH intersect with them. |
| 581 |
*/ |
| 582 |
template <int dim, typename Number> |
| 583 |
class SphereIntersectPredicate |
| 584 |
{ |
| 585 |
public: |
| 586 |
/** |
| 587 |
* Constructor. @p spheres is a list of spheres which we are interested in |
| 588 |
* knowing if they intersect ArborXWrappers::BVH primitives. |
| 589 |
*/ |
| 590 |
SphereIntersectPredicate( |
| 591 |
const std::vector<std::pair<dealii::Point<dim, Number>, Number>> |
| 592 |
&spheres); |
| 593 |
|
| 594 |
/** |
| 595 |
* The number of points stored in the structure. |
| 596 |
*/ |
| 597 |
std::size_t |
| 598 |
size() const; |
| 599 |
|
| 600 |
/** |
| 601 |
* Return the `i`th Point stored in the object. |
| 602 |
*/ |
| 603 |
const std::pair<dealii::Point<dim, Number>, Number> & |
| 604 |
get(unsigned int) const; |
| 605 |
|
| 606 |
/** |
| 607 |
* A flag that specifies if the predicate is nearest neighbors search. |
| 608 |
*/ |
| 609 |
static constexpr bool is_nearest = false; |
| 610 |
|
| 611 |
private: |
| 612 |
std::vector<std::pair<dealii::Point<dim, Number>, Number>> spheres; |
| 613 |
}; |
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
/** |
| 618 |
* This class defines a predicate used by ArborXWrappers::BVH to determine, |
| 619 |
* for the given spheres, which are the nearest bounding primitives among |
| 620 |
* the ones used to build the ArborXWrappers::BVH. |
| 621 |
*/ |
| 622 |
template <int dim, typename Number> |
| 623 |
class SphereNearestPredicate |
| 624 |
{ |
| 625 |
public: |
| 626 |
/** |
| 627 |
* Constructor. @p spheres is a list of spheres for which we are |
| 628 |
* interested in the @p n_nearest_neighbors in the ArborXWrappers::BVH |
| 629 |
* primitives. |
| 630 |
*/ |
| 631 |
SphereNearestPredicate( |
| 632 |
const std::vector<std::pair<dealii::Point<dim, Number>, Number>> &spheres, |
| 633 |
const unsigned int n_nearest_neighbors); |
| 634 |
|
| 635 |
/** |
| 636 |
* Return the number of nearest neighbors we are looking for. |
| 637 |
*/ |
| 638 |
unsigned int |
| 639 |
get_n_nearest_neighbors() const; |
| 640 |
|
| 641 |
/** |
| 642 |
* The number of points stored in the structure. |
| 643 |
*/ |
| 644 |
std::size_t |
| 645 |
size() const; |
| 646 |
|
| 647 |
/** |
| 648 |
* Return the `i`th Point stored in the object. |
| 649 |
*/ |
| 650 |
const std::pair<dealii::Point<dim, Number>, Number> & |
| 651 |
get(unsigned int) const; |
| 652 |
|
| 653 |
/** |
| 654 |
* A flag that specifies if the predicate is nearest neighbors search. |
| 655 |
*/ |
| 656 |
static constexpr bool is_nearest = true; |
| 657 |
|
| 658 |
private: |
| 659 |
std::vector<std::pair<dealii::Point<dim, Number>, Number>> spheres; |
| 660 |
unsigned int n_nearest_neighbors; |
| 661 |
}; |
| 662 |
# endif |
| 663 |
} // namespace ArborXWrappers |
| 664 |
|
| 665 |
DEAL_II_NAMESPACE_CLOSE |
| 666 |
|
| 667 |
/** |
| 668 |
* This namespace contains the implementation of AccessTraits used by ArborX. |
| 669 |
*/ |
| 670 |
namespace ArborX |
| 671 |
{ |
| 672 |
# if ARBORX_VERSION_MAJOR < 2 |
| 673 |
/** |
| 674 |
* This struct allows ArborX to use std::vector<dealii::Point> as |
| 675 |
* primitive. |
| 676 |
*/ |
| 677 |
template <int dim, typename Number> |
| 678 |
struct AccessTraits<std::vector<dealii::Point<dim, Number>>, PrimitivesTag> |
| 679 |
{ |
| 680 |
using memory_space = Kokkos::HostSpace; |
| 681 |
|
| 682 |
/** |
| 683 |
* Return the size of the vector @p v. |
| 684 |
*/ |
| 685 |
static std::size_t |
| 686 |
size(const std::vector<dealii::Point<dim, Number>> &v); |
| 687 |
|
| 688 |
/** |
| 689 |
* Return an ArborX::Point from the dealii::Point `v[i]`. |
| 690 |
*/ |
| 691 |
static Point |
| 692 |
get(const std::vector<dealii::Point<dim, Number>> &v, std::size_t i); |
| 693 |
}; |
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
/** |
| 698 |
* This struct allows ArborX to use std::vector<dealii::BoundingBox> as |
| 699 |
* primitive. |
| 700 |
*/ |
| 701 |
template <int dim, typename Number> |
| 702 |
struct AccessTraits<std::vector<dealii::BoundingBox<dim, Number>>, |
| 703 |
PrimitivesTag> |
| 704 |
{ |
| 705 |
using memory_space = Kokkos::HostSpace; |
| 706 |
|
| 707 |
/** |
| 708 |
* Return the size of the vector @p v. |
| 709 |
*/ |
| 710 |
static std::size_t |
| 711 |
size(const std::vector<dealii::BoundingBox<dim, Number>> &v); |
| 712 |
|
| 713 |
/** |
| 714 |
* Return an ArborX::Box from the dealii::BoundingBox `v[i]`. |
| 715 |
*/ |
| 716 |
static Box |
| 717 |
get(const std::vector<dealii::BoundingBox<dim, Number>> &v, std::size_t i); |
| 718 |
}; |
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
/** |
| 723 |
* This struct allows ArborX to use |
| 724 |
* std::vector<std::pair<dealii::Point, Number> as primitive. |
| 725 |
*/ |
| 726 |
template <int dim, typename Number> |
| 727 |
struct AccessTraits< |
| 728 |
std::vector<std::pair<dealii::Point<dim, Number>, Number>>, |
| 729 |
PrimitivesTag> |
| 730 |
{ |
| 731 |
using memory_space = Kokkos::HostSpace; |
| 732 |
|
| 733 |
/** |
| 734 |
* Return the size of the vector @p v. |
| 735 |
*/ |
| 736 |
static std::size_t |
| 737 |
size(const std::vector<std::pair<dealii::Point<dim, Number>, Number>> &v); |
| 738 |
|
| 739 |
/** |
| 740 |
* Return an ArborX::Sphere from the std::pair<dealii::Point, Number> |
| 741 |
* `v[i]`. |
| 742 |
*/ |
| 743 |
static Sphere |
| 744 |
get(const std::vector<std::pair<dealii::Point<dim, Number>, Number>> &v, |
| 745 |
std::size_t i); |
| 746 |
}; |
| 747 |
# else |
| 748 |
/** |
| 749 |
* This struct allows ArborX to use std::vector<T> as primitive. |
| 750 |
*/ |
| 751 |
template <typename T> |
| 752 |
struct AccessTraits< |
| 753 |
std::vector<T>, |
| 754 |
std::enable_if_t< |
| 755 |
std::is_same_v<T, dealii::Point<T::dimension, float>> || |
| 756 |
std::is_same_v<T, dealii::Point<T::dimension, double>> || |
| 757 |
std::is_same_v<T, dealii::BoundingBox<T::dimension, float>> || |
| 758 |
std::is_same_v<T, dealii::BoundingBox<T::dimension, double>> || |
| 759 |
std::is_same_v<T, std::pair<dealii::Point<T::dimension, float>, float>> || |
| 760 |
std::is_same_v<T, |
| 761 |
std::pair<dealii::Point<T::dimension, double>, double>>>> |
| 762 |
{ |
| 763 |
using memory_space = Kokkos::HostSpace; |
| 764 |
|
| 765 |
/** |
| 766 |
* Return the size of the vector @p v. |
| 767 |
*/ |
| 768 |
static std::size_t |
| 769 |
size(const std::vector<T> &v); |
| 770 |
|
| 771 |
/** |
| 772 |
* Return the ith element of the vector @p v. |
| 773 |
*/ |
| 774 |
static T |
| 775 |
get(const std::vector<T> &v, std::size_t i); |
| 776 |
}; |
| 777 |
# endif |
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
# if ARBORX_VERSION_MAJOR < 2 |
| 782 |
/** |
| 783 |
* This struct allows ArborX to use PointIntersectPredicate as a predicate. |
| 784 |
*/ |
| 785 |
template <> |
| 786 |
struct AccessTraits<dealii::ArborXWrappers::PointIntersectPredicate, |
| 787 |
PredicatesTag> |
| 788 |
{ |
| 789 |
using memory_space = Kokkos::HostSpace; |
| 790 |
|
| 791 |
/** |
| 792 |
* The number of points stored in @p pt_intersect. |
| 793 |
*/ |
| 794 |
static std::size_t |
| 795 |
size(const dealii::ArborXWrappers::PointIntersectPredicate &pt_intersect); |
| 796 |
|
| 797 |
/** |
| 798 |
* Return an ArborX::intersects(ArborX::Point) object constructed from the |
| 799 |
* `i`th dealii::Point stored in @p pt_intersect. |
| 800 |
*/ |
| 801 |
static auto |
| 802 |
get(const dealii::ArborXWrappers::PointIntersectPredicate &pt_intersect, |
| 803 |
std::size_t i); |
| 804 |
}; |
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
/** |
| 809 |
* This struct allows ArborX to use PointNearestPredicate as a predicate. |
| 810 |
*/ |
| 811 |
template <> |
| 812 |
struct AccessTraits<dealii::ArborXWrappers::PointNearestPredicate, |
| 813 |
PredicatesTag> |
| 814 |
{ |
| 815 |
using memory_space = Kokkos::HostSpace; |
| 816 |
|
| 817 |
/** |
| 818 |
* The number of points stored in @p pt_nearest. |
| 819 |
*/ |
| 820 |
static std::size_t |
| 821 |
size(const dealii::ArborXWrappers::PointNearestPredicate &pt_nearest); |
| 822 |
|
| 823 |
/** |
| 824 |
* Return an ArborX::nearest(ArborX::Point, |
| 825 |
* PointNearestPredicate::get_n_nearest_neighbors) object constructed from |
| 826 |
* the `i`th dealii::Point stored in @p pt_nearest. |
| 827 |
*/ |
| 828 |
static auto |
| 829 |
get(const dealii::ArborXWrappers::PointNearestPredicate &pt_nearest, |
| 830 |
std::size_t i); |
| 831 |
}; |
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
/** |
| 836 |
* This struct allows ArborX to use BoundingBoxIntersectPredicate as a |
| 837 |
* predicate. |
| 838 |
*/ |
| 839 |
template <> |
| 840 |
struct AccessTraits<dealii::ArborXWrappers::BoundingBoxIntersectPredicate, |
| 841 |
PredicatesTag> |
| 842 |
{ |
| 843 |
using memory_space = Kokkos::HostSpace; |
| 844 |
|
| 845 |
/** |
| 846 |
* The number of bounding boxes stored in @p bb_intersect. |
| 847 |
*/ |
| 848 |
static std::size_t |
| 849 |
size(const dealii::ArborXWrappers::BoundingBoxIntersectPredicate |
| 850 |
&bb_intersect); |
| 851 |
|
| 852 |
/** |
| 853 |
* Return an Arbox::intersects(ArborX::Box) object constructed from the |
| 854 |
* `i`th dealii::BoundingBox stored in @p bb_intersect. |
| 855 |
*/ |
| 856 |
static auto |
| 857 |
get( |
| 858 |
const dealii::ArborXWrappers::BoundingBoxIntersectPredicate &bb_intersect, |
| 859 |
std::size_t i); |
| 860 |
}; |
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
/** |
| 865 |
* This struct allows ArborX to use BoundingBoxNearstPredicate as a |
| 866 |
* predicate. |
| 867 |
*/ |
| 868 |
template <> |
| 869 |
struct AccessTraits<dealii::ArborXWrappers::BoundingBoxNearestPredicate, |
| 870 |
PredicatesTag> |
| 871 |
{ |
| 872 |
using memory_space = Kokkos::HostSpace; |
| 873 |
|
| 874 |
/** |
| 875 |
* The number of bounding boxes stored in @p bb_nearest. |
| 876 |
*/ |
| 877 |
static std::size_t |
| 878 |
size(const dealii::ArborXWrappers::BoundingBoxNearestPredicate &bb_nearest); |
| 879 |
|
| 880 |
/** |
| 881 |
* Return an Arbox::nearest(ArborX::Box, |
| 882 |
* BoundingBoxtNearestPredicate::get_n_nearest_neighbors) object constructed |
| 883 |
* from the `i`th dealii::BoundingBox stored in @p bb_nearest. |
| 884 |
*/ |
| 885 |
static auto |
| 886 |
get(const dealii::ArborXWrappers::BoundingBoxNearestPredicate &bb_nearest, |
| 887 |
std::size_t i); |
| 888 |
}; |
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
/** |
| 893 |
* This struct allows ArborX to use SphereIntersectPredicate as a |
| 894 |
predicate. |
| 895 |
*/ |
| 896 |
template <> |
| 897 |
struct AccessTraits<dealii::ArborXWrappers::SphereIntersectPredicate, |
| 898 |
PredicatesTag> |
| 899 |
{ |
| 900 |
using memory_space = Kokkos::HostSpace; |
| 901 |
|
| 902 |
/** |
| 903 |
* The number of points stored in @p sph_intersect. |
| 904 |
*/ |
| 905 |
static std::size_t |
| 906 |
size(const dealii::ArborXWrappers::SphereIntersectPredicate &sph_intersect); |
| 907 |
|
| 908 |
/** |
| 909 |
* Return an ArborX::intersects(ArborX::Sphere) object constructed from the |
| 910 |
* `i`th sphere stored in @p sph_intersect. |
| 911 |
*/ |
| 912 |
static auto |
| 913 |
get(const dealii::ArborXWrappers::SphereIntersectPredicate &sph_intersect, |
| 914 |
std::size_t i); |
| 915 |
}; |
| 916 |
|
| 917 |
|
| 918 |
|
| 919 |
/** |
| 920 |
* This struct allows ArborX to use SphereNearestPredicate as a predicate. |
| 921 |
*/ |
| 922 |
template <> |
| 923 |
struct AccessTraits<dealii::ArborXWrappers::SphereNearestPredicate, |
| 924 |
PredicatesTag> |
| 925 |
{ |
| 926 |
using memory_space = Kokkos::HostSpace; |
| 927 |
|
| 928 |
/** |
| 929 |
* The number of spheres stored in @p sph_nearest. |
| 930 |
*/ |
| 931 |
static std::size_t |
| 932 |
size(const dealii::ArborXWrappers::SphereNearestPredicate &sph_nearest); |
| 933 |
|
| 934 |
/** |
| 935 |
* Return an ArborX::nearest(ArborX::Sphere, |
| 936 |
* SphereNearestPredicate::get_n_nearest_neighbors) object constructed from |
| 937 |
* the `i`th sphere stored in @p sph_nearest. |
| 938 |
*/ |
| 939 |
static auto |
| 940 |
get(const dealii::ArborXWrappers::SphereNearestPredicate &sph_nearest, |
| 941 |
std::size_t i); |
| 942 |
}; |
| 943 |
# else |
| 944 |
/** |
| 945 |
* This struct allows ArborX to use PointIntersectPredicate as a predicate. |
| 946 |
*/ |
| 947 |
template <int dim, typename Number> |
| 948 |
struct AccessTraits< |
| 949 |
dealii::ArborXWrappers::PointIntersectPredicate<dim, Number>> |
| 950 |
{ |
| 951 |
using memory_space = Kokkos::HostSpace; |
| 952 |
|
| 953 |
/** |
| 954 |
* The number of points stored in @p pt_intersect. |
| 955 |
*/ |
| 956 |
static std::size_t |
| 957 |
size(const dealii::ArborXWrappers::PointIntersectPredicate<dim, Number> |
| 958 |
&pt_intersect); |
| 959 |
|
| 960 |
/** |
| 961 |
* Return an ArborX::intersects(ArborX::Point) object constructed from the |
| 962 |
* `i`th dealii::Point stored in @p pt_intersect. |
| 963 |
*/ |
| 964 |
static auto |
| 965 |
get(const dealii::ArborXWrappers::PointIntersectPredicate<dim, Number> |
| 966 |
&pt_intersect, |
| 967 |
std::size_t i); |
| 968 |
}; |
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
/** |
| 973 |
* This struct allows ArborX to use PointNearestPredicate as a predicate. |
| 974 |
*/ |
| 975 |
template <int dim, typename Number> |
| 976 |
struct AccessTraits< |
| 977 |
dealii::ArborXWrappers::PointNearestPredicate<dim, Number>> |
| 978 |
{ |
| 979 |
using memory_space = Kokkos::HostSpace; |
| 980 |
|
| 981 |
/** |
| 982 |
* The number of points stored in @p pt_nearest. |
| 983 |
*/ |
| 984 |
static std::size_t |
| 985 |
size(const dealii::ArborXWrappers::PointNearestPredicate<dim, Number> |
| 986 |
&pt_nearest); |
| 987 |
|
| 988 |
/** |
| 989 |
* Return an ArborX::nearest(ArborX::Point, |
| 990 |
* PointNearestPredicate::get_n_nearest_neighbors) object constructed from |
| 991 |
* the `i`th dealii::Point stored in @p pt_nearest. |
| 992 |
*/ |
| 993 |
static auto |
| 994 |
get(const dealii::ArborXWrappers::PointNearestPredicate<dim, Number> |
| 995 |
&pt_nearest, |
| 996 |
std::size_t i); |
| 997 |
}; |
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
/** |
| 1002 |
* This struct allows ArborX to use BoundingBoxIntersectPredicate as a |
| 1003 |
* predicate. |
| 1004 |
*/ |
| 1005 |
template <int dim, typename Number> |
| 1006 |
struct AccessTraits< |
| 1007 |
dealii::ArborXWrappers::BoundingBoxIntersectPredicate<dim, Number>> |
| 1008 |
{ |
| 1009 |
using memory_space = Kokkos::HostSpace; |
| 1010 |
|
| 1011 |
/** |
| 1012 |
* The number of bounding boxes stored in @p bb_intersect. |
| 1013 |
*/ |
| 1014 |
static std::size_t |
| 1015 |
size( |
| 1016 |
const dealii::ArborXWrappers::BoundingBoxIntersectPredicate<dim, Number> |
| 1017 |
&bb_intersect); |
| 1018 |
|
| 1019 |
/** |
| 1020 |
* Return an Arbox::intersects(ArborX::Box) object constructed from the |
| 1021 |
* `i`th dealii::BoundingBox stored in @p bb_intersect. |
| 1022 |
*/ |
| 1023 |
static auto |
| 1024 |
get(const dealii::ArborXWrappers::BoundingBoxIntersectPredicate<dim, Number> |
| 1025 |
&bb_intersect, |
| 1026 |
std::size_t i); |
| 1027 |
}; |
| 1028 |
|
| 1029 |
|
| 1030 |
|
| 1031 |
/** |
| 1032 |
* This struct allows ArborX to use BoundingBoxNearstPredicate as a |
| 1033 |
* predicate. |
| 1034 |
*/ |
| 1035 |
template <int dim, typename Number> |
| 1036 |
struct AccessTraits< |
| 1037 |
dealii::ArborXWrappers::BoundingBoxNearestPredicate<dim, Number>> |
| 1038 |
{ |
| 1039 |
using memory_space = Kokkos::HostSpace; |
| 1040 |
|
| 1041 |
/** |
| 1042 |
* The number of bounding boxes stored in @p bb_nearest. |
| 1043 |
*/ |
| 1044 |
static std::size_t |
| 1045 |
size(const dealii::ArborXWrappers::BoundingBoxNearestPredicate<dim, Number> |
| 1046 |
&bb_nearest); |
| 1047 |
|
| 1048 |
/** |
| 1049 |
* Return an Arbox::nearest(ArborX::Box, |
| 1050 |
* BoundingBoxtNearestPredicate::get_n_nearest_neighbors) object constructed |
| 1051 |
* from the `i`th dealii::BoundingBox stored in @p bb_nearest. |
| 1052 |
*/ |
| 1053 |
static auto |
| 1054 |
get(const dealii::ArborXWrappers::BoundingBoxNearestPredicate<dim, Number> |
| 1055 |
&bb_nearest, |
| 1056 |
std::size_t i); |
| 1057 |
}; |
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
/** |
| 1062 |
* This struct allows ArborX to use SphereIntersectPredicate as a |
| 1063 |
predicate. |
| 1064 |
*/ |
| 1065 |
template <int dim, typename Number> |
| 1066 |
struct AccessTraits< |
| 1067 |
dealii::ArborXWrappers::SphereIntersectPredicate<dim, Number>> |
| 1068 |
{ |
| 1069 |
using memory_space = Kokkos::HostSpace; |
| 1070 |
|
| 1071 |
/** |
| 1072 |
* The number of points stored in @p sph_intersect. |
| 1073 |
*/ |
| 1074 |
static std::size_t |
| 1075 |
size(const dealii::ArborXWrappers::SphereIntersectPredicate<dim, Number> |
| 1076 |
&sph_intersect); |
| 1077 |
|
| 1078 |
/** |
| 1079 |
* Return an ArborX::intersects(ArborX::Sphere) object constructed from the |
| 1080 |
* `i`th sphere stored in @p sph_intersect. |
| 1081 |
*/ |
| 1082 |
static auto |
| 1083 |
get(const dealii::ArborXWrappers::SphereIntersectPredicate<dim, Number> |
| 1084 |
&sph_intersect, |
| 1085 |
std::size_t i); |
| 1086 |
}; |
| 1087 |
|
| 1088 |
|
| 1089 |
|
| 1090 |
/** |
| 1091 |
* This struct allows ArborX to use SphereNearestPredicate as a predicate. |
| 1092 |
*/ |
| 1093 |
template <int dim, typename Number> |
| 1094 |
struct AccessTraits< |
| 1095 |
dealii::ArborXWrappers::SphereNearestPredicate<dim, Number>> |
| 1096 |
{ |
| 1097 |
using memory_space = Kokkos::HostSpace; |
| 1098 |
|
| 1099 |
/** |
| 1100 |
* The number of spheres stored in @p sph_nearest. |
| 1101 |
*/ |
| 1102 |
static std::size_t |
| 1103 |
size(const dealii::ArborXWrappers::SphereNearestPredicate<dim, Number> |
| 1104 |
&sph_nearest); |
| 1105 |
|
| 1106 |
/** |
| 1107 |
* Return an ArborX::nearest(ArborX::Sphere, |
| 1108 |
* SphereNearestPredicate::get_n_nearest_neighbors) object constructed from |
| 1109 |
* the `i`th sphere stored in @p sph_nearest. |
| 1110 |
*/ |
| 1111 |
static auto |
| 1112 |
get(const dealii::ArborXWrappers::SphereNearestPredicate<dim, Number> |
| 1113 |
&sph_nearest, |
| 1114 |
std::size_t i); |
| 1115 |
}; |
| 1116 |
# endif |
| 1117 |
|
| 1118 |
// ------------------------------- Inline ----------------------------------// |
| 1119 |
|
| 1120 |
// The implementation of AccessTraits<..., PredicatesTag> needs to be in the |
| 1121 |
// header file otherwise the return type of auto get() cannot be determined. |
| 1122 |
// We use auto because ArborX does not expose the type of intersects |
| 1123 |
|
| 1124 |
# if ARBORX_VERSION_MAJOR < 2 |
| 1125 |
inline std::size_t |
| 1126 |
AccessTraits<dealii::ArborXWrappers::PointIntersectPredicate, PredicatesTag>:: |
| 1127 |
size(const dealii::ArborXWrappers::PointIntersectPredicate &pt_intersect) |
| 1128 |
{ |
| 1129 |
return pt_intersect.size(); |
| 1130 |
} |
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
inline auto |
| 1135 |
AccessTraits<dealii::ArborXWrappers::PointIntersectPredicate, PredicatesTag>:: |
| 1136 |
get(const dealii::ArborXWrappers::PointIntersectPredicate &pt_intersect, |
| 1137 |
std::size_t i) |
| 1138 |
{ |
| 1139 |
const auto dealii_point = pt_intersect.get(i); |
| 1140 |
return intersects(Point{dealii_point[0], dealii_point[1], dealii_point[2]}); |
| 1141 |
} |
| 1142 |
|
| 1143 |
|
| 1144 |
|
| 1145 |
inline std::size_t |
| 1146 |
AccessTraits<dealii::ArborXWrappers::PointNearestPredicate, PredicatesTag>:: |
| 1147 |
size(const dealii::ArborXWrappers::PointNearestPredicate &pt_nearest) |
| 1148 |
{ |
| 1149 |
return pt_nearest.size(); |
| 1150 |
} |
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
inline auto |
| 1155 |
AccessTraits<dealii::ArborXWrappers::PointNearestPredicate, PredicatesTag>:: |
| 1156 |
get(const dealii::ArborXWrappers::PointNearestPredicate &pt_nearest, |
| 1157 |
std::size_t i) |
| 1158 |
{ |
| 1159 |
const auto dealii_point = pt_nearest.get(i); |
| 1160 |
return nearest(Point{dealii_point[0], dealii_point[1], dealii_point[2]}, |
| 1161 |
pt_nearest.get_n_nearest_neighbors()); |
| 1162 |
} |
| 1163 |
|
| 1164 |
|
| 1165 |
|
| 1166 |
inline std::size_t |
| 1167 |
AccessTraits<dealii::ArborXWrappers::BoundingBoxIntersectPredicate, |
| 1168 |
PredicatesTag>:: |
| 1169 |
size( |
| 1170 |
const dealii::ArborXWrappers::BoundingBoxIntersectPredicate &bb_intersect) |
| 1171 |
{ |
| 1172 |
return bb_intersect.size(); |
| 1173 |
} |
| 1174 |
|
| 1175 |
|
| 1176 |
|
| 1177 |
inline auto |
| 1178 |
AccessTraits<dealii::ArborXWrappers::BoundingBoxIntersectPredicate, |
| 1179 |
PredicatesTag>:: |
| 1180 |
get( |
| 1181 |
const dealii::ArborXWrappers::BoundingBoxIntersectPredicate &bb_intersect, |
| 1182 |
std::size_t i) |
| 1183 |
{ |
| 1184 |
const auto boundary_points = bb_intersect.get(i).get_boundary_points(); |
| 1185 |
const dealii::Point<3, float> min_corner = boundary_points.first; |
| 1186 |
const dealii::Point<3, float> max_corner = boundary_points.second; |
| 1187 |
|
| 1188 |
return intersects(Box{{min_corner[0], min_corner[1], min_corner[2]}, |
| 1189 |
{max_corner[0], max_corner[1], max_corner[2]}}); |
| 1190 |
} |
| 1191 |
|
| 1192 |
|
| 1193 |
|
| 1194 |
inline std::size_t |
| 1195 |
AccessTraits<dealii::ArborXWrappers::BoundingBoxNearestPredicate, |
| 1196 |
PredicatesTag>:: |
| 1197 |
size(const dealii::ArborXWrappers::BoundingBoxNearestPredicate &bb_nearest) |
| 1198 |
{ |
| 1199 |
return bb_nearest.size(); |
| 1200 |
} |
| 1201 |
|
| 1202 |
|
| 1203 |
|
| 1204 |
inline auto |
| 1205 |
AccessTraits<dealii::ArborXWrappers::BoundingBoxNearestPredicate, |
| 1206 |
PredicatesTag>:: |
| 1207 |
get(const dealii::ArborXWrappers::BoundingBoxNearestPredicate &bb_nearest, |
| 1208 |
std::size_t i) |
| 1209 |
{ |
| 1210 |
const auto boundary_points = bb_nearest.get(i).get_boundary_points(); |
| 1211 |
const dealii::Point<3, float> min_corner = boundary_points.first; |
| 1212 |
const dealii::Point<3, float> max_corner = boundary_points.second; |
| 1213 |
|
| 1214 |
return nearest(Box{{min_corner[0], min_corner[1], min_corner[2]}, |
| 1215 |
{max_corner[0], max_corner[1], max_corner[2]}}, |
| 1216 |
bb_nearest.get_n_nearest_neighbors()); |
| 1217 |
} |
| 1218 |
|
| 1219 |
|
| 1220 |
|
| 1221 |
inline std::size_t |
| 1222 |
AccessTraits<dealii::ArborXWrappers::SphereIntersectPredicate, |
| 1223 |
PredicatesTag>:: |
| 1224 |
size(const dealii::ArborXWrappers::SphereIntersectPredicate &sph_intersect) |
| 1225 |
{ |
| 1226 |
return sph_intersect.size(); |
| 1227 |
} |
| 1228 |
|
| 1229 |
|
| 1230 |
|
| 1231 |
inline auto |
| 1232 |
AccessTraits<dealii::ArborXWrappers::SphereIntersectPredicate, |
| 1233 |
PredicatesTag>:: |
| 1234 |
get(const dealii::ArborXWrappers::SphereIntersectPredicate &sph_intersect, |
| 1235 |
std::size_t i) |
| 1236 |
{ |
| 1237 |
const auto sphere = sph_intersect.get(i); |
| 1238 |
return intersects( |
| 1239 |
Sphere{{sphere.first[0], sphere.first[1], sphere.first[2]}, |
| 1240 |
sphere.second}); |
| 1241 |
} |
| 1242 |
|
| 1243 |
|
| 1244 |
|
| 1245 |
inline std::size_t |
| 1246 |
AccessTraits<dealii::ArborXWrappers::SphereNearestPredicate, PredicatesTag>:: |
| 1247 |
size(const dealii::ArborXWrappers::SphereNearestPredicate &sph_nearest) |
| 1248 |
{ |
| 1249 |
return sph_nearest.size(); |
| 1250 |
} |
| 1251 |
|
| 1252 |
|
| 1253 |
|
| 1254 |
inline auto |
| 1255 |
AccessTraits<dealii::ArborXWrappers::SphereNearestPredicate, PredicatesTag>:: |
| 1256 |
get(const dealii::ArborXWrappers::SphereNearestPredicate &sph_nearest, |
| 1257 |
std::size_t i) |
| 1258 |
{ |
| 1259 |
const auto sphere = sph_nearest.get(i); |
| 1260 |
return nearest(Sphere{{sphere.first[0], sphere.first[1], sphere.first[2]}, |
| 1261 |
sphere.second}, |
| 1262 |
sph_nearest.get_n_nearest_neighbors()); |
| 1263 |
} |
| 1264 |
# else |
| 1265 |
template <int dim, typename Number> |
| 1266 |
inline std::size_t |
| 1267 |
AccessTraits<dealii::ArborXWrappers::PointIntersectPredicate<dim, Number>>:: |
| 1268 |
size(const dealii::ArborXWrappers::PointIntersectPredicate<dim, Number> |
| 1269 |
&pt_intersect) |
| 1270 |
{ |
| 1271 |
return pt_intersect.size(); |
| 1272 |
} |
| 1273 |
|
| 1274 |
|
| 1275 |
|
| 1276 |
template <int dim, typename Number> |
| 1277 |
inline auto |
| 1278 |
AccessTraits<dealii::ArborXWrappers::PointIntersectPredicate<dim, Number>>:: |
| 1279 |
get(const dealii::ArborXWrappers::PointIntersectPredicate<dim, Number> |
| 1280 |
&pt_intersect, |
| 1281 |
std::size_t i) |
| 1282 |
{ |
| 1283 |
return intersects( |
| 1284 |
dealii::ArborXWrappers::internal::to_arborx_point(pt_intersect.get(i))); |
| 1285 |
} |
| 1286 |
|
| 1287 |
|
| 1288 |
|
| 1289 |
template <int dim, typename Number> |
| 1290 |
inline std::size_t |
| 1291 |
AccessTraits<dealii::ArborXWrappers::PointNearestPredicate<dim, Number>>:: |
| 1292 |
size(const dealii::ArborXWrappers::PointNearestPredicate<dim, Number> |
| 1293 |
&pt_nearest) |
| 1294 |
{ |
| 1295 |
return pt_nearest.size(); |
| 1296 |
} |
| 1297 |
|
| 1298 |
|
| 1299 |
|
| 1300 |
template <int dim, typename Number> |
| 1301 |
inline auto |
| 1302 |
AccessTraits<dealii::ArborXWrappers::PointNearestPredicate<dim, Number>>::get( |
| 1303 |
const dealii::ArborXWrappers::PointNearestPredicate<dim, Number> |
| 1304 |
&pt_nearest, |
| 1305 |
std::size_t i) |
| 1306 |
{ |
| 1307 |
return nearest(dealii::ArborXWrappers::internal::to_arborx_point( |
| 1308 |
pt_nearest.get(i)), |
| 1309 |
pt_nearest.get_n_nearest_neighbors()); |
| 1310 |
} |
| 1311 |
|
| 1312 |
|
| 1313 |
|
| 1314 |
template <int dim, typename Number> |
| 1315 |
inline std::size_t |
| 1316 |
AccessTraits< |
| 1317 |
dealii::ArborXWrappers::BoundingBoxIntersectPredicate<dim, Number>>:: |
| 1318 |
size( |
| 1319 |
const dealii::ArborXWrappers::BoundingBoxIntersectPredicate<dim, Number> |
| 1320 |
&bb_intersect) |
| 1321 |
{ |
| 1322 |
return bb_intersect.size(); |
| 1323 |
} |
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
template <int dim, typename Number> |
| 1328 |
inline auto |
| 1329 |
AccessTraits< |
| 1330 |
dealii::ArborXWrappers::BoundingBoxIntersectPredicate<dim, Number>>:: |
| 1331 |
get(const dealii::ArborXWrappers::BoundingBoxIntersectPredicate<dim, Number> |
| 1332 |
&bb_intersect, |
| 1333 |
std::size_t i) |
| 1334 |
{ |
| 1335 |
const auto boundary_points = bb_intersect.get(i).get_boundary_points(); |
| 1336 |
const dealii::Point<dim, Number> min_corner = boundary_points.first; |
| 1337 |
const dealii::Point<dim, Number> max_corner = boundary_points.second; |
| 1338 |
|
| 1339 |
return intersects( |
| 1340 |
Box{dealii::ArborXWrappers::internal::to_arborx_point(min_corner), |
| 1341 |
dealii::ArborXWrappers::internal::to_arborx_point(max_corner)}); |
| 1342 |
} |
| 1343 |
|
| 1344 |
|
| 1345 |
|
| 1346 |
template <int dim, typename Number> |
| 1347 |
inline std::size_t |
| 1348 |
AccessTraits< |
| 1349 |
dealii::ArborXWrappers::BoundingBoxNearestPredicate<dim, Number>>:: |
| 1350 |
size(const dealii::ArborXWrappers::BoundingBoxNearestPredicate<dim, Number> |
| 1351 |
&bb_nearest) |
| 1352 |
{ |
| 1353 |
return bb_nearest.size(); |
| 1354 |
} |
| 1355 |
|
| 1356 |
|
| 1357 |
|
| 1358 |
template <int dim, typename Number> |
| 1359 |
inline auto |
| 1360 |
AccessTraits< |
| 1361 |
dealii::ArborXWrappers::BoundingBoxNearestPredicate<dim, Number>>:: |
| 1362 |
get(const dealii::ArborXWrappers::BoundingBoxNearestPredicate<dim, Number> |
| 1363 |
&bb_nearest, |
| 1364 |
std::size_t i) |
| 1365 |
{ |
| 1366 |
const auto boundary_points = bb_nearest.get(i).get_boundary_points(); |
| 1367 |
const dealii::Point<dim, Number> min_corner = boundary_points.first; |
| 1368 |
const dealii::Point<dim, Number> max_corner = boundary_points.second; |
| 1369 |
|
| 1370 |
return nearest( |
| 1371 |
Box{dealii::ArborXWrappers::internal::to_arborx_point(min_corner), |
| 1372 |
dealii::ArborXWrappers::internal::to_arborx_point(max_corner)}, |
| 1373 |
bb_nearest.get_n_nearest_neighbors()); |
| 1374 |
} |
| 1375 |
|
| 1376 |
|
| 1377 |
|
| 1378 |
template <int dim, typename Number> |
| 1379 |
inline std::size_t |
| 1380 |
AccessTraits<dealii::ArborXWrappers::SphereIntersectPredicate<dim, Number>>:: |
| 1381 |
size(const dealii::ArborXWrappers::SphereIntersectPredicate<dim, Number> |
| 1382 |
&sph_intersect) |
| 1383 |
{ |
| 1384 |
return sph_intersect.size(); |
| 1385 |
} |
| 1386 |
|
| 1387 |
|
| 1388 |
|
| 1389 |
template <int dim, typename Number> |
| 1390 |
inline auto |
| 1391 |
AccessTraits<dealii::ArborXWrappers::SphereIntersectPredicate<dim, Number>>:: |
| 1392 |
get(const dealii::ArborXWrappers::SphereIntersectPredicate<dim, Number> |
| 1393 |
&sph_intersect, |
| 1394 |
std::size_t i) |
| 1395 |
{ |
| 1396 |
const auto sphere = sph_intersect.get(i); |
| 1397 |
return intersects( |
| 1398 |
Sphere{dealii::ArborXWrappers::internal::to_arborx_point(sphere.first), |
| 1399 |
sphere.second}); |
| 1400 |
} |
| 1401 |
|
| 1402 |
|
| 1403 |
|
| 1404 |
template <int dim, typename Number> |
| 1405 |
inline std::size_t |
| 1406 |
AccessTraits<dealii::ArborXWrappers::SphereNearestPredicate<dim, Number>>:: |
| 1407 |
size(const dealii::ArborXWrappers::SphereNearestPredicate<dim, Number> |
| 1408 |
&sph_nearest) |
| 1409 |
{ |
| 1410 |
return sph_nearest.size(); |
| 1411 |
} |
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
template <int dim, typename Number> |
| 1416 |
inline auto |
| 1417 |
AccessTraits<dealii::ArborXWrappers::SphereNearestPredicate<dim, Number>>:: |
| 1418 |
get(const dealii::ArborXWrappers::SphereNearestPredicate<dim, Number> |
| 1419 |
&sph_nearest, |
| 1420 |
std::size_t i) |
| 1421 |
{ |
| 1422 |
const auto sphere = sph_nearest.get(i); |
| 1423 |
return nearest(Sphere{dealii::ArborXWrappers::internal::to_arborx_point( |
| 1424 |
sphere.first), |
| 1425 |
sphere.second}, |
| 1426 |
sph_nearest.get_n_nearest_neighbors()); |
| 1427 |
} |
| 1428 |
# endif |
| 1429 |
} // namespace ArborX |
| 1430 |
|
| 1431 |
#else |
| 1432 |
|
| 1433 |
// Make sure the scripts that create the C++20 module input files have |
| 1434 |
// something to latch on if the preprocessor #ifdef above would |
| 1435 |
// otherwise lead to an empty content of the file. |
| 1436 |
DEAL_II_NAMESPACE_OPEN |
| 1437 |
DEAL_II_NAMESPACE_CLOSE |
| 1438 |
|
| 1439 |
#endif |
| 1440 |
|
| 1441 |
#endif |