PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
neighborPolicy.cpp
Go to the documentation of this file.
1/*
2 * -------------------------------------------
3 * Copyright (c) 2021 - 2026 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 "neighborPolicy.h"
12
13#include "data/modelData.h"
14#include "util/io.h"
16#include "util/function.h"
17#include "util/vecMethods.h"
18#include "util/parallelUtil.h"
19
20#include <format>
21
22#include <taskflow/taskflow/taskflow.hpp>
23#include <taskflow/taskflow/algorithm/for_each.hpp>
24
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}
A class to store model data.
Definition modelData.h:50
Definition contact.h:20
void updatePeridynamicNeighborlist(data::ModelData &data)
Horizon search restricted to the same particle.
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:304
unsigned int getNThreads()
Get number of threads to be used by taskflow.