PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
geometryUtil.cpp
Go to the documentation of this file.
1/*
2 * -------------------------------------------
3 * Copyright (c) 2021 - 2024 Prashant K. Jha
4 * -------------------------------------------
5 * PeriDEM https://github.com/prashjha/PeriDEM
6 *
7 * Distributed under the Boost Software License, Version 1.0. (See accompanying
8 * file LICENSE)
9 */
10
11#include "geometryUtil.h"
12#include "nsearch/nsearch.h"
13#include <fmt/format.h>
14
16
17void geometry::computeNonlocalNeighborhood(const std::vector<util::Point> &nodes,
18 double horizon,
19 std::vector<std::vector<size_t>> &nodeNeighs) {
20 nodeNeighs.resize(nodes.size());
21
22 auto nsearch_p = std::make_unique<NSearch>(nodes);
23 double set_tree_time = nsearch_p->updatePointCloud(nodes, true);
24 set_tree_time += nsearch_p->setInputCloud();
25 std::cout << fmt::format("Tree setup time (ms) = {}. \n", set_tree_time);
26
27 for (size_t i=0; i<nodes.size(); i++) {
28 std::vector<size_t> neighs;
29 std::vector<double> sqr_dist;
30 nodeNeighs[i].resize(0);
31
32 if (nsearch_p->radiusSearch(nodes[i], horizon, neighs, sqr_dist) > 0) {
33 for (std::size_t j = 0; j < neighs.size(); ++j)
34 if (neighs[j] != i) {
35 nodeNeighs[i].push_back(neighs[j]);
36 }
37 }
38 }
39}
A class for nearest neighbor search using nanoflann library.
Definition nsearch.h:178
nsearch::NFlannSearchKd< 3 > NSearch
void computeNonlocalNeighborhood(const std::vector< util::Point > &nodes, double horizon, std::vector< std::vector< size_t > > &nodeNeighs)
Partitions the nodes based on node neighborlist supplied. Function first creates a graph with nodes a...