Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
particle_particle_broad_search.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2020-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
6
7using namespace DEM;
8
9template <int dim>
10void
12 dealii::Particles::ParticleHandler<dim> &particle_handler,
14 &cells_local_neighbor_list,
16 &cells_ghost_neighbor_list,
18 &local_contact_pair_candidates,
20 &ghost_contact_pair_candidates)
21{
22 // Clear containers
23 local_contact_pair_candidates.clear();
24 ghost_contact_pair_candidates.clear();
25
26 // First we handle the local-local candidate pairs
27 // Looping over the potential cells which may contain particles.
28 // This includes the cell itself as well as the neighbouring cells that
29 // were identified.
30 // cell_neighbor_list_iterator is [cell_it, neighbor_0_it, neighbor_1_it, ...]
31 for (auto cell_neighbor_list_iterator = cells_local_neighbor_list.begin();
32 cell_neighbor_list_iterator != cells_local_neighbor_list.end();
33 ++cell_neighbor_list_iterator)
34 {
35 // The main cell
36 auto cell_neighbor_iterator = cell_neighbor_list_iterator->begin();
37
38 // Particles in the main cell
39 typename Particles::ParticleHandler<dim>::particle_iterator_range
40 particles_in_main_cell =
41 particle_handler.particles_in_cell(*cell_neighbor_iterator);
42
43 const bool particles_exist_in_main_cell = !particles_in_main_cell.empty();
44
45 // Check to see if the main cell has any particles
46 if (particles_exist_in_main_cell)
47 {
48 // Find local-local collision pairs in the main cell, 1st particle
49 // iterator is skipped since the main particle will not be
50 // considered as collision partner with itself
51 for (auto particle_in_main_cell = particles_in_main_cell.begin();
52 particle_in_main_cell != particles_in_main_cell.end();
53 ++particle_in_main_cell)
54 {
55 store_candidates<dim>(particle_in_main_cell->get_id(),
56 std::next(particle_in_main_cell, 1),
57 particles_in_main_cell,
58 local_contact_pair_candidates);
59 }
60
61 // Going through neighbor cells of the main cell
62 ++cell_neighbor_iterator;
63 for (; cell_neighbor_iterator != cell_neighbor_list_iterator->end();
64 ++cell_neighbor_iterator)
65 {
66 // Defining iterator on local particles in the neighbor cell
67 typename Particles::ParticleHandler<dim>::particle_iterator_range
68 particles_in_neighbor_cell =
69 particle_handler.particles_in_cell(*cell_neighbor_iterator);
70
71 // Capturing particle pairs, the first particle in the main
72 // cell and the second particle in the neighbor cells
73 for (auto particle_in_main_cell = particles_in_main_cell.begin();
74 particle_in_main_cell != particles_in_main_cell.end();
75 ++particle_in_main_cell)
76 {
77 store_candidates<dim>(particle_in_main_cell->get_id(),
78 particles_in_neighbor_cell.begin(),
79 particles_in_neighbor_cell,
80 local_contact_pair_candidates);
81 }
82 }
83 }
84 }
85
86 // Now we go through the local-ghost pairs (the first iterator shows a local
87 // particles, and the second a ghost particle)
88
89 // Looping over cells_ghost_neighbor_list
90 for (auto cell_neighbor_list_iterator = cells_ghost_neighbor_list.begin();
91 cell_neighbor_list_iterator != cells_ghost_neighbor_list.end();
92 ++cell_neighbor_list_iterator)
93 {
94 // The main cell
95 auto cell_neighbor_iterator = cell_neighbor_list_iterator->begin();
96
97 // Particles in the main cell
98 typename Particles::ParticleHandler<dim>::particle_iterator_range
99 particles_in_main_cell =
100 particle_handler.particles_in_cell(*cell_neighbor_iterator);
101
102 const bool particles_exist_in_main_cell = !particles_in_main_cell.empty();
103
104 if (particles_exist_in_main_cell)
105 {
106 // Going through ghost neighbor cells of the main cell
107 ++cell_neighbor_iterator;
108
109 for (; cell_neighbor_iterator != cell_neighbor_list_iterator->end();
110 ++cell_neighbor_iterator)
111 {
112 // Defining iterator on ghost particles in the neighbor cells
113 typename Particles::ParticleHandler<dim>::particle_iterator_range
114 particles_in_neighbor_cell =
115 particle_handler.particles_in_cell(*cell_neighbor_iterator);
116
117 // Capturing particle pairs, the first particle (local) in
118 // the main cell and the second particle (ghost) in the
119 // neighbor cells
120 for (auto particle_in_main_cell = particles_in_main_cell.begin();
121 particle_in_main_cell != particles_in_main_cell.end();
122 ++particle_in_main_cell)
123 {
124 store_candidates<dim>(particle_in_main_cell->get_id(),
125 particles_in_neighbor_cell.begin(),
126 particles_in_neighbor_cell,
127 ghost_contact_pair_candidates);
128 }
129 }
130 }
131 }
132}
133
134template <int dim, typename PropertiesIndex>
135void
137 dealii::Particles::ParticleHandler<dim> &particle_handler,
139 &cells_local_neighbor_list,
141 &cells_ghost_neighbor_list,
143 &local_contact_pair_candidates,
145 &ghost_contact_pair_candidates,
146 const AdaptiveSparseContacts<dim, PropertiesIndex> &sparse_contacts_object)
147{
148 // Clear containers
149 local_contact_pair_candidates.clear();
150 ghost_contact_pair_candidates.clear();
151
152 // First we handle the local-local candidate pairs
153
154 // Looping over the potential cells which may contain particles.
155 // This includes the cell itself as well as the neighbouring cells that
156 // were identified.
157 // cell_neighbor_list_iterator is [cell_it, neighbor_0_it, neighbor_1_it, ...]
158 for (auto cell_neighbor_list_iterator = cells_local_neighbor_list.begin();
159 cell_neighbor_list_iterator != cells_local_neighbor_list.end();
160 ++cell_neighbor_list_iterator)
161 {
162 // The main cell & its mobility status
163 auto cell_neighbor_iterator = cell_neighbor_list_iterator->begin();
164 unsigned int main_cell_mobility_status =
165 sparse_contacts_object.check_cell_mobility(*cell_neighbor_iterator);
166
167 // If main cell has status inactive or advected, skip to next main
168 // cell No needs to check if the main cell has any particle after this
169 // step since empty cells have inactive or advected mobility status
170 // and are skipped
171 if (main_cell_mobility_status ==
173 main_cell_mobility_status ==
175 continue;
176
177 // Get particles in the main cell
178 typename Particles::ParticleHandler<dim>::particle_iterator_range
179 particles_in_main_cell =
180 particle_handler.particles_in_cell(*cell_neighbor_iterator);
181
182 // Store other particles in the main cell as contact candidates if
183 // main cell is mobile only (this is equivalent to when adaptive sparse
184 // contacts feature is not enabled)
185 if (main_cell_mobility_status ==
187 {
188 // Find local-local collision pairs in the main cell, 1st particle
189 // iterator is skipped since the main particle will not be
190 // considered as collision partner with itself
191 for (auto particle_in_main_cell = particles_in_main_cell.begin();
192 particle_in_main_cell != particles_in_main_cell.end();
193 ++particle_in_main_cell)
194 {
195 store_candidates<dim>(particle_in_main_cell->get_id(),
196 std::next(particle_in_main_cell, 1),
197 particles_in_main_cell,
198 local_contact_pair_candidates);
199 }
200 }
201
202 // Going through neighbor cells of the main cell
203 ++cell_neighbor_iterator;
204 for (; cell_neighbor_iterator != cell_neighbor_list_iterator->end();
205 ++cell_neighbor_iterator)
206 {
207 // Get mobility status of current neighbor cell
208 unsigned int neighbor_cell_mobility_status =
209 sparse_contacts_object.check_cell_mobility(*cell_neighbor_iterator);
210
211 // No storing of particles as candidate if main cell has any active
212 // status, but neighbor is not mobile (active or inactive). Particle
213 // contacts between particles in 2 active cells or with particles in
214 // inactive cells are irrelevant. In this case, we skip this neighbor
215 // cell.
216 if (neighbor_cell_mobility_status !=
218 {
219 if (main_cell_mobility_status ==
221 continue;
222 if (main_cell_mobility_status ==
224 continue;
225 }
226
227 // Store particles in the neighbor cell as contact candidates
228 typename Particles::ParticleHandler<dim>::particle_iterator_range
229 particles_in_neighbor_cell =
230 particle_handler.particles_in_cell(*cell_neighbor_iterator);
231 for (auto particle_in_main_cell = particles_in_main_cell.begin();
232 particle_in_main_cell != particles_in_main_cell.end();
233 ++particle_in_main_cell)
234 {
235 store_candidates<dim>(particle_in_main_cell->get_id(),
236 particles_in_neighbor_cell.begin(),
237 particles_in_neighbor_cell,
238 local_contact_pair_candidates);
239 }
240 }
241 }
242
243 // Now we go through the local-ghost pairs (the first iterator shows a local
244 // particles, and the second a ghost particle)
245
246 // Looping over cells_ghost_neighbor_list
247 for (auto cell_neighbor_list_iterator = cells_ghost_neighbor_list.begin();
248 cell_neighbor_list_iterator != cells_ghost_neighbor_list.end();
249 ++cell_neighbor_list_iterator)
250 {
251 // The main cell & its mobility status
252 auto cell_neighbor_iterator = cell_neighbor_list_iterator->begin();
253 unsigned int main_cell_mobility_status =
254 sparse_contacts_object.check_cell_mobility(*cell_neighbor_iterator);
255
256 // If main cell has status inactive or advected, skip to next main
257 // cell No needs to check if the main cell has any particle after this
258 // step since empty cells have inactive or advected mobility status and
259 // are skipped
260 if (main_cell_mobility_status ==
262 main_cell_mobility_status ==
264 continue;
265
266 // Particles in the main cell
267 typename Particles::ParticleHandler<dim>::particle_iterator_range
268 particles_in_main_cell =
269 particle_handler.particles_in_cell(*cell_neighbor_iterator);
270
271
272 // Going through ghost neighbor cells of the main cell
273 ++cell_neighbor_iterator;
274 for (; cell_neighbor_iterator != cell_neighbor_list_iterator->end();
275 ++cell_neighbor_iterator)
276 {
277 unsigned int neighbor_cell_mobility_status =
278 sparse_contacts_object.check_cell_mobility(*cell_neighbor_iterator);
279
280 // No storing of particles as candidate if main cell is active
281 // but neighbor is not mobile
282 if (neighbor_cell_mobility_status !=
284 {
285 if (main_cell_mobility_status ==
287 continue;
288 if (main_cell_mobility_status ==
290 continue;
291 }
292
293
294 // Defining iterator on ghost particles in the neighbor cells
295 typename Particles::ParticleHandler<dim>::particle_iterator_range
296 particles_in_neighbor_cell =
297 particle_handler.particles_in_cell(*cell_neighbor_iterator);
298
299 // Capturing particle pairs, the first particle (local) in
300 // the main cell and the second particle (ghost) in the
301 // neighbor cells
302 for (auto particle_in_main_cell = particles_in_main_cell.begin();
303 particle_in_main_cell != particles_in_main_cell.end();
304 ++particle_in_main_cell)
305 {
306 store_candidates<dim>(particle_in_main_cell->get_id(),
307 particles_in_neighbor_cell.begin(),
308 particles_in_neighbor_cell,
309 ghost_contact_pair_candidates);
310 }
311 }
312 }
313}
314
315
316template <int dim>
317void
319 dealii::Particles::ParticleHandler<dim> &particle_handler,
321 &cells_local_periodic_neighbor_list,
323 &cells_ghost_periodic_neighbor_list,
325 &cells_ghost_local_periodic_neighbor_list,
327 &local_contact_pair_periodic_candidates,
329 &ghost_contact_pair_periodic_candidates,
331 &ghost_local_contact_pair_periodic_candidates)
332{
333 // Clear containers
334 local_contact_pair_periodic_candidates.clear();
335 ghost_contact_pair_periodic_candidates.clear();
336 ghost_local_contact_pair_periodic_candidates.clear();
337
338 // Looping over the potential periodic cells which may contain particles.
339 for (auto cell_periodic_neighbor_list_iterator =
340 cells_local_periodic_neighbor_list.begin();
341 cell_periodic_neighbor_list_iterator !=
342 cells_local_periodic_neighbor_list.end();
343 ++cell_periodic_neighbor_list_iterator)
344 {
345 // The main cell is on periodic boundary 0
346 auto cell_periodic_neighbor_iterator =
347 cell_periodic_neighbor_list_iterator->begin();
348
349 // Particles in the main cell
350 typename Particles::ParticleHandler<dim>::particle_iterator_range
351 particles_in_main_cell =
352 particle_handler.particles_in_cell(*cell_periodic_neighbor_iterator);
353
354 const bool particles_exist_in_main_cell = !particles_in_main_cell.empty();
355
356 // Check to see if the main cell has any particles
357 if (particles_exist_in_main_cell)
358 {
359 // Going through periodic neighbor cells on the periodic boundary 1
360 // of the main cell. We start at the second iterator since the first
361 // one is the main cell.
362 ++cell_periodic_neighbor_iterator;
363 for (; cell_periodic_neighbor_iterator !=
364 cell_periodic_neighbor_list_iterator->end();
365 ++cell_periodic_neighbor_iterator)
366 {
367 // Defining iterator on particles in the local periodic neighbor
368 // cell
369 typename Particles::ParticleHandler<dim>::particle_iterator_range
370 particles_in_periodic_neighbor_cell =
371 particle_handler.particles_in_cell(
372 *cell_periodic_neighbor_iterator);
373
374 // Capturing particle pairs, the first particle in the main
375 // cell and the second particle in the local periodic neighbor
376 // cell
377 for (auto particle_in_main_cell = particles_in_main_cell.begin();
378 particle_in_main_cell != particles_in_main_cell.end();
379 ++particle_in_main_cell)
380 {
382 particle_in_main_cell->get_id(),
383 particles_in_periodic_neighbor_cell.begin(),
384 particles_in_periodic_neighbor_cell,
385 local_contact_pair_periodic_candidates);
386 }
387 }
388 }
389 }
390
391 // Now we go through the local-ghost pairs (the first iterator shows a local
392 // particles, and the second a ghost particle)
393
394 // Looping over cells_ghost_neighbor_list
395 for (auto cell_periodic_neighbor_list_iterator =
396 cells_ghost_periodic_neighbor_list.begin();
397 cell_periodic_neighbor_list_iterator !=
398 cells_ghost_periodic_neighbor_list.end();
399 ++cell_periodic_neighbor_list_iterator)
400 {
401 // The main cell
402 auto cell_periodic_neighbor_iterator =
403 cell_periodic_neighbor_list_iterator->begin();
404
405 // Particles in the main cell
406 typename Particles::ParticleHandler<dim>::particle_iterator_range
407 particles_in_main_cell =
408 particle_handler.particles_in_cell(*cell_periodic_neighbor_iterator);
409
410 const bool particles_exist_in_main_cell = !particles_in_main_cell.empty();
411
412 if (particles_exist_in_main_cell)
413 {
414 // Going through ghost neighbor cells of the main cell
415 ++cell_periodic_neighbor_iterator;
416
417 for (; cell_periodic_neighbor_iterator !=
418 cell_periodic_neighbor_list_iterator->end();
419 ++cell_periodic_neighbor_iterator)
420 {
421 // Defining iterator on ghost particles in the neighbor cells
422 typename Particles::ParticleHandler<dim>::particle_iterator_range
423 particles_in_periodic_neighbor_cell =
424 particle_handler.particles_in_cell(
425 *cell_periodic_neighbor_iterator);
426
427 // Capturing particle pairs, the first particle (local) in
428 // the main cell and the second particle (ghost) in the
429 // neighbor cells
430 for (auto particle_in_main_cell = particles_in_main_cell.begin();
431 particle_in_main_cell != particles_in_main_cell.end();
432 ++particle_in_main_cell)
433 {
435 particle_in_main_cell->get_id(),
436 particles_in_periodic_neighbor_cell.begin(),
437 particles_in_periodic_neighbor_cell,
438 ghost_contact_pair_periodic_candidates);
439 }
440 }
441 }
442 }
443
444 // Looping over cells_ghost_local_periodic_neighbor_list
445 for (auto cell_periodic_neighbor_list_iterator =
446 cells_ghost_local_periodic_neighbor_list.begin();
447 cell_periodic_neighbor_list_iterator !=
448 cells_ghost_local_periodic_neighbor_list.end();
449 ++cell_periodic_neighbor_list_iterator)
450 {
451 // The main cell
452 auto cell_periodic_neighbor_iterator =
453 cell_periodic_neighbor_list_iterator->begin();
454
455 // Particles in the main cell
456 typename Particles::ParticleHandler<dim>::particle_iterator_range
457 particles_in_main_cell =
458 particle_handler.particles_in_cell(*cell_periodic_neighbor_iterator);
459
460 const bool particles_exist_in_main_cell = !particles_in_main_cell.empty();
461
462 if (particles_exist_in_main_cell)
463 {
464 // Going through ghost neighbor cells of the main cell
465 ++cell_periodic_neighbor_iterator;
466
467 for (; cell_periodic_neighbor_iterator !=
468 cell_periodic_neighbor_list_iterator->end();
469 ++cell_periodic_neighbor_iterator)
470 {
471 // Defining iterator on local particles in the neighbor cells
472 typename Particles::ParticleHandler<dim>::particle_iterator_range
473 particles_in_periodic_neighbor_cell =
474 particle_handler.particles_in_cell(
475 *cell_periodic_neighbor_iterator);
476
477 // Capturing particle pairs, the first particle (ghost) in
478 // the main cell and the second particles (local) in the
479 // neighbor cells
480 for (auto particle_in_main_cell = particles_in_main_cell.begin();
481 particle_in_main_cell != particles_in_main_cell.end();
482 ++particle_in_main_cell)
483 {
485 particle_in_main_cell->get_id(),
486 particles_in_periodic_neighbor_cell.begin(),
487 particles_in_periodic_neighbor_cell,
488 ghost_local_contact_pair_periodic_candidates);
489 }
490 }
491 }
492 }
493}
494
495template <int dim, typename PropertiesIndex>
496void
498 dealii::Particles::ParticleHandler<dim> &particle_handler,
500 &cells_local_periodic_neighbor_list,
502 &cells_ghost_periodic_neighbor_list,
504 &cells_ghost_local_periodic_neighbor_list,
506 &local_contact_pair_periodic_candidates,
508 &ghost_contact_pair_periodic_candidates,
510 &ghost_local_contact_pair_periodic_candidates,
511 const AdaptiveSparseContacts<dim, PropertiesIndex> &sparse_contacts_object)
512{
513 // Clear containers
514 local_contact_pair_periodic_candidates.clear();
515 ghost_contact_pair_periodic_candidates.clear();
516 ghost_local_contact_pair_periodic_candidates.clear();
517
518 // Looping over the potential periodic cells which may contain particles.
519 for (auto cell_periodic_neighbor_list_iterator =
520 cells_local_periodic_neighbor_list.begin();
521 cell_periodic_neighbor_list_iterator !=
522 cells_local_periodic_neighbor_list.end();
523 ++cell_periodic_neighbor_list_iterator)
524 {
525 // The main cell on periodic boundary 0 & its mobility status
526 auto cell_periodic_neighbor_iterator =
527 cell_periodic_neighbor_list_iterator->begin();
528 unsigned int main_cell_mobility_status =
529 sparse_contacts_object.check_cell_mobility(
530 *cell_periodic_neighbor_iterator);
531
532 // If main cell has status inactive or advected, skip to next main cell
533 // No needs to check if the main cell has any particle after this
534 // step since empty cells have inactive or advected mobility status
535 // and are skipped
536 if (main_cell_mobility_status ==
538 main_cell_mobility_status ==
540 continue;
541
542 // Particles in the main cell
543 typename Particles::ParticleHandler<dim>::particle_iterator_range
544 particles_in_main_cell =
545 particle_handler.particles_in_cell(*cell_periodic_neighbor_iterator);
546
547 // Going through periodic neighbor cells on the periodic boundary 1
548 // of the main cell
549 ++cell_periodic_neighbor_iterator;
550 for (; cell_periodic_neighbor_iterator !=
551 cell_periodic_neighbor_list_iterator->end();
552 ++cell_periodic_neighbor_iterator)
553 {
554 unsigned int neighbor_cell_mobility_status =
555 sparse_contacts_object.check_cell_mobility(
556 *cell_periodic_neighbor_iterator);
557
558 // No storing of particles if main cell is active but neighbor is
559 // not mobile
560 if ((main_cell_mobility_status ==
562 main_cell_mobility_status ==
564 PropertiesIndex>::advected_active) &&
565 neighbor_cell_mobility_status !=
567 continue;
568
569 // Defining iterator on local particles in the periodic neighbor
570 // cell
571 typename Particles::ParticleHandler<dim>::particle_iterator_range
572 particles_in_periodic_neighbor_cell =
573 particle_handler.particles_in_cell(
574 *cell_periodic_neighbor_iterator);
575
576 // Capturing particle pairs, the first particle in the main
577 // cell and the second particle in the neighbor cells
578 for (auto particle_in_main_cell = particles_in_main_cell.begin();
579 particle_in_main_cell != particles_in_main_cell.end();
580 ++particle_in_main_cell)
581 {
582 store_candidates<dim>(particle_in_main_cell->get_id(),
583 particles_in_periodic_neighbor_cell.begin(),
584 particles_in_periodic_neighbor_cell,
585 local_contact_pair_periodic_candidates);
586 }
587 }
588 }
589
590 // Now we go through the local-ghost pairs (the first iterator shows a local
591 // particles, and the second a ghost particle)
592 for (auto cell_periodic_neighbor_list_iterator =
593 cells_ghost_periodic_neighbor_list.begin();
594 cell_periodic_neighbor_list_iterator !=
595 cells_ghost_periodic_neighbor_list.end();
596 ++cell_periodic_neighbor_list_iterator)
597 {
598 // The main cell & its mobility status
599 auto cell_periodic_neighbor_iterator =
600 cell_periodic_neighbor_list_iterator->begin();
601 unsigned int main_cell_mobility_status =
602 sparse_contacts_object.check_cell_mobility(
603 *cell_periodic_neighbor_iterator);
604
605 // If main cell has status inactive or advected, skip to next main
606 // cell No needs to check if the main cell has any particle after this
607 // step since empty cells have inactive or advected mobility status
608 // and are skipped
609 if (main_cell_mobility_status ==
611 main_cell_mobility_status ==
613 continue;
614
615 // Particles in the main cell
616 typename Particles::ParticleHandler<dim>::particle_iterator_range
617 particles_in_main_cell =
618 particle_handler.particles_in_cell(*cell_periodic_neighbor_iterator);
619
620 // Going through ghost neighbor cells of the main cell
621 ++cell_periodic_neighbor_iterator;
622 for (; cell_periodic_neighbor_iterator !=
623 cell_periodic_neighbor_list_iterator->end();
624 ++cell_periodic_neighbor_iterator)
625 {
626 unsigned int neighbor_cell_mobility_status =
627 sparse_contacts_object.check_cell_mobility(
628 *cell_periodic_neighbor_iterator);
629
630 // No storing of particles if main cell is active but neighbor is
631 // not mobile
632 if ((main_cell_mobility_status ==
634 main_cell_mobility_status ==
636 PropertiesIndex>::advected_active) &&
637 neighbor_cell_mobility_status !=
639 continue;
640
641 // Defining iterator on ghost particles in the neighbor cells
642 typename Particles::ParticleHandler<dim>::particle_iterator_range
643 particles_in_periodic_neighbor_cell =
644 particle_handler.particles_in_cell(
645 *cell_periodic_neighbor_iterator);
646
647 // Capturing particle pairs, the first particle (local) in
648 // the main cell and the second particle (ghost) in the
649 // neighbor cells
650 for (auto particle_in_main_cell = particles_in_main_cell.begin();
651 particle_in_main_cell != particles_in_main_cell.end();
652 ++particle_in_main_cell)
653 {
654 store_candidates<dim>(particle_in_main_cell->get_id(),
655 particles_in_periodic_neighbor_cell.begin(),
656 particles_in_periodic_neighbor_cell,
657 ghost_contact_pair_periodic_candidates);
658 }
659 }
660 }
661
662 // Looping over cells_ghost_local_periodic_neighbor_list
663 for (auto cell_periodic_neighbor_list_iterator =
664 cells_ghost_local_periodic_neighbor_list.begin();
665 cell_periodic_neighbor_list_iterator !=
666 cells_ghost_local_periodic_neighbor_list.end();
667 ++cell_periodic_neighbor_list_iterator)
668 {
669 // The main cell
670 auto cell_periodic_neighbor_iterator =
671 cell_periodic_neighbor_list_iterator->begin();
672
673 // If main cell has status inactive or advected, skip to next main
674 // cell No needs to check if the main cell has any particle after this
675 // step since empty cells have inactive or advected mobility status
676 // and are skipped
677 unsigned int main_cell_mobility_status =
678 sparse_contacts_object.check_cell_mobility(
679 *cell_periodic_neighbor_iterator);
680 if (main_cell_mobility_status ==
682 main_cell_mobility_status ==
684 continue;
685
686 // Particles in the main cell
687 typename Particles::ParticleHandler<dim>::particle_iterator_range
688 particles_in_main_cell =
689 particle_handler.particles_in_cell(*cell_periodic_neighbor_iterator);
690
691 // Going through ghost neighbor cells of the main cell
692 ++cell_periodic_neighbor_iterator;
693 for (; cell_periodic_neighbor_iterator !=
694 cell_periodic_neighbor_list_iterator->end();
695 ++cell_periodic_neighbor_iterator)
696 {
697 unsigned int neighbor_cell_mobility_status =
698 sparse_contacts_object.check_cell_mobility(
699 *cell_periodic_neighbor_iterator);
700
701 // No storing of particles if main cell is active but neighbor is
702 // not mobile
703 if ((main_cell_mobility_status ==
705 main_cell_mobility_status ==
707 PropertiesIndex>::advected_active) &&
708 neighbor_cell_mobility_status !=
710 continue;
711
712 // Defining iterator on local particles in the neighbor cells
713 typename Particles::ParticleHandler<dim>::particle_iterator_range
714 particles_in_periodic_neighbor_cell =
715 particle_handler.particles_in_cell(
716 *cell_periodic_neighbor_iterator);
717
718 // Capturing particle pairs, the first particle (ghost) in
719 // the main cell and the second particles (local) in the
720 // neighbor cells
721 for (auto particle_in_main_cell = particles_in_main_cell.begin();
722 particle_in_main_cell != particles_in_main_cell.end();
723 ++particle_in_main_cell)
724 {
726 particle_in_main_cell->get_id(),
727 particles_in_periodic_neighbor_cell.begin(),
728 particles_in_periodic_neighbor_cell,
729 ghost_local_contact_pair_periodic_candidates);
730 }
731 }
732 }
733}
734
735template <int dim>
736void
738 const types::particle_index &main_particle_id,
739 const typename Particles::ParticleHandler<
740 dim>::particle_iterator_range::iterator &particle_begin,
741 const typename Particles::ParticleHandler<dim>::particle_iterator_range
742 &particles_to_evaluate,
744 &contact_pair_candidates)
745{
746 // Find the contact candidate container of the main particle
747 auto [candidates_container_it, inserted] =
748 contact_pair_candidates.try_emplace(main_particle_id);
749
750 // Reserve arbitrary vector capacity and store if the particle does not have
751 // contact candidate yet
752 if (inserted)
753 {
754 // This 40 is arbitrary and will need to be monitored. Some initial
755 // tests suggest that 60 might be a more adequate number.
756 candidates_container_it->second.reserve(40);
757 }
758
759 // Store particle ids from the selected particle iterator
760 for (auto particle_iterator = particle_begin;
761 particle_iterator != particles_to_evaluate.end();
762 ++particle_iterator)
763 {
764 candidates_container_it->second.emplace_back(particle_iterator->get_id());
765 }
766}
767
768template void
770 dealii::Particles::ParticleHandler<2> &particle_handler,
772 &cells_local_neighbor_list,
774 &cells_ghost_neighbor_list,
776 &local_contact_pair_candidates,
778 &ghost_contact_pair_candidates);
779
780template void
782 dealii::Particles::ParticleHandler<3> &particle_handler,
784 &cells_local_neighbor_list,
786 &cells_ghost_neighbor_list,
788 &local_contact_pair_candidates,
790 &ghost_contact_pair_candidates);
791
792template void
794 dealii::Particles::ParticleHandler<2> &particle_handler,
796 &cells_local_neighbor_list,
798 &cells_ghost_neighbor_list,
800 &local_contact_pair_candidates,
802 &ghost_contact_pair_candidates,
804 &sparse_contacts_object);
805
806template void
808 dealii::Particles::ParticleHandler<3> &particle_handler,
810 &cells_local_neighbor_list,
812 &cells_ghost_neighbor_list,
814 &local_contact_pair_candidates,
816 &ghost_contact_pair_candidates,
818 &sparse_contacts_object);
819
820template void
822 dealii::Particles::ParticleHandler<2> &particle_handler,
824 &cells_local_periodic_neighbor_list,
826 &cells_ghost_periodic_neighbor_list,
828 &cells_ghost_local_neighbor_list,
830 &local_contact_pair_periodic_candidates,
832 &ghost_contact_pair_periodic_candidates,
834 &ghost_local_contact_pair_periodic_candidates);
835
836template void
838 dealii::Particles::ParticleHandler<3> &particle_handler,
840 &cells_local_periodic_neighbor_list,
842 &cells_ghost_periodic_neighbor_list,
844 &cells_ghost_local_neighbor_list,
846 &local_contact_pair_periodic_candidates,
848 &ghost_contact_pair_periodic_candidates,
850 &ghost_local_contact_pair_periodic_candidates);
851
852template void
854 dealii::Particles::ParticleHandler<2> &particle_handler,
856 &cells_local_periodic_neighbor_list,
858 &cells_ghost_periodic_neighbor_list,
860 &cells_ghost_local_neighbor_list,
862 &local_contact_pair_periodic_candidates,
864 &ghost_contact_pair_periodic_candidates,
866 &ghost_local_contact_pair_periodic_candidates,
868 &sparse_contacts_object);
869
870template void
872 dealii::Particles::ParticleHandler<3> &particle_handler,
874 &cells_local_periodic_neighbor_list,
876 &cells_ghost_periodic_neighbor_list,
878 &cells_ghost_local_neighbor_list,
880 &local_contact_pair_periodic_candidates,
882 &ghost_contact_pair_periodic_candidates,
884 &ghost_local_contact_pair_periodic_candidates,
886 &sparse_contacts_object);
887
888template void
890 dealii::Particles::ParticleHandler<2> &particle_handler,
892 &cells_local_neighbor_list,
894 &cells_ghost_neighbor_list,
896 &local_contact_pair_candidates,
898 &ghost_contact_pair_candidates,
900 &sparse_contacts_object);
901
902template void
904 dealii::Particles::ParticleHandler<3> &particle_handler,
906 &cells_local_neighbor_list,
908 &cells_ghost_neighbor_list,
910 &local_contact_pair_candidates,
912 &ghost_contact_pair_candidates,
914 &sparse_contacts_object);
915
916template void
918 dealii::Particles::ParticleHandler<2> &particle_handler,
920 &cells_local_periodic_neighbor_list,
922 &cells_ghost_periodic_neighbor_list,
924 &cells_ghost_local_neighbor_list,
926 &local_contact_pair_periodic_candidates,
928 &ghost_contact_pair_periodic_candidates,
930 &ghost_local_contact_pair_periodic_candidates,
932 &sparse_contacts_object);
933
934template void
936 dealii::Particles::ParticleHandler<3> &particle_handler,
938 &cells_local_periodic_neighbor_list,
940 &cells_ghost_periodic_neighbor_list,
942 &cells_ghost_local_neighbor_list,
944 &local_contact_pair_periodic_candidates,
946 &ghost_contact_pair_periodic_candidates,
948 &ghost_local_contact_pair_periodic_candidates,
950 &sparse_contacts_object);
951
952template void
954 dealii::Particles::ParticleHandler<2> &particle_handler,
956 &cells_local_neighbor_list,
958 &cells_ghost_neighbor_list,
960 &local_contact_pair_candidates,
962 &ghost_contact_pair_candidates,
964 &sparse_contacts_object);
965
966template void
969 dealii::Particles::ParticleHandler<2> &particle_handler,
971 &cells_local_neighbor_list,
973 &cells_ghost_neighbor_list,
975 &local_contact_pair_candidates,
977 &ghost_contact_pair_candidates,
979 &sparse_contacts_object);
980
981template void
983 dealii::Particles::ParticleHandler<3> &particle_handler,
985 &cells_local_neighbor_list,
987 &cells_ghost_neighbor_list,
989 &local_contact_pair_candidates,
991 &ghost_contact_pair_candidates,
993 &sparse_contacts_object);
994
995template void
998 dealii::Particles::ParticleHandler<3> &particle_handler,
1000 &cells_local_neighbor_list,
1002 &cells_ghost_neighbor_list,
1004 &local_contact_pair_candidates,
1006 &ghost_contact_pair_candidates,
1008 &sparse_contacts_object);
1009
1010template void
1012 dealii::Particles::ParticleHandler<2> &particle_handler,
1014 &cells_local_periodic_neighbor_list,
1016 &cells_ghost_periodic_neighbor_list,
1018 &cells_ghost_local_neighbor_list,
1020 &local_contact_pair_periodic_candidates,
1022 &ghost_contact_pair_periodic_candidates,
1024 &ghost_local_contact_pair_periodic_candidates,
1026 &sparse_contacts_object);
1027
1028template void
1030 dealii::Particles::ParticleHandler<2> &particle_handler,
1032 &cells_local_periodic_neighbor_list,
1034 &cells_ghost_periodic_neighbor_list,
1036 &cells_ghost_local_neighbor_list,
1038 &local_contact_pair_periodic_candidates,
1040 &ghost_contact_pair_periodic_candidates,
1042 &ghost_local_contact_pair_periodic_candidates,
1044 &sparse_contacts_object);
1045
1046template void
1048 dealii::Particles::ParticleHandler<3> &particle_handler,
1050 &cells_local_periodic_neighbor_list,
1052 &cells_ghost_periodic_neighbor_list,
1054 &cells_ghost_local_neighbor_list,
1056 &local_contact_pair_periodic_candidates,
1058 &ghost_contact_pair_periodic_candidates,
1060 &ghost_local_contact_pair_periodic_candidates,
1062 &sparse_contacts_object);
1063
1064template void
1066 dealii::Particles::ParticleHandler<3> &particle_handler,
1068 &cells_local_periodic_neighbor_list,
1070 &cells_ghost_periodic_neighbor_list,
1072 &cells_ghost_local_neighbor_list,
1074 &local_contact_pair_periodic_candidates,
1076 &ghost_contact_pair_periodic_candidates,
1078 &ghost_local_contact_pair_periodic_candidates,
1080 &sparse_contacts_object);
Mechanism that disables contacts computation through mobility status of cells based on granular tempe...
unsigned int check_cell_mobility(const typename Triangulation< dim >::active_cell_iterator &cell) const
Find the mobility status of a cell.
PropertiesIndex
Particle property indices for CFD-DEM multiphysics simulations.
This namespace defines all the data containers and required operations on these containers for the DE...
void find_particle_particle_periodic_contact_pairs(dealii::Particles::ParticleHandler< dim > &particle_handler, const typename dem_data_structures< dim >::cells_neighbor_list &cells_local_periodic_neighbor_list, const typename dem_data_structures< dim >::cells_neighbor_list &cells_ghost_periodic_neighbor_list, const typename dem_data_structures< dim >::cells_neighbor_list &cells_ghost_local_periodic_neighbor_list, typename dem_data_structures< dim >::particle_particle_candidates &local_contact_pair_periodic_candidates, typename dem_data_structures< dim >::particle_particle_candidates &ghost_contact_pair_periodic_candidates, typename dem_data_structures< dim >::particle_particle_candidates &ghost_local_contact_pair_periodic_candidates)
Finds vectors of pairs (particle_particle_candidates) which contains the candidate particle-particle ...
template void find_particle_particle_contact_pairs< 2, DEM::DEMProperties::PropertiesIndex >(dealii::Particles::ParticleHandler< 2 > &particle_handler, const typename dem_data_structures< 2 >::cells_neighbor_list &cells_local_neighbor_list, const typename dem_data_structures< 2 >::cells_neighbor_list &cells_ghost_neighbor_list, typename dem_data_structures< 2 >::particle_particle_candidates &local_contact_pair_candidates, typename dem_data_structures< 2 >::particle_particle_candidates &ghost_contact_pair_candidates, const AdaptiveSparseContacts< 2, DEM::DEMProperties::PropertiesIndex > &sparse_contacts_object)
template void find_particle_particle_contact_pairs< 2 >(dealii::Particles::ParticleHandler< 2 > &particle_handler, const typename dem_data_structures< 2 >::cells_neighbor_list &cells_local_neighbor_list, const typename dem_data_structures< 2 >::cells_neighbor_list &cells_ghost_neighbor_list, typename dem_data_structures< 2 >::particle_particle_candidates &local_contact_pair_candidates, typename dem_data_structures< 2 >::particle_particle_candidates &ghost_contact_pair_candidates)
template void find_particle_particle_contact_pairs< 3, DEM::CFDDEMProperties::PropertiesIndex >(dealii::Particles::ParticleHandler< 3 > &particle_handler, const typename dem_data_structures< 3 >::cells_neighbor_list &cells_local_neighbor_list, const typename dem_data_structures< 3 >::cells_neighbor_list &cells_ghost_neighbor_list, typename dem_data_structures< 3 >::particle_particle_candidates &local_contact_pair_candidates, typename dem_data_structures< 3 >::particle_particle_candidates &ghost_contact_pair_candidates, const AdaptiveSparseContacts< 3, DEM::CFDDEMProperties::PropertiesIndex > &sparse_contacts_object)
template void find_particle_particle_contact_pairs< 3, DEM::DEMMPProperties::PropertiesIndex >(dealii::Particles::ParticleHandler< 3 > &particle_handler, const typename dem_data_structures< 3 >::cells_neighbor_list &cells_local_neighbor_list, const typename dem_data_structures< 3 >::cells_neighbor_list &cells_ghost_neighbor_list, typename dem_data_structures< 3 >::particle_particle_candidates &local_contact_pair_candidates, typename dem_data_structures< 3 >::particle_particle_candidates &ghost_contact_pair_candidates, const AdaptiveSparseContacts< 3, DEM::DEMMPProperties::PropertiesIndex > &sparse_contacts_object)
void find_particle_particle_contact_pairs(dealii::Particles::ParticleHandler< dim > &particle_handler, const typename dem_data_structures< dim >::cells_neighbor_list &cells_local_neighbor_list, const typename dem_data_structures< dim >::cells_neighbor_list &cells_ghost_neighbor_list, typename dem_data_structures< dim >::particle_particle_candidates &local_contact_pair_candidates, typename dem_data_structures< dim >::particle_particle_candidates &ghost_contact_pair_candidates)
Finds a vector of pairs (particle_particle_candidates) which shows the candidate particle-particle co...
void store_candidates(const types::particle_index &main_particle_id, const typename Particles::ParticleHandler< dim >::particle_iterator_range::iterator &particle_begin, const typename Particles::ParticleHandler< dim >::particle_iterator_range &particles_to_evaluate, typename dem_data_structures< dim >::particle_particle_candidates &contact_pair_candidates)
template void find_particle_particle_contact_pairs< 2, DEM::CFDDEMProperties::PropertiesIndex >(dealii::Particles::ParticleHandler< 2 > &particle_handler, const typename dem_data_structures< 2 >::cells_neighbor_list &cells_local_neighbor_list, const typename dem_data_structures< 2 >::cells_neighbor_list &cells_ghost_neighbor_list, typename dem_data_structures< 2 >::particle_particle_candidates &local_contact_pair_candidates, typename dem_data_structures< 2 >::particle_particle_candidates &ghost_contact_pair_candidates, const AdaptiveSparseContacts< 2, DEM::CFDDEMProperties::PropertiesIndex > &sparse_contacts_object)
template void find_particle_particle_contact_pairs< 3 >(dealii::Particles::ParticleHandler< 3 > &particle_handler, const typename dem_data_structures< 3 >::cells_neighbor_list &cells_local_neighbor_list, const typename dem_data_structures< 3 >::cells_neighbor_list &cells_ghost_neighbor_list, typename dem_data_structures< 3 >::particle_particle_candidates &local_contact_pair_candidates, typename dem_data_structures< 3 >::particle_particle_candidates &ghost_contact_pair_candidates)
template void find_particle_particle_contact_pairs< 3, DEM::DEMProperties::PropertiesIndex >(dealii::Particles::ParticleHandler< 3 > &particle_handler, const typename dem_data_structures< 3 >::cells_neighbor_list &cells_local_neighbor_list, const typename dem_data_structures< 3 >::cells_neighbor_list &cells_ghost_neighbor_list, typename dem_data_structures< 3 >::particle_particle_candidates &local_contact_pair_candidates, typename dem_data_structures< 3 >::particle_particle_candidates &ghost_contact_pair_candidates, const AdaptiveSparseContacts< 3, DEM::DEMProperties::PropertiesIndex > &sparse_contacts_object)
template void find_particle_particle_contact_pairs< 2, DEM::DEMMPProperties::PropertiesIndex >(dealii::Particles::ParticleHandler< 2 > &particle_handler, const typename dem_data_structures< 2 >::cells_neighbor_list &cells_local_neighbor_list, const typename dem_data_structures< 2 >::cells_neighbor_list &cells_ghost_neighbor_list, typename dem_data_structures< 2 >::particle_particle_candidates &local_contact_pair_candidates, typename dem_data_structures< 2 >::particle_particle_candidates &ghost_contact_pair_candidates, const AdaptiveSparseContacts< 2, DEM::DEMMPProperties::PropertiesIndex > &sparse_contacts_object)
template void find_particle_particle_periodic_contact_pairs< 2 >(dealii::Particles::ParticleHandler< 2 > &particle_handler, const typename dem_data_structures< 2 >::cells_neighbor_list &cells_local_periodic_neighbor_list, const typename dem_data_structures< 2 >::cells_neighbor_list &cells_ghost_periodic_neighbor_list, const typename dem_data_structures< 2 >::cells_neighbor_list &cells_ghost_local_neighbor_list, typename dem_data_structures< 2 >::particle_particle_candidates &local_contact_pair_periodic_candidates, typename dem_data_structures< 2 >::particle_particle_candidates &ghost_contact_pair_periodic_candidates, typename dem_data_structures< 2 >::particle_particle_candidates &ghost_local_contact_pair_periodic_candidates)
template void find_particle_particle_periodic_contact_pairs< 3 >(dealii::Particles::ParticleHandler< 3 > &particle_handler, const typename dem_data_structures< 3 >::cells_neighbor_list &cells_local_periodic_neighbor_list, const typename dem_data_structures< 3 >::cells_neighbor_list &cells_ghost_periodic_neighbor_list, const typename dem_data_structures< 3 >::cells_neighbor_list &cells_ghost_local_neighbor_list, typename dem_data_structures< 3 >::particle_particle_candidates &local_contact_pair_periodic_candidates, typename dem_data_structures< 3 >::particle_particle_candidates &ghost_contact_pair_periodic_candidates, typename dem_data_structures< 3 >::particle_particle_candidates &ghost_local_contact_pair_periodic_candidates)
void find_particle_particle_contact_pairs(dealii::Particles::ParticleHandler< dim > &particle_handler, const typename DEM::dem_data_structures< dim >::cells_neighbor_list &cells_local_neighbor_list, const typename DEM::dem_data_structures< dim >::cells_neighbor_list &cells_ghost_neighbor_list, typename DEM::dem_data_structures< dim >::particle_particle_candidates &local_contact_pair_candidates, typename DEM::dem_data_structures< dim >::particle_particle_candidates &ghost_contact_pair_candidates)
Finds a vector of pairs (particle_particle_candidates) which shows the candidate particle-particle co...
std::vector< std::vector< typename Triangulation< dim >::active_cell_iterator > > cells_neighbor_list
ankerl::unordered_dense::map< types::particle_index, std::vector< types::particle_index > > particle_particle_candidates