idaholab / moose

Multiphysics Object Oriented Simulation Environment
https://www.mooseframework.org
GNU Lesser General Public License v2.1
1.78k stars 1.05k forks source link

Small improvements to KDTree #10546

Closed dschwen closed 6 years ago

dschwen commented 6 years ago

Rationale

Remove unnecessary copying, container creation on the stack, and use new nanoflann API features (libmesh/libmesh#1563).

Description

We get the number of matched points (no need to screw around with limits max). We can pass the pointer to the internal data of Point rather than copy it into a C array. We should use Utility::pow rather than std::pow. We should have a permanent container for the distance dummy data. I'd also like to add an API to get the distance data, but maybe not in this issue.

Impact

Performance improvements.

dschwen commented 6 years ago

There are some iffy bits in the design of KDTree. It is not guaranteed that the index list is fully populated (it is padded with max uint). In SlaveNeighborhoodThread the entire list is used to index into nodes. This can potentially segfault. I'll fix this when I switch to the new api stuff.