SPHinXsys  alpha version
cell_linked_list.hpp
1 
7 #pragma once
8 
9 #include "base_particles.h"
10 #include "cell_linked_list.h"
11 
12 namespace SPH
13 {
14  //=================================================================================================//
15  template<typename GetParticleIndex, typename GetSearchDepth, typename GetNeighborRelation>
16  void CellLinkedList::searchNeighborsByParticles(size_t total_real_particles, BaseParticles& source_particles,
17  ParticleConfiguration& particle_configuration, GetParticleIndex& get_particle_index,
18  GetSearchDepth& get_search_depth, GetNeighborRelation& get_neighbor_relation)
19  {
20  parallel_for(blocked_range<size_t>(0, total_real_particles),
21  [&](const blocked_range<size_t>& r) {
22  StdLargeVec<Vecd>& pos_n = source_particles.pos_;
23  for (size_t num = r.begin(); num != r.end(); ++num) {
24  size_t index_i = get_particle_index(num);
25  Vecd& particle_position = pos_n[index_i];
26  int search_depth = get_search_depth(index_i);
27  Vecu target_cell_index = CellIndexFromPosition(particle_position);
28  int i = (int)target_cell_index[0];
29  int j = (int)target_cell_index[1];
30 
31  Neighborhood& neighborhood = particle_configuration[index_i];
32  for (int l = SMAX(i - search_depth, 0); l <= SMIN(i + search_depth, int(number_of_cells_[0]) - 1); ++l)
33  for (int m = SMAX(j - search_depth, 0); m <= SMIN(j + search_depth, int(number_of_cells_[1]) - 1); ++m)
34  {
35  ListDataVector& target_particles = cell_linked_lists_[l][m].cell_list_data_;
36  for (const ListData& list_data : target_particles)
37  {
38  //displacement pointing from neighboring particle to origin particle
39  Vecd displacement = particle_position - list_data.second;
40  get_neighbor_relation(neighborhood, displacement, index_i, list_data.first);
41  }
42  }
43  }
44  }, ap);
45  }
46  //=================================================================================================//
47 }
A neighborhood around particle i.
Definition: neighbor_relation.h:47
Particles with essential (geometric and kinematic) data. There are three types of particles, all par...
Definition: base_particles.h:81
Vecu number_of_cells_
Definition: base_mesh.h:110
Definition: base_data_type.h:43
Here gives the classes for managing cell linked lists. This is the basic class for building the parti...
MeshDataMatrix< CellList > cell_linked_lists_
Definition: cell_linked_list.h:118
StdLargeVec< ListData > ListDataVector
Definition: sph_data_containers.h:44
StdLargeVec< Neighborhood > ParticleConfiguration
Definition: neighbor_relation.h:66
std::pair< size_t, Vecd > ListData
Definition: sph_data_containers.h:42
This is the base class of SPH particles. The basic data of the particles is saved in separated large ...
StdLargeVec< Vecd > pos_
Definition: base_particles.h:88
void searchNeighborsByParticles(size_t total_real_particles, BaseParticles &source_particles, ParticleConfiguration &particle_configuration, GetParticleIndex &get_particle_index, GetSearchDepth &get_search_depth, GetNeighborRelation &get_neighbor_relation)
Definition: cell_linked_list.hpp:16
Definition: solid_body_supplementary.cpp:9