11#include <deal.II/particles/particle.h>
13#include <boost/range/adaptor/map.hpp>
22template <
int dim, ContactType contact_type>
29 &contact_pair_candidates,
30 const double neighborhood_threshold,
31 const std::array<double, dim> &periodic_offset_per_direction)
34 for (
auto &&adjacent_particles_list :
35 adjacent_particles | boost::adaptors::map_values)
38 auto &second_particles = adjacent_particles_list.second_particles;
41 if (second_particles.empty())
46 auto &particle_one = adjacent_particles_list.particle_one;
47 Point<dim, double> particle_one_location = particle_one->get_location();
54 for (
auto adjacent_particles_list_iterator = second_particles.begin();
55 adjacent_particles_list_iterator != second_particles.end();)
58 auto &adjacent_pair_information =
59 adjacent_particles_list_iterator->second;
60 auto &particle_two = adjacent_pair_information.particle_two;
63 Point<dim, double> particle_two_location =
64 particle_two->get_location();
66 const double square_distance =
67 particle_one_location.distance_square(particle_two_location);
68 if (square_distance > neighborhood_threshold)
70 adjacent_particles_list_iterator =
71 second_particles.erase(adjacent_particles_list_iterator);
75 ++adjacent_particles_list_iterator;
86 for (
auto adjacent_particles_list_iterator = second_particles.begin();
87 adjacent_particles_list_iterator != second_particles.end();)
91 auto &adjacent_pair_information =
92 adjacent_particles_list_iterator->second;
93 auto &particle_two = adjacent_pair_information.particle_two;
96 Point<dim, double> particle_two_real_location =
97 particle_two->get_location();
103 Tensor<1, dim> cached_translation =
104 adjacent_pair_information.periodic_offset;
105 const double cached_square_distance =
106 particle_one_location.distance_square(
107 particle_two_real_location + cached_translation);
112 if (cached_square_distance <= neighborhood_threshold)
113 ++adjacent_particles_list_iterator;
125 const auto [nearest_translation, found_periodic_translation] =
127 particle_one_location,
128 particle_two_real_location,
129 periodic_offset_per_direction);
135 const double min_square_distance =
136 found_periodic_translation ?
137 particle_one_location.distance_square(
138 particle_two_real_location + nearest_translation) :
139 std::numeric_limits<double>::max();
145 if (min_square_distance > neighborhood_threshold)
146 adjacent_particles_list_iterator =
147 second_particles.erase(adjacent_particles_list_iterator);
154 adjacent_pair_information.periodic_offset =
156 ++adjacent_particles_list_iterator;
166 for (
auto &[particle_one_id, second_particle_container] :
167 contact_pair_candidates)
169 if (second_particle_container.empty())
172 auto particle_one = particle_container.at(particle_one_id);
173 Point<dim, double> particle_one_location = particle_one->get_location();
175 for (
const types::particle_index &particle_two_id :
176 second_particle_container)
178 auto particle_two = particle_container.at(particle_two_id);
184 Point<dim, double> particle_two_location =
185 particle_two->get_location();
187 const double square_distance =
188 particle_one_location.distance_square(particle_two_location);
190 if (square_distance < neighborhood_threshold)
192 auto &particle_one_contact_list =
193 adjacent_particles[particle_one_id];
194 particle_one_contact_list.particle_one = particle_one;
196 particle_one_contact_list.second_particles.emplace(
209 Point<dim, double> particle_two_real_location =
210 particle_two->get_location();
215 const auto [nearest_translation, found_periodic_translation] =
217 particle_one_location,
218 particle_two_real_location,
219 periodic_offset_per_direction);
226 const double min_square_distance =
227 found_periodic_translation ?
228 particle_one_location.distance_square(
229 particle_two_real_location + nearest_translation) :
230 std::numeric_limits<double>::max();
235 if (min_square_distance < neighborhood_threshold)
237 auto &particle_one_contact_list =
238 adjacent_particles[particle_one_id];
239 particle_one_contact_list.particle_one = particle_one;
241 particle_one_contact_list.second_particles.emplace(
244 {particle_two, Tensor<1, 3>(), Tensor<1, 3>()},
245 nearest_translation});
253std::pair<Tensor<1, dim>,
bool>
255 const Point<dim, double> &particle_one_location,
256 const Point<dim, double> &particle_two_real_location,
257 const std::array<double, dim> &periodic_offset_per_direction)
259 Tensor<1, dim> nearest_translation;
260 bool found_periodic_translation =
false;
263 for (
int d = 0; d < dim; ++d)
268 if (periodic_offset_per_direction[d] != 0.)
272 particle_one_location[d] - particle_two_real_location[d];
281 nearest_translation[d] =
282 std::round(
delta / periodic_offset_per_direction[d]) *
283 periodic_offset_per_direction[d];
290 found_periodic_translation |= (nearest_translation[d] != 0.);
293 return {nearest_translation, found_periodic_translation};
304 &contact_pair_candidates,
305 const double neighborhood_threshold,
306 const std::array<double, 2> &periodic_offset_per_direction);
315 &contact_pair_candidates,
316 const double neighborhood_threshold,
317 const std::array<double, 2> &periodic_offset_per_direction);
326 &contact_pair_candidates,
327 const double neighborhood_threshold,
328 const std::array<double, 2> &periodic_offset_per_direction);
337 &contact_pair_candidates,
338 const double neighborhood_threshold,
339 const std::array<double, 2> &periodic_offset_per_direction);
348 &contact_pair_candidates,
349 const double neighborhood_threshold,
350 const std::array<double, 2> &periodic_offset_per_direction);
361 &contact_pair_candidates,
362 const double neighborhood_threshold,
363 const std::array<double, 3> &periodic_offset_per_direction);
372 &contact_pair_candidates,
373 const double neighborhood_threshold,
374 const std::array<double, 3> &periodic_offset_per_direction);
383 &contact_pair_candidates,
384 const double neighborhood_threshold,
385 const std::array<double, 3> &periodic_offset_per_direction);
394 &contact_pair_candidates,
395 const double neighborhood_threshold,
396 const std::array<double, 3> &periodic_offset_per_direction);
405 &contact_pair_candidates,
406 const double neighborhood_threshold,
407 const std::array<double, 3> &periodic_offset_per_direction);
Vector< double > delta(unsigned int order, unsigned int n, unsigned int j, const Vector< double > ×)
Recursive function for calculating the order divided differences ( ) that is used for calculating ba...
DEM particle property definitions and output name management.
template void particle_particle_fine_search< 3, local_particle_particle >(const typename DEM::dem_data_structures< 3 >::particle_index_iterator_map &particle_container, typename DEM::dem_data_structures< 3 >::adjacent_particle_pairs &adjacent_particles, const typename DEM::dem_data_structures< 3 >::particle_particle_candidates &contact_pair_candidates, const double neighborhood_threshold, const std::array< double, 3 > &periodic_offset_per_direction)
template void particle_particle_fine_search< 2, local_particle_particle >(const typename DEM::dem_data_structures< 2 >::particle_index_iterator_map &particle_container, typename DEM::dem_data_structures< 2 >::adjacent_particle_pairs &adjacent_particles, const typename DEM::dem_data_structures< 2 >::particle_particle_candidates &contact_pair_candidates, const double neighborhood_threshold, const std::array< double, 2 > &periodic_offset_per_direction)
template void particle_particle_fine_search< 2, ghost_local_periodic_particle_particle >(const typename DEM::dem_data_structures< 2 >::particle_index_iterator_map &particle_container, typename DEM::dem_data_structures< 2 >::periodic_adjacent_particle_pairs &adjacent_particles, const typename DEM::dem_data_structures< 2 >::particle_particle_candidates &contact_pair_candidates, const double neighborhood_threshold, const std::array< double, 2 > &periodic_offset_per_direction)
template void particle_particle_fine_search< 3, local_periodic_particle_particle >(const typename DEM::dem_data_structures< 3 >::particle_index_iterator_map &particle_container, typename DEM::dem_data_structures< 3 >::periodic_adjacent_particle_pairs &adjacent_particles, const typename DEM::dem_data_structures< 3 >::particle_particle_candidates &contact_pair_candidates, const double neighborhood_threshold, const std::array< double, 3 > &periodic_offset_per_direction)
void particle_particle_fine_search(const typename DEM::dem_data_structures< dim >::particle_index_iterator_map &particle_container, adjacent_pairs_for_contact_t< dim, contact_type > &adjacent_particles, const typename DEM::dem_data_structures< dim >::particle_particle_candidates &contact_pair_candidates, const double neighborhood_threshold, const std::array< double, dim > &periodic_offset_per_direction)
Iterates over a vector of maps (pairs_in_contact) to see if the particles which were in contact in th...
template void particle_particle_fine_search< 2, ghost_periodic_particle_particle >(const typename DEM::dem_data_structures< 2 >::particle_index_iterator_map &particle_container, typename DEM::dem_data_structures< 2 >::periodic_adjacent_particle_pairs &adjacent_particles, const typename DEM::dem_data_structures< 2 >::particle_particle_candidates &contact_pair_candidates, const double neighborhood_threshold, const std::array< double, 2 > &periodic_offset_per_direction)
template void particle_particle_fine_search< 3, ghost_periodic_particle_particle >(const typename DEM::dem_data_structures< 3 >::particle_index_iterator_map &particle_container, typename DEM::dem_data_structures< 3 >::periodic_adjacent_particle_pairs &adjacent_particles, const typename DEM::dem_data_structures< 3 >::particle_particle_candidates &contact_pair_candidates, const double neighborhood_threshold, const std::array< double, 3 > &periodic_offset_per_direction)
template void particle_particle_fine_search< 2, ghost_particle_particle >(const typename DEM::dem_data_structures< 2 >::particle_index_iterator_map &particle_container, typename DEM::dem_data_structures< 2 >::adjacent_particle_pairs &adjacent_particles, const typename DEM::dem_data_structures< 2 >::particle_particle_candidates &contact_pair_candidates, const double neighborhood_threshold, const std::array< double, 2 > &periodic_offset_per_direction)
std::pair< Tensor< 1, dim >, bool > nearest_periodic_translation(const Point< dim, double > &particle_one_location, const Point< dim, double > &particle_two_real_location, const std::array< double, dim > &periodic_offset_per_direction)
Find the translation that brings the nearest periodic image of particle two to particle one....
template void particle_particle_fine_search< 3, ghost_particle_particle >(const typename DEM::dem_data_structures< 3 >::particle_index_iterator_map &particle_container, typename DEM::dem_data_structures< 3 >::adjacent_particle_pairs &adjacent_particles, const typename DEM::dem_data_structures< 3 >::particle_particle_candidates &contact_pair_candidates, const double neighborhood_threshold, const std::array< double, 3 > &periodic_offset_per_direction)
template void particle_particle_fine_search< 2, local_periodic_particle_particle >(const typename DEM::dem_data_structures< 2 >::particle_index_iterator_map &particle_container, typename DEM::dem_data_structures< 2 >::periodic_adjacent_particle_pairs &adjacent_particles, const typename DEM::dem_data_structures< 2 >::particle_particle_candidates &contact_pair_candidates, const double neighborhood_threshold, const std::array< double, 2 > &periodic_offset_per_direction)
template void particle_particle_fine_search< 3, ghost_local_periodic_particle_particle >(const typename DEM::dem_data_structures< 3 >::particle_index_iterator_map &particle_container, typename DEM::dem_data_structures< 3 >::periodic_adjacent_particle_pairs &adjacent_particles, const typename DEM::dem_data_structures< 3 >::particle_particle_candidates &contact_pair_candidates, const double neighborhood_threshold, const std::array< double, 3 > &periodic_offset_per_direction)
std::conditional_t< contact_type==local_periodic_particle_particle|| contact_type==ghost_periodic_particle_particle|| contact_type==ghost_local_periodic_particle_particle, typename DEM::dem_data_structures< dim >::periodic_adjacent_particle_pairs, typename DEM::dem_data_structures< dim >::adjacent_particle_pairs > adjacent_pairs_for_contact_t
Selects adjacent_particle_pairs or periodic_adjacent_particle_pairs based on the contact_type.
ankerl::unordered_dense::map< types::particle_index, Particles::ParticleIterator< dim > > particle_index_iterator_map
ankerl::unordered_dense::map< types::particle_index, periodic_adjacent_particle_pairs_value > periodic_adjacent_particle_pairs
ankerl::unordered_dense::map< types::particle_index, std::vector< types::particle_index > > particle_particle_candidates
ankerl::unordered_dense::map< types::particle_index, adjacent_particle_pairs_value > adjacent_particle_pairs
Handle the information related to the calculation of the particle-particle contact force....
Derived struct of the base struct particle_particle_contact_info for periodic particle-particle conta...