17#ifndef dealii_face_setup_internal_h
18#define dealii_face_setup_internal_h
41 namespace MatrixFreeFunctions
83 const unsigned int mg_level,
84 const bool hold_all_faces_to_owned_cells,
85 std::vector<std::pair<unsigned int, unsigned int>> &cell_levels);
96 const std::vector<std::pair<unsigned int, unsigned int>> &cell_levels,
107 const unsigned int face_no,
108 const typename ::Triangulation<dim>::cell_iterator &cell,
109 const unsigned int number_cell_interior,
110 const typename ::Triangulation<dim>::cell_iterator &neighbor,
111 const unsigned int number_cell_exterior);
121 locally_active_at_boundary,
122 locally_active_done_here,
123 locally_active_done_elsewhere,
125 multigrid_refinement_edge
141 template <
int vectorization_w
idth>
145 const std::vector<bool> & hard_vectorization_boundary,
146 std::vector<unsigned int> & face_partition_data,
157 : use_active_cells(true)
164 FaceSetup<dim>::initialize(
166 const unsigned int mg_level,
167 const bool hold_all_faces_to_owned_cells,
168 std::vector<std::pair<unsigned int, unsigned int>> &cell_levels)
174 if (use_active_cells)
175 for (
const auto &cell_level : cell_levels)
177 typename ::Triangulation<dim>::cell_iterator dcell(
186 at_processor_boundary.resize(cell_levels.size(),
false);
189 FaceCategory::locally_active_done_elsewhere);
193 std::map<types::subdomain_id, FaceIdentifier>
194 inner_faces_at_proc_boundary;
200 for (
unsigned int i = 0; i < cell_levels.size(); ++i)
202 if (i > 0 && cell_levels[i] == cell_levels[i - 1])
204 typename ::Triangulation<dim>::cell_iterator dcell(
206 for (
const unsigned int f : dcell->face_indices())
208 if (dcell->at_boundary(f) && !dcell->has_periodic_neighbor(f))
210 typename ::Triangulation<dim>::cell_iterator neighbor =
211 dcell->neighbor_or_periodic_neighbor(f);
217 const CellId id_mine = dcell->id();
218 if (use_active_cells && neighbor->has_children())
219 for (
unsigned int c = 0;
220 c < (dcell->has_periodic_neighbor(f) ?
221 dcell->periodic_neighbor(f)
222 ->face(dcell->periodic_neighbor_face_no(f))
224 dcell->face(f)->n_children());
227 typename ::Triangulation<dim>::cell_iterator
229 dcell->at_boundary(f) ?
230 dcell->periodic_neighbor_child_on_subface(f, c) :
231 dcell->neighbor_child_on_subface(f, c);
233 neighbor_c->subdomain_id();
234 if (my_domain < neigh_domain)
235 inner_faces_at_proc_boundary[neigh_domain]
236 .n_hanging_faces_larger_subdomain++;
237 else if (my_domain > neigh_domain)
238 inner_faces_at_proc_boundary[neigh_domain]
239 .n_hanging_faces_smaller_subdomain++;
244 use_active_cells ? neighbor->subdomain_id() :
245 neighbor->level_subdomain_id();
246 if (neighbor->level() < dcell->level() &&
249 if (my_domain < neigh_domain)
250 inner_faces_at_proc_boundary[neigh_domain]
251 .n_hanging_faces_smaller_subdomain++;
252 else if (my_domain > neigh_domain)
253 inner_faces_at_proc_boundary[neigh_domain]
254 .n_hanging_faces_larger_subdomain++;
256 else if (neighbor->level() == dcell->level() &&
257 my_domain != neigh_domain)
263 const CellId id_neigh = neighbor->id();
264 if (my_domain < neigh_domain)
265 inner_faces_at_proc_boundary[neigh_domain]
266 .shared_faces.emplace_back(id_mine, id_neigh);
268 inner_faces_at_proc_boundary[neigh_domain]
269 .shared_faces.emplace_back(id_neigh, id_mine);
278 for (
auto &inner_face : inner_faces_at_proc_boundary)
280 Assert(inner_face.first != my_domain,
282 std::sort(inner_face.second.shared_faces.begin(),
283 inner_face.second.shared_faces.end());
284 inner_face.second.shared_faces.erase(
285 std::unique(inner_face.second.shared_faces.begin(),
286 inner_face.second.shared_faces.end()),
287 inner_face.second.shared_faces.end());
292# if defined(DEAL_II_WITH_MPI) && defined(DEBUG)
294 if (const ::parallel::TriangulationBase<dim> *ptria =
295 dynamic_cast<const ::parallel::TriangulationBase<dim>
297 comm = ptria->get_communicator();
300 unsigned int mysize = inner_face.second.shared_faces.size();
302 MPI_Sendrecv(&mysize,
311 600 + inner_face.first,
315 mysize = inner_face.second.n_hanging_faces_smaller_subdomain;
316 MPI_Sendrecv(&mysize,
325 700 + inner_face.first,
329 mysize = inner_face.second.n_hanging_faces_larger_subdomain;
330 MPI_Sendrecv(&mysize,
339 800 + inner_face.first,
360 std::vector<std::tuple<CellId, CellId, unsigned int>> other_range(
361 inner_face.second.shared_faces.size());
362 for (
unsigned int i = 0; i < other_range.size(); ++i)
364 std::make_tuple(inner_face.second.shared_faces[i].second,
365 inner_face.second.shared_faces[i].first,
367 std::sort(other_range.begin(), other_range.end());
375 unsigned int n_faces_lower_proc = 0, n_faces_higher_proc = 0;
376 std::vector<char> assignment(other_range.size(), 0);
377 if (inner_face.second.shared_faces.size() > 0)
381 unsigned int count = 0;
382 for (
unsigned int i = 1;
383 i < inner_face.second.shared_faces.size();
385 if (inner_face.second.shared_faces[i].first ==
386 inner_face.second.shared_faces[i - 1 - count].first)
393 for (
unsigned int k = 0; k <= count; ++k)
394 assignment[i - 1 - k] = 1;
395 n_faces_higher_proc += count + 1;
405 for (
unsigned int i = 1; i < other_range.size(); ++i)
406 if (std::get<0>(other_range[i]) ==
407 std::get<0>(other_range[i - 1 - count]))
414 for (
unsigned int k = 0; k <= count; ++k)
417 .shared_faces[std::get<2>(
421 .shared_faces[std::get<2>(
422 other_range[i - 1 - k])]
427 if (assignment[std::get<2>(
428 other_range[i - 1 - k])] == 0)
430 assignment[std::get<2>(
431 other_range[i - 1 - k])] = -1;
432 ++n_faces_lower_proc;
446 n_faces_lower_proc +=
447 inner_face.second.n_hanging_faces_smaller_subdomain;
448 n_faces_higher_proc +=
449 inner_face.second.n_hanging_faces_larger_subdomain;
450 const unsigned int n_total_faces_at_proc_boundary =
451 (inner_face.second.shared_faces.size() +
452 inner_face.second.n_hanging_faces_smaller_subdomain +
453 inner_face.second.n_hanging_faces_larger_subdomain);
454 unsigned int split_index = n_total_faces_at_proc_boundary / 2;
455 if (split_index < n_faces_lower_proc)
457 else if (split_index <
458 n_total_faces_at_proc_boundary - n_faces_higher_proc)
459 split_index -= n_faces_lower_proc;
461 split_index = n_total_faces_at_proc_boundary -
462 n_faces_higher_proc - n_faces_lower_proc;
465# if defined(DEAL_II_WITH_MPI) && defined(DEBUG)
466 MPI_Sendrecv(&split_index,
475 900 + inner_face.first,
479 MPI_Sendrecv(&n_faces_lower_proc,
488 1000 + inner_face.first,
492 MPI_Sendrecv(&n_faces_higher_proc,
501 1100 + inner_face.first,
508 std::vector<std::pair<CellId, CellId>> owned_faces_lower,
510 for (
unsigned int i = 0; i < assignment.size(); ++i)
511 if (assignment[i] < 0)
512 owned_faces_lower.push_back(
513 inner_face.second.shared_faces[i]);
514 else if (assignment[i] > 0)
515 owned_faces_higher.push_back(
516 inner_face.second.shared_faces[i]);
518 inner_face.second.shared_faces.size() + 1 -
519 owned_faces_lower.size() -
520 owned_faces_higher.size());
522 unsigned int i = 0, c = 0;
523 for (; i < assignment.size() && c < split_index; ++i)
524 if (assignment[i] == 0)
526 owned_faces_lower.push_back(
527 inner_face.second.shared_faces[i]);
530 for (; i < assignment.size(); ++i)
531 if (assignment[i] == 0)
533 owned_faces_higher.push_back(
534 inner_face.second.shared_faces[i]);
539 std::vector<std::pair<CellId, CellId>> check_faces;
540 check_faces.insert(check_faces.end(),
541 owned_faces_lower.begin(),
542 owned_faces_lower.end());
543 check_faces.insert(check_faces.end(),
544 owned_faces_higher.begin(),
545 owned_faces_higher.end());
546 std::sort(check_faces.begin(), check_faces.end());
548 inner_face.second.shared_faces.size());
549 for (
unsigned int i = 0; i < check_faces.size(); ++i)
550 Assert(check_faces[i] == inner_face.second.shared_faces[i],
555 if (my_domain < inner_face.first)
556 inner_face.second.shared_faces.swap(owned_faces_lower);
558 inner_face.second.shared_faces.swap(owned_faces_higher);
560 std::sort(inner_face.second.shared_faces.begin(),
561 inner_face.second.shared_faces.end());
567 std::set<std::pair<unsigned int, unsigned int>> ghost_cells;
568 for (
unsigned int i = 0; i < cell_levels.size(); ++i)
570 typename ::Triangulation<dim>::cell_iterator dcell(
572 if (use_active_cells)
574 for (
const auto f : dcell->face_indices())
576 if (dcell->at_boundary(f) && !dcell->has_periodic_neighbor(f))
577 face_is_owned[dcell->face(f)->index()] =
578 FaceCategory::locally_active_at_boundary;
582 else if ((dcell->at_boundary(f) ==
false ||
583 dcell->has_periodic_neighbor(f)) &&
585 dcell->neighbor_or_periodic_neighbor(f)->level() <
588 face_is_owned[dcell->face(f)->index()] =
589 FaceCategory::multigrid_refinement_edge;
593 typename ::Triangulation<dim>::cell_iterator neighbor =
594 dcell->neighbor_or_periodic_neighbor(f);
597 if (use_active_cells && neighbor->has_children() &&
598 hold_all_faces_to_owned_cells ==
false)
601 bool add_to_ghost =
false;
603 id1 = use_active_cells ? dcell->subdomain_id() :
604 dcell->level_subdomain_id(),
605 id2 = use_active_cells ?
606 (neighbor->has_children() ?
607 dcell->neighbor_child_on_subface(f, 0)
609 neighbor->subdomain_id()) :
610 neighbor->level_subdomain_id();
618 (use_active_cells ==
false || neighbor->is_active())) ||
619 dcell->level() > neighbor->level() ||
621 inner_faces_at_proc_boundary[id2].shared_faces.begin(),
622 inner_faces_at_proc_boundary[id2].shared_faces.end(),
623 std::make_pair(id1 < id2 ? dcell->
id() : neighbor->id(),
624 id1 < id2 ? neighbor->
id() :
627 face_is_owned[dcell->face(f)->index()] =
628 FaceCategory::locally_active_done_here;
629 if (dcell->level() == neighbor->level())
632 ->face(dcell->has_periodic_neighbor(f) ?
633 dcell->periodic_neighbor_face_no(f) :
634 dcell->neighbor_face_no(f))
636 FaceCategory::locally_active_done_here;
642 if (use_active_cells)
644 (dcell->subdomain_id() != neighbor->subdomain_id());
646 add_to_ghost = (dcell->level_subdomain_id() !=
647 neighbor->level_subdomain_id());
649 else if (hold_all_faces_to_owned_cells ==
true)
652 face_is_owned[dcell->face(f)->index()] =
653 FaceCategory::ghosted;
654 if (use_active_cells)
656 if (neighbor->has_children())
657 for (
unsigned int s = 0;
658 s < dcell->face(f)->n_children();
660 if (dcell->at_boundary(f))
663 ->periodic_neighbor_child_on_subface(f,
666 dcell->subdomain_id())
671 if (dcell->neighbor_child_on_subface(f, s)
673 dcell->subdomain_id())
677 add_to_ghost = (dcell->subdomain_id() !=
678 neighbor->subdomain_id());
681 add_to_ghost = (dcell->level_subdomain_id() !=
682 neighbor->level_subdomain_id());
687 if (use_active_cells && neighbor->has_children())
688 for (
unsigned int s = 0;
689 s < dcell->face(f)->n_children();
692 typename ::Triangulation<dim>::cell_iterator
694 dcell->at_boundary(f) ?
695 dcell->periodic_neighbor_child_on_subface(f,
697 dcell->neighbor_child_on_subface(f, s);
698 if (neighbor_child->subdomain_id() !=
699 dcell->subdomain_id())
701 std::pair<unsigned int, unsigned int>(
702 neighbor_child->level(),
703 neighbor_child->index()));
707 std::pair<unsigned int, unsigned int>(
708 neighbor->level(), neighbor->index()));
709 at_processor_boundary[i] =
true;
717 for (
const auto &ghost_cell : ghost_cells)
718 cell_levels.push_back(ghost_cell);
725 FaceSetup<dim>::generate_faces(
727 const std::vector<std::pair<unsigned int, unsigned int>> &cell_levels,
728 TaskInfo & task_info)
732 std::map<std::pair<unsigned int, unsigned int>,
unsigned int>
734 for (
unsigned int cell = 0; cell < cell_levels.size(); ++cell)
735 if (cell == 0 || cell_levels[cell] != cell_levels[cell - 1])
737 typename ::Triangulation<dim>::cell_iterator dcell(
739 cell_levels[cell].
first,
740 cell_levels[cell].
second);
741 std::pair<unsigned int, unsigned int> level_index(dcell->level(),
743 map_to_vectorized[level_index] = cell;
747 const unsigned int vectorization_length = task_info.vectorization_length;
748 task_info.face_partition_data.resize(
749 task_info.cell_partition_data.size() - 1, 0);
750 task_info.boundary_partition_data.resize(
751 task_info.cell_partition_data.size() - 1, 0);
752 std::vector<unsigned char> face_visited(face_is_owned.size(), 0);
754 partition < task_info.cell_partition_data.size() - 2;
757 unsigned int boundary_counter = 0;
758 unsigned int inner_counter = 0;
759 for (
unsigned int cell = task_info.cell_partition_data[
partition] *
760 vectorization_length;
761 cell < task_info.cell_partition_data[
partition + 1] *
762 vectorization_length;
764 if (cell == 0 || cell_levels[cell] != cell_levels[cell - 1])
766 typename ::Triangulation<dim>::cell_iterator dcell(
768 cell_levels[cell].
first,
769 cell_levels[cell].
second);
770 for (
const auto f : dcell->face_indices())
773 if (face_is_owned[dcell->face(f)->index()] ==
774 FaceCategory::locally_active_at_boundary)
778 FaceToCellTopology<1> info;
779 info.cells_interior[0] = cell;
781 info.interior_face_no = f;
782 info.exterior_face_no = dcell->face(f)->boundary_id();
784 dcell->face(f)->reference_cell() !=
788 info.face_orientation = 0;
789 boundary_faces.push_back(info);
791 face_visited[dcell->face(f)->index()]++;
796 typename ::Triangulation<dim>::cell_iterator
797 neighbor = dcell->neighbor_or_periodic_neighbor(f);
798 if (use_active_cells && neighbor->has_children())
800 for (
unsigned int c = 0;
801 c < dcell->face(f)->n_children();
805 dim>::cell_iterator neighbor_c =
806 dcell->at_boundary(f) ?
807 dcell->periodic_neighbor_child_on_subface(
809 dcell->neighbor_child_on_subface(f, c);
811 neighbor_c->subdomain_id();
812 const unsigned int neighbor_face_no =
813 dcell->has_periodic_neighbor(f) ?
814 dcell->periodic_neighbor_face_no(f) :
815 dcell->neighbor_face_no(f);
816 if (neigh_domain != dcell->subdomain_id() ||
818 [dcell->face(f)->child(c)->index()] ==
821 std::pair<unsigned int, unsigned int>
822 level_index(neighbor_c->level(),
823 neighbor_c->index());
825 [dcell->face(f)->child(c)->index()] ==
826 FaceCategory::locally_active_done_here)
829 inner_faces.push_back(create_face(
832 map_to_vectorized[level_index],
836 else if (face_is_owned[dcell->face(f)
839 FaceCategory::ghosted)
841 inner_ghost_faces.push_back(create_face(
844 map_to_vectorized[level_index],
850 face_is_owned[dcell->face(f)
853 locally_active_done_elsewhere ||
854 face_is_owned[dcell->face(f)
856 FaceCategory::ghosted,
862 [dcell->face(f)->child(c)->index()] = 1;
869 use_active_cells ? dcell->subdomain_id() :
870 dcell->level_subdomain_id();
872 use_active_cells ? neighbor->subdomain_id() :
873 neighbor->level_subdomain_id();
874 if (neigh_domain != my_domain ||
875 face_visited[dcell->face(f)->index()] == 1)
877 std::pair<unsigned int, unsigned int>
878 level_index(neighbor->level(),
880 if (face_is_owned[dcell->face(f)->index()] ==
881 FaceCategory::locally_active_done_here)
883 Assert(use_active_cells ||
888 inner_faces.push_back(create_face(
893 map_to_vectorized[level_index]));
895 else if (face_is_owned[dcell->face(f)
897 FaceCategory::ghosted)
899 inner_ghost_faces.push_back(create_face(
904 map_to_vectorized[level_index]));
909 face_visited[dcell->face(f)->index()] = 1;
910 if (dcell->has_periodic_neighbor(f))
914 dcell->periodic_neighbor_face_no(f))
917 if (face_is_owned[dcell->face(f)->index()] ==
918 FaceCategory::multigrid_refinement_edge)
920 refinement_edge_faces.push_back(
925 refinement_edge_faces.size()));
931 task_info.face_partition_data[
partition + 1] =
932 task_info.face_partition_data[
partition] + inner_counter;
933 task_info.boundary_partition_data[
partition + 1] =
934 task_info.boundary_partition_data[
partition] + boundary_counter;
936 task_info.ghost_face_partition_data.resize(2);
937 task_info.ghost_face_partition_data[0] = 0;
938 task_info.ghost_face_partition_data[1] = inner_ghost_faces.size();
939 task_info.refinement_edge_face_partition_data.resize(2);
940 task_info.refinement_edge_face_partition_data[0] = 0;
941 task_info.refinement_edge_face_partition_data[1] =
942 refinement_edge_faces.size();
948 FaceToCellTopology<1>
949 FaceSetup<dim>::create_face(
950 const unsigned int face_no,
951 const typename ::Triangulation<dim>::cell_iterator &cell,
952 const unsigned int number_cell_interior,
953 const typename ::Triangulation<dim>::cell_iterator &neighbor,
954 const unsigned int number_cell_exterior)
956 FaceToCellTopology<1> info;
957 info.cells_interior[0] = number_cell_interior;
958 info.cells_exterior[0] = number_cell_exterior;
959 info.interior_face_no = face_no;
960 if (cell->has_periodic_neighbor(face_no))
961 info.exterior_face_no = cell->periodic_neighbor_face_no(face_no);
963 info.exterior_face_no = cell->neighbor_face_no(face_no);
965 info.face_type = cell->face(face_no)->reference_cell() !=
970 if (cell->level() > neighbor->level())
972 if (cell->has_periodic_neighbor(face_no))
974 cell->periodic_neighbor_of_coarser_periodic_neighbor(face_no)
978 cell->neighbor_of_coarser_neighbor(face_no).second;
982 if (dim == 3 && cell->has_periodic_neighbor(face_no))
984 const unsigned int exterior_face_orientation =
985 !cell->get_triangulation()
986 .get_periodic_face_map()
989 2 * cell->get_triangulation()
990 .get_periodic_face_map()
993 4 * cell->get_triangulation()
994 .get_periodic_face_map()
998 info.face_orientation = exterior_face_orientation;
1003 info.face_orientation = 0;
1004 const unsigned int interior_face_orientation =
1005 !cell->face_orientation(face_no) + 2 * cell->face_flip(face_no) +
1006 4 * cell->face_rotation(face_no);
1007 const unsigned int exterior_face_orientation =
1008 !neighbor->face_orientation(info.exterior_face_no) +
1009 2 * neighbor->face_flip(info.exterior_face_no) +
1010 4 * neighbor->face_rotation(info.exterior_face_no);
1011 if (interior_face_orientation != 0)
1013 info.face_orientation = 8 + interior_face_orientation;
1014 Assert(exterior_face_orientation == 0,
1016 "Face seems to be wrongly oriented from both sides"));
1019 info.face_orientation = exterior_face_orientation;
1032 compare_faces_for_vectorization(
1033 const FaceToCellTopology<1> & face1,
1034 const FaceToCellTopology<1> & face2,
1035 const std::vector<unsigned int> &active_fe_indices,
1036 const unsigned int length)
1038 if (face1.interior_face_no != face2.interior_face_no)
1040 if (face1.exterior_face_no != face2.exterior_face_no)
1042 if (face1.subface_index != face2.subface_index)
1044 if (face1.face_orientation != face2.face_orientation)
1046 if (face1.face_type != face2.face_type)
1049 if (active_fe_indices.size() > 0)
1051 if (active_fe_indices[face1.cells_interior[0] / length] !=
1052 active_fe_indices[face2.cells_interior[0] / length])
1056 if (active_fe_indices[face1.cells_exterior[0] / length] !=
1057 active_fe_indices[face2.cells_exterior[0] / length])
1072 template <
int length>
1073 struct FaceComparator
1075 FaceComparator(
const std::vector<unsigned int> &active_fe_indices)
1076 : active_fe_indices(active_fe_indices)
1080 operator()(
const FaceToCellTopology<length> &face1,
1081 const FaceToCellTopology<length> &face2)
const
1084 if (face1.face_type < face2.face_type)
1086 else if (face1.face_type > face2.face_type)
1090 if (active_fe_indices.size() > 0)
1093 if (active_fe_indices[face1.cells_interior[0] / length] <
1094 active_fe_indices[face2.cells_interior[0] / length])
1096 else if (active_fe_indices[face1.cells_interior[0] / length] >
1097 active_fe_indices[face2.cells_interior[0] / length])
1103 if (active_fe_indices[face1.cells_exterior[0] / length] <
1104 active_fe_indices[face2.cells_exterior[0] / length])
1106 else if (active_fe_indices[face1.cells_exterior[0] / length] >
1107 active_fe_indices[face2.cells_exterior[0] / length])
1112 for (
unsigned int i = 0; i < length; ++i)
1113 if (face1.cells_interior[i] < face2.cells_interior[i])
1115 else if (face1.cells_interior[i] > face2.cells_interior[i])
1117 for (
unsigned int i = 0; i < length; ++i)
1118 if (face1.cells_exterior[i] < face2.cells_exterior[i])
1120 else if (face1.cells_exterior[i] > face2.cells_exterior[i])
1122 if (face1.interior_face_no < face2.interior_face_no)
1124 else if (face1.interior_face_no > face2.interior_face_no)
1126 if (face1.exterior_face_no < face2.exterior_face_no)
1128 else if (face1.exterior_face_no > face2.exterior_face_no)
1141 const std::vector<unsigned int> &active_fe_indices;
1146 template <
int vectorization_w
idth>
1149 const std::vector<FaceToCellTopology<1>> &faces_in,
1150 const std::vector<bool> & hard_vectorization_boundary,
1151 std::vector<unsigned int> & face_partition_data,
1152 std::vector<FaceToCellTopology<vectorization_width>> &faces_out,
1153 const std::vector<unsigned int> & active_fe_indices)
1155 FaceToCellTopology<vectorization_width> macro_face;
1156 std::vector<std::vector<unsigned int>> faces_type;
1158 unsigned int face_start = face_partition_data[0],
1159 face_end = face_partition_data[0];
1161 face_partition_data[0] = faces_out.size();
1163 partition < face_partition_data.size() - 1;
1166 std::vector<std::vector<unsigned int>> new_faces_type;
1169 face_start = face_end;
1170 face_end = face_partition_data[
partition + 1];
1177 for (
unsigned int face = face_start; face < face_end; ++face)
1179 for (
auto &face_type : faces_type)
1182 if (compare_faces_for_vectorization(faces_in[face],
1183 faces_in[face_type[0]],
1185 vectorization_width))
1187 face_type.push_back(face);
1191 faces_type.emplace_back(1, face);
1197 FaceComparator<vectorization_width> face_comparator(
1199 std::set<FaceToCellTopology<vectorization_width>,
1200 FaceComparator<vectorization_width>>
1201 new_faces(face_comparator);
1202 for (
const auto &face_type : faces_type)
1204 macro_face.face_type = faces_in[face_type[0]].face_type;
1205 macro_face.interior_face_no =
1206 faces_in[face_type[0]].interior_face_no;
1207 macro_face.exterior_face_no =
1208 faces_in[face_type[0]].exterior_face_no;
1209 macro_face.subface_index = faces_in[face_type[0]].subface_index;
1210 macro_face.face_orientation =
1211 faces_in[face_type[0]].face_orientation;
1212 unsigned int no_faces = face_type.size();
1213 std::vector<unsigned char> touched(no_faces, 0);
1219 unsigned int n_vectorized = 0;
1220 for (
unsigned int f = 0; f < no_faces; ++f)
1221 if (faces_in[face_type[f]].cells_interior[0] %
1222 vectorization_width ==
1225 bool is_contiguous =
true;
1226 if (f + vectorization_width > no_faces)
1227 is_contiguous =
false;
1229 for (
unsigned int v = 1; v < vectorization_width; ++v)
1230 if (faces_in[face_type[f + v]].cells_interior[0] !=
1231 faces_in[face_type[f]].cells_interior[0] + v)
1232 is_contiguous =
false;
1237 vectorization_width + 1);
1238 for (
unsigned int v = 0; v < vectorization_width; ++v)
1240 macro_face.cells_interior[v] =
1241 faces_in[face_type[f + v]].cells_interior[0];
1242 macro_face.cells_exterior[v] =
1243 faces_in[face_type[f + v]].cells_exterior[0];
1246 new_faces.insert(macro_face);
1247 f += vectorization_width - 1;
1248 n_vectorized += vectorization_width;
1252 std::vector<unsigned int> untouched;
1253 untouched.reserve(no_faces - n_vectorized);
1254 for (
unsigned int f = 0; f < no_faces; ++f)
1255 if (touched[f] == 0)
1256 untouched.push_back(f);
1258 for (
const auto f : untouched)
1260 macro_face.cells_interior[v] =
1261 faces_in[face_type[f]].cells_interior[0];
1262 macro_face.cells_exterior[v] =
1263 faces_in[face_type[f]].cells_exterior[0];
1265 if (v == vectorization_width)
1267 new_faces.insert(macro_face);
1271 if (v > 0 && v < vectorization_width)
1274 if (hard_vectorization_boundary[
partition + 1] ||
1275 partition == face_partition_data.size() - 2)
1277 for (; v < vectorization_width; ++v)
1280 macro_face.cells_interior[v] =
1282 macro_face.cells_exterior[v] =
1285 new_faces.insert(macro_face);
1290 std::vector<unsigned int> untreated(v);
1291 for (
unsigned int f = 0; f < v; ++f)
1292 untreated[f] = face_type[*(untouched.end() - 1 - f)];
1293 new_faces_type.push_back(untreated);
1299 for (
auto it = new_faces.begin(); it != new_faces.end(); ++it)
1300 faces_out.push_back(*it);
1301 face_partition_data[
partition + 1] += new_faces.size();
1304 faces_type = std::move(new_faces_type);
1309 for (
const auto &face_type : faces_type)
1313 unsigned int nfaces = 0;
1314 for (
unsigned int i = face_partition_data[0];
1315 i < face_partition_data.back();
1317 for (
unsigned int v = 0; v < vectorization_width; ++v)
1322 std::vector<std::pair<unsigned int, unsigned int>> in_faces, out_faces;
1323 for (
const auto &face_in : faces_in)
1324 in_faces.emplace_back(face_in.cells_interior[0],
1325 face_in.cells_exterior[0]);
1326 for (
unsigned int i = face_partition_data[0];
1327 i < face_partition_data.back();
1329 for (
unsigned int v = 0;
1330 v < vectorization_width &&
1333 out_faces.emplace_back(faces_out[i].cells_interior[v],
1334 faces_out[i].cells_exterior[v]);
1335 std::sort(in_faces.begin(), in_faces.end());
1336 std::sort(out_faces.begin(), out_faces.end());
1338 for (
unsigned int i = 0; i < in_faces.size(); ++i)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
constexpr const ReferenceCell & get_hypercube()
void collect_faces_vectorization(const std::vector< FaceToCellTopology< 1 > > &faces_in, const std::vector< bool > &hard_vectorization_boundary, std::vector< unsigned int > &face_partition_data, std::vector< FaceToCellTopology< vectorization_width > > &faces_out)
const types::subdomain_id invalid_subdomain_id
static const unsigned int invalid_unsigned_int
TriangulationBase< dim, spacedim > Triangulation
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation
*braid_SplitCommworld & comm
unsigned int n_hanging_faces_smaller_subdomain
unsigned int n_hanging_faces_larger_subdomain
std::vector< std::pair< CellId, CellId > > shared_faces
std::vector< FaceToCellTopology< 1 > > inner_faces
std::vector< bool > at_processor_boundary
std::vector< FaceToCellTopology< 1 > > boundary_faces
std::vector< FaceToCellTopology< 1 > > refinement_edge_faces
std::vector< FaceCategory > face_is_owned
void initialize(const ::Triangulation< dim > &triangulation, const unsigned int mg_level, const bool hold_all_faces_to_owned_cells, std::vector< std::pair< unsigned int, unsigned int > > &cell_levels)
FaceToCellTopology< 1 > create_face(const unsigned int face_no, const typename ::Triangulation< dim >::cell_iterator &cell, const unsigned int number_cell_interior, const typename ::Triangulation< dim >::cell_iterator &neighbor, const unsigned int number_cell_exterior)
std::vector< FaceToCellTopology< 1 > > inner_ghost_faces
void generate_faces(const ::Triangulation< dim > &triangulation, const std::vector< std::pair< unsigned int, unsigned int > > &cell_levels, TaskInfo &task_info)