DOLFIN-X
DOLFIN-X C++ interface
utils.h
1 // Copyright (C) 2019-2021 Garth N. Wells and Jørgen S. Dokken
2 //
3 // This file is part of DOLFINX (https://www.fenicsproject.org)
4 //
5 // SPDX-License-Identifier: LGPL-3.0-or-later
6 
7 #pragma once
8 
9 #include <Eigen/Core>
10 #include <dolfinx/common/span.hpp>
11 #include <utility>
12 #include <vector>
13 
14 namespace dolfinx
15 {
16 namespace mesh
17 {
18 class Mesh;
19 } // namespace mesh
20 
21 namespace geometry
22 {
23 class BoundingBoxTree;
24 
31 BoundingBoxTree
32 create_midpoint_tree(const mesh::Mesh& mesh, int tdim,
33  const std::vector<std::int32_t>& entity_indices);
34 
40 std::vector<std::array<int, 2>>
41 compute_collisions(const BoundingBoxTree& tree0, const BoundingBoxTree& tree1);
42 
47 std::vector<int> compute_collisions(const BoundingBoxTree& tree,
48  const Eigen::Vector3d& p);
49 
58 std::pair<std::int32_t, double>
59 compute_closest_entity(const BoundingBoxTree& tree, const Eigen::Vector3d& p,
60  const mesh::Mesh& mesh, double R = -1);
61 
65  const Eigen::Array<double, 2, 3, Eigen::RowMajor>& b,
66  const Eigen::Vector3d& x);
67 
81 double squared_distance(const mesh::Mesh& mesh, int dim, std::int32_t index,
82  const Eigen::Vector3d& p);
83 
92 std::vector<std::int32_t>
94  const tcb::span<const std::int32_t>& candidate_cells,
95  const Eigen::Vector3d& point, int n);
96 } // namespace geometry
97 } // namespace dolfinx
A Mesh consists of a set of connected and numbered mesh topological entities, and geometry data.
Definition: Mesh.h:57
std::vector< std::int32_t > select_colliding_cells(const dolfinx::mesh::Mesh &mesh, const tcb::span< const std::int32_t > &candidate_cells, const Eigen::Vector3d &point, int n)
From the given Mesh, select up to n cells (local to process) from the list which actually collide wit...
Definition: utils.cpp:326
std::vector< std::array< int, 2 > > compute_collisions(const BoundingBoxTree &tree0, const BoundingBoxTree &tree1)
Compute all collisions between two BoundingBoxTrees (local to process).
Definition: utils.cpp:214
BoundingBoxTree create_midpoint_tree(const mesh::Mesh &mesh, int tdim, const std::vector< std::int32_t > &entity_indices)
Create a bounding box tree for a subset of entities (local to process) based on the entity midpoints.
Definition: utils.cpp:189
std::pair< std::int32_t, double > compute_closest_entity(const BoundingBoxTree &tree, const Eigen::Vector3d &p, const mesh::Mesh &mesh, double R=-1)
Compute closest mesh entity (local to process) for the topological distance of the bounding box tree ...
Definition: utils.cpp:251
double squared_distance(const mesh::Mesh &mesh, int dim, std::int32_t index, const Eigen::Vector3d &p)
Compute squared distance from a given point to the nearest point on a cell (only first order convex c...
Definition: utils.cpp:275
double compute_squared_distance_bbox(const Eigen::Array< double, 2, 3, Eigen::RowMajor > &b, const Eigen::Vector3d &x)
Compute squared distance between point and bounding box wih index "node". Returns zero if point is in...
Definition: utils.cpp:240