6 #ifndef SEARCH_POINTS_BY_CELLS_H 7 #define SEARCH_POINTS_BY_CELLS_H 19 #include "lretypes.hh" 33 template <
int dim,
class SourceSwarm,
class TargetSwarm>
52 TargetSwarm
const& target_swarm,
55 Meshfree::WeightCenter center = Meshfree::Scatter)
56 : source_swarm_(source_swarm),
57 target_swarm_(target_swarm),
58 source_extents_(source_extents),
59 target_extents_(target_extents),
62 using namespace Meshfree;
64 int const nb_source = source_swarm_.num_particles();
65 int const nb_target = target_swarm_.num_particles();
66 bool const do_scatter = (center == Scatter);
71 assert(
unsigned(nb_source) == source_extents_.size());
73 assert(
unsigned(nb_target) == target_extents_.size());
78 Pairs::vpile source_vp(dim, nb_source);
79 Pairs::vpile target_vp(dim, nb_target);
80 Pairs::vpile extents_vp(dim, do_scatter ? nb_source : nb_target);
82 for (
int i = 0; i < nb_source; i++ ) {
83 auto p = source_swarm_.get_particle_coordinates(i);
84 for (
int m = 0; m < dim; m++) {
85 source_vp[m][i] = p[m];
89 for (
int i = 0; i < nb_target; i++ ) {
90 auto p = target_swarm_.get_particle_coordinates(i);
91 for (
int m = 0; m < dim; m++) {
92 target_vp[m][i] = p[m];
97 for (
int i = 0; i < nb_source; i++ ) {
98 for (
int m = 0; m < dim; m++) {
99 Point<dim> p = source_extents_[i];
100 extents_vp[m][i] = p[m];
101 source_extents_[i] = p;
104 }
else if (center_ == Gather) {
105 for (
int i = 0; i < nb_target; i++ ) {
106 for (
int m = 0; m < dim; m++) {
107 Point<dim> p = target_extents_[i];
108 extents_vp[m][i] = p[m];
109 target_extents_[i] = p;
114 pair_finder_ = std::make_shared<Pairs::CellPairFinder>(source_vp, target_vp,
115 extents_vp, do_scatter);
137 auto result = pair_finder_->find(pointId);
138 return std::vector<int>(result.begin(), result.end());
143 SourceSwarm
const& source_swarm_;
144 TargetSwarm
const& target_swarm_;
147 std::shared_ptr<Meshfree::Pairs::CellPairFinder> pair_finder_;
148 Meshfree::WeightCenter center_ = Meshfree::Scatter;
154 #endif // SEARCH_POINTS_BY_CELLS_H std::vector< T > vector
Definition: portage.h:238
A simple, crude search algorithm that does a linear-time search over a swarm of points.
Definition: search_points_by_cells.h:34
SearchPointsByCells()=delete
Default constructor (disabled)
~SearchPointsByCells()=default
Destructor.
SearchPointsByCells & operator=(SearchPointsByCells const &)=delete
Assignment operator (disabled)
Definition: coredriver.h:42
SearchPointsByCells(SourceSwarm const &source_swarm, TargetSwarm const &target_swarm, Portage::vector< Point< dim >> const &source_extents, Portage::vector< Point< dim >> const &target_extents, Meshfree::WeightCenter center=Meshfree::Scatter)
Builds the search structure for finding neighboring points.
Definition: search_points_by_cells.h:51
std::vector< int > operator()(int pointId) const
Find the source swarm points within an appropriate distance of a target point.
Definition: search_points_by_cells.h:136