Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
find_cell_neighbors.h
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
4#ifndef lethe_find_cell_neighbors_h
5#define lethe_find_cell_neighbors_h
6
8
9#include <deal.II/distributed/tria.h>
10
11using namespace dealii;
12
13/**
14 * @brief Finds the neighbor list (without repetition) of all the active
15 * cells in the triangulation. It gets the vertices of the cells to get lists
16 * of the neighbor for each cell. There is some check to prevent repetition
17 * of a cell in a list (up to 8 vertices can have the same cell in common in
18 * 3D).
19 * 2 types of container are used for cell neighbors : local-local cells
20 * and local-ghost cells.
21 *
22 * @tparam dim An integer that denotes the dimension of the space in which
23 * the problem is solved.
24 * @tparam reciprocal A boolean that denotes if the cells_local_neighbor_list of
25 * cell i and j contains cell j and i, respectively.
26 *
27 * @param triangulation Triangulation to access the information of the cells
28 * @param cells_local_neighbor_list A vector (with size of the local cell
29 * number) of vectors (local adjacent cells of each local cell). First element
30 * of each set shows the main cell itself
31 * @param cells_ghost_neighbor_list A vector (with size of the local cell
32 * number) of vectors (ghost adjacent cells of each local cell). First element
33 * of each set shows the main cell itself
34 */
35template <int dim, bool reciprocal = false>
36void
38 const parallel::distributed::Triangulation<dim> &triangulation,
40 &cells_local_neighbor_list,
42 &cells_ghost_neighbor_list);
43
44/**
45 * @brief Finds the periodic neighbor list (without repetition) of all the
46 * active cells in the triangulation. It gets the coinciding vertices of the
47 * cells at the periodic boundary 0 to get lists of the periodic neighbor
48 * cells on the periodic boundary 1 for each cell. There is some check to
49 * prevent repetition of a cell in a list (up to 8 vertices can have the
50 * same cell in common in 3D).
51 * 3 types of container are used for periodic mapping of cell neighbors :
52 * local-local cells, local-ghost cells and ghost-local cells. The last
53 * container is necessary since the mapping are only from periodic boundary 0
54 * to periodic boundary 1 and the ghost-local particle pairs need distinction
55 * for proper handling of search of particle pairs and contact forces.
56 *
57 * @param triangulation Triangulation to access the information of the cells
58 * @param periodic_boundaries_cells_information A container of information
59 * related to the pairs of cell at periodic boundaries, used to get the cells
60 * on periodic boundary 0
61 * @param cells_local_periodic_neighbor_list A vector (with size of the local
62 * cell number) of vectors (local adjacent cells of each local cell). First
63 * element of each set shows the main cell itself
64 * @param cells_ghost_periodic_neighbor_list A vector (with size of the local
65 * cell number) of vectors (ghost adjacent cells of each local cell). First
66 * element of each set shows the main cell itself
67 * @param cells_ghost_local_periodic_neighbor_list A vector (with size of the
68 * ghost cell number) of vectors (local adjacent cells of each ghost cell).
69 * First element of each set shows the main ghost cell itself
70 */
71template <int dim>
72void
74 const parallel::distributed::Triangulation<dim> &triangulation,
76 &periodic_boundaries_cells_information,
78 &cells_local_periodic_neighbor_list,
80 &cells_ghost_periodic_neighbor_list,
82 &cells_ghost_local_periodic_neighbor_list);
83
84/**
85 * @brief Finds the full neighbor list (with repetition) of all the active
86 * cells in the triangulation. This function is used in particle-floating mesh
87 * contacts, as in this situation, we need to define all the particles located
88 * in the neighbor cells of the background cell (cut by the floating mesh) as
89 * contact candidates
90 *
91 * @param triangulation Triangulation to access the information of the cells
92 * @param cells_total_neighbor_list An unordered_map (with size of the local
93 * cell number) of vectors (all adjacent cells of each local cell)
94 */
95template <int dim>
96void
98 const parallel::distributed::Triangulation<dim> &triangulation,
100 &cells_total_neighbor_list);
101
102/**
103 * @brief Generate a periodic neighbor cells list of the cell. With the
104 * coinciding_vertex_groups and the vertex_to_coinciding_vertex_group, we can
105 * get the coinciding vertices on a periodic boundary and with v_to_c we can
106 * get the list of the periodic neighbor cells to the main cell.
107 *
108 * Here is an example to understand how the search works :
109 * Cell 8 has vertices 0, 1, 2, 3 on the periodic boundary. First,
110 * it checks in the coinciding_vertex_groups if the vertex 0 is a key in the
111 * map, and if it is, it gets a label, let's say that label is 10. In the
112 * vertex_to_coinciding_vertex_group, it can find the coinciding vertices
113 * with the label. Using the label 10, it gets the vertices 0 and 34, which
114 * means that vertices 0 and 34 are periodic. We do not want the cells
115 * attached to the vertex 0 since they are already found with the regular
116 * find_cell_neighbor function, so it skips vertex 0, but gets the cells 21,
117 * 22, 23, 24 attached to the vertex 34. The same checks are done for vertices
118 * 1, 2 and 3 and all periodic cells are returned as a vector.
119 *
120 * @param cell The cell that needs the periodic neighbor list
121 * @param coinciding_vertex_groups A map of coinciding vertices labeled by an
122 * arbitrary element from them
123 * @param vertex_to_coinciding_vertex_group Map of a vertex to the label of a
124 * group of coinciding vertices
125 * @param v_to_c A vector of set with adjacent cells of all the vertices
126 * @param periodic_neighbor_list A vector which is the list of periodic cell
127 * neighbors
128 */
129template <int dim>
130void
132 const typename Triangulation<dim>::active_cell_iterator &cell,
133 const std::map<unsigned int, std::vector<unsigned int>>
134 &coinciding_vertex_groups,
135 const std::map<unsigned int, unsigned int> &vertex_to_coinciding_vertex_group,
136 const std::vector<std::set<typename Triangulation<dim>::active_cell_iterator>>
137 &v_to_c,
138 typename DEM::dem_data_structures<dim>::cell_vector &periodic_neighbor_list);
139
140#endif
void get_periodic_neighbor_list(const typename Triangulation< dim >::active_cell_iterator &cell, const std::map< unsigned int, std::vector< unsigned int > > &coinciding_vertex_groups, const std::map< unsigned int, unsigned int > &vertex_to_coinciding_vertex_group, const std::vector< std::set< typename Triangulation< dim >::active_cell_iterator > > &v_to_c, typename DEM::dem_data_structures< dim >::cell_vector &periodic_neighbor_list)
Generate a periodic neighbor cells list of the cell. With the coinciding_vertex_groups and the vertex...
void find_cell_neighbors(const parallel::distributed::Triangulation< dim > &triangulation, typename DEM::dem_data_structures< dim >::cells_neighbor_list &cells_local_neighbor_list, typename DEM::dem_data_structures< dim >::cells_neighbor_list &cells_ghost_neighbor_list)
Finds the neighbor list (without repetition) of all the active cells in the triangulation....
void find_cell_periodic_neighbors(const parallel::distributed::Triangulation< dim > &triangulation, const typename DEM::dem_data_structures< dim >::periodic_boundaries_cells_info &periodic_boundaries_cells_information, typename DEM::dem_data_structures< dim >::cells_neighbor_list &cells_local_periodic_neighbor_list, typename DEM::dem_data_structures< dim >::cells_neighbor_list &cells_ghost_periodic_neighbor_list, typename DEM::dem_data_structures< dim >::cells_neighbor_list &cells_ghost_local_periodic_neighbor_list)
Finds the periodic neighbor list (without repetition) of all the active cells in the triangulation....
void find_full_cell_neighbors(const parallel::distributed::Triangulation< dim > &triangulation, typename DEM::dem_data_structures< dim >::cells_total_neighbor_list &cells_total_neighbor_list)
Finds the full neighbor list (with repetition) of all the active cells in the triangulation....
std::vector< std::vector< typename Triangulation< dim >::active_cell_iterator > > cells_neighbor_list
std::unordered_multimap< types::global_cell_index, periodic_boundaries_cells_info_struct< dim > > periodic_boundaries_cells_info
ankerl::unordered_dense::map< types::global_cell_index, std::vector< typename Triangulation< dim >::active_cell_iterator > > cells_total_neighbor_list
std::vector< typename Triangulation< dim >::active_cell_iterator > cell_vector