Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
particle_point_line_fine_search.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2020, 2022-2025 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
6
7#include <dem/contact_info.h>
9
10#include <deal.II/particles/particle_handler.h>
11using namespace dealii;
12
13// In this function, the output of particle-point broad search is investigated
14// to see if the pairs are in contact or not. If they are in contact, the normal
15// overlap, normal vector and normal relative velocity of the contact are
16// calculated. The output of this function is used for calculation of the
17// contact force
18template <int dim, typename PropertiesIndex>
19void
22 &particle_point_contact_candidates,
23 const double neighborhood_threshold,
25 &particle_point_pairs_in_contact)
26{
27 // Iterating over contact candidates from broad search. If a particle-point
28 // pair is in contact (distance > 0) it is inserted into the output of this
29 // function (particle_point_pairs_in_contact)
30 for (auto contact_pair_candidates_iterator =
31 particle_point_contact_candidates.begin();
32 contact_pair_candidates_iterator !=
33 particle_point_contact_candidates.end();
34 ++contact_pair_candidates_iterator)
35 {
36 // Get the value of the map (pair candidate) from the
37 // contact_pair_candidates_iterator
38 const particle_point_contact_info<dim> &pair_candidates =
39 contact_pair_candidates_iterator->second;
40
41 // Get the particle, particle diameter and boundary vertex location once
42 Particles::ParticleIterator<dim> particle = pair_candidates.particle;
43 double particle_diameter =
44 particle->get_properties()[PropertiesIndex::dp];
45
46 Point<3> vertex_location = pair_candidates.point;
47 Point<3> particle_location = [&] {
48 if constexpr (dim == 3)
49 return particle->get_location();
50 else
51 return point_nd_to_3d(particle->get_location());
52 }();
53
54 // Calculation of the square_distance between the particle and boundary
55 // vertex
56 const double square_distance =
57 (particle_diameter / 2.0) -
58 vertex_location.distance_square(particle_location);
59
60 // If the distance is larger than neighborhood threshold, then the
61 // particle-point pair are in contact
62 if (square_distance > neighborhood_threshold)
63 {
64 // Adding contact info to the sample
65 particle_point_pairs_in_contact.emplace(particle->get_id(),
66 pair_candidates);
67 }
68 }
69}
70
71// In this function, the output of particle-line broad search is investigated
72// to see if the pairs are in contact or not. If they are in contact, the normal
73// overlap, normal vector and normal relative velocity of the contact are
74// calculated. The output of this function is used for calculation of the
75// contact force
76template <int dim, typename PropertiesIndex>
77void
80 &particle_line_contact_candidates,
81 const double neighborhood_threshold,
83 &particle_line_pairs_in_contact)
84{
85 // Iterating over contact candidates from broad search. If a particle-line
86 // pair is in contact (distance > 0) it is inserted into the output of this
87 // function (particle_line_pairs_in_contact);
88 for (auto contact_pair_candidates_iterator =
89 particle_line_contact_candidates.begin();
90 contact_pair_candidates_iterator !=
91 particle_line_contact_candidates.end();
92 ++contact_pair_candidates_iterator)
93 {
94 // Get the value of the map (pair candidate) from the
95 // contact_pair_candidates_iterator
96 const particle_line_contact_info<dim> &pair_candidates =
97 contact_pair_candidates_iterator->second;
98
99 // Get the particle, particle diameter and the locations of beginning
100 // and ending vertices of the boundary line
101 Particles::ParticleIterator<dim> particle = pair_candidates.particle;
102 double particle_diameter =
103 particle->get_properties()[PropertiesIndex::dp];
104
105 Point<3> vertex_one_location = pair_candidates.point_one;
106 Point<3> vertex_two_location = pair_candidates.point_two;
107 Point<3> particle_location = [&] {
108 if constexpr (dim == 3)
109 return particle->get_location();
110 else
111 return point_nd_to_3d(particle->get_location());
112 }();
113
114 // For finding the particle-line distance, the projection of the particle
115 // on the line should be obtained
116 Point<3> projection = find_projection_point(particle_location,
117 vertex_one_location,
118 vertex_two_location);
119
120 // Calculation of the distance between the particle and boundary line
121 const double square_distance =
122 (particle_diameter / 2.0) -
123 projection.distance_square(particle_location);
124
125 // If the distance is positive, then the particle-line pair are in
126 // contact
127 if (square_distance > neighborhood_threshold)
128 {
129 // Creating a sample from the particle_point_line_contact_info
130 // and adding contact info to the sample
131 particle_line_pairs_in_contact.emplace(particle->get_id(),
132 pair_candidates);
133 }
134 }
135}
136
137Point<3>
138find_projection_point(const Point<3> &point_p,
139 const Point<3> &point_a,
140 const Point<3> &point_b)
141{
142 Tensor<1, 3> vector_ab = point_b - point_a;
143 Tensor<1, 3> vector_ap = point_p - point_a;
144
145 Point<3> projection =
146 point_a + ((vector_ap * vector_ab) / (vector_ab * vector_ab)) * vector_ab;
147
148 return projection;
149}
150
151template void
154 &particle_point_contact_candidates,
155 const double neighborhood_threshold,
157 &particle_point_pairs_in_contact);
158
159template void
162 &particle_point_contact_candidates,
163 const double neighborhood_threshold,
165 &particle_point_pairs_in_contact);
166
167template void
170 &particle_line_contact_candidates,
171 const double neighborhood_threshold,
173 &particle_line_pairs_in_contact);
174
175template void
178 &particle_line_contact_candidates,
179 const double neighborhood_threshold,
181 &particle_line_pairs_in_contact);
182
183template void
186 &particle_point_contact_candidates,
187 const double neighborhood_threshold,
189 &particle_point_pairs_in_contact);
190
191template void
194 &particle_point_contact_candidates,
195 const double neighborhood_threshold,
197 &particle_point_pairs_in_contact);
198
199template void
202 &particle_line_contact_candidates,
203 const double neighborhood_threshold,
205 &particle_line_pairs_in_contact);
206
207template void
210 &particle_line_contact_candidates,
211 const double neighborhood_threshold,
213 &particle_line_pairs_in_contact);
214
215template void
218 &particle_point_contact_candidates,
219 const double neighborhood_threshold,
221 &particle_point_pairs_in_contact);
222
223template void
226 &particle_point_contact_candidates,
227 const double neighborhood_threshold,
229 &particle_point_pairs_in_contact);
230
231template void
234 &particle_point_contact_candidates,
235 const double neighborhood_threshold,
237 &particle_point_pairs_in_contact);
238
239template void
242 &particle_point_contact_candidates,
243 const double neighborhood_threshold,
245 &particle_point_pairs_in_contact);
246
247template void
250 &particle_line_contact_candidates,
251 const double neighborhood_threshold,
253 &particle_line_pairs_in_contact);
254
255template void
258 &particle_line_contact_candidates,
259 const double neighborhood_threshold,
261 &particle_line_pairs_in_contact);
262
263template void
266 &particle_line_contact_candidates,
267 const double neighborhood_threshold,
269 &particle_line_pairs_in_contact);
270
271template void
274 &particle_line_contact_candidates,
275 const double neighborhood_threshold,
277 &particle_line_pairs_in_contact);
DEM particle property definitions and output name management.
Point< 3 > find_projection_point(const Point< 3 > &point_p, const Point< 3 > &point_a, const Point< 3 > &point_b)
This private function is used to find the projection of point_p on a line with beginning and ending v...
template void particle_line_fine_search< 2, DEM::CFDDEMProperties::PropertiesIndex >(const DEM::dem_data_structures< 2 >::particle_line_candidates &particle_line_contact_candidates, const double neighborhood_threshold, DEM::dem_data_structures< 2 >::particle_line_in_contact &particle_line_pairs_in_contact)
template void particle_line_fine_search< 3, DEM::CFDDEMMPProperties::PropertiesIndex >(const DEM::dem_data_structures< 3 >::particle_line_candidates &particle_line_contact_candidates, const double neighborhood_threshold, DEM::dem_data_structures< 3 >::particle_line_in_contact &particle_line_pairs_in_contact)
template void particle_point_fine_search< 2, DEM::CFDDEMMPProperties::PropertiesIndex >(const DEM::dem_data_structures< 2 >::particle_point_candidates &particle_point_contact_candidates, const double neighborhood_threshold, DEM::dem_data_structures< 2 >::particle_point_in_contact &particle_point_pairs_in_contact)
template void particle_point_fine_search< 3, DEM::CFDDEMProperties::PropertiesIndex >(const DEM::dem_data_structures< 3 >::particle_point_candidates &particle_point_contact_candidates, const double neighborhood_threshold, DEM::dem_data_structures< 3 >::particle_point_in_contact &particle_point_pairs_in_contact)
void particle_line_fine_search(const typename DEM::dem_data_structures< dim >::particle_line_candidates &particle_line_contact_candidates, const double neighborhood_threshold, typename DEM::dem_data_structures< dim >::particle_line_in_contact &particle_line_pairs_in_contact)
Iterate over a map of tuples (particle_line_contact_candidates) to see if the particle-line pairs are...
template void particle_line_fine_search< 3, DEM::DEMMPProperties::PropertiesIndex >(const DEM::dem_data_structures< 3 >::particle_line_candidates &particle_line_contact_candidates, const double neighborhood_threshold, DEM::dem_data_structures< 3 >::particle_line_in_contact &particle_line_pairs_in_contact)
template void particle_point_fine_search< 2, DEM::DEMMPProperties::PropertiesIndex >(const DEM::dem_data_structures< 2 >::particle_point_candidates &particle_point_contact_candidates, const double neighborhood_threshold, DEM::dem_data_structures< 2 >::particle_point_in_contact &particle_point_pairs_in_contact)
template void particle_point_fine_search< 2, DEM::DEMProperties::PropertiesIndex >(const DEM::dem_data_structures< 2 >::particle_point_candidates &particle_point_contact_candidates, const double neighborhood_threshold, DEM::dem_data_structures< 2 >::particle_point_in_contact &particle_point_pairs_in_contact)
void particle_point_fine_search(const typename DEM::dem_data_structures< dim >::particle_point_candidates &particle_point_contact_candidates, const double neighborhood_threshold, typename DEM::dem_data_structures< dim >::particle_point_in_contact &particle_point_pairs_in_contact)
Iterate over a map of pairs (particle_point_contact_candidates) to see if the particle-point pairs ar...
template void particle_line_fine_search< 3, DEM::DEMProperties::PropertiesIndex >(const DEM::dem_data_structures< 3 >::particle_line_candidates &particle_line_contact_candidates, const double neighborhood_threshold, DEM::dem_data_structures< 3 >::particle_line_in_contact &particle_line_pairs_in_contact)
template void particle_point_fine_search< 3, DEM::CFDDEMMPProperties::PropertiesIndex >(const DEM::dem_data_structures< 3 >::particle_point_candidates &particle_point_contact_candidates, const double neighborhood_threshold, DEM::dem_data_structures< 3 >::particle_point_in_contact &particle_point_pairs_in_contact)
template void particle_point_fine_search< 2, DEM::CFDDEMProperties::PropertiesIndex >(const DEM::dem_data_structures< 2 >::particle_point_candidates &particle_point_contact_candidates, const double neighborhood_threshold, DEM::dem_data_structures< 2 >::particle_point_in_contact &particle_point_pairs_in_contact)
template void particle_line_fine_search< 2, DEM::DEMProperties::PropertiesIndex >(const DEM::dem_data_structures< 2 >::particle_line_candidates &particle_line_contact_candidates, const double neighborhood_threshold, DEM::dem_data_structures< 2 >::particle_line_in_contact &particle_line_pairs_in_contact)
template void particle_line_fine_search< 3, DEM::CFDDEMProperties::PropertiesIndex >(const DEM::dem_data_structures< 3 >::particle_line_candidates &particle_line_contact_candidates, const double neighborhood_threshold, DEM::dem_data_structures< 3 >::particle_line_in_contact &particle_line_pairs_in_contact)
template void particle_point_fine_search< 3, DEM::DEMProperties::PropertiesIndex >(const DEM::dem_data_structures< 3 >::particle_point_candidates &particle_point_contact_candidates, const double neighborhood_threshold, DEM::dem_data_structures< 3 >::particle_point_in_contact &particle_point_pairs_in_contact)
template void particle_line_fine_search< 2, DEM::CFDDEMMPProperties::PropertiesIndex >(const DEM::dem_data_structures< 2 >::particle_line_candidates &particle_line_contact_candidates, const double neighborhood_threshold, DEM::dem_data_structures< 2 >::particle_line_in_contact &particle_line_pairs_in_contact)
template void particle_line_fine_search< 2, DEM::DEMMPProperties::PropertiesIndex >(const DEM::dem_data_structures< 2 >::particle_line_candidates &particle_line_contact_candidates, const double neighborhood_threshold, DEM::dem_data_structures< 2 >::particle_line_in_contact &particle_line_pairs_in_contact)
template void particle_point_fine_search< 3, DEM::DEMMPProperties::PropertiesIndex >(const DEM::dem_data_structures< 3 >::particle_point_candidates &particle_point_contact_candidates, const double neighborhood_threshold, DEM::dem_data_structures< 3 >::particle_point_in_contact &particle_point_pairs_in_contact)
std::unordered_map< types::particle_index, particle_line_contact_info< dim > > particle_line_candidates
std::unordered_map< types::particle_index, particle_line_contact_info< dim > > particle_line_in_contact
std::unordered_map< types::particle_index, particle_point_contact_info< dim > > particle_point_candidates
std::unordered_map< types::particle_index, particle_point_contact_info< dim > > particle_point_in_contact
Handle information related to the calculation of the particle-line contact forces.
Particles::ParticleIterator< dim > particle
Handle information related to the calculation of the particle-point contact forces.
Particles::ParticleIterator< dim > particle
Point< 3 > point_nd_to_3d(const Point< dim > &point)