Files
ResInsight/ApplicationLibCode/ReservoirDataModel/ResultCalculators
Kristian Bendiksen 5ee62c61e1 #14128 Use KD-tree (nanoflann) for fault distance nearest-face search
computeFaultDistances faked a nearest-point query with cvf::BoundingBoxTree,
which only supports box overlap: it grew a cell-sized box until it overlapped a
fault face. For cells far from any fault this did many full tree traversals and
then brute-forced the distance to a large, over-collected candidate set, and the
answer was only approximate. This was slow on grids with ~10 million cells.

The metric is the distance from each cell center to the nearest fault face
center, which is exactly a nearest-point search. Replace the bounding-box tree
and the grow-the-box loop with a nanoflann KD-tree built over the fault face
centers and a single nearest-neighbor query per active cell. A zero-copy adaptor
reads the existing std::vector<cvf::Vec3d> directly. The OpenMP loop is retained
since nanoflann queries are read-only. The result is O(F log F) build plus
O(N log F) queries, the full grid-node array copy is gone, and distances are now
exact rather than approximate.

Add nanoflann as a vcpkg dependency, wired in like Clipper2 as an imported
target.

Refs: https://github.com/OPM/ResInsight/issues/14128
2026-06-08 21:39:08 +02:00
..
2025-08-27 14:22:11 +02:00