Skip to content

Commit

Permalink
Avoid copying initial positions reporter vector
Browse files Browse the repository at this point in the history
  • Loading branch information
GiudGiud committed Oct 6, 2024
1 parent 03a486d commit d961b8d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion framework/include/utils/KDTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using ResultItem = std::pair<T, U>;
class KDTree
{
public:
KDTree(std::vector<Point> & master_points, unsigned int max_leaf_size);
KDTree(const std::vector<Point> & master_points, unsigned int max_leaf_size);

virtual ~KDTree() = default;

Expand Down
5 changes: 1 addition & 4 deletions framework/src/positions/Positions.C
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ Positions::Positions(const InputParameters & parameters)
{

if (_initial_positions)
{
auto initial_positions_copy = *_initial_positions;
_initial_positions_kd_tree = std::make_unique<KDTree>(initial_positions_copy, 1);
}
_initial_positions_kd_tree = std::make_unique<KDTree>(*_initial_positions, 1);
}

const Point &
Expand Down
2 changes: 1 addition & 1 deletion framework/src/utils/KDTree.C
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using ResultItem = std::pair<T, U>;
}
#endif

KDTree::KDTree(std::vector<Point> & master_points, unsigned int max_leaf_size)
KDTree::KDTree(const std::vector<Point> & master_points, unsigned int max_leaf_size)
: _point_list_adaptor(master_points.begin(), master_points.end()),
_kd_tree(std::make_unique<KdTreeT>(
LIBMESH_DIM, _point_list_adaptor, nanoflann::KDTreeSingleIndexAdaptorParams(max_leaf_size)))
Expand Down

0 comments on commit d961b8d

Please sign in to comment.