Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
find_boundary_cells_information.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
5
9
10#include <deal.II/distributed/tria.h>
11
12#include <deal.II/grid/grid_generator.h>
13#include <deal.II/grid/grid_tools.h>
14#include <deal.II/grid/tria.h>
15
16#include <boost/range/adaptor/map.hpp>
17
18using namespace dealii;
19
20// The constructor of this class is empty
21template <int dim>
23
24template <int dim>
25void
27 const parallel::distributed::Triangulation<dim> &triangulation,
28 const Parameters::Lagrangian::FloatingWalls<dim> &floating_wall_properties,
29 const std::set<types::boundary_id> &outlet_boundaries,
30 const bool &check_diamond_cells,
31 const bool &expand_particle_wall_contact_search,
32 const ConditionalOStream &pcout)
33{
42
43 const double maximal_cell_diameter =
44 GridTools::maximal_cell_diameter(triangulation);
45
46 find_boundary_cells_information(triangulation, outlet_boundaries);
47
48 // Finding boundary cells with lines and points
50
51 // Finding cells adjacent to floating walls
53 floating_wall_properties,
54 maximal_cell_diameter);
55
56 // Add cells with boundary lines to boundary cells container
58 outlet_boundaries,
59 check_diamond_cells,
60 pcout);
61
62 if (expand_particle_wall_contact_search)
63 {
65 {
66 pcout
67 << "Warning: expansion of particle-wall contact list is enabled. "
68 << std::endl
69 << "This feature is only useful in geometries with convex boundaries."
70 << std::endl;
72 }
73
75 triangulation,
76 outlet_boundaries,
79 }
80 else
81 {
83 {
84 pcout
85 << "Warning: expansion of particle-wall contact list is disabled. "
86 << std::endl
87 << "This feature is useful in geometries with convex boundaries. "
88 << std::endl;
90 }
91 }
92}
93
94template <int dim>
95void
97 const parallel::distributed::Triangulation<dim> &triangulation,
98 const std::set<types::boundary_id> &outlet_boundaries,
99 const bool &check_diamond_cells,
100 const ConditionalOStream &pcout)
101{
110
111 find_boundary_cells_information(triangulation, outlet_boundaries);
112
113 // Finding boundary cells with lines and points
115
116 // Add cells with boundary lines to boundary cells container
118 outlet_boundaries,
119 check_diamond_cells,
120 pcout);
121}
122
123// This function finds all the boundary cells and faces in the triangulation,
124// for each cell the boundary faces are specified and the normal vector as well
125// as a point on the boundary faces are obtained
126template <int dim>
127void
129 const parallel::distributed::Triangulation<dim> &triangulation,
130 const std::set<types::boundary_id> &outlet_boundaries)
131{
132 // Initializing output_vector and a search_vector (containing boundary_id and
133 // cell) to avoid replication of a boundary face. All the found boundary faces
134 // will be searched in this vector before being added to the output_vector. If
135 // they are not found in this search_vector they will be added to the
136 // output_vector as well as the search_vector
137 // std::map<int, boundary_cells_info_struct<dim>> output_vector;
138 std::vector<std::pair<int, typename Triangulation<dim>::active_cell_iterator>>
139 search_vector;
140
141 // Initialize a simple quadrature on the system. This will be used to
142 // obtain a single sample point on the boundary faces
143 const FE_Q<dim> fe(1);
144 QGauss<dim - 1> face_quadrature_formula(1);
145 FEFaceValues<dim> fe_face_values(fe,
146 face_quadrature_formula,
147 update_values | update_quadrature_points |
148 update_normal_vectors);
149
150 // Iterating over the active cells in the triangulation
151 for (const auto &cell : triangulation.active_cell_iterators())
152 {
153 // Iterating over the faces of each cell
154 for (const auto &face : cell->face_iterators())
155 {
156 // We search to see if the boundary is defined as an outlet, periodic
157 // or not. If it is not defined as one of those, we proceed.
158 const int face_id = cell->face_iterator_to_index(face);
159 const bool is_outlet =
160 outlet_boundaries.contains(face->boundary_id());
161 const bool is_periodic = cell->has_periodic_neighbor(face_id);
162
163 if (!is_outlet && !is_periodic)
164 {
165 // Check if the face is located at boundary
166 if (face->at_boundary())
167 {
168 fe_face_values.reinit(cell, face_id);
169
170 // Finding the normal vector of the boundary face
171 Tensor<1, dim> normal_vector =
172 -fe_face_values.normal_vector(0);
173
174 // Finding a point on the boundary face
175 Point<dim> quad_point = fe_face_values.quadrature_point(0);
176
177 // Get global index of the face
178 unsigned int global_face_id = cell->face_index(face_id);
179
180 // Storing these information into the
181 // boundary_cells_info_struct
182 boundary_cells_info_struct<dim> boundary_information;
183 boundary_information.cell = cell;
184 boundary_information.boundary_id = face->boundary_id();
185 boundary_information.global_face_id = global_face_id;
186 boundary_information.normal_vector = normal_vector;
187 boundary_information.point_on_face = quad_point;
188
189 // Searching to see if boundary with this information was
190 // already found or not. If this is a new
191 // boundary face, it will be added to the
192 // output_vector as well as the search_vector to avoid
193 // repetition
194 auto information_search_element =
195 std::make_pair(face_id, cell);
196 auto search_iterator = std::find(search_vector.begin(),
197 search_vector.end(),
198 information_search_element);
199 if (search_iterator == search_vector.end())
200 {
201 if (cell->is_locally_owned())
202 {
204 {global_face_id, boundary_information});
205 boundary_cells_with_faces.push_back(cell);
206 search_vector.push_back(information_search_element);
207 }
209 {global_face_id, boundary_information});
210 }
211 }
212 }
213 }
214 }
215}
216
217
218// This function is used to update the normal vector and the location of the
219// stored point of the boundary faces. It is used when the grid is moving.
220// Updated points and normal vectors are then used to update the particle-wall
221// contact list.
222template <int dim>
223void
226 &new_boundary_points_and_normal_vectors)
227{
228 // If there is no grid motion, exit the function
229 if (!DEMActionManager::get_action_manager()->check_grid_motion_enabled())
230 return;
231
232 // Initialize a simple quadrature for on the system. This will be used to
233 // obtain a single sample point on the boundary faces
234 const FE_Q<dim> fe(1);
235 QGauss<dim - 1> face_quadrature_formula(1);
236 FEFaceValues<dim> fe_face_values(fe,
237 face_quadrature_formula,
238 update_values | update_quadrature_points |
239 update_normal_vectors);
240 for (auto &cell : boundary_cells_with_faces)
241 {
242 if (cell->is_locally_owned())
243 {
244 // Iterating over the faces of each cell
245 for (const auto &face : cell->face_iterators())
246 {
247 // Check to see if the face is located at boundary
248 if (face->at_boundary())
249 {
250 int face_id = cell->face_iterator_to_index(face);
251 fe_face_values.reinit(cell, face_id);
252
253 // Finding the normal vector of the boundary face
254 Tensor<1, 3> normal_vector;
255
256 if constexpr (dim == 3)
257 normal_vector = -fe_face_values.normal_vector(0);
258
259 if constexpr (dim == 2)
260 normal_vector =
261 tensor_nd_to_3d(-fe_face_values.normal_vector(0));
262
263 // Finding a point on the boundary face
264 Point<3> quad_point;
265
266 if constexpr (dim == 3)
267 quad_point = fe_face_values.quadrature_point(0);
268
269 if constexpr (dim == 2)
270 quad_point =
271 point_nd_to_3d(fe_face_values.quadrature_point(0));
272
273 new_boundary_points_and_normal_vectors[cell->face_index(
274 face_id)] = std::make_pair(normal_vector, quad_point);
275 }
276 }
277 }
278 }
279}
280
281// This function returns all the cells at which particle-line and particle-point
282// contact search should be performed
283template <int dim>
284void
286 const parallel::distributed::Triangulation<dim> &triangulation)
287{
288 // Here, we first loop through all the non-boundary faces of the local cells
289 // and find (add them to all cells_with_boundary_lines container) all boundary
290 // lines of these faces. Then the boundary lines which are the borders of two
291 // boundary faces should be removed from this container. Finally, the
292 // remaining elements of this container are added to boundary_cells_with_lines
293
294 // Boundary lines only exist in three-dimensional cases
295 if (dim == 3)
296 {
297 std::unordered_map<std::string,
298 std::unordered_map<types::global_dof_index,
299 std::pair<Point<dim>, Point<dim>>>>
300 all_cells_with_boundary_lines;
301
302 // Iterating over the active cells in the triangulation
303 for (const auto &cell : triangulation.active_cell_iterators())
304 {
305 if (cell->is_locally_owned())
306 {
307 // Looping through all the faces of the cell
308 for (const auto &face : cell->face_iterators())
309 {
310 // Check to see if the face is not located at boundary
311 if (!face->at_boundary())
312 {
313 // Adding all the boundary lines of these faces into the
314 // all_cells_with_boundary_lines container
315 for (unsigned int l = 0; l < face->n_lines(); ++l)
316 {
317 if (face->line(l)->at_boundary())
318 {
319 all_cells_with_boundary_lines[cell->id()
320 .to_string()]
321 .emplace(
322 face->line_index(l),
323 std::make_pair(face->line(l)->vertex(0),
324 face->line(l)->vertex(1)));
325 }
326 }
327 }
328 }
329 }
330 }
331
332 // Now iterating again over the cells, faces and lines and if the boundary
333 // line of the boundary face exists in the container, it is removed from
334 // the container
335 if (!all_cells_with_boundary_lines.empty())
336 {
337 for (const auto &cell : triangulation.active_cell_iterators())
338 {
339 if (cell->is_locally_owned())
340 {
341 for (const auto &face : cell->face_iterators())
342 {
343 // Check to see if the face is located at boundary
344 if (face->at_boundary())
345 {
346 for (unsigned int l = 0; l < face->n_lines(); ++l)
347 {
348 all_cells_with_boundary_lines[cell->id()
349 .to_string()]
350 .erase(face->line_index(l));
351 }
352 }
353 }
354 }
355 }
356 }
357
358 // Finally, adding the remaining elements of the
359 // all_cells_with_boundary_lines container to boundary_cells_with_lines
360 if (!all_cells_with_boundary_lines.empty())
361 {
362 for (const auto &cell : triangulation.active_cell_iterators())
363 {
364 if (cell->is_locally_owned())
365 {
366 std::string cell_id_string = cell->id().to_string();
367 std::unordered_map<types::global_dof_index,
368 std::pair<Point<dim>, Point<dim>>>
369 &cell_boundary_lines =
370 all_cells_with_boundary_lines[cell_id_string];
371
372 if (!cell_boundary_lines.empty())
373 {
374 for (auto &map_iterator : cell_boundary_lines)
375 {
376 Point<3> vertex_one, vertex_two;
377
378 if constexpr (dim == 3)
379 {
380 vertex_one = map_iterator.second.first;
381 vertex_two = map_iterator.second.second;
382 }
383
384 if constexpr (dim == 2)
385 {
386 vertex_one =
387 point_nd_to_3d(map_iterator.second.first);
388 vertex_two =
389 point_nd_to_3d(map_iterator.second.second);
390 }
392 cell_id_string,
393 cell_line_info<dim>{cell, vertex_one, vertex_two});
394
395 // Add the cell to local_cells_with_boundary_lines to
396 // be used in
397 // add_cells_with_boundary_lines_to_boundary_cells
398 local_cells_with_boundary_lines.push_back(cell);
399 }
400 }
401 }
402 }
403 }
404 }
405
406 // Finding boundary points. We need this container because at_boundary()
407 // function is not defined for vertex id (unsigned int) nor vertex position
408 // (Point<dim>). For line and face objects, at_boundary() function is
409 // available to help
410
411 // First getting a set of all boundary vertices
412 std::set<unsigned int> boundary_vertices;
413 for (const auto &face : triangulation.active_face_iterators())
414 {
415 if (face->at_boundary())
416 {
417 for (unsigned int v = 0; v < face->n_vertices(); ++v)
418 {
419 boundary_vertices.insert(face->vertex_index(v));
420 }
421 }
422 }
423
424 // If a cell does not have any boundary line, but has boundary vertex, it is
425 // added to boundary_cells_with_points container Iterating over the active
426 // cells in the triangulation
427 for (const auto &cell : triangulation.active_cell_iterators())
428 {
429 if (cell->is_locally_owned() && !cell->has_boundary_lines())
430 {
431 for (const auto &face : cell->face_iterators())
432 {
433 if (!face->at_boundary())
434 {
435 for (unsigned int v = 0; v < face->n_vertices(); ++v)
436 {
437 if (boundary_vertices.contains(face->vertex_index(v)))
438 {
439 Point<3> vertex;
440
441 if constexpr (dim == 3)
442 vertex = face->vertex(v);
443
444 if constexpr (dim == 2)
445 vertex = point_nd_to_3d(face->vertex(v));
446
448 cell->id().to_string(),
449 cell_point_info<dim>{cell, vertex});
450 }
451 }
452 }
453 }
454 }
455 }
456}
457
458template <int dim>
459void
461 const parallel::distributed::Triangulation<dim> &triangulation,
462 const std::set<types::boundary_id> &outlet_boundaries)
463{
464 // Iterating over the active cells in the triangulation
465 for (const auto &cell : triangulation.active_cell_iterators())
466 {
467 // Iterating over the faces of each cell
468 for (const auto &face : cell->face_iterators())
469 {
470 // We search to see if the boundary is defined as an outlet or
471 // not. If it is not defined as an outlet we proceed.
472 if (!outlet_boundaries.contains(face->boundary_id()))
473 {
474 // Check to see if the face is located at boundary
475 if (face->at_boundary())
476 {
477 global_boundary_cells_with_faces.push_back(cell);
478 }
479 }
480 }
481 }
482}
483
484template <int dim>
485void
487 const parallel::distributed::Triangulation<dim> &triangulation,
488 const std::set<types::boundary_id> &outlet_boundaries,
489 const bool &check_diamond_cells,
490 const ConditionalOStream &pcout)
491{
492 std::vector<typename Triangulation<dim>::active_cell_iterator>
493 boundary_neighbor_cells;
494
495 // First we have to store all the global (including local and non-local) cells
496 // with boundary faces in a container. Note that the boundary_cells_with_faces
497 // container only stores the local boundary cells
498 find_global_boundary_cells_with_faces(triangulation, outlet_boundaries);
499
501 {
502 for (auto &cell_with_boundary_line : local_cells_with_boundary_lines)
503 {
504 // Each cell with boundary line must have two neighbor cells with
505 // boundary faces. We have to find these two neighbors first.
506 // Finding neighbors of the cell
507 std::vector<typename Triangulation<dim>::active_cell_iterator>
508 active_neighbors;
509 GridTools::get_active_neighbors<Triangulation<dim>>(
510 cell_with_boundary_line, active_neighbors);
511
512 // Looping through the neighbors and storing the ones with boundary
513 // faces
514 boundary_neighbor_cells.clear();
515 for (auto &neighbor : active_neighbors)
516 {
517 if (std::count(global_boundary_cells_with_faces.begin(),
519 neighbor))
520 {
521 boundary_neighbor_cells.push_back(neighbor);
522 }
523 }
524
525 // Find the information of every combination of two cells in
526 // global_boundary_cells_normals with counters
527 for (unsigned int counter_one = 0;
528 counter_one < boundary_neighbor_cells.size();
529 ++counter_one)
530 {
531 for (unsigned int counter_two = 0;
532 counter_two < boundary_neighbor_cells.size();
533 ++counter_two)
534 {
535 if (counter_one > counter_two)
536 {
537 // Get the pair of cells
538 const typename Triangulation<dim>::active_cell_iterator
539 &cell_one = boundary_neighbor_cells[counter_one];
540 const typename Triangulation<dim>::active_cell_iterator
541 &cell_two = boundary_neighbor_cells[counter_two];
542
543 // Loop on all faces of the 2 cells
544 for (const auto &face_one : cell_one->face_iterators())
545 {
546 for (const auto &face_two :
547 cell_two->face_iterators())
548 {
549 // Check if faces are located at boundaries
550 if (face_one->at_boundary() &&
551 face_two->at_boundary())
552 {
553 unsigned int face_id_one, face_id_two;
554 face_id_one =
555 cell_one->face_iterator_to_index(face_one);
556 face_id_two =
557 cell_two->face_iterator_to_index(face_two);
558
559 // Check if faces are on a wall boundary
560 // (not outlet nor periodic)
561 const bool face_one_is_wall =
562 (!outlet_boundaries.contains(
563 face_one->boundary_id()) &&
564 !cell_one->has_periodic_neighbor(
565 face_id_one));
566 const bool face_two_is_wall =
567 (!outlet_boundaries.contains(
568 face_two->boundary_id()) &&
569 !cell_two->has_periodic_neighbor(
570 face_id_two));
571
572 if (face_one_is_wall && face_two_is_wall)
573 {
574 // Get the normal vector of the first cell
575 Tensor<1, dim> normal_vector_one,
576 normal_vector_two;
577 normal_vector_one =
579 .at(cell_one->face_index(face_id_one))
580 .normal_vector;
581
582 normal_vector_two =
584 .at(cell_two->face_index(face_id_two))
585 .normal_vector;
586
587 // Check to see if the dot product of the
588 // two normal vectors is larger than a
589 // specified threshold (cos(45) = 0.707)
590 if (normal_vector_one *
591 normal_vector_two >
592 0.707)
593 {
595 {
596 pcout
597 << std::endl
598 << "Warning: Diamond-shaped cells were detected in the input triangulation. These cells have a vertex or edge shared with a wall, but not a face. It is strongly recommended to use a triangulation without such cells. If you wish to include them in the particle-wall contact list, set check_diamond_cells = true in the .prm file. Note: these cells are not detected when grid motion is enabled."
599 << std::endl;
601 false;
602 }
603
604 if (check_diamond_cells &&
605 cell_with_boundary_line
606 ->is_locally_owned())
607 {
608 // If this condition is true, add
609 // this cell to
610 // boundary_cells_information.
611 // Since the key of
612 // boundary_cells_information is
613 // the boundary face id, and this
614 // cell does not have a boundary
615 // face, we add it to the
616 // boundary_cells_information with
617 // a negative key
618 int imaginary_face_id =
619 -1 * cell_two->face_index(
620 face_id_two);
621
622 // Update cell to the cell with
623 // boundary line
625 imaginary_information =
627 .at(cell_two->face_index(
628 face_id_two));
629 imaginary_information.cell =
630 cell_with_boundary_line;
631 imaginary_information
633 imaginary_face_id;
634
636 {imaginary_face_id,
637 imaginary_information});
638 }
639 }
640 }
641 }
642 }
643 }
644 }
645 }
646 }
647 }
648 }
649}
650
651// This function finds the triangulation cells adjacent to the floating walls
652template <int dim>
653void
655 const parallel::distributed::Triangulation<dim> &triangulation,
656 const Parameters::Lagrangian::FloatingWalls<dim> &floating_wall_properties,
657 const double maximum_cell_diameter)
658{
659 // Reading floating wall properties
660 std::vector<Point<dim>> point_on_wall =
661 floating_wall_properties.points_on_walls;
662 std::vector<Tensor<1, dim>> wall_normal_vector =
663 floating_wall_properties.floating_walls_normal_vectors;
664 unsigned int floating_wall_number =
665 floating_wall_properties.floating_walls_number;
666
667 // Looping through floating walls
668 for (unsigned int floating_wall_id = 0;
669 floating_wall_id < floating_wall_number;
670 ++floating_wall_id)
671 {
672 // Looping through cells
673 for (const auto &cell : triangulation.active_cell_iterators())
674 {
675 // If the cell is owned by the processor
676 if (cell->is_locally_owned())
677 {
678 // Looping over vertices of each cell
679 for (unsigned int vertex = 0; vertex < cell->n_vertices();
680 ++vertex)
681 {
682 // Finding vertex-floating wall distance
683 Tensor<1, dim> connecting_vector =
684 cell->vertex(vertex) - point_on_wall[floating_wall_id];
685 double vertex_wall_distance =
686 connecting_vector * wall_normal_vector[floating_wall_id];
687
688 // If the distance is less than the largest cell size,
689 // it should be added to the
690 // boundary_cells_for_floating_walls
691 if (abs(vertex_wall_distance) < maximum_cell_diameter)
692 {
693 boundary_cells_for_floating_walls[floating_wall_id]
694 .insert(cell);
695 }
696 }
697 }
698 }
699 }
700}
701
702template <int dim>
703void
705 const parallel::distributed::Triangulation<dim> &triangulation,
706 const std::set<types::boundary_id> &outlet_boundaries,
708 const std::map<int, boundary_cells_info_struct<dim>>
710{
711 // Store imaginary boundary-face entries here and add them to
712 // boundary_cells_information after the loop to avoid modifying the map while
713 // iterating over it. The original map uses the global face id as the key.
714 // Since the new entries correspond to existing boundary faces but associated
715 // with a different cell, we need to generate unique imaginary keys for them.
716
717 std::map<int, boundary_cells_info_struct<dim>> imaginary_boundary_faces;
718
719 // Create a vector of sets containing the adjacent cells of all the vertices
720 std::vector<std::set<typename Triangulation<dim>::active_cell_iterator>>
721 v_to_c = GridTools::vertex_to_cell_map(triangulation);
722
723 for (auto &&boundary_cell_info :
724 boundary_cells_information | boost::adaptors::map_values)
725 {
726 // Each entry in boundary_cells_information corresponds to a boundary face
727 // We start by getting the face iterator of the boundary face in the main
728 // boundary cell. This is needed to access the vertices of that face and
729 // find the neighboring cells
730 TriaIterator<TriaAccessor<dim - 1, dim, dim>> main_face_iterator;
731 bool has_boundary_face = false;
732 // Loop over the local face ids of the main cell
733 for (const unsigned int face_id : boundary_cell_info.cell->face_indices())
734 {
735 // Check if the global index of this face is the same as the one
736 // stored in boundary_cell_info. If so, we get the face iterator. This
737 // face iterator is associated with the "main face".
738 if (boundary_cell_info.cell->face_index(face_id) ==
739 boundary_cell_info.global_face_id)
740 {
741 main_face_iterator = boundary_cell_info.cell->face(face_id);
742 has_boundary_face = true;
743 break;
744 }
745 }
746
747 Assert(has_boundary_face,
748 ExcMessage("Boundary face not found in boundary cell."));
749
750 // Loop over the vertices of the main face
751 for (auto vertex_id : main_face_iterator->vertex_indices())
752 {
753 // Iterate over the neighboring cells linked to this vertex
754 for (const auto &neighboring_cell :
755 v_to_c[main_face_iterator->vertex_index(vertex_id)])
756 {
757 // Iterate over the faces of the current neighboring cell
758 for (const auto &neighboring_face :
759 neighboring_cell->face_iterators())
760 {
761 // Check if the neighboring face is located at boundary
762 if (!neighboring_face->at_boundary())
763 continue;
764
765 // Check if the neighboring face is a wall (not outlet nor
766 // periodic)
767 const unsigned int face_id =
768 neighboring_cell->face_iterator_to_index(neighboring_face);
769
770 const bool face_is_wall =
771 (!outlet_boundaries.contains(
772 neighboring_face->boundary_id()) &&
773 !neighboring_cell->has_periodic_neighbor(face_id));
774
775 if (!face_is_wall)
776 continue;
777
778 // At this point, we know that the neighboring face is at the
779 // boundary and is a wall
780
781 // Get the information of the neighboring face
783 &boundary_neighbor_info =
785 neighboring_cell->face_index(face_id));
786
787 // Check if the neighboring face shares an edge with the main
788 // face
789 bool share_edge = false;
790 unsigned int common_vertices = 0;
791
792 // Count the number of shared vertices between the main and
793 // neighboring faces
794 for (auto main_vertex_id :
795 main_face_iterator->vertex_indices())
796 for (auto neighbor_vertex_id :
797 neighboring_face->vertex_indices())
798 if (main_face_iterator->vertex_index(main_vertex_id) ==
799 neighboring_face->vertex_index(neighbor_vertex_id))
800 common_vertices++;
801
802 // This part assumes a mesh with a uniform refinement
803 // level. In 2D, two boundary faces share an "edge" if
804 // they have one common vertex. In 3D, the boundary faces
805 // share an edge if they have two common vertices.
806 if constexpr (dim == 2)
807 share_edge = (common_vertices == 1);
808 else if constexpr (dim == 3)
809 share_edge = (common_vertices == 2);
810
811 // Exit the loop if the main and neighboring faces do not
812 // share an edge
813 if (!share_edge)
814 continue;
815
816 // Get the normal to the main face, pointing outwards from the
817 // cell
818 const auto normal_1 = -boundary_cell_info.normal_vector;
819
820 // Get the point on the two faces
821 const auto &point_1 = boundary_cell_info.point_on_face;
822 const auto &point_2 = boundary_neighbor_info.point_on_face;
823
824 // Create a vector from point_1 to point_2
825 Tensor<1, dim> vector_main_to_neighbor = point_2 - point_1;
826 vector_main_to_neighbor /= vector_main_to_neighbor.norm();
827 const double tolerance = 1e-12;
828
829 // Check if the main and neighboring faces form a convex
830 // surface. This is needed in geometries with both concave and
831 // convex regions
832 const bool is_convex =
833 (normal_1 * vector_main_to_neighbor) < -tolerance;
834
835 // Exit the loop if the boundary faces do not form a convex
836 // surface
837 if (!is_convex)
838 continue;
839
840 // Add the main boundary cell with the information (point and
841 // normal vector) of the neighbor boundary face to the
842 // boundary_cells_information container. Note that since we
843 // may already have an element with the key of face_id (key of
844 // the boundary_cells_information map) in the
845 // boundary_cells_information, we add the new element with a
846 // unique key to create a unique id in the map. This unique
847 // key is generated using Cantor pairing function: unique_key
848 // = 0.5 * (a + b) * (a + b + 1) + b where a and b are global
849 // main and neighboring boundary face ids
850 int imaginary_face_id =
851 static_cast<int>(-0.5 *
852 (boundary_cell_info.global_face_id +
853 boundary_neighbor_info.global_face_id) *
854 (boundary_cell_info.global_face_id +
855 boundary_neighbor_info.global_face_id +
856 1)) +
857 boundary_neighbor_info.global_face_id;
858
859 // Create a cell info structure which is contains all the
860 // neighboring cell information applied to the main boundary
861 // cell & store in map with imaginary key.
862 boundary_cells_info_struct<dim> boundary_information =
863 boundary_neighbor_info;
864 boundary_information.cell = boundary_cell_info.cell;
865
866 imaginary_boundary_faces.insert(
867 {imaginary_face_id, boundary_information});
868 }
869 }
870 }
871 }
872
873 // Add the imaginary entries to the boundary_cells_information map
874 boundary_cells_information.merge(imaginary_boundary_faces);
875}
876
877template class BoundaryCellsInformation<2>;
878template class BoundaryCellsInformation<3>;
Finds all the boundary cells and faces in the triangulation, for each cell the boundary face is speci...
std::vector< typename Triangulation< dim >::active_cell_iterator > local_cells_with_boundary_lines
std::vector< typename Triangulation< dim >::active_cell_iterator > boundary_cells_with_faces
std::unordered_map< types::global_dof_index, std::set< typename Triangulation< dim >::active_cell_iterator > > boundary_cells_for_floating_walls
void find_boundary_cells_information(const parallel::distributed::Triangulation< dim > &triangulation, const std::set< types::boundary_id > &outlet_boundaries)
void update_boundary_info_after_grid_motion(typename DEM::dem_data_structures< dim >::boundary_points_and_normal_vectors &new_boundary_points_and_normal_vectors)
std::unordered_map< std::string, cell_point_info< dim > > boundary_cells_with_points
std::vector< typename Triangulation< dim >::active_cell_iterator > global_boundary_cells_with_faces
void build(const parallel::distributed::Triangulation< dim > &triangulation, const Parameters::Lagrangian::FloatingWalls< dim > &floating_wall_properties, const std::set< types::boundary_id > &outlet_boundaries, const bool &check_diamond_cells, const bool &expand_particle_wall_contact_search, const ConditionalOStream &pcout)
The build function builds all the boundary cell information structure that finds which cell has a bou...
void add_cells_with_boundary_lines_to_boundary_cells(const parallel::distributed::Triangulation< dim > &triangulation, const std::set< types::boundary_id > &outlet_boundaries, const bool &check_diamond_cells, const ConditionalOStream &pcout)
std::unordered_map< std::string, cell_line_info< dim > > boundary_cells_with_lines
void add_boundary_neighbors_of_boundary_cells(const parallel::distributed::Triangulation< dim > &triangulation, const std::set< types::boundary_id > &outlet_boundaries, std::map< int, boundary_cells_info_struct< dim > > &boundary_cells_information, const std::map< int, boundary_cells_info_struct< dim > > &global_boundary_cells_information)
void find_global_boundary_cells_with_faces(const parallel::distributed::Triangulation< dim > &triangulation, const std::set< types::boundary_id > &outlet_boundaries)
std::map< int, boundary_cells_info_struct< dim > > global_boundary_cells_information
void find_particle_point_and_line_contact_cells(const parallel::distributed::Triangulation< dim > &triangulation)
void find_boundary_cells_for_floating_walls(const parallel::distributed::Triangulation< dim > &triangulation, const Parameters::Lagrangian::FloatingWalls< dim > &floating_wall_properties, const double maximum_cell_diameter)
std::map< int, boundary_cells_info_struct< dim > > boundary_cells_information
static DEMActionManager * get_action_manager()
Getter of the unique instance of the DEMActionManager.
Parameters for floating walls in DEM simulations.
std::vector< Point< dim > > points_on_walls
A point on each floating wall surface.
std::vector< Tensor< 1, dim > > floating_walls_normal_vectors
Outward normal vector of each floating wall.
unsigned int floating_walls_number
Number of floating walls.
ankerl::unordered_dense::map< global_face_id, std::pair< Tensor< 1, 3 >, Point< 3 > > > boundary_points_and_normal_vectors
Handle the information related to the boundary cells which will be used for particle-wall contact det...
Triangulation< dim >::active_cell_iterator cell
Handle information related to the cell-line matching.
Handle information related to the cell-point matching.
Tensor< 1, 3 > tensor_nd_to_3d(const Tensor< 1, dim > &tensor)
Point< 3 > point_nd_to_3d(const Point< dim > &point)