14 const size_t num_raw_cells =
raw_cells_.size();
15 const size_t num_raw_vertices =
vertices_.size();
18 int num_bndry_faces = 0;
20 for (
auto& face : cell->faces)
21 if (not face.has_neighbor) ++num_bndry_faces;
24 <<
" Number of unconnected faces "
25 "before connectivity: " << num_bndry_faces;
28 <<
" Establishing cell connectivity.";
34 uint64_t cur_cell_id=0;
37 for (
auto vid : cell->vertex_ids)
44 <<
" Vertex cell subscriptions complete.";
48 uint64_t aux_counter = 0;
49 uint64_t cur_cell_id=0;
52 for (
auto& cur_cell_face : cell->faces)
54 if (cur_cell_face.has_neighbor) {
continue;}
55 const std::set<uint64_t> cfvids(cur_cell_face.vertex_ids.begin(),
56 cur_cell_face.vertex_ids.end());
58 std::set<size_t> cells_to_search;
59 for (uint64_t vid : cfvids)
61 if (cell_id != cur_cell_id)
62 cells_to_search.insert(cell_id);
64 for (uint64_t adj_cell_id : cells_to_search)
68 for (
auto& adj_cell_face : adj_cell->faces)
70 if (adj_cell_face.has_neighbor) {
continue;}
71 const std::set<uint64_t> afvids(adj_cell_face.vertex_ids.begin(),
72 adj_cell_face.vertex_ids.end());
76 cur_cell_face.neighbor = adj_cell_id;
77 adj_cell_face.neighbor = cur_cell_id;
79 cur_cell_face.has_neighbor =
true;
80 adj_cell_face.has_neighbor =
true;
82 goto face_neighbor_found;
90 const double fraction_complete =
static_cast<double>(cur_cell_id)/
91 static_cast<double>(num_raw_cells);
92 if (fraction_complete >=
static_cast<double>(aux_counter+1)*0.1)
95 <<
" Surpassing cell " << cur_cell_id
96 <<
" of " << num_raw_cells
97 <<
" (" << (aux_counter+1)*10 <<
"%)";
104 <<
" Establishing cell boundary connectivity.";
108 std::vector<LightWeightCell*> internal_cells_on_boundary;
111 bool cell_on_boundary =
false;
112 for (
auto& face : cell->faces)
113 if (not face.has_neighbor)
114 { cell_on_boundary =
true;
break; }
116 if (cell_on_boundary) internal_cells_on_boundary.push_back(cell);
120 std::vector<std::set<uint64_t>> vertex_bndry_cell_subscriptions(
vertices_.size());
122 uint64_t cur_cell_id=0;
125 for (
auto vid : cell->vertex_ids)
126 vertex_bndry_cell_subscriptions.at(vid).insert(cur_cell_id);
132 for (
auto& cell : internal_cells_on_boundary)
133 for (
auto& face : cell->faces)
135 if (face.has_neighbor)
continue;
136 std::set<uint64_t> cfvids(face.vertex_ids.begin(),
137 face.vertex_ids.end());
139 std::set<size_t> cells_to_search;
140 for (uint64_t vid : face.vertex_ids)
141 for (uint64_t cell_id : vertex_bndry_cell_subscriptions[vid])
142 cells_to_search.insert(cell_id);
144 for (uint64_t adj_cell_id : cells_to_search)
148 std::set<uint64_t> afvids(adj_cell->vertex_ids.begin(),
149 adj_cell->vertex_ids.end());
151 if (cfvids == afvids)
153 face.neighbor = adj_cell->material_id;
161 for (
auto& face : cell->faces)
162 if (not face.has_neighbor) ++num_bndry_faces;
165 <<
" Number of boundary faces "
166 "after connectivity: " << num_bndry_faces;
169 <<
" Done establishing cell connectivity.";
static chi::Timer program_timer
LogStream Log(LOG_LVL level=LOG_0)
std::string GetTimeString() const
void BuildMeshConnectivity()
std::vector< chi_mesh::Vertex > vertices_
std::vector< std::set< uint64_t > > vertex_cell_subscriptions_
std::vector< LightWeightCell * > raw_cells_
std::vector< LightWeightCell * > raw_boundary_cells_