PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
nsearch Namespace Reference

Methods for performing efficient search of neighboring points. More...

Data Structures

class  BaseNSearch
 A class for nearest neighbor search. More...
 
class  NFlannSearchKd
 A class for nearest neighbor search using nanoflann library. More...
 
struct  PointCloudAdaptor
 Allows custom point cloud data structure to interface with nanoflann. See https://github.com/jlblancoc/nanoflann for more details. More...
 
class  TreeSearchCheckIDExcludeResult
 To collect results of nanoflann tree search. In this class, we check the tag of a potential point and add the point to search list if the tag does not match the tag of a point for which neighbors are computed. This is useful when computing neighbor list for contact. In this case, we do not want points from the same particle to be in the contact neighbor lsit. Default result output of nanoflann search uses std::vector<std::pair<size_t, double>>. We prefer to get the index and distance in a separate list. More...
 
class  TreeSearchCheckIDIncludeResult
 To collect results of nanoflann tree search. In this class, we check the tag of a potential point and add the point to search list if the tag matches the tag of a point for which neighbors are computed. This is useful when computing neighbor list for peridynamics. In this case, we want points from the same particle to be in the peridynamics neighbor lsit. Default result output of nanoflann search uses std::vector<std::pair<size_t, double>>. We prefer to get the index and distance in a separate list. More...
 
class  TreeSearchResult
 To collect results of nanoflann tree search. Default result output of nanoflann search uses std::vector<std::pair<size_t, double>>. We prefer to get the index and distance in a separate list. More...
 

Typedefs

typedef std::vector< util::Point > PointCloud
 Define list of points for tree search using nanoflann lib.
 
typedef TreeSearchResult< double, size_t > TreeSearchRes
 Define result attributes.
 
typedef TreeSearchCheckIDIncludeResult< double, size_t > TreeSearchCheckIDIncludeRes
 
typedef TreeSearchCheckIDExcludeResult< double, size_t > TreeSearchCheckIDExcludeRes
 
typedef nanoflann::KDTreeSingleIndexAdaptor< nanoflann::L2_Simple_Adaptor< double, PointCloudAdaptor >, PointCloudAdaptor, 3 > NFlannKdTree
 Define tree data type for nanoflann.
 
typedef nanoflann::KDTreeSingleIndexAdaptor< nanoflann::L2_Simple_Adaptor< double, PointCloudAdaptor >, PointCloudAdaptor, 3 > NFlannKdTree3D
 Define tree data type for nanoflann (3D)
 
typedef nanoflann::KDTreeSingleIndexAdaptor< nanoflann::L2_Simple_Adaptor< double, PointCloudAdaptor >, PointCloudAdaptor, 2 > NFlannKdTree2D
 Define tree data type for nanoflann (2D)
 

Functions

void updatePeridynamicNeighborlist (data::ModelData &data)
 Horizon search restricted to the same particle.
 

Detailed Description

Methods for performing efficient search of neighboring points.

Typedef Documentation

◆ NFlannKdTree

typedef nanoflann::KDTreeSingleIndexAdaptor< nanoflann::L2_Simple_Adaptor<double, PointCloudAdaptor>, PointCloudAdaptor, 3 > nsearch::NFlannKdTree

Define tree data type for nanoflann.

Definition at line 438 of file nflannSetup.h.

◆ NFlannKdTree2D

typedef nanoflann::KDTreeSingleIndexAdaptor< nanoflann::L2_Simple_Adaptor<double, PointCloudAdaptor>, PointCloudAdaptor, 2 > nsearch::NFlannKdTree2D

Define tree data type for nanoflann (2D)

Definition at line 452 of file nflannSetup.h.

◆ NFlannKdTree3D

typedef nanoflann::KDTreeSingleIndexAdaptor< nanoflann::L2_Simple_Adaptor<double, PointCloudAdaptor>, PointCloudAdaptor, 3 > nsearch::NFlannKdTree3D

Define tree data type for nanoflann (3D)

Definition at line 445 of file nflannSetup.h.

◆ PointCloud

typedef std::vector<util::Point> nsearch::PointCloud

Define list of points for tree search using nanoflann lib.

Definition at line 20 of file nflannSetup.h.

◆ TreeSearchCheckIDExcludeRes

Definition at line 430 of file nflannSetup.h.

◆ TreeSearchCheckIDIncludeRes

Definition at line 429 of file nflannSetup.h.

◆ TreeSearchRes

typedef TreeSearchResult<double, size_t> nsearch::TreeSearchRes

Define result attributes.

Definition at line 428 of file nflannSetup.h.

Function Documentation

◆ updatePeridynamicNeighborlist()

void nsearch::updatePeridynamicNeighborlist ( data::ModelData &  data)

Horizon search restricted to the same particle.

Definition at line 25 of file neighborPolicy.cpp.

25 {
26
27
28 data.d_neighPd.resize(data.d_x.size());
29 // data.d_neighPdSqdDist.resize(data.d_x.size());
30 auto t1 = steady_clock::now();
31
32 tf::Executor executor(util::parallel::getNThreads());
33 tf::Taskflow taskflow;
34
35 taskflow.for_each_index((std::size_t) 0, data.d_x.size(), (std::size_t) 1, [&data](std::size_t i) {
36 const auto &pi = data.d_ptId[i];
37 double search_r = data.d_particlesListTypeAll[pi]->d_material_p->getHorizon();
38
39 std::vector<size_t> neighs;
40 std::vector<double> sqr_dist;
41 if (data.d_nsearch_p->radiusSearchIncludeTag(data.d_x[i],
42 search_r,
43 neighs,
44 sqr_dist,
45 data.d_ptId[i],
46 data.d_ptId) > 0) {
47 for (std::size_t j = 0; j < neighs.size(); ++j)
48 if (neighs[j] != i && data.d_ptId[neighs[j]] == pi) {
49 data.d_neighPd[i].push_back(size_t(neighs[j]));
50 // data.d_neighPdSqdDist[i].push_back(sqr_dist[j]);
51 }
52 }
53 }
54 ); // for_each
55
56 executor.run(taskflow).get();
57
58 auto t2 = steady_clock::now();
59 util::io::log(2, std::format("{}: Peridynamics neighbor update time = {}\n",
60 data.d_name, util::methods::timeDiff(t1, t2)));
61
62}
Definition contact.h:20
void log(std::ostringstream &oss, bool screen_out=false, int printMpiRank=print_default_mpi_rank)
Global method to log the message.
Definition io.cpp:41
float timeDiff(std::chrono::steady_clock::time_point begin, std::chrono::steady_clock::time_point end, std::string unit="microseconds")
Returns difference between two times.
Definition vecMethods.h:309
unsigned int getNThreads()
Get number of threads to be used by taskflow.

References util::parallel::getNThreads().

Referenced by PeriDEMModel::init().

Here is the call graph for this function:
Here is the caller graph for this function: