50 namespace TriangulationImplementation
124 template <
int dim,
int spacedim>
126 cell_is_patch_level_1(
131 unsigned int n_active_children = 0;
132 for (
unsigned int i = 0; i < cell->n_children(); ++i)
133 if (cell->child(i)->is_active())
136 return (n_active_children == 0) ||
137 (n_active_children == cell->n_children());
147 template <
int dim,
int spacedim>
149 cell_will_be_coarsened(
155 if (cell->has_children())
157 unsigned int children_to_coarsen = 0;
158 const unsigned int n_children = cell->n_children();
160 for (
unsigned int c = 0; c < n_children; ++c)
161 if (cell->child(c)->is_active() && cell->child(c)->coarsen_flag_set())
162 ++children_to_coarsen;
163 if (children_to_coarsen == n_children)
166 for (
unsigned int c = 0; c < n_children; ++c)
167 if (cell->child(c)->is_active())
168 cell->child(c)->clear_coarsen_flag();
204 template <
int dim,
int spacedim>
206 face_will_be_refined_by_neighbor_internal(
208 const unsigned int face_no,
217 cell->neighbor(face_no);
224 if (neighbor->has_children())
229 if (cell_will_be_coarsened(neighbor))
238 expected_face_ref_case = cell->face(face_no)->refinement_case();
250 const unsigned int neighbor_neighbor = cell->neighbor_face_no(face_no);
258 neighbor->face_orientation(neighbor_neighbor),
259 neighbor->face_flip(neighbor_neighbor),
260 neighbor->face_rotation(neighbor_neighbor));
264 neighbor_face = neighbor->face(neighbor_neighbor);
265 const int this_face_index = cell->face_index(face_no);
271 if (neighbor_face->index() == this_face_index)
277 expected_face_ref_case = face_ref_case;
295 for (
unsigned int c = 0; c < neighbor_face->n_children(); ++c)
296 if (neighbor_face->child_index(c) == this_face_index)
305 if ((neighbor_face->refinement_case() | face_ref_case) ==
306 neighbor_face->refinement_case())
325 expected_face_ref_case =
326 ~neighbor_face->refinement_case();
353 template <
int dim,
int spacedim>
355 face_will_be_refined_by_neighbor(
357 const unsigned int face_no)
360 return face_will_be_refined_by_neighbor_internal(cell, face_no, dummy);
367 template <
int dim,
int spacedim>
369 face_will_be_refined_by_neighbor(
371 const unsigned int face_no,
374 return face_will_be_refined_by_neighbor_internal(cell,
376 expected_face_ref_case);
381 template <
int dim,
int spacedim>
383 satisfies_level1_at_vertex_rule(
386 std::vector<unsigned int> min_adjacent_cell_level(
388 std::vector<unsigned int> max_adjacent_cell_level(
391 for (
const auto &cell :
triangulation.active_cell_iterators())
392 for (
const unsigned int v : cell->vertex_indices())
394 min_adjacent_cell_level[cell->vertex_index(v)] =
395 std::min<unsigned int>(
396 min_adjacent_cell_level[cell->vertex_index(v)], cell->level());
397 max_adjacent_cell_level[cell->vertex_index(v)] =
398 std::max<unsigned int>(
399 min_adjacent_cell_level[cell->vertex_index(v)], cell->level());
402 for (
unsigned int k = 0; k <
triangulation.n_vertices(); ++k)
404 if (max_adjacent_cell_level[k] - min_adjacent_cell_level[k] > 1)
417 template <
int dim,
int spacedim>
418 std::vector<unsigned int>
423 std::vector<unsigned int> line_cell_count(
triangulation.n_raw_lines(),
426 for (
unsigned int l = 0;
l < cell->n_lines(); ++
l)
427 ++line_cell_count[cell->line_index(
l)];
428 return line_cell_count;
431 return std::vector<unsigned int>();
442 template <
int dim,
int spacedim>
443 std::vector<unsigned int>
448 std::vector<unsigned int> quad_cell_count(
triangulation.n_raw_quads(),
451 for (
unsigned int q : cell->face_indices())
452 ++quad_cell_count[cell->quad_index(q)];
453 return quad_cell_count;
480 void reorder_compatibility(std::vector<
CellData<2>> &cells,
483 for (
auto &cell : cells)
485 std::swap(cell.vertices[2], cell.vertices[3]);
489 void reorder_compatibility(std::vector<
CellData<3>> &cells,
493 for (
auto &cell : cells)
497 tmp[i] = cell.vertices[i];
505 std::swap(boundary_quad.vertices[2], boundary_quad.vertices[3]);
527 template <
int dim,
int spacedim>
532 if (line->has_children())
533 return line->child(0)->vertex_index(1);
538 template <
int dim,
int spacedim>
543 switch (
static_cast<unsigned char>(quad->refinement_case()))
546 return middle_vertex_index<dim, spacedim>(quad->child(0)->line(1));
549 return middle_vertex_index<dim, spacedim>(quad->child(0)->line(3));
552 return quad->child(0)->vertex_index(3);
561 template <
int dim,
int spacedim>
566 switch (
static_cast<unsigned char>(hex->refinement_case()))
569 return middle_vertex_index<dim, spacedim>(hex->child(0)->quad(1));
572 return middle_vertex_index<dim, spacedim>(hex->child(0)->quad(3));
575 return middle_vertex_index<dim, spacedim>(hex->child(0)->quad(5));
578 return middle_vertex_index<dim, spacedim>(hex->child(0)->line(11));
581 return middle_vertex_index<dim, spacedim>(hex->child(0)->line(5));
584 return middle_vertex_index<dim, spacedim>(hex->child(0)->line(7));
587 return hex->child(0)->vertex_index(7);
608 template <
class TRIANGULATION>
609 inline typename TRIANGULATION::DistortedCellList
610 collect_distorted_coarse_cells(
const TRIANGULATION &)
612 return typename TRIANGULATION::DistortedCellList();
630 for (
const auto &cell :
triangulation.cell_iterators_on_level(0))
640 if (determinants[i] <= 1
e-9 *
std::pow(cell->diameter(), 1. * dim))
642 distorted_cells.distorted_cells.push_back(cell);
647 return distorted_cells;
659 has_distorted_children(
664 for (
unsigned int c = 0; c < cell->n_children(); ++c)
668 vertices[i] = cell->child(c)->vertex(i);
674 if (determinants[i] <=
675 1
e-9 *
std::pow(cell->child(c)->diameter(), 1. * dim))
690 template <
int dim,
int spacedim>
692 has_distorted_children(
699 template <
int dim,
int spacedim>
701 update_periodic_face_map_recursively(
704 unsigned int n_face_1,
705 unsigned int n_face_2,
706 const std::bitset<3> & orientation,
712 std::bitset<3>>> &periodic_face_map)
715 const FaceIterator face_1 = cell_1->face(n_face_1);
716 const FaceIterator face_2 = cell_2->face(n_face_2);
718 const bool face_orientation = orientation[0];
719 const bool face_flip = orientation[1];
720 const bool face_rotation = orientation[2];
722 Assert((dim != 1) || (face_orientation ==
true && face_flip ==
false &&
723 face_rotation ==
false),
725 "(face_orientation, face_flip, face_rotation) "
726 "is invalid for 1D"));
728 Assert((dim != 2) || (face_orientation ==
true && face_rotation ==
false),
730 "(face_orientation, face_flip, face_rotation) "
731 "is invalid for 2D"));
735 Assert(face_1->at_boundary() && face_2->at_boundary(),
736 ExcMessage(
"Periodic faces must be on the boundary"));
742 Assert(dim == 1 ||
std::abs(cell_1->level() - cell_2->level()) < 2,
747 std::pair<typename Triangulation<dim, spacedim>::cell_iterator,
749 const CellFace cell_face_1(cell_1, n_face_1);
750 const CellFace cell_face_2(cell_2, n_face_2);
751 const std::pair<CellFace, std::bitset<3>> cell_face_orientation_2(
752 cell_face_2, orientation);
754 const std::pair<CellFace, std::pair<CellFace, std::bitset<3>>>
755 periodic_faces(cell_face_1, cell_face_orientation_2);
759 periodic_face_map.insert(periodic_faces);
763 if (cell_1->has_children())
765 if (cell_2->has_children())
767 update_periodic_face_map_recursively<dim, spacedim>(
768 cell_1->child(n_face_1),
769 cell_2->child(n_face_2),
777 update_periodic_face_map_recursively<dim, spacedim>(
778 cell_1->child(n_face_1),
793 static const int lookup_table_2d[2][2] =
800 static const int lookup_table_3d[2][2][2][4] =
819 if (cell_1->has_children())
821 if (cell_2->has_children())
827 Assert(face_1->n_children() ==
833 for (
unsigned int i = 0;
834 i < GeometryInfo<dim>::max_children_per_face;
842 j = lookup_table_2d[face_flip][i];
845 j = lookup_table_3d[face_orientation][face_flip]
853 unsigned int child_cell_1 =
855 cell_1->refinement_case(),
858 cell_1->face_orientation(n_face_1),
859 cell_1->face_flip(n_face_1),
860 cell_1->face_rotation(n_face_1),
861 face_1->refinement_case());
862 unsigned int child_cell_2 =
864 cell_2->refinement_case(),
867 cell_2->face_orientation(n_face_2),
868 cell_2->face_flip(n_face_2),
869 cell_2->face_rotation(n_face_2),
870 face_2->refinement_case());
872 Assert(cell_1->child(child_cell_1)->face(n_face_1) ==
875 Assert(cell_2->child(child_cell_2)->face(n_face_2) ==
881 update_periodic_face_map_recursively<dim, spacedim>(
882 cell_1->child(child_cell_1),
883 cell_2->child(child_cell_2),
892 for (
unsigned int i = 0;
893 i < GeometryInfo<dim>::max_children_per_face;
897 unsigned int child_cell_1 =
899 cell_1->refinement_case(),
902 cell_1->face_orientation(n_face_1),
903 cell_1->face_flip(n_face_1),
904 cell_1->face_rotation(n_face_1),
905 face_1->refinement_case());
908 update_periodic_face_map_recursively<dim, spacedim>(
909 cell_1->child(child_cell_1),
927 namespace TriangulationImplementation
943 <<
"Something went wrong when making cell " << arg1
944 <<
". Read the docs and the source code "
945 <<
"for more information.");
952 <<
"Something went wrong upon construction of cell "
966 <<
" has negative measure. This typically "
967 <<
"indicates some distortion in the cell, or a mistakenly "
968 <<
"swapped pair of vertices in the input to "
969 <<
"Triangulation::create_triangulation().");
981 <<
"Error while creating cell " << arg1
982 <<
": the vertex index " << arg2 <<
" must be between 0 and "
991 <<
"While trying to assign a boundary indicator to a line: "
992 <<
"the line with end vertices " << arg1 <<
" and " << arg2
993 <<
" does not exist.");
1003 <<
"While trying to assign a boundary indicator to a quad: "
1004 <<
"the quad with bounding lines " << arg1 <<
", " << arg2
1005 <<
", " << arg3 <<
", " << arg4 <<
" does not exist.");
1015 <<
"The input data for creating a triangulation contained "
1016 <<
"information about a line with indices " << arg1 <<
" and " << arg2
1017 <<
" that is described to have boundary indicator "
1018 <<
static_cast<int>(arg3)
1019 <<
". However, this is an internal line not located on the "
1020 <<
"boundary. You cannot assign a boundary indicator to it." << std::endl
1022 <<
"If this happened at a place where you call "
1023 <<
"Triangulation::create_triangulation() yourself, you need "
1024 <<
"to check the SubCellData object you pass to this function."
1027 <<
"If this happened in a place where you are reading a mesh "
1028 <<
"from a file, then you need to investigate why such a line "
1029 <<
"ended up in the input file. A typical case is a geometry "
1030 <<
"that consisted of multiple parts and for which the mesh "
1031 <<
"generator program assumes that the interface between "
1032 <<
"two parts is a boundary when that isn't supposed to be "
1033 <<
"the case, or where the mesh generator simply assigns "
1034 <<
"'geometry indicators' to lines at the perimeter of "
1035 <<
"a part that are not supposed to be interpreted as "
1036 <<
"'boundary indicators'.");
1048 <<
"The input data for creating a triangulation contained "
1049 <<
"information about a quad with indices " << arg1 <<
", " << arg2
1050 <<
", " << arg3 <<
", and " << arg4
1051 <<
" that is described to have boundary indicator "
1052 <<
static_cast<int>(arg5)
1053 <<
". However, this is an internal quad not located on the "
1054 <<
"boundary. You cannot assign a boundary indicator to it." << std::endl
1056 <<
"If this happened at a place where you call "
1057 <<
"Triangulation::create_triangulation() yourself, you need "
1058 <<
"to check the SubCellData object you pass to this function."
1061 <<
"If this happened in a place where you are reading a mesh "
1062 <<
"from a file, then you need to investigate why such a quad "
1063 <<
"ended up in the input file. A typical case is a geometry "
1064 <<
"that consisted of multiple parts and for which the mesh "
1065 <<
"generator program assumes that the interface between "
1066 <<
"two parts is a boundary when that isn't supposed to be "
1067 <<
"the case, or where the mesh generator simply assigns "
1068 <<
"'geometry indicators' to quads at the surface of "
1069 <<
"a part that are not supposed to be interpreted as "
1070 <<
"'boundary indicators'.");
1079 <<
"In SubCellData the line info of the line with vertex indices " << arg1
1080 <<
" and " << arg2 <<
" appears more than once. "
1081 <<
"This is not allowed.");
1091 <<
"In SubCellData the line info of the line with vertex indices " << arg1
1092 <<
" and " << arg2 <<
" appears multiple times with different (valid) "
1093 << arg3 <<
". This is not allowed.");
1105 <<
"In SubCellData the quad info of the quad with line indices " << arg1
1106 <<
", " << arg2 <<
", " << arg3 <<
" and " << arg4
1107 <<
" appears multiple times with different (valid) " << arg5
1108 <<
". This is not allowed.");
1119 const unsigned int new_quads_in_pairs,
1120 const unsigned int new_quads_single)
1126 unsigned int next_free_single = 0;
1127 unsigned int next_free_pair = 0;
1131 unsigned int n_quads = 0;
1132 unsigned int n_unused_pairs = 0;
1133 unsigned int n_unused_singles = 0;
1134 for (
unsigned int i = 0; i < tria_faces.
quads.
used.size(); ++i)
1138 else if (i + 1 < tria_faces.
quads.
used.size())
1143 if (next_free_single == 0)
1144 next_free_single = i;
1149 if (next_free_pair == 0)
1157 Assert(n_quads + 2 * n_unused_pairs + n_unused_singles ==
1162 const int additional_single_quads = new_quads_single - n_unused_singles;
1164 unsigned int new_size =
1165 tria_faces.
quads.
used.size() + new_quads_in_pairs - 2 * n_unused_pairs;
1166 if (additional_single_quads > 0)
1167 new_size += additional_single_quads;
1206 const unsigned int total_cells,
1207 const unsigned int dimension,
1208 const unsigned int space_dimension)
1260 if (dimension < space_dimension)
1271 tria_level.
parents.reserve((total_cells + 1) / 2);
1273 (total_cells + 1) / 2 -
1277 tria_level.
neighbors.reserve(total_cells * (2 * dimension));
1279 total_cells * (2 * dimension) -
1281 std::make_pair(-1, -1));
1283 if (tria_level.
dim == 2 || tria_level.
dim == 3)
1285 const unsigned int max_faces_per_cell = 2 * dimension;
1287 max_faces_per_cell);
1290 total_cells * max_faces_per_cell -
1312 <<
"The containers have sizes " << arg1 <<
" and " << arg2
1313 <<
", which is not as expected.");
1322 const unsigned int true_dimension)
1325 (void)true_dimension;
1352 const unsigned int new_objects_in_pairs,
1353 const unsigned int new_objects_single = 0)
1365 unsigned int n_objects = 0;
1366 unsigned int n_unused_pairs = 0;
1367 unsigned int n_unused_singles = 0;
1368 for (
unsigned int i = 0; i < tria_objects.
used.size(); ++i)
1370 if (tria_objects.
used[i])
1372 else if (i + 1 < tria_objects.
used.size())
1374 if (tria_objects.
used[i + 1])
1391 Assert(n_objects + 2 * n_unused_pairs + n_unused_singles ==
1392 tria_objects.
used.size(),
1397 const int additional_single_objects =
1398 new_objects_single - n_unused_singles;
1400 unsigned int new_size = tria_objects.
used.size() +
1401 new_objects_in_pairs - 2 * n_unused_pairs;
1402 if (additional_single_objects > 0)
1403 new_size += additional_single_objects;
1406 if (new_size > tria_objects.
n_objects())
1408 const unsigned int max_faces_per_cell =
1410 const unsigned int max_children_per_cell =
1413 tria_objects.
cells.reserve(new_size * max_faces_per_cell);
1414 tria_objects.
cells.insert(tria_objects.
cells.end(),
1419 tria_objects.
used.reserve(new_size);
1420 tria_objects.
used.insert(tria_objects.
used.end(),
1421 new_size - tria_objects.
used.size(),
1430 const unsigned int factor = max_children_per_cell / 2;
1431 tria_objects.
children.reserve(factor * new_size);
1451 tria_objects.
user_data.reserve(new_size);
1452 tria_objects.
user_data.resize(new_size);
1461 if (n_unused_singles == 0)
1469 const unsigned int new_hexes = new_objects_in_pairs;
1471 const unsigned int new_size =
1472 new_hexes + std::count(tria_objects.
used.begin(),
1473 tria_objects.
used.end(),
1477 if (new_size > tria_objects.
n_objects())
1479 const unsigned int max_faces_per_cell =
1482 tria_objects.
cells.reserve(new_size * max_faces_per_cell);
1483 tria_objects.
cells.insert(tria_objects.
cells.end(),
1488 tria_objects.
used.reserve(new_size);
1489 tria_objects.
used.insert(tria_objects.
used.end(),
1490 new_size - tria_objects.
used.size(),
1499 tria_objects.
children.reserve(4 * new_size);
1518 tria_objects.
user_data.reserve(new_size);
1519 tria_objects.
user_data.resize(new_size);
1543 tria_object.
used.size()));
1584 template <
int dim,
int spacedim>
1606 std::vector<unsigned int> & line_cell_count,
1607 std::vector<unsigned int> &quad_cell_count) = 0;
1614 const bool check_for_distorted_cells) = 0;
1643 virtual std::unique_ptr<Policy<dim, spacedim>>
1654 template <
int dim,
int spacedim,
typename T>
1661 T::update_neighbors(tria);
1668 std::vector<unsigned int> & line_cell_count,
1669 std::vector<unsigned int> &quad_cell_count)
override
1671 T::delete_children(tria, cell, line_cell_count, quad_cell_count);
1676 const bool check_for_distorted_cells)
override
1678 return T::execute_refinement(
triangulation, check_for_distorted_cells);
1700 return T::template coarsening_allowed<dim, spacedim>(cell);
1703 std::unique_ptr<Policy<dim, spacedim>>
1706 return std::make_unique<PolicyWrapper<dim, spacedim, T>>();
1820 template <
int dim,
int spacedim>
1824 const unsigned int level_objects,
1827 using line_iterator =
1831 if (level_objects > 0)
1864 for (; line != endc; ++line)
1867 if (line->has_children() ==
false)
1885 for (; line != endc; ++line)
1888 if (line->has_children() ==
false)
1908 template <
int dim,
int spacedim>
1912 const unsigned int level_objects,
1923 &compute_number_cache<dim, spacedim>),
1929 using quad_iterator =
1946 unsigned int n_levels = 0;
1947 if (level_objects > 0)
1951 n_levels =
level + 1;
1964 (
level == n_levels - 1 ?
1967 for (; quad != endc; ++quad)
1970 if (quad->has_children() ==
false)
1988 for (; quad != endc; ++quad)
1991 if (quad->has_children() ==
false)
1997 update_lines.
join();
2015 template <
int dim,
int spacedim>
2019 const unsigned int level_objects,
2030 &compute_number_cache<dim, spacedim>),
2036 using hex_iterator =
2054 unsigned int n_levels = 0;
2055 if (level_objects > 0)
2059 n_levels =
level + 1;
2071 endc = (
level == n_levels - 1 ?
2074 for (; hex != endc; ++hex)
2077 if (hex->has_children() ==
false)
2095 for (; hex != endc; ++hex)
2098 if (hex->has_children() ==
false)
2104 update_quads_and_lines.
join();
2109 template <
int spacedim>
2114 template <
int dim,
int spacedim>
2169 static const unsigned int left_right_offset[2][6][2] = {
2178 {{0, 1}, {1, 0}, {0, 1}, {1, 0}, {0, 1}, {1, 0}}};
2189 std::vector<typename Triangulation<dim, spacedim>::cell_iterator>
2193 for (
auto f : cell->face_indices())
2198 const unsigned int offset =
2199 (cell->direction_flag() ?
2200 left_right_offset[dim - 2][f][cell->face_orientation(f)] :
2202 left_right_offset[dim - 2][f][cell->face_orientation(f)]);
2214 if (cell->is_active() && face->has_children())
2244 if (face->has_children() &&
2245 (cell->is_active() ||
2247 cell->refinement_case(), f) ==
2250 for (
unsigned int c = 0; c < face->n_children(); ++c)
2253 if (face->child(0)->has_children())
2260 if (face->child(1)->has_children())
2277 for (
auto f : cell->face_indices())
2279 const unsigned int offset =
2280 (cell->direction_flag() ?
2281 left_right_offset[dim - 2][f][cell->face_orientation(f)] :
2283 left_right_offset[dim - 2][f][cell->face_orientation(f)]);
2293 template <
int dim,
int spacedim>
2307 if (dim == spacedim)
2308 for (
unsigned int cell_no = 0; cell_no < cells.size(); ++cell_no)
2316 const double cell_measure = GridTools::cell_measure<spacedim>(
2331 tria.
faces = std::make_unique<
2339 const auto connectivity = build_connectivity<unsigned int>(cells);
2340 const unsigned int n_cell = cells.size();
2345 auto &lines_0 = tria.
faces->lines;
2348 const auto & crs = connectivity.entity_to_entities(1, 0);
2349 const unsigned int n_lines = crs.ptr.size() - 1;
2355 for (
unsigned int line = 0; line < n_lines; ++line)
2356 for (
unsigned int i = crs.ptr[line], j = 0; i < crs.ptr[line + 1];
2365 auto &quads_0 = tria.
faces->quads;
2366 auto &faces = *tria.
faces;
2369 const auto & crs = connectivity.entity_to_entities(2, 1);
2370 const unsigned int n_quads = crs.ptr.size() - 1;
2377 for (
unsigned int q = 0, k = 0; q < n_quads; ++q)
2380 faces.quad_reference_cell[q] = connectivity.entity_types(2)[q];
2383 for (
unsigned int i = crs.ptr[q], j = 0; i < crs.ptr[q + 1];
2391 faces.quads_line_orientations
2393 connectivity.entity_orientations(1)[k];
2400 auto &cells_0 = tria.
levels[0]->cells;
2404 const auto &crs = connectivity.entity_to_entities(dim, dim - 1);
2405 const auto &nei = connectivity.entity_to_entities(dim, dim);
2409 const bool orientation_needed =
2412 std::any_of(connectivity.entity_orientations(1).begin(),
2413 connectivity.entity_orientations(1).end(),
2414 [](
const auto &i) { return i == 0; }));
2421 for (
unsigned int cell = 0; cell < n_cell; ++cell)
2424 cells_0.boundary_or_material_id[cell].material_id =
2425 cells[cell].material_id;
2428 cells_0.manifold_id[cell] = cells[cell].manifold_id;
2431 level.reference_cell[cell] = connectivity.entity_types(dim)[cell];
2434 for (
unsigned int i = crs.ptr[cell], j = 0; i < crs.ptr[cell + 1];
2438 if (nei.col[i] !=
static_cast<unsigned int>(-1))
2440 j] = {0, nei.col[i]};
2447 if (orientation_needed)
2448 level.face_orientations
2450 connectivity.entity_orientations(dim - 1)[i];
2458 auto &bids_face = dim == 3 ?
2459 tria.
faces->quads.boundary_or_material_id :
2460 tria.
faces->lines.boundary_or_material_id;
2463 std::vector<unsigned int> count(bids_face.size(), 0);
2466 const auto &crs = connectivity.entity_to_entities(dim, dim - 1);
2469 for (
unsigned int cell = 0; cell < cells.size(); ++cell)
2470 for (
unsigned int i = crs.ptr[cell]; i < crs.ptr[cell + 1]; ++i)
2471 count[crs.col[i]]++;
2474 for (
unsigned int face = 0; face < count.size(); ++face)
2476 if (count[face] != 1)
2480 bids_face[face].boundary_id = 0;
2486 const auto &crs = connectivity.entity_to_entities(2, 1);
2487 for (
unsigned int i = crs.ptr[face]; i < crs.ptr[face + 1]; ++i)
2488 tria.
faces->lines.boundary_or_material_id[crs.col[i]]
2494 static const unsigned int t_tba =
static_cast<unsigned int>(-1);
2495 static const unsigned int t_inner =
static_cast<unsigned int>(-2);
2497 std::vector<unsigned int> type(
vertices.size(), t_tba);
2499 const auto &crs = connectivity.entity_to_entities(1, 0);
2501 for (
unsigned int cell = 0; cell < cells.size(); ++cell)
2502 for (
unsigned int i = crs.ptr[cell], j = 0; i < crs.ptr[cell + 1];
2504 if (type[crs.col[i]] != t_inner)
2505 type[crs.col[i]] = type[crs.col[i]] == t_tba ? j : t_inner;
2507 for (
unsigned int face = 0; face < type.size(); ++face)
2512 if (type[face] != t_inner && type[face] != t_tba)
2531 template <
int structdim,
typename T>
2540 if (boundary_objects_in.size() == 0)
2544 auto boundary_objects = boundary_objects_in;
2547 for (
auto &boundary_object : boundary_objects)
2548 std::sort(boundary_object.vertices.begin(),
2549 boundary_object.vertices.end());
2552 std::sort(boundary_objects.begin(),
2553 boundary_objects.end(),
2554 [](
const auto &a,
const auto &
b) {
2555 return a.vertices < b.vertices;
2558 unsigned int counter = 0;
2560 std::vector<unsigned int> key;
2563 for (
unsigned int o = 0; o < obj.
n_objects(); ++o)
2577 key.assign(crs.
col.data() + crs.
ptr[o],
2578 crs.
col.data() + crs.
ptr[o + 1]);
2579 std::sort(key.begin(), key.end());
2582 const auto subcell_object =
2584 boundary_objects.end(),
2586 [&](
const auto &cell,
const auto &key) {
2587 return cell.vertices < key;
2591 if (subcell_object == boundary_objects.end() ||
2592 subcell_object->vertices != key)
2601 if (subcell_object->boundary_id !=
2619 const unsigned structdim,
2620 const unsigned int size)
2622 const unsigned int dim = faces.
dim;
2624 const unsigned int max_faces_per_cell = 2 * structdim;
2626 if (dim == 3 && structdim == 2)
2641 const unsigned int spacedim,
2642 const unsigned int size,
2643 const bool orientation_needed)
2645 const unsigned int dim =
level.dim;
2647 const unsigned int max_faces_per_cell = 2 * dim;
2649 level.active_cell_indices.assign(size, -1);
2650 level.subdomain_ids.assign(size, 0);
2651 level.level_subdomain_ids.assign(size, 0);
2653 level.refine_flags.assign(size,
false);
2654 level.coarsen_flags.assign(size,
false);
2656 level.parents.assign((size + 1) / 2, -1);
2659 level.direction_flags.assign(size,
true);
2661 level.neighbors.assign(size * max_faces_per_cell, {-1, -1});
2665 if (orientation_needed)
2666 level.face_orientations.assign(size * max_faces_per_cell, -1);
2668 level.global_active_cell_indices.assign(size,
2670 level.global_level_cell_indices.assign(size,
2679 const unsigned int structdim = obj.
structdim;
2681 const unsigned int max_children_per_cell = 1 << structdim;
2682 const unsigned int max_faces_per_cell = 2 * structdim;
2684 obj.
used.assign(size,
true);
2688 BoundaryOrMaterialId());
2696 obj.
children.assign(max_children_per_cell / 2 * size, -1);
2698 obj.
cells.assign(max_faces_per_cell * size, -1);
2728 template <
int spacedim>
2732 std::vector<unsigned int> &,
2733 std::vector<unsigned int> &)
2735 const unsigned int dim = 1;
2747 Assert(!cell->child(0)->has_children() &&
2748 !cell->child(1)->has_children(),
2754 if (cell->neighbor(0)->has_children())
2761 neighbor = neighbor->child(1);
2764 Assert(neighbor->neighbor(1) == cell->child(0),
2766 neighbor->set_neighbor(1, cell);
2772 if (neighbor->has_children())
2773 neighbor = neighbor->child(1);
2782 if (cell->neighbor(1)->has_children())
2789 neighbor = neighbor->child(0);
2792 Assert(neighbor->neighbor(0) == cell->child(1),
2794 neighbor->set_neighbor(0, cell);
2800 if (neighbor->has_children())
2801 neighbor = neighbor->child(0);
2811 triangulation.vertices_used[cell->child(0)->vertex_index(1)] =
false;
2817 for (
unsigned int child = 0; child < cell->n_children(); ++child)
2820 cell->child(child)->clear_user_flag();
2821 cell->child(child)->clear_used_flag();
2826 cell->clear_children();
2827 cell->clear_user_flag();
2832 template <
int spacedim>
2836 std::vector<unsigned int> & line_cell_count,
2837 std::vector<unsigned int> &)
2839 const unsigned int dim = 2;
2847 std::vector<typename Triangulation<dim, spacedim>::line_iterator>
2850 lines_to_delete.reserve(4 * 2 + 4);
2855 for (
unsigned int c = 0; c < cell->n_children(); ++c)
2859 for (
unsigned int l = 0; l < GeometryInfo<dim>::lines_per_cell; ++
l)
2860 --line_cell_count[child->line_index(
l)];
2875 .vertices_used[cell->child(0)->line(1)->vertex_index(1)] =
false;
2877 lines_to_delete.push_back(cell->child(0)->line(1));
2878 lines_to_delete.push_back(cell->child(0)->line(3));
2879 lines_to_delete.push_back(cell->child(3)->line(0));
2880 lines_to_delete.push_back(cell->child(3)->line(2));
2884 unsigned int inner_face_no =
2889 lines_to_delete.push_back(cell->child(0)->line(inner_face_no));
2893 for (
unsigned int child = 0; child < cell->n_children(); ++child)
2895 cell->child(child)->clear_user_data();
2896 cell->child(child)->clear_user_flag();
2897 cell->child(child)->clear_used_flag();
2902 cell->clear_children();
2903 cell->clear_refinement_case();
2904 cell->clear_user_flag();
2910 for (
unsigned int line_no = 0;
2911 line_no < GeometryInfo<dim>::lines_per_cell;
2915 cell->line(line_no);
2917 if (line->has_children())
2922 Assert((line_cell_count[line->child_index(0)] == 0 &&
2923 line_cell_count[line->child_index(1)] == 0) ||
2924 (line_cell_count[line->child_index(0)] > 0 &&
2925 line_cell_count[line->child_index(1)] > 0),
2928 if (line_cell_count[line->child_index(0)] == 0)
2930 for (
unsigned int c = 0; c < 2; ++c)
2931 Assert(!line->child(c)->has_children(),
2939 .vertices_used[line->child(0)->vertex_index(1)] =
false;
2941 lines_to_delete.push_back(line->child(0));
2942 lines_to_delete.push_back(line->child(1));
2944 line->clear_children();
2956 typename std::vector<
2958 line = lines_to_delete.
begin(),
2959 endline = lines_to_delete.end();
2960 for (; line != endline; ++line)
2962 (*line)->clear_user_data();
2963 (*line)->clear_user_flag();
2964 (*line)->clear_used_flag();
2970 template <
int spacedim>
2974 std::vector<unsigned int> & line_cell_count,
2975 std::vector<unsigned int> & quad_cell_count)
2977 const unsigned int dim = 3;
2989 std::vector<typename Triangulation<dim, spacedim>::line_iterator>
2991 std::vector<typename Triangulation<dim, spacedim>::quad_iterator>
2994 lines_to_delete.reserve(12 * 2 + 6 * 4 + 6);
2995 quads_to_delete.reserve(6 * 4 + 12);
2999 for (
unsigned int c = 0; c < cell->n_children(); ++c)
3003 for (
unsigned int l = 0; l < GeometryInfo<dim>::lines_per_cell; ++
l)
3004 --line_cell_count[child->line_index(
l)];
3006 --quad_cell_count[child->quad_index(f)];
3020 quads_to_delete.push_back(cell->child(0)->face(1));
3023 quads_to_delete.push_back(cell->child(0)->face(3));
3026 quads_to_delete.push_back(cell->child(0)->face(5));
3029 quads_to_delete.push_back(cell->child(0)->face(1));
3030 quads_to_delete.push_back(cell->child(0)->face(3));
3031 quads_to_delete.push_back(cell->child(3)->face(0));
3032 quads_to_delete.push_back(cell->child(3)->face(2));
3034 lines_to_delete.push_back(cell->child(0)->line(11));
3037 quads_to_delete.push_back(cell->child(0)->face(1));
3038 quads_to_delete.push_back(cell->child(0)->face(5));
3039 quads_to_delete.push_back(cell->child(3)->face(0));
3040 quads_to_delete.push_back(cell->child(3)->face(4));
3042 lines_to_delete.push_back(cell->child(0)->line(5));
3045 quads_to_delete.push_back(cell->child(0)->face(3));
3046 quads_to_delete.push_back(cell->child(0)->face(5));
3047 quads_to_delete.push_back(cell->child(3)->face(2));
3048 quads_to_delete.push_back(cell->child(3)->face(4));
3050 lines_to_delete.push_back(cell->child(0)->line(7));
3053 quads_to_delete.push_back(cell->child(0)->face(1));
3054 quads_to_delete.push_back(cell->child(2)->face(1));
3055 quads_to_delete.push_back(cell->child(4)->face(1));
3056 quads_to_delete.push_back(cell->child(6)->face(1));
3058 quads_to_delete.push_back(cell->child(0)->face(3));
3059 quads_to_delete.push_back(cell->child(1)->face(3));
3060 quads_to_delete.push_back(cell->child(4)->face(3));
3061 quads_to_delete.push_back(cell->child(5)->face(3));
3063 quads_to_delete.push_back(cell->child(0)->face(5));
3064 quads_to_delete.push_back(cell->child(1)->face(5));
3065 quads_to_delete.push_back(cell->child(2)->face(5));
3066 quads_to_delete.push_back(cell->child(3)->face(5));
3068 lines_to_delete.push_back(cell->child(0)->line(5));
3069 lines_to_delete.push_back(cell->child(0)->line(7));
3070 lines_to_delete.push_back(cell->child(0)->line(11));
3071 lines_to_delete.push_back(cell->child(7)->line(0));
3072 lines_to_delete.push_back(cell->child(7)->line(2));
3073 lines_to_delete.push_back(cell->child(7)->line(8));
3079 triangulation.vertices_used[cell->child(0)->vertex_index(7)] =
3091 for (
unsigned int child = 0; child < cell->n_children(); ++child)
3093 cell->child(child)->clear_user_data();
3094 cell->child(child)->clear_user_flag();
3101 cell->child(child)->set_face_orientation(f,
true);
3102 cell->child(child)->set_face_flip(f,
false);
3103 cell->child(child)->set_face_rotation(f,
false);
3106 cell->child(child)->clear_used_flag();
3111 cell->clear_children();
3112 cell->clear_refinement_case();
3113 cell->clear_user_flag();
3126 cell->face(quad_no);
3130 quad->has_children()) ||
3135 switch (quad->refinement_case())
3147 Assert((quad_cell_count[quad->child_index(0)] == 0 &&
3148 quad_cell_count[quad->child_index(1)] == 0) ||
3149 (quad_cell_count[quad->child_index(0)] > 0 &&
3150 quad_cell_count[quad->child_index(1)] > 0),
3156 unsigned int deleted_grandchildren = 0;
3157 unsigned int number_of_child_refinements = 0;
3159 for (
unsigned int c = 0; c < 2; ++c)
3160 if (quad->child(c)->has_children())
3162 ++number_of_child_refinements;
3167 (quad_cell_count[quad->child(c)->child_index(0)] ==
3169 quad_cell_count[quad->child(c)->child_index(1)] ==
3171 (quad_cell_count[quad->child(c)->child_index(0)] >
3173 quad_cell_count[quad->child(c)->child_index(1)] >
3176 if (quad_cell_count[quad->child(c)->child_index(0)] ==
3183 Assert(quad->refinement_case() +
3184 quad->child(c)->refinement_case() ==
3192 quads_to_delete.push_back(
3193 quad->child(c)->child(0));
3194 quads_to_delete.push_back(
3195 quad->child(c)->child(1));
3196 if (quad->child(c)->refinement_case() ==
3198 lines_to_delete.push_back(
3199 quad->child(c)->child(0)->line(1));
3201 lines_to_delete.push_back(
3202 quad->child(c)->child(0)->line(3));
3203 quad->child(c)->clear_children();
3204 quad->child(c)->clear_refinement_case();
3205 ++deleted_grandchildren;
3213 if (number_of_child_refinements > 0 &&
3214 deleted_grandchildren == number_of_child_refinements)
3219 middle_line = quad->child(0)->line(1);
3221 middle_line = quad->child(0)->line(3);
3223 lines_to_delete.push_back(middle_line->child(0));
3224 lines_to_delete.push_back(middle_line->child(1));
3226 .vertices_used[middle_vertex_index<dim, spacedim>(
3227 middle_line)] =
false;
3228 middle_line->clear_children();
3233 if (quad_cell_count[quad->child_index(0)] == 0)
3239 quads_to_delete.push_back(quad->child(0));
3240 quads_to_delete.push_back(quad->child(1));
3242 lines_to_delete.push_back(quad->child(0)->line(1));
3244 lines_to_delete.push_back(quad->child(0)->line(3));
3264 if (quad->child(0)->has_children())
3265 if (quad->refinement_case() ==
3299 quad_iterator switch_1 =
3300 quad->child(0)->child(1),
3302 quad->child(1)->child(0);
3304 Assert(!switch_1->has_children(),
3306 Assert(!switch_2->has_children(),
3309 const int switch_1_index = switch_1->index();
3310 const int switch_2_index = switch_2->index();
3311 for (
unsigned int l = 0;
3314 for (
unsigned int h = 0;
3318 for (
const unsigned int q :
3323 ->cells.get_bounding_object_indices(
3325 if (index == switch_1_index)
3327 ->cells.get_bounding_object_indices(
3328 h)[q] = switch_2_index;
3329 else if (index == switch_2_index)
3331 ->cells.get_bounding_object_indices(
3332 h)[q] = switch_1_index;
3337 const int switch_1_lines[4] = {
3338 static_cast<signed int>(
3339 switch_1->line_index(0)),
3340 static_cast<signed int>(
3341 switch_1->line_index(1)),
3342 static_cast<signed int>(
3343 switch_1->line_index(2)),
3344 static_cast<signed int>(
3345 switch_1->line_index(3))};
3346 const bool switch_1_line_orientations[4] = {
3347 switch_1->line_orientation(0),
3348 switch_1->line_orientation(1),
3349 switch_1->line_orientation(2),
3350 switch_1->line_orientation(3)};
3352 switch_1->boundary_id();
3353 const unsigned int switch_1_user_index =
3354 switch_1->user_index();
3355 const bool switch_1_user_flag =
3356 switch_1->user_flag_set();
3358 switch_1->set_bounding_object_indices(
3359 {switch_2->line_index(0),
3360 switch_2->line_index(1),
3361 switch_2->line_index(2),
3362 switch_2->line_index(3)});
3363 switch_1->set_line_orientation(
3364 0, switch_2->line_orientation(0));
3365 switch_1->set_line_orientation(
3366 1, switch_2->line_orientation(1));
3367 switch_1->set_line_orientation(
3368 2, switch_2->line_orientation(2));
3369 switch_1->set_line_orientation(
3370 3, switch_2->line_orientation(3));
3371 switch_1->set_boundary_id_internal(
3372 switch_2->boundary_id());
3373 switch_1->set_manifold_id(
3374 switch_2->manifold_id());
3375 switch_1->set_user_index(switch_2->user_index());
3376 if (switch_2->user_flag_set())
3377 switch_1->set_user_flag();
3379 switch_1->clear_user_flag();
3381 switch_2->set_bounding_object_indices(
3385 switch_1_lines[3]});
3386 switch_2->set_line_orientation(
3387 0, switch_1_line_orientations[0]);
3388 switch_2->set_line_orientation(
3389 1, switch_1_line_orientations[1]);
3390 switch_2->set_line_orientation(
3391 2, switch_1_line_orientations[2]);
3392 switch_2->set_line_orientation(
3393 3, switch_1_line_orientations[3]);
3394 switch_2->set_boundary_id_internal(
3395 switch_1_boundary_id);
3396 switch_2->set_manifold_id(
3397 switch_1->manifold_id());
3398 switch_2->set_user_index(switch_1_user_index);
3399 if (switch_1_user_flag)
3400 switch_2->set_user_flag();
3402 switch_2->clear_user_flag();
3404 const unsigned int child_0 =
3405 quad->child(0)->child_index(0);
3406 const unsigned int child_2 =
3407 quad->child(1)->child_index(0);
3408 quad->clear_children();
3409 quad->clear_refinement_case();
3410 quad->set_refinement_case(
3412 quad->set_children(0, child_0);
3413 quad->set_children(2, child_2);
3415 quad_cell_count[child_2]);
3430 const unsigned int child_0 =
3431 quad->child(0)->child_index(0);
3432 const unsigned int child_2 =
3433 quad->child(1)->child_index(0);
3434 quad->clear_children();
3435 quad->clear_refinement_case();
3436 quad->set_refinement_case(
3438 quad->set_children(0, child_0);
3439 quad->set_children(2, child_2);
3443 quad->clear_children();
3444 quad->clear_refinement_case();
3455 Assert((quad_cell_count[quad->child_index(0)] == 0 &&
3456 quad_cell_count[quad->child_index(1)] == 0 &&
3457 quad_cell_count[quad->child_index(2)] == 0 &&
3458 quad_cell_count[quad->child_index(3)] == 0) ||
3459 (quad_cell_count[quad->child_index(0)] > 0 &&
3460 quad_cell_count[quad->child_index(1)] > 0 &&
3461 quad_cell_count[quad->child_index(2)] > 0 &&
3462 quad_cell_count[quad->child_index(3)] > 0),
3465 if (quad_cell_count[quad->child_index(0)] == 0)
3471 lines_to_delete.push_back(quad->child(0)->line(1));
3472 lines_to_delete.push_back(quad->child(3)->line(0));
3473 lines_to_delete.push_back(quad->child(0)->line(3));
3474 lines_to_delete.push_back(quad->child(3)->line(2));
3476 for (
unsigned int child = 0; child < quad->n_children();
3478 quads_to_delete.push_back(quad->child(child));
3481 .vertices_used[quad->child(0)->vertex_index(3)] =
3484 quad->clear_children();
3485 quad->clear_refinement_case();
3504 for (
unsigned int line_no = 0;
3505 line_no < GeometryInfo<dim>::lines_per_cell;
3509 cell->line(line_no);
3513 line->has_children()) ||
3518 if (line->has_children())
3523 Assert((line_cell_count[line->child_index(0)] == 0 &&
3524 line_cell_count[line->child_index(1)] == 0) ||
3525 (line_cell_count[line->child_index(0)] > 0 &&
3526 line_cell_count[line->child_index(1)] > 0),
3529 if (line_cell_count[line->child_index(0)] == 0)
3531 for (
unsigned int c = 0; c < 2; ++c)
3532 Assert(!line->child(c)->has_children(),
3540 .vertices_used[line->child(0)->vertex_index(1)] =
false;
3542 lines_to_delete.push_back(line->child(0));
3543 lines_to_delete.push_back(line->child(1));
3545 line->clear_children();
3557 typename std::vector<
3559 line = lines_to_delete.
begin(),
3560 endline = lines_to_delete.end();
3561 for (; line != endline; ++line)
3563 (*line)->clear_user_data();
3564 (*line)->clear_user_flag();
3565 (*line)->clear_used_flag();
3568 typename std::vector<
3570 quad = quads_to_delete.
begin(),
3571 endquad = quads_to_delete.end();
3572 for (; quad != endquad; ++quad)
3574 (*quad)->clear_user_data();
3575 (*quad)->clear_children();
3576 (*quad)->clear_refinement_case();
3577 (*quad)->clear_user_flag();
3578 (*quad)->clear_used_flag();
3600 template <
int spacedim>
3603 unsigned int & next_unused_vertex,
3610 const unsigned int dim = 2;
3613 cell->clear_refine_flag();
3710 int new_vertices[9];
3711 for (
unsigned int vertex_no = 0; vertex_no < 4; ++vertex_no)
3712 new_vertices[vertex_no] = cell->vertex_index(vertex_no);
3713 for (
unsigned int line_no = 0; line_no < 4; ++line_no)
3714 if (cell->line(line_no)->has_children())
3715 new_vertices[4 + line_no] =
3716 cell->line(line_no)->child(0)->vertex_index(1);
3725 while (
triangulation.vertices_used[next_unused_vertex] ==
true)
3726 ++next_unused_vertex;
3730 "Internal error: During refinement, the triangulation wants to access an element of the 'vertices' array but it turns out that the array is not large enough."));
3733 new_vertices[8] = next_unused_vertex;
3745 if (dim == spacedim)
3748 triangulation.vertices[next_unused_vertex] = cell->center(
true);
3755 if (cell->user_flag_set())
3758 cell->clear_user_flag();
3760 cell->center(
true,
true);
3770 cell->clear_user_flag();
3776 cell->center(
true,
true);
3783 unsigned int lmin = 8;
3784 unsigned int lmax = 12;
3791 for (
unsigned int l = lmin;
l < lmax; ++
l)
3793 while (next_unused_line->used() ==
true)
3795 new_lines[
l] = next_unused_line;
3799 new_lines[
l]->used() ==
false,
3801 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
3816 for (
unsigned int c = 0; c < 2; ++c, ++
l)
3817 new_lines[
l] = cell->line(face_no)->child(c);
3820 new_lines[8]->set_bounding_object_indices(
3821 {new_vertices[6], new_vertices[8]});
3822 new_lines[9]->set_bounding_object_indices(
3823 {new_vertices[8], new_vertices[7]});
3824 new_lines[10]->set_bounding_object_indices(
3825 {new_vertices[4], new_vertices[8]});
3826 new_lines[11]->set_bounding_object_indices(
3827 {new_vertices[8], new_vertices[5]});
3836 new_lines[0] = cell->line(0);
3837 new_lines[1] = cell->line(1);
3838 new_lines[2] = cell->line(2)->child(0);
3839 new_lines[3] = cell->line(2)->child(1);
3840 new_lines[4] = cell->line(3)->child(0);
3841 new_lines[5] = cell->line(3)->child(1);
3842 new_lines[6]->set_bounding_object_indices(
3843 {new_vertices[6], new_vertices[7]});
3853 new_lines[0] = cell->line(0)->child(0);
3854 new_lines[1] = cell->line(0)->child(1);
3855 new_lines[2] = cell->line(1)->child(0);
3856 new_lines[3] = cell->line(1)->child(1);
3857 new_lines[4] = cell->line(2);
3858 new_lines[5] = cell->line(3);
3859 new_lines[6]->set_bounding_object_indices(
3860 {new_vertices[4], new_vertices[5]});
3863 for (
unsigned int l = lmin;
l < lmax; ++
l)
3865 new_lines[
l]->set_used_flag();
3866 new_lines[
l]->clear_user_flag();
3868 new_lines[
l]->clear_children();
3870 new_lines[
l]->set_boundary_id_internal(
3872 new_lines[
l]->set_manifold_id(cell->manifold_id());
3879 while (next_unused_cell->used() ==
true)
3883 for (
unsigned int i = 0; i < n_children; ++i)
3886 next_unused_cell->used() ==
false,
3888 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
3889 subcells[i] = next_unused_cell;
3891 if (i % 2 == 1 && i < n_children - 1)
3892 while (next_unused_cell->used() ==
true)
3910 subcells[0]->set_bounding_object_indices({new_lines[0]->index(),
3911 new_lines[8]->index(),
3912 new_lines[4]->index(),
3913 new_lines[10]->index()});
3914 subcells[1]->set_bounding_object_indices({new_lines[8]->index(),
3915 new_lines[2]->index(),
3916 new_lines[5]->index(),
3917 new_lines[11]->index()});
3918 subcells[2]->set_bounding_object_indices({new_lines[1]->index(),
3919 new_lines[9]->index(),
3920 new_lines[10]->index(),
3921 new_lines[6]->index()});
3922 subcells[3]->set_bounding_object_indices({new_lines[9]->index(),
3923 new_lines[3]->index(),
3924 new_lines[11]->index(),
3925 new_lines[7]->index()});
3941 subcells[0]->set_bounding_object_indices({new_lines[0]->index(),
3942 new_lines[6]->index(),
3943 new_lines[2]->index(),
3944 new_lines[4]->index()});
3945 subcells[1]->set_bounding_object_indices({new_lines[6]->index(),
3946 new_lines[1]->index(),
3947 new_lines[3]->index(),
3948 new_lines[5]->index()});
3965 subcells[0]->set_bounding_object_indices({new_lines[0]->index(),
3966 new_lines[2]->index(),
3967 new_lines[4]->index(),
3968 new_lines[6]->index()});
3969 subcells[1]->set_bounding_object_indices({new_lines[1]->index(),
3970 new_lines[3]->index(),
3971 new_lines[6]->index(),
3972 new_lines[5]->index()});
3977 for (
unsigned int i = 0; i < n_children; ++i)
3979 subcells[i]->set_used_flag();
3980 subcells[i]->clear_refine_flag();
3981 subcells[i]->clear_user_flag();
3983 subcells[i]->clear_children();
3986 subcells[i]->set_material_id(cell->material_id());
3987 subcells[i]->set_manifold_id(cell->manifold_id());
3988 subcells[i]->set_subdomain_id(subdomainid);
3991 subcells[i]->set_parent(cell->index());
3999 for (
unsigned int i = 0; i < n_children / 2; ++i)
4000 cell->set_children(2 * i, subcells[2 * i]->index());
4002 cell->set_refinement_case(ref_case);
4010 for (
unsigned int c = 0; c < n_children; ++c)
4011 cell->child(c)->set_direction_flag(cell->direction_flag());
4016 template <
int dim,
int spacedim>
4019 const bool check_for_distorted_cells)
4025 for (
const auto &cell :
triangulation.active_cell_iterators_on_level(
4027 if (cell->refine_flag_set())
4040 line->clear_user_flag();
4044 unsigned int n_single_lines = 0;
4045 unsigned int n_lines_in_pairs = 0;
4046 unsigned int needed_vertices = 0;
4052 unsigned int needed_cells = 0;
4054 for (
const auto &cell :
4056 if (cell->refine_flag_set())
4058 if (cell->reference_cell() ==
4062 needed_vertices += 0;
4063 n_single_lines += 3;
4065 else if (cell->reference_cell() ==
4069 needed_vertices += 1;
4070 n_single_lines += 4;
4077 for (
const auto line_no : cell->face_indices())
4079 auto line = cell->line(line_no);
4080 if (line->has_children() ==
false)
4081 line->set_user_flag();
4086 const unsigned int used_cells =
4093 used_cells + needed_cells,
4105 if (line->user_flag_set())
4108 n_lines_in_pairs += 2;
4109 needed_vertices += 1;
4114 needed_vertices += std::count(
triangulation.vertices_used.begin(),
4124 unsigned int next_unused_vertex = 0;
4133 for (; line != endl; ++line)
4134 if (line->user_flag_set())
4140 while (
triangulation.vertices_used[next_unused_vertex] ==
true)
4141 ++next_unused_vertex;
4145 "Internal error: During refinement, the triangulation wants to access an element of the 'vertices' array but it turns out that the array is not large enough."));
4148 triangulation.vertices[next_unused_vertex] = line->center(
true);
4150 bool pair_found =
false;
4152 for (; next_unused_line != endl; ++next_unused_line)
4153 if (!next_unused_line->used() &&
4154 !(++next_unused_line)->used())
4162 line->set_children(0, next_unused_line->index());
4165 children[2] = {next_unused_line, ++next_unused_line};
4168 children[0]->used() ==
false,
4170 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
4172 children[1]->used() ==
false,
4174 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
4176 children[0]->set_bounding_object_indices(
4177 {line->vertex_index(0), next_unused_vertex});
4178 children[1]->set_bounding_object_indices(
4179 {next_unused_vertex, line->vertex_index(1)});
4181 children[0]->set_used_flag();
4182 children[1]->set_used_flag();
4183 children[0]->clear_children();
4184 children[1]->clear_children();
4187 children[0]->clear_user_flag();
4188 children[1]->clear_user_flag();
4191 children[0]->set_boundary_id_internal(line->boundary_id());
4192 children[1]->set_boundary_id_internal(line->boundary_id());
4194 children[0]->set_manifold_id(line->manifold_id());
4195 children[1]->set_manifold_id(line->manifold_id());
4197 line->clear_user_flag();
4204 cells_with_distorted_children;
4210 unsigned int &next_unused_vertex,
4211 auto & next_unused_line,
4212 auto & next_unused_cell,
4213 const auto & cell) {
4214 const auto ref_case = cell->refine_flag_set();
4215 cell->clear_refine_flag();
4217 unsigned int n_new_vertices = 0;
4221 else if (cell->reference_cell() ==
4227 std::vector<int> new_vertices(n_new_vertices);
4228 for (
unsigned int vertex_no = 0; vertex_no < cell->
n_vertices();
4230 new_vertices[vertex_no] = cell->vertex_index(vertex_no);
4231 for (
unsigned int line_no = 0; line_no < cell->
n_lines(); ++line_no)
4232 if (cell->line(line_no)->has_children())
4234 cell->line(line_no)->child(0)->vertex_index(1);
4238 while (
triangulation.vertices_used[next_unused_vertex] ==
true)
4239 ++next_unused_vertex;
4243 "Internal error: During refinement, the triangulation wants to access an element of the 'vertices' array but it turns out that the array is not large enough."));
4246 new_vertices[8] = next_unused_vertex;
4248 if (dim == spacedim)
4253 if (cell->user_flag_set())
4255 cell->clear_user_flag();
4257 cell->center(
true,
true);
4262 cell->clear_user_flag();
4265 cell->center(
true,
true);
4269 std::array<typename Triangulation<dim, spacedim>::raw_line_iterator,
4272 unsigned int lmin = 0;
4273 unsigned int lmax = 0;
4280 else if (cell->reference_cell() ==
4291 for (
unsigned int l = lmin;
l < lmax; ++
l)
4293 while (next_unused_line->used() ==
true)
4295 new_lines[
l] = next_unused_line;
4299 new_lines[
l]->used() ==
false,
4301 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
4309 const auto ref = [&](
const unsigned int face_no,
4310 const unsigned int vertex_no) {
4311 if (cell->line(face_no)->child(0)->vertex_index(0) ==
4312 static_cast<unsigned int>(new_vertices[vertex_no]) ||
4313 cell->line(face_no)->child(0)->vertex_index(1) ==
4314 static_cast<unsigned int>(new_vertices[vertex_no]))
4316 new_lines[2 * face_no + 0] =
4317 cell->line(face_no)->child(0);
4318 new_lines[2 * face_no + 1] =
4319 cell->line(face_no)->child(1);
4323 new_lines[2 * face_no + 0] =
4324 cell->line(face_no)->child(1);
4325 new_lines[2 * face_no + 1] =
4326 cell->line(face_no)->child(0);
4334 new_lines[6]->set_bounding_object_indices(
4335 {new_vertices[3], new_vertices[4]});
4336 new_lines[7]->set_bounding_object_indices(
4337 {new_vertices[4], new_vertices[5]});
4338 new_lines[8]->set_bounding_object_indices(
4339 {new_vertices[5], new_vertices[3]});
4341 else if (cell->reference_cell() ==
4345 for (
const unsigned int face_no : cell->face_indices())
4346 for (
unsigned int c = 0; c < 2; ++c, ++
l)
4347 new_lines[
l] = cell->line(face_no)->child(c);
4349 new_lines[8]->set_bounding_object_indices(
4350 {new_vertices[6], new_vertices[8]});
4351 new_lines[9]->set_bounding_object_indices(
4352 {new_vertices[8], new_vertices[7]});
4353 new_lines[10]->set_bounding_object_indices(
4354 {new_vertices[4], new_vertices[8]});
4355 new_lines[11]->set_bounding_object_indices(
4356 {new_vertices[8], new_vertices[5]});
4365 for (
unsigned int l = lmin;
l < lmax; ++
l)
4367 new_lines[
l]->set_used_flag();
4368 new_lines[
l]->clear_user_flag();
4369 new_lines[
l]->clear_user_data();
4370 new_lines[
l]->clear_children();
4372 new_lines[
l]->set_boundary_id_internal(
4374 new_lines[
l]->set_manifold_id(cell->manifold_id());
4379 while (next_unused_cell->used() ==
true)
4382 unsigned int n_children = 0;
4386 else if (cell->reference_cell() ==
4392 for (
unsigned int i = 0; i < n_children; ++i)
4395 next_unused_cell->used() ==
false,
4397 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
4398 subcells[i] = next_unused_cell;
4400 if (i % 2 == 1 && i < n_children - 1)
4401 while (next_unused_cell->used() ==
true)
4408 subcells[0]->set_bounding_object_indices({new_lines[0]->index(),
4409 new_lines[8]->index(),
4410 new_lines[5]->index()});
4411 subcells[1]->set_bounding_object_indices({new_lines[1]->index(),
4412 new_lines[2]->index(),
4413 new_lines[6]->index()});
4414 subcells[2]->set_bounding_object_indices({new_lines[7]->index(),
4415 new_lines[3]->index(),
4416 new_lines[4]->index()});
4417 subcells[3]->set_bounding_object_indices({new_lines[6]->index(),
4418 new_lines[7]->index(),
4419 new_lines[8]->index()});
4423 const auto ref = [&](
const unsigned int line_no,
4424 const unsigned int vertex_no,
4425 const unsigned int subcell_no,
4426 const unsigned int subcell_line_no) {
4427 if (new_lines[line_no]->vertex_index(1) !=
4428 static_cast<unsigned int>(new_vertices[vertex_no]))
4430 ->face_orientations[subcells[subcell_no]->index() *
4432 subcell_line_no] = 0;
4456 else if ((dim == 2) && (cell->reference_cell() ==
4459 subcells[0]->set_bounding_object_indices(
4460 {new_lines[0]->index(),
4461 new_lines[8]->index(),
4462 new_lines[4]->index(),
4463 new_lines[10]->index()});
4464 subcells[1]->set_bounding_object_indices(
4465 {new_lines[8]->index(),
4466 new_lines[2]->index(),
4467 new_lines[5]->index(),
4468 new_lines[11]->index()});
4469 subcells[2]->set_bounding_object_indices({new_lines[1]->index(),
4470 new_lines[9]->index(),
4471 new_lines[10]->index(),
4472 new_lines[6]->index()});
4473 subcells[3]->set_bounding_object_indices({new_lines[9]->index(),
4474 new_lines[3]->index(),
4475 new_lines[11]->index(),
4476 new_lines[7]->index()});
4485 for (
unsigned int i = 0; i < n_children; ++i)
4487 subcells[i]->set_used_flag();
4488 subcells[i]->clear_refine_flag();
4489 subcells[i]->clear_user_flag();
4491 subcells[i]->clear_children();
4494 subcells[i]->set_material_id(cell->material_id());
4495 subcells[i]->set_manifold_id(cell->manifold_id());
4496 subcells[i]->set_subdomain_id(subdomainid);
4501 ->reference_cell[subcells[i]->index()] = cell->reference_cell();
4504 subcells[i]->set_parent(cell->index());
4507 for (
unsigned int i = 0; i < n_children / 2; ++i)
4508 cell->set_children(2 * i, subcells[2 * i]->index());
4510 cell->set_refinement_case(ref_case);
4513 for (
unsigned int c = 0; c < n_children; ++c)
4514 cell->child(c)->set_direction_flag(cell->direction_flag());
4524 for (
const auto &cell :
4526 if (cell->refine_flag_set())
4528 if (cell->at_boundary())
4529 cell->set_user_flag();
4537 if (cell->reference_cell() ==
4539 check_for_distorted_cells &&
4540 has_distorted_children<dim, spacedim>(cell))
4541 cells_with_distorted_children.distorted_cells.push_back(
4548 return cells_with_distorted_children;
4557 template <
int spacedim>
4562 const unsigned int dim = 1;
4566 for (
const auto &cell :
triangulation.active_cell_iterators_on_level(
4568 if (cell->refine_flag_set())
4581 unsigned int needed_vertices = 0;
4586 unsigned int flagged_cells = 0;
4588 for (
const auto &acell :
4590 if (acell->refine_flag_set())
4595 const unsigned int used_cells =
4615 needed_vertices += flagged_cells;
4620 needed_vertices += std::count(
triangulation.vertices_used.begin(),
4637 unsigned int next_unused_vertex = 0;
4644 for (
const auto &cell :
4646 if (cell->refine_flag_set())
4649 cell->clear_refine_flag();
4655 ++next_unused_vertex;
4659 "Internal error: During refinement, the triangulation wants to access an element of the 'vertices' array but it turns out that the array is not large enough."));
4674 while (next_unused_cell->used() ==
true)
4676 first_child = next_unused_cell;
4677 first_child->set_used_flag();
4681 next_unused_cell->used() ==
false,
4683 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
4684 second_child = next_unused_cell;
4685 second_child->set_used_flag();
4691 cell->set_children(0, first_child->index());
4692 first_child->clear_children();
4693 first_child->set_bounding_object_indices(
4694 {cell->vertex_index(0), next_unused_vertex});
4695 first_child->set_material_id(cell->material_id());
4696 first_child->set_manifold_id(cell->manifold_id());
4697 first_child->set_subdomain_id(subdomainid);
4698 first_child->set_direction_flag(cell->direction_flag());
4700 first_child->set_parent(cell->index());
4704 first_child->face(1)->set_manifold_id(cell->manifold_id());
4709 first_child->set_neighbor(1, second_child);
4711 first_child->set_neighbor(0, cell->neighbor(0));
4712 else if (cell->neighbor(0)->is_active())
4718 Assert(cell->neighbor(0)->level() <= cell->level(),
4720 first_child->set_neighbor(0, cell->neighbor(0));
4726 const unsigned int nbnb = cell->neighbor_of_neighbor(0);
4727 first_child->set_neighbor(0,
4728 cell->neighbor(0)->child(nbnb));
4733 left_neighbor = cell->neighbor(0);
4734 while (left_neighbor->has_children())
4736 left_neighbor = left_neighbor->child(nbnb);
4737 left_neighbor->set_neighbor(nbnb, first_child);
4742 second_child->clear_children();
4743 second_child->set_bounding_object_indices(
4744 {next_unused_vertex, cell->vertex_index(1)});
4745 second_child->set_neighbor(0, first_child);
4746 second_child->set_material_id(cell->material_id());
4747 second_child->set_manifold_id(cell->manifold_id());
4748 second_child->set_subdomain_id(subdomainid);
4749 second_child->set_direction_flag(cell->direction_flag());
4752 second_child->set_neighbor(1, cell->neighbor(1));
4753 else if (cell->neighbor(1)->is_active())
4755 Assert(cell->neighbor(1)->level() <= cell->level(),
4757 second_child->set_neighbor(1, cell->neighbor(1));
4762 const unsigned int nbnb = cell->neighbor_of_neighbor(1);
4763 second_child->set_neighbor(
4764 1, cell->neighbor(1)->child(nbnb));
4767 right_neighbor = cell->neighbor(1);
4768 while (right_neighbor->has_children())
4770 right_neighbor = right_neighbor->child(nbnb);
4771 right_neighbor->set_neighbor(nbnb, second_child);
4791 template <
int spacedim>
4794 const bool check_for_distorted_cells)
4796 const unsigned int dim = 2;
4802 bool do_isotropic_refinement =
true;
4803 for (
const auto &cell :
triangulation.active_cell_iterators())
4807 do_isotropic_refinement =
false;
4811 if (do_isotropic_refinement)
4813 check_for_distorted_cells);
4818 for (
const auto &cell :
triangulation.active_cell_iterators_on_level(
4820 if (cell->refine_flag_set())
4835 line->clear_user_flag();
4841 unsigned int n_single_lines = 0;
4845 unsigned int n_lines_in_pairs = 0;
4851 unsigned int needed_vertices = 0;
4856 unsigned int needed_cells = 0;
4858 for (
const auto &cell :
4860 if (cell->refine_flag_set())
4871 n_single_lines += 4;
4883 n_single_lines += 1;
4891 for (
const unsigned int line_no :
4895 cell->refine_flag_set(), line_no) ==
4899 line = cell->line(line_no);
4900 if (line->has_children() ==
false)
4901 line->set_user_flag();
4908 const unsigned int used_cells =
4918 used_cells + needed_cells,
4934 if (line->user_flag_set())
4937 n_lines_in_pairs += 2;
4938 needed_vertices += 1;
4950 needed_vertices += std::count(
triangulation.vertices_used.begin(),
4967 unsigned int next_unused_vertex = 0;
4979 for (; line != endl; ++line)
4980 if (line->user_flag_set())
4986 while (
triangulation.vertices_used[next_unused_vertex] ==
true)
4987 ++next_unused_vertex;
4991 "Internal error: During refinement, the triangulation wants to access an element of the 'vertices' array but it turns out that the array is not large enough."));
4994 triangulation.vertices[next_unused_vertex] = line->center(
true);
4999 bool pair_found =
false;
5001 for (; next_unused_line != endl; ++next_unused_line)
5002 if (!next_unused_line->used() &&
5003 !(++next_unused_line)->used())
5016 line->set_children(0, next_unused_line->index());
5020 children[2] = {next_unused_line, ++next_unused_line};
5024 children[0]->used() ==
false,
5026 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5028 children[1]->used() ==
false,
5030 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5032 children[0]->set_bounding_object_indices(
5033 {line->vertex_index(0), next_unused_vertex});
5034 children[1]->set_bounding_object_indices(
5035 {next_unused_vertex, line->vertex_index(1)});
5037 children[0]->set_used_flag();
5038 children[1]->set_used_flag();
5039 children[0]->clear_children();
5040 children[1]->clear_children();
5043 children[0]->clear_user_flag();
5044 children[1]->clear_user_flag();
5047 children[0]->set_boundary_id_internal(line->boundary_id());
5048 children[1]->set_boundary_id_internal(line->boundary_id());
5050 children[0]->set_manifold_id(line->manifold_id());
5051 children[1]->set_manifold_id(line->manifold_id());
5055 line->clear_user_flag();
5067 cells_with_distorted_children;
5081 for (
const auto &cell :
5083 if (cell->refine_flag_set())
5091 if (cell->at_boundary())
5092 cell->set_user_flag();
5102 if (check_for_distorted_cells &&
5103 has_distorted_children<dim, spacedim>(cell))
5111 return cells_with_distorted_children;
5119 template <
int spacedim>
5122 const bool check_for_distorted_cells)
5124 const unsigned int dim = 3;
5134 for (
const auto &cell :
triangulation.active_cell_iterators_on_level(
5136 if (cell->refine_flag_set())
5153 line->clear_user_flag();
5158 quad->clear_user_flag();
5181 unsigned int needed_vertices = 0;
5182 unsigned int needed_lines_single = 0;
5183 unsigned int needed_quads_single = 0;
5184 unsigned int needed_lines_pair = 0;
5185 unsigned int needed_quads_pair = 0;
5190 unsigned int new_cells = 0;
5192 for (
const auto &acell :
5194 if (acell->refine_flag_set())
5204 ++needed_quads_single;
5212 ++needed_lines_single;
5213 needed_quads_single += 4;
5220 needed_lines_single += 6;
5221 needed_quads_single += 12;
5235 for (
const unsigned int face :
5239 aface = acell->face(face);
5246 acell->face_orientation(face),
5247 acell->face_flip(face),
5248 acell->face_rotation(face));
5253 if (face_ref_case ==
5256 if (aface->n_active_descendants() < 4)
5259 aface->set_user_flag();
5261 else if (aface->refinement_case() != face_ref_case)
5272 Assert(aface->refinement_case() ==
5274 dim - 1>::isotropic_refinement ||
5275 aface->refinement_case() ==
5278 aface->set_user_index(face_ref_case);
5284 for (
unsigned int line = 0;
5285 line < GeometryInfo<dim>::lines_per_cell;
5289 !acell->line(line)->has_children())
5290 acell->line(line)->set_user_flag();
5296 const unsigned int used_cells =
5306 used_cells + new_cells,
5320 if (quad->user_flag_set())
5326 needed_quads_pair += 4;
5327 needed_lines_pair += 4;
5328 needed_vertices += 1;
5330 if (quad->user_index())
5334 needed_quads_pair += 2;
5335 needed_lines_single += 1;
5348 if (quad->has_children())
5350 Assert(quad->refinement_case() ==
5353 if ((face_refinement_cases[quad->user_index()] ==
5355 (quad->child(0)->line_index(1) + 1 !=
5356 quad->child(2)->line_index(1))) ||
5357 (face_refinement_cases[quad->user_index()] ==
5359 (quad->child(0)->line_index(3) + 1 !=
5360 quad->child(1)->line_index(3))))
5361 needed_lines_pair += 2;
5370 if (line->user_flag_set())
5372 needed_lines_pair += 2;
5373 needed_vertices += 1;
5379 needed_lines_single);
5383 needed_quads_single);
5386 needed_quads_single);
5390 needed_vertices += std::count(
triangulation.vertices_used.begin(),
5414 for (
const auto &cell :
triangulation.active_cell_iterators())
5415 if (!cell->refine_flag_set())
5416 for (
unsigned int line = 0;
5417 line < GeometryInfo<dim>::lines_per_cell;
5419 if (cell->line(line)->has_children())
5420 for (
unsigned int c = 0; c < 2; ++c)
5421 Assert(cell->line(line)->child(c)->user_flag_set() ==
false,
5433 unsigned int next_unused_vertex = 0;
5444 for (; line != endl; ++line)
5445 if (line->user_flag_set())
5451 while (
triangulation.vertices_used[next_unused_vertex] ==
true)
5452 ++next_unused_vertex;
5456 "Internal error: During refinement, the triangulation wants to access an element of the 'vertices' array but it turns out that the array is not large enough."));
5459 triangulation.vertices[next_unused_vertex] = line->center(
true);
5465 triangulation.faces->lines.template next_free_pair_object<1>(
5473 line->set_children(0, next_unused_line->index());
5477 children[2] = {next_unused_line, ++next_unused_line};
5482 children[0]->used() ==
false,
5484 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5486 children[1]->used() ==
false,
5488 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5490 children[0]->set_bounding_object_indices(
5491 {line->vertex_index(0), next_unused_vertex});
5492 children[1]->set_bounding_object_indices(
5493 {next_unused_vertex, line->vertex_index(1)});
5495 children[0]->set_used_flag();
5496 children[1]->set_used_flag();
5497 children[0]->clear_children();
5498 children[1]->clear_children();
5501 children[0]->clear_user_flag();
5502 children[1]->clear_user_flag();
5504 children[0]->set_boundary_id_internal(line->boundary_id());
5505 children[1]->set_boundary_id_internal(line->boundary_id());
5507 children[0]->set_manifold_id(line->manifold_id());
5508 children[1]->set_manifold_id(line->manifold_id());
5513 line->clear_user_flag();
5556 for (; quad != endq; ++quad)
5558 if (quad->user_index())
5561 face_refinement_cases[quad->user_index()];
5570 if (aniso_quad_ref_case == quad->refinement_case())
5573 Assert(quad->refinement_case() ==
5575 quad->refinement_case() ==
5580 Assert(quad->user_index() ==
5582 quad->user_index() ==
5594 new_line->used() ==
false,
5596 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5615 quad->line(2)->child(0)->vertex_index(1);
5617 quad->line(3)->child(0)->vertex_index(1);
5622 quad->line(0)->child(0)->vertex_index(1);
5624 quad->line(1)->child(0)->vertex_index(1);
5627 new_line->set_bounding_object_indices(
5629 new_line->set_used_flag();
5630 new_line->clear_user_flag();
5632 new_line->clear_children();
5633 new_line->set_boundary_id_internal(quad->boundary_id());
5634 new_line->set_manifold_id(quad->manifold_id());
5642 const unsigned int index[2][2] = {
5654 new_quads[0] = next_unused_quad;
5656 new_quads[0]->used() ==
false,
5658 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5661 new_quads[1] = next_unused_quad;
5663 new_quads[1]->used() ==
false,
5665 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5670 new_quads[0]->set_bounding_object_indices(
5671 {
static_cast<int>(quad->line_index(0)),
5674 ->child(index[0][quad->line_orientation(2)])
5677 ->child(index[0][quad->line_orientation(3)])
5679 new_quads[1]->set_bounding_object_indices(
5681 static_cast<int>(quad->line_index(1)),
5683 ->child(index[1][quad->line_orientation(2)])
5686 ->child(index[1][quad->line_orientation(3)])
5691 new_quads[0]->set_bounding_object_indices(
5693 ->child(index[0][quad->line_orientation(0)])
5696 ->child(index[0][quad->line_orientation(1)])
5698 static_cast<int>(quad->line_index(2)),
5699 new_line->index()});
5700 new_quads[1]->set_bounding_object_indices(
5702 ->child(index[1][quad->line_orientation(0)])
5705 ->child(index[1][quad->line_orientation(1)])
5708 static_cast<int>(quad->line_index(3))});
5711 for (
const auto &new_quad : new_quads)
5713 new_quad->set_used_flag();
5714 new_quad->clear_user_flag();
5716 new_quad->clear_children();
5717 new_quad->set_boundary_id_internal(quad->boundary_id());
5718 new_quad->set_manifold_id(quad->manifold_id());
5722 for (
unsigned int j = 0;
5723 j < GeometryInfo<dim>::lines_per_face;
5725 new_quad->set_line_orientation(j,
true);
5731 new_quads[0]->set_line_orientation(
5732 0, quad->line_orientation(0));
5733 new_quads[0]->set_line_orientation(
5734 2, quad->line_orientation(2));
5735 new_quads[1]->set_line_orientation(
5736 1, quad->line_orientation(1));
5737 new_quads[1]->set_line_orientation(
5738 3, quad->line_orientation(3));
5741 new_quads[0]->set_line_orientation(
5742 3, quad->line_orientation(3));
5743 new_quads[1]->set_line_orientation(
5744 2, quad->line_orientation(2));
5748 new_quads[0]->set_line_orientation(
5749 1, quad->line_orientation(1));
5750 new_quads[1]->set_line_orientation(
5751 0, quad->line_orientation(0));
5757 if (quad->refinement_case() ==
5780 if (aniso_quad_ref_case ==
5783 old_child[0] = quad->child(0)->line(1);
5784 old_child[1] = quad->child(2)->line(1);
5788 Assert(aniso_quad_ref_case ==
5792 old_child[0] = quad->child(0)->line(3);
5793 old_child[1] = quad->child(1)->line(3);
5796 if (old_child[0]->index() + 1 != old_child[1]->index())
5802 spacedim>::raw_line_iterator
5805 new_child[0] = new_child[1] =
5807 .template next_free_pair_object<1>(
5811 new_child[0]->set_used_flag();
5812 new_child[1]->set_used_flag();
5814 const int old_index_0 = old_child[0]->index(),
5815 old_index_1 = old_child[1]->index(),
5816 new_index_0 = new_child[0]->index(),
5817 new_index_1 = new_child[1]->index();
5821 for (
unsigned int q = 0;
5824 for (
unsigned int l = 0;
5825 l < GeometryInfo<dim>::lines_per_face;
5828 const int this_index =
5830 .get_bounding_object_indices(q)[
l];
5831 if (this_index == old_index_0)
5833 .get_bounding_object_indices(q)[
l] =
5835 else if (this_index == old_index_1)
5837 .get_bounding_object_indices(q)[
l] =
5842 for (
unsigned int i = 0; i < 2; ++i)
5844 Assert(!old_child[i]->has_children(),
5847 new_child[i]->set_bounding_object_indices(
5848 {old_child[i]->vertex_index(0),
5849 old_child[i]->vertex_index(1)});
5850 new_child[i]->set_boundary_id_internal(
5852 new_child[i]->set_manifold_id(
5854 new_child[i]->set_user_index(
5855 old_child[i]->user_index());
5856 if (old_child[i]->user_flag_set())
5857 new_child[i]->set_user_flag();
5859 new_child[i]->clear_user_flag();
5861 new_child[i]->clear_children();
5863 old_child[i]->clear_user_flag();
5864 old_child[i]->clear_user_index();
5865 old_child[i]->clear_used_flag();
5871 if (aniso_quad_ref_case ==
5874 new_line->set_children(
5875 0, quad->child(0)->line_index(1));
5876 Assert(new_line->child(1) ==
5877 quad->child(2)->line(1),
5914 quad_iterator switch_1 = quad->child(1),
5915 switch_2 = quad->child(2);
5916 const int switch_1_index = switch_1->index();
5917 const int switch_2_index = switch_2->index();
5918 for (
unsigned int l = 0;
5921 for (
unsigned int h = 0;
5925 for (
const unsigned int q :
5928 const int face_index =
5930 ->cells.get_bounding_object_indices(
5932 if (face_index == switch_1_index)
5934 ->cells.get_bounding_object_indices(
5935 h)[q] = switch_2_index;
5936 else if (face_index == switch_2_index)
5938 ->cells.get_bounding_object_indices(
5939 h)[q] = switch_1_index;
5943 const unsigned int switch_1_lines[4] = {
5944 switch_1->line_index(0),
5945 switch_1->line_index(1),
5946 switch_1->line_index(2),
5947 switch_1->line_index(3)};
5948 const bool switch_1_line_orientations[4] = {
5949 switch_1->line_orientation(0),
5950 switch_1->line_orientation(1),
5951 switch_1->line_orientation(2),
5952 switch_1->line_orientation(3)};
5954 switch_1->boundary_id();
5955 const unsigned int switch_1_user_index =
5956 switch_1->user_index();
5957 const bool switch_1_user_flag =
5958 switch_1->user_flag_set();
5960 switch_1_refinement_case =
5961 switch_1->refinement_case();
5962 const int switch_1_first_child_pair =
5963 (switch_1_refinement_case ?
5964 switch_1->child_index(0) :
5966 const int switch_1_second_child_pair =
5967 (switch_1_refinement_case ==
5969 switch_1->child_index(2) :
5972 switch_1->set_bounding_object_indices(
5973 {switch_2->line_index(0),
5974 switch_2->line_index(1),
5975 switch_2->line_index(2),
5976 switch_2->line_index(3)});
5977 switch_1->set_line_orientation(
5978 0, switch_2->line_orientation(0));
5979 switch_1->set_line_orientation(
5980 1, switch_2->line_orientation(1));
5981 switch_1->set_line_orientation(
5982 2, switch_2->line_orientation(2));
5983 switch_1->set_line_orientation(
5984 3, switch_2->line_orientation(3));
5985 switch_1->set_boundary_id_internal(
5986 switch_2->boundary_id());
5987 switch_1->set_manifold_id(switch_2->manifold_id());
5988 switch_1->set_user_index(switch_2->user_index());
5989 if (switch_2->user_flag_set())
5990 switch_1->set_user_flag();
5992 switch_1->clear_user_flag();
5993 switch_1->clear_refinement_case();
5994 switch_1->set_refinement_case(
5995 switch_2->refinement_case());
5996 switch_1->clear_children();
5997 if (switch_2->refinement_case())
5998 switch_1->set_children(0,
5999 switch_2->child_index(0));
6000 if (switch_2->refinement_case() ==
6002 switch_1->set_children(2,
6003 switch_2->child_index(2));
6005 switch_2->set_bounding_object_indices(
6009 switch_1_lines[3]});
6010 switch_2->set_line_orientation(
6011 0, switch_1_line_orientations[0]);
6012 switch_2->set_line_orientation(
6013 1, switch_1_line_orientations[1]);
6014 switch_2->set_line_orientation(
6015 2, switch_1_line_orientations[2]);
6016 switch_2->set_line_orientation(
6017 3, switch_1_line_orientations[3]);
6018 switch_2->set_boundary_id_internal(
6019 switch_1_boundary_id);
6020 switch_2->set_manifold_id(switch_1->manifold_id());
6021 switch_2->set_user_index(switch_1_user_index);
6022 if (switch_1_user_flag)
6023 switch_2->set_user_flag();
6025 switch_2->clear_user_flag();
6026 switch_2->clear_refinement_case();
6027 switch_2->set_refinement_case(
6028 switch_1_refinement_case);
6029 switch_2->clear_children();
6030 switch_2->set_children(0,
6031 switch_1_first_child_pair);
6032 switch_2->set_children(2,
6033 switch_1_second_child_pair);
6035 new_quads[0]->set_refinement_case(
6037 new_quads[0]->set_children(0, quad->child_index(0));
6038 new_quads[1]->set_refinement_case(
6040 new_quads[1]->set_children(0, quad->child_index(2));
6044 new_quads[0]->set_refinement_case(
6046 new_quads[0]->set_children(0, quad->child_index(0));
6047 new_quads[1]->set_refinement_case(
6049 new_quads[1]->set_children(0, quad->child_index(2));
6050 new_line->set_children(
6051 0, quad->child(0)->line_index(3));
6052 Assert(new_line->child(1) ==
6053 quad->child(1)->line(3),
6056 quad->clear_children();
6060 quad->set_children(0, new_quads[0]->index());
6062 quad->set_refinement_case(aniso_quad_ref_case);
6069 if (quad->user_flag_set())
6081 ++next_unused_vertex;
6085 "Internal error: During refinement, the triangulation wants to access an element of the 'vertices' array but it turns out that the array is not large enough."));
6093 quad->refinement_case();
6099 quad->child(0)->set_user_index(
6101 quad->child(1)->set_user_index(
6107 middle_line = quad->child(0)->line(1);
6109 middle_line = quad->child(0)->line(3);
6116 if (!middle_line->has_children())
6124 middle_line->center(
true);
6132 .template next_free_pair_object<1>(
6137 middle_line->set_children(
6138 0, next_unused_line->index());
6142 raw_line_iterator children[2] = {
6143 next_unused_line, ++next_unused_line};
6149 children[0]->used() ==
false,
6151 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
6153 children[1]->used() ==
false,
6155 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
6157 children[0]->set_bounding_object_indices(
6158 {middle_line->vertex_index(0),
6159 next_unused_vertex});
6160 children[1]->set_bounding_object_indices(
6161 {next_unused_vertex,
6162 middle_line->vertex_index(1)});
6164 children[0]->set_used_flag();
6165 children[1]->set_used_flag();
6166 children[0]->clear_children();
6167 children[1]->clear_children();
6170 children[0]->clear_user_flag();
6171 children[1]->clear_user_flag();
6173 children[0]->set_boundary_id_internal(
6174 middle_line->boundary_id());
6175 children[1]->set_boundary_id_internal(
6176 middle_line->boundary_id());
6178 children[0]->set_manifold_id(
6179 middle_line->manifold_id());
6180 children[1]->set_manifold_id(
6181 middle_line->manifold_id());
6187 quad->clear_user_flag();
6217 quad->center(
true,
true);
6226 for (
unsigned int i = 0; i < 4; ++i)
6239 new_lines[i] = next_unused_line;
6243 new_lines[i]->used() ==
false,
6245 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
6266 quad->line(0)->child(0)->vertex_index(1),
6267 quad->line(1)->child(0)->vertex_index(1),
6268 quad->line(2)->child(0)->vertex_index(1),
6269 quad->line(3)->child(0)->vertex_index(1),
6270 next_unused_vertex};
6272 new_lines[0]->set_bounding_object_indices(
6274 new_lines[1]->set_bounding_object_indices(
6276 new_lines[2]->set_bounding_object_indices(
6278 new_lines[3]->set_bounding_object_indices(
6281 for (
const auto &new_line : new_lines)
6283 new_line->set_used_flag();
6284 new_line->clear_user_flag();
6286 new_line->clear_children();
6287 new_line->set_boundary_id_internal(quad->boundary_id());
6288 new_line->set_manifold_id(quad->manifold_id());
6307 const unsigned int index[2][2] = {
6311 const int line_indices[12] = {
6313 ->child(index[0][quad->line_orientation(0)])
6316 ->child(index[1][quad->line_orientation(0)])
6319 ->child(index[0][quad->line_orientation(1)])
6322 ->child(index[1][quad->line_orientation(1)])
6325 ->child(index[0][quad->line_orientation(2)])
6328 ->child(index[1][quad->line_orientation(2)])
6331 ->child(index[0][quad->line_orientation(3)])
6334 ->child(index[1][quad->line_orientation(3)])
6336 new_lines[0]->index(),
6337 new_lines[1]->index(),
6338 new_lines[2]->index(),
6339 new_lines[3]->index()};
6351 new_quads[0] = next_unused_quad;
6353 new_quads[0]->used() ==
false,
6355 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
6358 new_quads[1] = next_unused_quad;
6360 new_quads[1]->used() ==
false,
6362 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
6367 new_quads[2] = next_unused_quad;
6369 new_quads[2]->used() ==
false,
6371 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
6374 new_quads[3] = next_unused_quad;
6376 new_quads[3]->used() ==
false,
6378 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
6381 quad->set_children(0, new_quads[0]->index());
6382 quad->set_children(2, new_quads[2]->index());
6385 new_quads[0]->set_bounding_object_indices(
6390 new_quads[1]->set_bounding_object_indices(
6395 new_quads[2]->set_bounding_object_indices(
6400 new_quads[3]->set_bounding_object_indices(
6405 for (
const auto &new_quad : new_quads)
6407 new_quad->set_used_flag();
6408 new_quad->clear_user_flag();
6410 new_quad->clear_children();
6411 new_quad->set_boundary_id_internal(quad->boundary_id());
6412 new_quad->set_manifold_id(quad->manifold_id());
6416 for (
unsigned int j = 0;
6417 j < GeometryInfo<dim>::lines_per_face;
6419 new_quad->set_line_orientation(j,
true);
6425 new_quads[0]->set_line_orientation(
6426 0, quad->line_orientation(0));
6427 new_quads[0]->set_line_orientation(
6428 2, quad->line_orientation(2));
6429 new_quads[1]->set_line_orientation(
6430 1, quad->line_orientation(1));
6431 new_quads[1]->set_line_orientation(
6432 2, quad->line_orientation(2));
6433 new_quads[2]->set_line_orientation(
6434 0, quad->line_orientation(0));
6435 new_quads[2]->set_line_orientation(
6436 3, quad->line_orientation(3));
6437 new_quads[3]->set_line_orientation(
6438 1, quad->line_orientation(1));
6439 new_quads[3]->set_line_orientation(
6440 3, quad->line_orientation(3));
6444 quad->clear_user_flag();
6455 cells_with_distorted_children;
6469 for (; hex != endh; ++hex)
6470 if (hex->refine_flag_set())
6478 hex->clear_refine_flag();
6479 hex->set_refinement_case(ref_case);
6490 unsigned int n_new_lines = 0;
6491 unsigned int n_new_quads = 0;
6492 unsigned int n_new_hexes = 0;
6523 new_lines(n_new_lines);
6524 for (
unsigned int i = 0; i < n_new_lines; ++i)
6531 new_lines[i]->used() ==
false,
6533 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
6534 new_lines[i]->set_used_flag();
6535 new_lines[i]->clear_user_flag();
6536 new_lines[i]->clear_user_data();
6537 new_lines[i]->clear_children();
6539 new_lines[i]->set_boundary_id_internal(
6543 new_lines[i]->set_manifold_id(hex->manifold_id());
6550 new_quads(n_new_quads);
6551 for (
unsigned int i = 0; i < n_new_quads; ++i)
6558 new_quads[i]->used() ==
false,
6560 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
6561 new_quads[i]->set_used_flag();
6562 new_quads[i]->clear_user_flag();
6563 new_quads[i]->clear_user_data();
6564 new_quads[i]->clear_children();
6566 new_quads[i]->set_boundary_id_internal(
6570 new_quads[i]->set_manifold_id(hex->manifold_id());
6573 for (
unsigned int j = 0;
6574 j < GeometryInfo<dim>::lines_per_face;
6576 new_quads[i]->set_line_orientation(j,
true);
6585 new_hexes(n_new_hexes);
6586 for (
unsigned int i = 0; i < n_new_hexes; ++i)
6595 new_hexes[i] = next_unused_hex;
6598 new_hexes[i]->used() ==
false,
6600 "Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
6601 new_hexes[i]->set_used_flag();
6602 new_hexes[i]->clear_user_flag();
6603 new_hexes[i]->clear_user_data();
6604 new_hexes[i]->clear_children();
6607 new_hexes[i]->set_material_id(hex->material_id());
6608 new_hexes[i]->set_manifold_id(hex->manifold_id());
6609 new_hexes[i]->set_subdomain_id(subdomainid);
6612 new_hexes[i]->set_parent(hex->index());
6624 for (
const unsigned int f :
6627 new_hexes[i]->set_face_orientation(f,
true);
6628 new_hexes[i]->set_face_flip(f,
false);
6629 new_hexes[i]->set_face_rotation(f,
false);
6633 for (
unsigned int i = 0; i < n_new_hexes / 2; ++i)
6634 hex->set_children(2 * i, new_hexes[2 * i]->index());
6641 const bool f_or[6] = {hex->face_orientation(0),
6642 hex->face_orientation(1),
6643 hex->face_orientation(2),
6644 hex->face_orientation(3),
6645 hex->face_orientation(4),
6646 hex->face_orientation(5)};
6649 const bool f_fl[6] = {hex->face_flip(0),
6657 const bool f_ro[6] = {hex->face_rotation(0),
6658 hex->face_rotation(1),
6659 hex->face_rotation(2),
6660 hex->face_rotation(3),
6661 hex->face_rotation(4),
6662 hex->face_rotation(5)};
6672 const unsigned int child_at_origin[2][2][2] = {
6759 raw_line_iterator lines[4] = {
6760 hex->face(2)->child(0)->line(
6761 (hex->face(2)->refinement_case() ==
6765 hex->face(3)->child(0)->line(
6766 (hex->face(3)->refinement_case() ==
6770 hex->face(4)->child(0)->line(
6771 (hex->face(4)->refinement_case() ==
6775 hex->face(5)->child(0)->line(
6776 (hex->face(5)->refinement_case() ==
6782 unsigned int line_indices[4];
6783 for (
unsigned int i = 0; i < 4; ++i)
6784 line_indices[i] = lines[i]->index();
6791 bool line_orientation[4];
6797 const unsigned int middle_vertices[2] = {
6798 hex->line(2)->child(0)->vertex_index(1),
6799 hex->line(7)->child(0)->vertex_index(1)};
6801 for (
unsigned int i = 0; i < 4; ++i)
6802 if (lines[i]->vertex_index(i % 2) ==
6803 middle_vertices[i % 2])
6804 line_orientation[i] =
true;
6809 Assert(lines[i]->vertex_index((i + 1) % 2) ==
6810 middle_vertices[i % 2],
6812 line_orientation[i] =
false;
6817 new_quads[0]->set_bounding_object_indices(
6823 new_quads[0]->set_line_orientation(
6824 0, line_orientation[0]);
6825 new_quads[0]->set_line_orientation(
6826 1, line_orientation[1]);
6827 new_quads[0]->set_line_orientation(
6828 2, line_orientation[2]);
6829 new_quads[0]->set_line_orientation(
6830 3, line_orientation[3]);
6863 const int quad_indices[11] = {
6864 new_quads[0]->index(),
6866 hex->face(0)->index(),
6868 hex->face(1)->index(),
6870 hex->face(2)->child_index(
6871 child_at_origin[hex->face(2)->refinement_case() -
6872 1][f_fl[2]][f_ro[2]]),
6873 hex->face(2)->child_index(
6875 child_at_origin[hex->face(2)->refinement_case() -
6876 1][f_fl[2]][f_ro[2]]),
6878 hex->face(3)->child_index(
6879 child_at_origin[hex->face(3)->refinement_case() -
6880 1][f_fl[3]][f_ro[3]]),
6881 hex->face(3)->child_index(
6883 child_at_origin[hex->face(3)->refinement_case() -
6884 1][f_fl[3]][f_ro[3]]),
6886 hex->face(4)->child_index(
6887 child_at_origin[hex->face(4)->refinement_case() -
6888 1][f_fl[4]][f_ro[4]]),
6889 hex->face(4)->child_index(
6891 child_at_origin[hex->face(4)->refinement_case() -
6892 1][f_fl[4]][f_ro[4]]),
6894 hex->face(5)->child_index(
6895 child_at_origin[hex->face(5)->refinement_case() -
6896 1][f_fl[5]][f_ro[5]]),
6897 hex->face(5)->child_index(
6899 child_at_origin[hex->face(5)->refinement_case() -
6900 1][f_fl[5]][f_ro[5]])
6904 new_hexes[0]->set_bounding_object_indices(
6911 new_hexes[1]->set_bounding_object_indices(
6986 raw_line_iterator lines[4] = {
6987 hex->face(0)->child(0)->line(
6988 (hex->face(0)->refinement_case() ==
6992 hex->face(1)->child(0)->line(
6993 (hex->face(1)->refinement_case() ==
6997 hex->face(4)->child(0)->line(
6998 (hex->face(4)->refinement_case() ==
7002 hex->face(5)->child(0)->line(
7003 (hex->face(5)->refinement_case() ==
7009 unsigned int line_indices[4];
7010 for (
unsigned int i = 0; i < 4; ++i)
7011 line_indices[i] = lines[i]->index();
7018 bool line_orientation[4];
7024 const unsigned int middle_vertices[2] = {
7025 hex->line(0)->child(0)->vertex_index(1),
7026 hex->line(5)->child(0)->vertex_index(1)};
7028 for (
unsigned int i = 0; i < 4; ++i)
7029 if (lines[i]->vertex_index(i % 2) ==
7030 middle_vertices[i % 2])
7031 line_orientation[i] =
true;
7035 Assert(lines[i]->vertex_index((i + 1) % 2) ==
7036 middle_vertices[i % 2],
7038 line_orientation[i] =
false;
7043 new_quads[0]->set_bounding_object_indices(
7049 new_quads[0]->set_line_orientation(
7050 0, line_orientation[2]);
7051 new_quads[0]->set_line_orientation(
7052 1, line_orientation[3]);
7053 new_quads[0]->set_line_orientation(
7054 2, line_orientation[0]);
7055 new_quads[0]->set_line_orientation(
7056 3, line_orientation[1]);
7089 const int quad_indices[11] = {
7090 new_quads[0]->index(),
7092 hex->face(0)->child_index(
7093 child_at_origin[hex->face(0)->refinement_case() -
7094 1][f_fl[0]][f_ro[0]]),
7095 hex->face(0)->child_index(
7097 child_at_origin[hex->face(0)->refinement_case() -
7098 1][f_fl[0]][f_ro[0]]),
7100 hex->face(1)->child_index(
7101 child_at_origin[hex->face(1)->refinement_case() -
7102 1][f_fl[1]][f_ro[1]]),
7103 hex->face(1)->child_index(
7105 child_at_origin[hex->face(1)->refinement_case() -
7106 1][f_fl[1]][f_ro[1]]),
7108 hex->face(2)->index(),
7110 hex->face(3)->index(),
7112 hex->face(4)->child_index(
7113 child_at_origin[hex->face(4)->refinement_case() -
7114 1][f_fl[4]][f_ro[4]]),
7115 hex->face(4)->child_index(
7117 child_at_origin[hex->face(4)->refinement_case() -
7118 1][f_fl[4]][f_ro[4]]),
7120 hex->face(5)->child_index(
7121 child_at_origin[hex->face(5)->refinement_case() -
7122 1][f_fl[5]][f_ro[5]]),
7123 hex->face(5)->child_index(
7125 child_at_origin[hex->face(5)->refinement_case() -
7126 1][f_fl[5]][f_ro[5]])
7130 new_hexes[0]->set_bounding_object_indices(
7137 new_hexes[1]->set_bounding_object_indices(
7214 raw_line_iterator lines[4] = {
7215 hex->face(0)->child(0)->line(
7216 (hex->face(0)->refinement_case() ==
7220 hex->face(1)->child(0)->line(
7221 (hex->face(1)->refinement_case() ==
7225 hex->face(2)->child(0)->line(
7226 (hex->face(2)->refinement_case() ==
7230 hex->face(3)->child(0)->line(
7231 (hex->face(3)->refinement_case() ==
7237 unsigned int line_indices[4];
7238 for (
unsigned int i = 0; i < 4; ++i)
7239 line_indices[i] = lines[i]->index();
7246 bool line_orientation[4];
7252 const unsigned int middle_vertices[2] = {
7253 middle_vertex_index<dim, spacedim>(hex->line(8)),
7254 middle_vertex_index<dim, spacedim>(hex->line(11))};
7256 for (
unsigned int i = 0; i < 4; ++i)
7257 if (lines[i]->vertex_index(i % 2) ==
7258 middle_vertices[i % 2])
7259 line_orientation[i] =
true;
7263 Assert(lines[i]->vertex_index((i + 1) % 2) ==
7264 middle_vertices[i % 2],
7266 line_orientation[i] =
false;
7271 new_quads[0]->set_bounding_object_indices(
7277 new_quads[0]->set_line_orientation(
7278 0, line_orientation[0]);
7279 new_quads[0]->set_line_orientation(
7280 1, line_orientation[1]);
7281 new_quads[0]->set_line_orientation(
7282 2, line_orientation[2]);
7283 new_quads[0]->set_line_orientation(
7284 3, line_orientation[3]);
7318 const int quad_indices[11] = {
7319 new_quads[0]->index(),
7321 hex->face(0)->child_index(
7322 child_at_origin[hex->face(0)->refinement_case() -
7323 1][f_fl[0]][f_ro[0]]),
7324 hex->face(0)->child_index(
7326 child_at_origin[hex->face(0)->refinement_case() -
7327 1][f_fl[0]][f_ro[0]]),
7329 hex->face(1)->child_index(
7330 child_at_origin[hex->face(1)->refinement_case() -
7331 1][f_fl[1]][f_ro[1]]),
7332 hex->face(1)->child_index(
7334 child_at_origin[hex->face(1)->refinement_case() -
7335 1][f_fl[1]][f_ro[1]]),
7337 hex->face(2)->child_index(
7338 child_at_origin[hex->face(2)->refinement_case() -
7339 1][f_fl[2]][f_ro[2]]),
7340 hex->face(2)->child_index(
7342 child_at_origin[hex->face(2)->refinement_case() -
7343 1][f_fl[2]][f_ro[2]]),
7345 hex->face(3)->child_index(
7346 child_at_origin[hex->face(3)->refinement_case() -
7347 1][f_fl[3]][f_ro[3]]),
7348 hex->face(3)->child_index(
7350 child_at_origin[hex->face(3)->refinement_case() -
7351 1][f_fl[3]][f_ro[3]]),
7353 hex->face(4)->index(),
7355 hex->face(5)->index()
7358 new_hexes[0]->set_bounding_object_indices(
7365 new_hexes[1]->set_bounding_object_indices(
7397 new_lines[0]->set_bounding_object_indices(
7398 {middle_vertex_index<dim, spacedim>(hex->face(4)),
7399 middle_vertex_index<dim, spacedim>(hex->face(5))});
7467 spacedim>::raw_line_iterator lines[13] = {
7468 hex->face(0)->child(0)->line(
7469 (hex->face(0)->refinement_case() ==
7473 hex->face(1)->child(0)->line(
7474 (hex->face(1)->refinement_case() ==
7478 hex->face(2)->child(0)->line(
7479 (hex->face(2)->refinement_case() ==
7483 hex->face(3)->child(0)->line(
7484 (hex->face(3)->refinement_case() ==
7492 0, f_or[4], f_fl[4], f_ro[4]))
7495 1, f_or[4], f_fl[4], f_ro[4])),
7499 3, f_or[4], f_fl[4], f_ro[4]))
7502 0, f_or[4], f_fl[4], f_ro[4])),
7506 0, f_or[4], f_fl[4], f_ro[4]))
7509 3, f_or[4], f_fl[4], f_ro[4])),
7513 3, f_or[4], f_fl[4], f_ro[4]))
7516 2, f_or[4], f_fl[4], f_ro[4])),
7521 0, f_or[5], f_fl[5], f_ro[5]))
7524 1, f_or[5], f_fl[5], f_ro[5])),
7528 3, f_or[5], f_fl[5], f_ro[5]))
7531 0, f_or[5], f_fl[5], f_ro[5])),
7535 0, f_or[5], f_fl[5], f_ro[5]))
7538 3, f_or[5], f_fl[5], f_ro[5])),
7542 3, f_or[5], f_fl[5], f_ro[5]))
7545 2, f_or[5], f_fl[5], f_ro[5])),
7550 unsigned int line_indices[13];
7551 for (
unsigned int i = 0; i < 13; ++i)
7552 line_indices[i] = lines[i]->index();
7559 bool line_orientation[13];
7563 const unsigned int middle_vertices[4] = {
7564 hex->line(0)->child(0)->vertex_index(1),
7565 hex->line(1)->child(0)->vertex_index(1),
7566 hex->line(2)->child(0)->vertex_index(1),
7567 hex->line(3)->child(0)->vertex_index(1),
7573 for (
unsigned int i = 0; i < 4; ++i)
7574 if (lines[i]->vertex_index(0) == middle_vertices[i])
7575 line_orientation[i] =
true;
7579 Assert(lines[i]->vertex_index(1) ==
7582 line_orientation[i] =
false;
7591 for (
unsigned int i = 4; i < 12; ++i)
7592 if (lines[i]->vertex_index((i + 1) % 2) ==
7593 middle_vertex_index<dim, spacedim>(
7594 hex->face(3 + i / 4)))
7595 line_orientation[i] =
true;
7600 Assert(lines[i]->vertex_index(i % 2) ==
7601 (middle_vertex_index<dim, spacedim>(
7602 hex->face(3 + i / 4))),
7604 line_orientation[i] =
false;
7609 line_orientation[12] =
true;
7634 new_quads[0]->set_bounding_object_indices(
7639 new_quads[1]->set_bounding_object_indices(
7644 new_quads[2]->set_bounding_object_indices(
7649 new_quads[3]->set_bounding_object_indices(
7655 new_quads[0]->set_line_orientation(
7656 0, line_orientation[2]);
7657 new_quads[0]->set_line_orientation(
7658 2, line_orientation[4]);
7659 new_quads[0]->set_line_orientation(
7660 3, line_orientation[8]);
7662 new_quads[1]->set_line_orientation(
7663 1, line_orientation[3]);
7664 new_quads[1]->set_line_orientation(
7665 2, line_orientation[5]);
7666 new_quads[1]->set_line_orientation(
7667 3, line_orientation[9]);
7669 new_quads[2]->set_line_orientation(
7670 0, line_orientation[6]);
7671 new_quads[2]->set_line_orientation(
7672 1, line_orientation[10]);
7673 new_quads[2]->set_line_orientation(
7674 2, line_orientation[0]);
7676 new_quads[3]->set_line_orientation(
7677 0, line_orientation[7]);
7678 new_quads[3]->set_line_orientation(
7679 1, line_orientation[11]);
7680 new_quads[3]->set_line_orientation(
7681 3, line_orientation[1]);
7714 const int quad_indices[20] = {
7715 new_quads[0]->index(),
7716 new_quads[1]->index(),
7717 new_quads[2]->index(),
7718 new_quads[3]->index(),
7720 hex->face(0)->child_index(
7721 child_at_origin[hex->face(0)->refinement_case() -
7722 1][f_fl[0]][f_ro[0]]),
7723 hex->face(0)->child_index(
7725 child_at_origin[hex->face(0)->refinement_case() -
7726 1][f_fl[0]][f_ro[0]]),
7728 hex->face(1)->child_index(
7729 child_at_origin[hex->face(1)->refinement_case() -
7730 1][f_fl[1]][f_ro[1]]),
7731 hex->face(1)->child_index(
7733 child_at_origin[hex->face(1)->refinement_case() -
7734 1][f_fl[1]][f_ro[1]]),
7736 hex->face(2)->child_index(
7737 child_at_origin[hex->face(2)->refinement_case() -
7738 1][f_fl[2]][f_ro[2]]),
7739 hex->face(2)->child_index(
7741 child_at_origin[hex->face(2)->refinement_case() -
7742 1][f_fl[2]][f_ro[2]]),
7744 hex->face(3)->child_index(
7745 child_at_origin[hex->face(3)->refinement_case() -
7746 1][f_fl[3]][f_ro[3]]),
7747 hex->face(3)->child_index(
7749 child_at_origin[hex->face(3)->refinement_case() -
7750 1][f_fl[3]][f_ro[3]]),
7752 hex->face(4)->isotropic_child_index(
7754 0, f_or[4], f_fl[4], f_ro[4])),
7755 hex->face(4)->isotropic_child_index(
7757 1, f_or[4], f_fl[4], f_ro[4])),
7758 hex->face(4)->isotropic_child_index(
7760 2, f_or[4], f_fl[4], f_ro[4])),
7761 hex->face(4)->isotropic_child_index(
7763 3, f_or[4], f_fl[4], f_ro[4])),
7765 hex->face(5)->isotropic_child_index(
7767 0, f_or[5], f_fl[5], f_ro[5])),
7768 hex->face(5)->isotropic_child_index(
7770 1, f_or[5], f_fl[5], f_ro[5])),
7771 hex->face(5)->isotropic_child_index(
7773 2, f_or[5], f_fl[5], f_ro[5])),
7774 hex->face(5)->isotropic_child_index(
7776 3, f_or[5], f_fl[5], f_ro[5]))};
7778 new_hexes[0]->set_bounding_object_indices(
7785 new_hexes[1]->set_bounding_object_indices(
7792 new_hexes[2]->set_bounding_object_indices(
7799 new_hexes[3]->set_bounding_object_indices(
7831 new_lines[0]->set_bounding_object_indices(
7832 {middle_vertex_index<dim, spacedim>(hex->face(2)),
7833 middle_vertex_index<dim, spacedim>(hex->face(3))});
7901 spacedim>::raw_line_iterator lines[13] = {
7902 hex->face(0)->child(0)->line(
7903 (hex->face(0)->refinement_case() ==
7907 hex->face(1)->child(0)->line(
7908 (hex->face(1)->refinement_case() ==
7912 hex->face(4)->child(0)->line(
7913 (hex->face(4)->refinement_case() ==
7917 hex->face(5)->child(0)->line(
7918 (hex->face(5)->refinement_case() ==
7926 0, f_or[2], f_fl[2], f_ro[2]))
7929 3, f_or[2], f_fl[2], f_ro[2])),
7933 3, f_or[2], f_fl[2], f_ro[2]))
7936 2, f_or[2], f_fl[2], f_ro[2])),
7940 0, f_or[2], f_fl[2], f_ro[2]))
7943 1, f_or[2], f_fl[2], f_ro[2])),
7947 3, f_or[2], f_fl[2], f_ro[2]))
7950 0, f_or[2], f_fl[2], f_ro[2])),
7955 0, f_or[3], f_fl[3], f_ro[3]))
7958 3, f_or[3], f_fl[3], f_ro[3])),
7962 3, f_or[3], f_fl[3], f_ro[3]))
7965 2, f_or[3], f_fl[3], f_ro[3])),
7969 0, f_or[3], f_fl[3], f_ro[3]))
7972 1, f_or[3], f_fl[3], f_ro[3])),
7976 3, f_or[3], f_fl[3], f_ro[3]))
7979 0, f_or[3], f_fl[3], f_ro[3])),
7984 unsigned int line_indices[13];
7985 for (
unsigned int i = 0; i < 13; ++i)
7986 line_indices[i] = lines[i]->index();
7993 bool line_orientation[13];
7997 const unsigned int middle_vertices[4] = {
7998 hex->line(8)->child(0)->vertex_index(1),
7999 hex->line(9)->child(0)->vertex_index(1),
8000 hex->line(2)->child(0)->vertex_index(1),
8001 hex->line(6)->child(0)->vertex_index(1),
8006 for (
unsigned int i = 0; i < 4; ++i)
8007 if (lines[i]->vertex_index(0) == middle_vertices[i])
8008 line_orientation[i] =
true;
8012 Assert(lines[i]->vertex_index(1) ==
8015 line_orientation[i] =
false;
8024 for (
unsigned int i = 4; i < 12; ++i)
8025 if (lines[i]->vertex_index((i + 1) % 2) ==
8026 middle_vertex_index<dim, spacedim>(
8027 hex->face(1 + i / 4)))
8028 line_orientation[i] =
true;
8033 Assert(lines[i]->vertex_index(i % 2) ==
8034 (middle_vertex_index<dim, spacedim>(
8035 hex->face(1 + i / 4))),
8037 line_orientation[i] =
false;
8042 line_orientation[12] =
true;
8068 new_quads[0]->set_bounding_object_indices(
8073 new_quads[1]->set_bounding_object_indices(
8078 new_quads[2]->set_bounding_object_indices(
8083 new_quads[3]->set_bounding_object_indices(
8089 new_quads[0]->set_line_orientation(
8090 0, line_orientation[0]);
8091 new_quads[0]->set_line_orientation(
8092 2, line_orientation[6]);
8093 new_quads[0]->set_line_orientation(
8094 3, line_orientation[10]);
8096 new_quads[1]->set_line_orientation(
8097 1, line_orientation[1]);
8098 new_quads[1]->set_line_orientation(
8099 2, line_orientation[7]);
8100 new_quads[1]->set_line_orientation(
8101 3, line_orientation[11]);
8103 new_quads[2]->set_line_orientation(
8104 0, line_orientation[4]);
8105 new_quads[2]->set_line_orientation(
8106 1, line_orientation[8]);
8107 new_quads[2]->set_line_orientation(
8108 2, line_orientation[2]);
8110 new_quads[3]->set_line_orientation(
8111 0, line_orientation[5]);
8112 new_quads[3]->set_line_orientation(
8113 1, line_orientation[9]);
8114 new_quads[3]->set_line_orientation(
8115 3, line_orientation[3]);
8149 const int quad_indices[20] = {
8150 new_quads[0]->index(),
8151 new_quads[1]->index(),
8152 new_quads[2]->index(),
8153 new_quads[3]->index(),
8155 hex->face(0)->child_index(
8156 child_at_origin[hex->face(0)->refinement_case() -
8157 1][f_fl[0]][f_ro[0]]),
8158 hex->face(0)->child_index(
8160 child_at_origin[hex->face(0)->refinement_case() -
8161 1][f_fl[0]][f_ro[0]]),
8163 hex->face(1)->child_index(
8164 child_at_origin[hex->face(1)->refinement_case() -
8165 1][f_fl[1]][f_ro[1]]),
8166 hex->face(1)->child_index(
8168 child_at_origin[hex->face(1)->refinement_case() -
8169 1][f_fl[1]][f_ro[1]]),
8171 hex->face(2)->isotropic_child_index(
8173 0, f_or[2], f_fl[2], f_ro[2])),
8174 hex->face(2)->isotropic_child_index(
8176 1, f_or[2], f_fl[2], f_ro[2])),
8177 hex->face(2)->isotropic_child_index(
8179 2, f_or[2], f_fl[2], f_ro[2])),
8180 hex->face(2)->isotropic_child_index(
8182 3, f_or[2], f_fl[2], f_ro[2])),
8184 hex->face(3)->isotropic_child_index(
8186 0, f_or[3], f_fl[3], f_ro[3])),
8187 hex->face(3)->isotropic_child_index(
8189 1, f_or[3], f_fl[3], f_ro[3])),
8190 hex->face(3)->isotropic_child_index(
8192 2, f_or[3], f_fl[3], f_ro[3])),
8193 hex->face(3)->isotropic_child_index(
8195 3, f_or[3], f_fl[3], f_ro[3])),
8197 hex->face(4)->child_index(
8198 child_at_origin[hex->face(4)->refinement_case() -
8199 1][f_fl[4]][f_ro[4]]),
8200 hex->face(4)->child_index(
8202 child_at_origin[hex->face(4)->refinement_case() -
8203 1][f_fl[4]][f_ro[4]]),
8205 hex->face(5)->child_index(
8206 child_at_origin[hex->face(5)->refinement_case() -
8207 1][f_fl[5]][f_ro[5]]),
8208 hex->face(5)->child_index(
8210 child_at_origin[hex->face(5)->refinement_case() -
8211 1][f_fl[5]][f_ro[5]])};
8222 new_hexes[0]->set_bounding_object_indices(
8229 new_hexes[1]->set_bounding_object_indices(
8236 new_hexes[2]->set_bounding_object_indices(
8243 new_hexes[3]->set_bounding_object_indices(
8276 new_lines[0]->set_bounding_object_indices(
8278 {middle_vertex_index<dim, spacedim>(hex->face(0)),
8279 middle_vertex_index<dim, spacedim>(hex->face(1))});
8348 spacedim>::raw_line_iterator lines[13] = {
8349 hex->face(2)->child(0)->line(
8350 (hex->face(2)->refinement_case() ==
8354 hex->face(3)->child(0)->line(
8355 (hex->face(3)->refinement_case() ==
8359 hex->face(4)->child(0)->line(
8360 (hex->face(4)->refinement_case() ==
8364 hex->face(5)->child(0)->line(
8365 (hex->face(5)->refinement_case() ==
8373 0, f_or[0], f_fl[0], f_ro[0]))
8376 1, f_or[0], f_fl[0], f_ro[0])),
8380 3, f_or[0], f_fl[0], f_ro[0]))
8383 0, f_or[0], f_fl[0], f_ro[0])),
8387 0, f_or[0], f_fl[0], f_ro[0]))
8390 3, f_or[0], f_fl[0], f_ro[0])),
8394 3, f_or[0], f_fl[0], f_ro[0]))
8397 2, f_or[0], f_fl[0], f_ro[0])),
8402 0, f_or[1], f_fl[1], f_ro[1]))
8405 1, f_or[1], f_fl[1], f_ro[1])),
8409 3, f_or[1], f_fl[1], f_ro[1]))
8412 0, f_or[1], f_fl[1], f_ro[1])),
8416 0, f_or[1], f_fl[1], f_ro[1]))
8419 3, f_or[1], f_fl[1], f_ro[1])),
8423 3, f_or[1], f_fl[1], f_ro[1]))
8426 2, f_or[1], f_fl[1], f_ro[1])),
8431 unsigned int line_indices[13];
8433 for (
unsigned int i = 0; i < 13; ++i)
8434 line_indices[i] = lines[i]->index();
8441 bool line_orientation[13];
8445 const unsigned int middle_vertices[4] = {
8446 hex->line(8)->child(0)->vertex_index(1),
8447 hex->line(10)->child(0)->vertex_index(1),
8448 hex->line(0)->child(0)->vertex_index(1),
8449 hex->line(4)->child(0)->vertex_index(1),
8454 for (
unsigned int i = 0; i < 4; ++i)
8455 if (lines[i]->vertex_index(0) == middle_vertices[i])
8456 line_orientation[i] =
true;
8460 Assert(lines[i]->vertex_index(1) ==
8463 line_orientation[i] =
false;
8472 for (
unsigned int i = 4; i < 12; ++i)
8473 if (lines[i]->vertex_index((i + 1) % 2) ==
8474 middle_vertex_index<dim, spacedim>(
8475 hex->face(i / 4 - 1)))
8476 line_orientation[i] =
true;
8481 Assert(lines[i]->vertex_index(i % 2) ==
8482 (middle_vertex_index<dim, spacedim>(
8483 hex->face(i / 4 - 1))),
8485 line_orientation[i] =
false;
8490 line_orientation[12] =
true;
8510 new_quads[0]->set_bounding_object_indices(
8515 new_quads[1]->set_bounding_object_indices(
8520 new_quads[2]->set_bounding_object_indices(
8525 new_quads[3]->set_bounding_object_indices(
8531 new_quads[0]->set_line_orientation(
8532 0, line_orientation[6]);
8533 new_quads[0]->set_line_orientation(
8534 1, line_orientation[10]);
8535 new_quads[0]->set_line_orientation(
8536 2, line_orientation[0]);
8538 new_quads[1]->set_line_orientation(
8539 0, line_orientation[7]);
8540 new_quads[1]->set_line_orientation(
8541 1, line_orientation[11]);
8542 new_quads[1]->set_line_orientation(
8543 3, line_orientation[1]);
8545 new_quads[2]->set_line_orientation(
8546 0, line_orientation[2]);
8547 new_quads[2]->set_line_orientation(
8548 2, line_orientation[4]);
8549 new_quads[2]->set_line_orientation(
8550 3, line_orientation[8]);
8552 new_quads[3]->set_line_orientation(
8553 1, line_orientation[3]);
8554 new_quads[3]->set_line_orientation(
8555 2, line_orientation[5]);
8556 new_quads[3]->set_line_orientation(
8557 3, line_orientation[9]);
8591 const int quad_indices[20] = {
8592 new_quads[0]->index(),
8593 new_quads[1]->index(),
8594 new_quads[2]->index(),
8595 new_quads[3]->index(),
8597 hex->face(0)->isotropic_child_index(
8599 0, f_or[0], f_fl[0], f_ro[0])),
8600 hex->face(0)->isotropic_child_index(
8602 1, f_or[0], f_fl[0], f_ro[0])),
8603 hex->face(0)->isotropic_child_index(
8605 2, f_or[0], f_fl[0], f_ro[0])),
8606 hex->face(0)->isotropic_child_index(
8608 3, f_or[0], f_fl[0], f_ro[0])),
8610 hex->face(1)->isotropic_child_index(
8612 0, f_or[1], f_fl[1], f_ro[1])),
8613 hex->face(1)->isotropic_child_index(
8615 1, f_or[1], f_fl[1], f_ro[1])),
8616 hex->face(1)->isotropic_child_index(
8618 2, f_or[1], f_fl[1], f_ro[1])),
8619 hex->face(1)->isotropic_child_index(
8621 3, f_or[1], f_fl[1], f_ro[1])),
8623 hex->face(2)->child_index(
8624 child_at_origin[hex->face(2)->refinement_case() -
8625 1][f_fl[2]][f_ro[2]]),
8626 hex->face(2)->child_index(
8628 child_at_origin[hex->face(2)->refinement_case() -
8629 1][f_fl[2]][f_ro[2]]),
8631 hex->face(3)->child_index(
8632 child_at_origin[hex->face(3)->refinement_case() -
8633 1][f_fl[3]][f_ro[3]]),
8634 hex->face(3)->child_index(
8636 child_at_origin[hex->face(3)->refinement_case() -
8637 1][f_fl[3]][f_ro[3]]),
8639 hex->face(4)->child_index(
8640 child_at_origin[hex->face(4)->refinement_case() -
8641 1][f_fl[4]][f_ro[4]]),
8642 hex->face(4)->child_index(
8644 child_at_origin[hex->face(4)->refinement_case() -
8645 1][f_fl[4]][f_ro[4]]),
8647 hex->face(5)->child_index(
8648 child_at_origin[hex->face(5)->refinement_case() -
8649 1][f_fl[5]][f_ro[5]]),
8650 hex->face(5)->child_index(
8652 child_at_origin[hex->face(5)->refinement_case() -
8653 1][f_fl[5]][f_ro[5]])};
8655 new_hexes[0]->set_bounding_object_indices(
8662 new_hexes[1]->set_bounding_object_indices(
8669 new_hexes[2]->set_bounding_object_indices(
8676 new_hexes[3]->set_bounding_object_indices(
8714 ++next_unused_vertex;
8718 "Internal error: During refinement, the triangulation wants to access an element of the 'vertices' array but it turns out that the array is not large enough."));
8729 hex->center(
true,
true);
8751 middle_vertex_index<dim, spacedim>(hex->face(0)),
8752 middle_vertex_index<dim, spacedim>(hex->face(1)),
8753 middle_vertex_index<dim, spacedim>(hex->face(2)),
8754 middle_vertex_index<dim, spacedim>(hex->face(3)),
8755 middle_vertex_index<dim, spacedim>(hex->face(4)),
8756 middle_vertex_index<dim, spacedim>(hex->face(5)),
8757 next_unused_vertex};
8759 new_lines[0]->set_bounding_object_indices(
8761 new_lines[1]->set_bounding_object_indices(
8763 new_lines[2]->set_bounding_object_indices(
8765 new_lines[3]->set_bounding_object_indices(
8767 new_lines[4]->set_bounding_object_indices(
8769 new_lines[5]->set_bounding_object_indices(
8839 spacedim>::raw_line_iterator lines[30] = {
8843 0, f_or[0], f_fl[0], f_ro[0]))
8846 1, f_or[0], f_fl[0], f_ro[0])),
8850 3, f_or[0], f_fl[0], f_ro[0]))
8853 0, f_or[0], f_fl[0], f_ro[0])),
8857 0, f_or[0], f_fl[0], f_ro[0]))
8860 3, f_or[0], f_fl[0], f_ro[0])),
8864 3, f_or[0], f_fl[0], f_ro[0]))
8867 2, f_or[0], f_fl[0], f_ro[0])),
8872 0, f_or[1], f_fl[1], f_ro[1]))
8875 1, f_or[1], f_fl[1], f_ro[1])),
8879 3, f_or[1], f_fl[1], f_ro[1]))
8882 0, f_or[1], f_fl[1], f_ro[1])),
8886 0, f_or[1], f_fl[1], f_ro[1]))
8889 3, f_or[1], f_fl[1], f_ro[1])),
8893 3, f_or[1], f_fl[1], f_ro[1]))
8896 2, f_or[1], f_fl[1], f_ro[1])),
8901 0, f_or[2], f_fl[2], f_ro[2]))
8904 1, f_or[2], f_fl[2], f_ro[2])),
8908 3, f_or[2], f_fl[2], f_ro[2]))
8911 0, f_or[2], f_fl[2], f_ro[2])),
8915 0, f_or[2], f_fl[2], f_ro[2]))
8918 3, f_or[2], f_fl[2], f_ro[2])),
8922 3, f_or[2], f_fl[2], f_ro[2]))
8925 2, f_or[2], f_fl[2], f_ro[2])),
8930 0, f_or[3], f_fl[3], f_ro[3]))
8933 1, f_or[3], f_fl[3], f_ro[3])),
8937 3, f_or[3], f_fl[3], f_ro[3]))
8940 0, f_or[3], f_fl[3], f_ro[3])),
8944 0, f_or[3], f_fl[3], f_ro[3]))
8947 3, f_or[3], f_fl[3], f_ro[3])),
8951 3, f_or[3], f_fl[3], f_ro[3]))
8954 2, f_or[3], f_fl[3], f_ro[3])),
8959 0, f_or[4], f_fl[4], f_ro[4]))
8962 1, f_or[4], f_fl[4], f_ro[4])),
8966 3, f_or[4], f_fl[4], f_ro[4]))
8969 0, f_or[4], f_fl[4], f_ro[4])),
8973 0, f_or[4], f_fl[4], f_ro[4]))
8976 3, f_or[4], f_fl[4], f_ro[4])),
8980 3, f_or[4], f_fl[4], f_ro[4]))
8983 2, f_or[4], f_fl[4], f_ro[4])),
8988 0, f_or[5], f_fl[5], f_ro[5]))
8991 1, f_or[5], f_fl[5], f_ro[5])),
8995 3, f_or[5], f_fl[5], f_ro[5]))
8998 0, f_or[5], f_fl[5], f_ro[5])),
9002 0, f_or[5], f_fl[5], f_ro[5]))
9005 3, f_or[5], f_fl[5], f_ro[5])),
9009 3, f_or[5], f_fl[5], f_ro[5]))
9012 2, f_or[5], f_fl[5], f_ro[5])),
9022 unsigned int line_indices[30];
9023 for (
unsigned int i = 0; i < 30; ++i)
9024 line_indices[i] = lines[i]->index();
9031 bool line_orientation[30];
9039 for (
unsigned int i = 0; i < 24; ++i)
9040 if (lines[i]->vertex_index((i + 1) % 2) ==
9042 line_orientation[i] =
true;
9047 Assert(lines[i]->vertex_index(i % 2) ==
9050 line_orientation[i] =
false;
9055 for (
unsigned int i = 24; i < 30; ++i)
9056 line_orientation[i] =
true;
9088 new_quads[0]->set_bounding_object_indices(
9093 new_quads[1]->set_bounding_object_indices(
9098 new_quads[2]->set_bounding_object_indices(
9103 new_quads[3]->set_bounding_object_indices(
9108 new_quads[4]->set_bounding_object_indices(
9113 new_quads[5]->set_bounding_object_indices(
9118 new_quads[6]->set_bounding_object_indices(
9123 new_quads[7]->set_bounding_object_indices(
9128 new_quads[8]->set_bounding_object_indices(
9133 new_quads[9]->set_bounding_object_indices(
9138 new_quads[10]->set_bounding_object_indices(
9143 new_quads[11]->set_bounding_object_indices(
9152 new_quads[0]->set_line_orientation(
9153 0, line_orientation[10]);
9154 new_quads[0]->set_line_orientation(
9155 2, line_orientation[16]);
9157 new_quads[1]->set_line_orientation(
9158 1, line_orientation[14]);
9159 new_quads[1]->set_line_orientation(
9160 2, line_orientation[17]);
9162 new_quads[2]->set_line_orientation(
9163 0, line_orientation[11]);
9164 new_quads[2]->set_line_orientation(
9165 3, line_orientation[20]);
9167 new_quads[3]->set_line_orientation(
9168 1, line_orientation[15]);
9169 new_quads[3]->set_line_orientation(
9170 3, line_orientation[21]);
9172 new_quads[4]->set_line_orientation(
9173 0, line_orientation[18]);
9174 new_quads[4]->set_line_orientation(
9175 2, line_orientation[0]);
9177 new_quads[5]->set_line_orientation(
9178 1, line_orientation[22]);
9179 new_quads[5]->set_line_orientation(
9180 2, line_orientation[1]);
9182 new_quads[6]->set_line_orientation(
9183 0, line_orientation[19]);
9184 new_quads[6]->set_line_orientation(
9185 3, line_orientation[4]);
9187 new_quads[7]->set_line_orientation(
9188 1, line_orientation[23]);
9189 new_quads[7]->set_line_orientation(
9190 3, line_orientation[5]);
9192 new_quads[8]->set_line_orientation(
9193 0, line_orientation[2]);
9194 new_quads[8]->set_line_orientation(
9195 2, line_orientation[8]);
9197 new_quads[9]->set_line_orientation(
9198 1, line_orientation[6]);
9199 new_quads[9]->set_line_orientation(
9200 2, line_orientation[9]);
9202 new_quads[10]->set_line_orientation(
9203 0, line_orientation[3]);
9204 new_quads[10]->set_line_orientation(
9205 3, line_orientation[12]);
9207 new_quads[11]->set_line_orientation(
9208 1, line_orientation[7]);
9209 new_quads[11]->set_line_orientation(
9210 3, line_orientation[13]);
9251 const int quad_indices[36] = {
9252 new_quads[0]->index(),
9253 new_quads[1]->index(),
9254 new_quads[2]->index(),
9255 new_quads[3]->index(),
9256 new_quads[4]->index(),
9257 new_quads[5]->index(),
9258 new_quads[6]->index(),
9259 new_quads[7]->index(),
9260 new_quads[8]->index(),
9261 new_quads[9]->index(),
9262 new_quads[10]->index(),
9263 new_quads[11]->index(),
9265 hex->face(0)->isotropic_child_index(
9267 0, f_or[0], f_fl[0], f_ro[0])),
9268 hex->face(0)->isotropic_child_index(
9270 1, f_or[0], f_fl[0], f_ro[0])),
9271 hex->face(0)->isotropic_child_index(
9273 2, f_or[0], f_fl[0], f_ro[0])),
9274 hex->face(0)->isotropic_child_index(
9276 3, f_or[0], f_fl[0], f_ro[0])),
9278 hex->face(1)->isotropic_child_index(
9280 0, f_or[1], f_fl[1], f_ro[1])),
9281 hex->face(1)->isotropic_child_index(
9283 1, f_or[1], f_fl[1], f_ro[1])),
9284 hex->face(1)->isotropic_child_index(
9286 2, f_or[1], f_fl[1], f_ro[1])),
9287 hex->face(1)->isotropic_child_index(
9289 3, f_or[1], f_fl[1], f_ro[1])),
9291 hex->face(2)->isotropic_child_index(
9293 0, f_or[2], f_fl[2], f_ro[2])),
9294 hex->face(2)->isotropic_child_index(
9296 1, f_or[2], f_fl[2], f_ro[2])),
9297 hex->face(2)->isotropic_child_index(
9299 2, f_or[2], f_fl[2], f_ro[2])),
9300 hex->face(2)->isotropic_child_index(
9302 3, f_or[2], f_fl[2], f_ro[2])),
9304 hex->face(3)->isotropic_child_index(
9306 0, f_or[3], f_fl[3], f_ro[3])),
9307 hex->face(3)->isotropic_child_index(
9309 1, f_or[3], f_fl[3], f_ro[3])),
9310 hex->face(3)->isotropic_child_index(
9312 2, f_or[3], f_fl[3], f_ro[3])),
9313 hex->face(3)->isotropic_child_index(
9315 3, f_or[3], f_fl[3], f_ro[3])),
9317 hex->face(4)->isotropic_child_index(
9319 0, f_or[4], f_fl[4], f_ro[4])),
9320 hex->face(4)->isotropic_child_index(
9322 1, f_or[4], f_fl[4], f_ro[4])),
9323 hex->face(4)->isotropic_child_index(
9325 2, f_or[4], f_fl[4], f_ro[4])),
9326 hex->face(4)->isotropic_child_index(
9328 3, f_or[4], f_fl[4], f_ro[4])),
9330 hex->face(5)->isotropic_child_index(
9332 0, f_or[5], f_fl[5], f_ro[5])),
9333 hex->face(5)->isotropic_child_index(
9335 1, f_or[5], f_fl[5], f_ro[5])),
9336 hex->face(5)->isotropic_child_index(
9338 2, f_or[5], f_fl[5], f_ro[5])),
9339 hex->face(5)->isotropic_child_index(
9341 3, f_or[5], f_fl[5], f_ro[5]))};
9344 new_hexes[0]->set_bounding_object_indices(
9351 new_hexes[1]->set_bounding_object_indices(
9358 new_hexes[2]->set_bounding_object_indices(
9365 new_hexes[3]->set_bounding_object_indices(
9374 new_hexes[4]->set_bounding_object_indices(
9381 new_hexes[5]->set_bounding_object_indices(
9388 new_hexes[6]->set_bounding_object_indices(
9395 new_hexes[7]->set_bounding_object_indices(
9435 for (
unsigned int s = 0;
9442 const unsigned int current_child =
9451 ref_case, f, f_or[f], f_fl[f], f_ro[f]));
9452 new_hexes[current_child]->set_face_orientation(f,
9454 new_hexes[current_child]->set_face_flip(f, f_fl[f]);
9455 new_hexes[current_child]->set_face_rotation(f, f_ro[f]);
9460 if (check_for_distorted_cells &&
9461 has_distorted_children<dim, spacedim>(hex))
9481 return cells_with_distorted_children;
9497 template <
int spacedim>
9503 template <
int dim,
int spacedim>
9514 if (cell->at_boundary() && cell->refine_flag_set() &&
9515 cell->refine_flag_set() !=
9522 for (
const unsigned int face_no :
9524 if (cell->face(face_no)->at_boundary())
9535 spacedim>::face_iterator
9536 face = cell->face(face_no);
9543 cell->reference_cell()
9557 std::fabs(new_unit[face_no / 2] - face_no % 2);
9562 const double allowed = 0.25;
9565 cell->flag_for_face_refinement(face_no);
9584 template <
int dim,
int spacedim>
9589 ExcMessage(
"Wrong function called -- there should "
9590 "be a specialization."));
9594 template <
int spacedim>
9598 const unsigned int dim = 3;
9610 bool mesh_changed =
false;
9614 mesh_changed =
false;
9625 if (cell->refine_flag_set())
9627 for (
unsigned int line = 0; line < cell->
n_lines(); ++line)
9629 cell->refine_flag_set(), line) ==
9633 cell->line(line)->set_user_flag();
9635 else if (cell->has_children() &&
9636 !cell->child(0)->coarsen_flag_set())
9638 for (
unsigned int line = 0;
9639 line < GeometryInfo<dim>::lines_per_cell;
9642 cell->refinement_case(), line) ==
9646 cell->line(line)->set_user_flag();
9648 else if (cell->has_children() &&
9649 cell->child(0)->coarsen_flag_set())
9650 cell->set_user_flag();
9661 for (
unsigned int line = 0; line < cell->
n_lines(); ++line)
9663 if (cell->line(line)->has_children())
9672 bool offending_line_found =
false;
9674 for (
unsigned int c = 0; c < 2; ++c)
9676 Assert(cell->line(line)->child(c)->has_children() ==
9680 if (cell->line(line)->child(c)->user_flag_set() &&
9682 cell->refine_flag_set(), line) ==
9686 cell->clear_coarsen_flag();
9693 allow_anisotropic_smoothing)
9694 cell->flag_for_line_refinement(line);
9696 cell->set_refine_flag();
9698 for (
unsigned int l = 0;
9699 l < GeometryInfo<dim>::lines_per_cell;
9702 cell->refine_flag_set(), line) ==
9705 cell->line(
l)->set_user_flag();
9708 offending_line_found =
true;
9714 for (
unsigned int l = 0;
9715 l < GeometryInfo<dim>::lines_per_cell;
9717 if (!cell->line(
l)->has_children() &&
9719 cell->refine_flag_set(),
l) !=
9721 cell->line(
l)->set_user_flag();
9727 if (offending_line_found)
9729 mesh_changed =
true;
9751 if (cell->user_flag_set())
9752 for (
unsigned int line = 0;
9753 line < GeometryInfo<dim>::lines_per_cell;
9755 if (cell->line(line)->has_children() &&
9756 (cell->line(line)->child(0)->user_flag_set() ||
9757 cell->line(line)->child(1)->user_flag_set()))
9759 for (
unsigned int c = 0; c < cell->n_children(); ++c)
9760 cell->child(c)->clear_coarsen_flag();
9761 cell->clear_user_flag();
9762 for (
unsigned int l = 0;
9763 l < GeometryInfo<dim>::lines_per_cell;
9766 cell->refinement_case(),
l) ==
9770 cell->line(
l)->set_user_flag();
9771 mesh_changed =
true;
9776 while (mesh_changed ==
true);
9787 template <
int dim,
int spacedim>
9807 const unsigned int n_subfaces =
9810 if (n_subfaces == 0 || cell->at_boundary(n))
9812 for (
unsigned int c = 0; c < n_subfaces; ++c)
9815 child = cell->child(
9819 child_neighbor = child->neighbor(n);
9820 if (!child->neighbor_is_coarser(n))
9833 if ((child_neighbor->has_children() &&
9834 !child_neighbor->user_flag_set()) ||
9843 child_neighbor->refine_flag_set())
9857 template <
int spacedim>
9861 template <
int dim,
int spacedim>
9864 std::vector<std::pair<unsigned int, unsigned int>>
adjacent_cells(
9866 {numbers::invalid_unsigned_int, numbers::invalid_unsigned_int});
9868 const auto set_entry = [&](
const auto &face_index,
const auto &cell) {
9869 const std::pair<unsigned int, unsigned int> cell_pair = {
9870 cell->level(), cell->index()};
9878 index = 2 * face_index + 0;
9887 index = 2 * face_index + 1;
9893 const auto get_entry =
9894 [&](
const auto &face_index,
9898 if (test == std::pair<unsigned int, unsigned int>(cell->level(),
9912 for (
const auto &face : cell->face_iterators())
9914 set_entry(face->index(), cell);
9916 if (cell->is_active() && face->has_children())
9917 for (
unsigned int c = 0; c < face->n_children(); ++c)
9918 set_entry(face->child(c)->index(), cell);
9922 for (
auto f : cell->face_indices())
9923 cell->set_neighbor(f, get_entry(cell->face(f)->index(), cell));
9926 template <
int dim,
int spacedim>
9931 std::vector<unsigned int> & line_cell_count,
9932 std::vector<unsigned int> & quad_cell_count)
9937 (void)line_cell_count;
9938 (void)quad_cell_count;
9941 template <
int dim,
int spacedim>
9944 const bool check_for_distorted_cells)
9950 template <
int dim,
int spacedim>
9959 template <
int dim,
int spacedim>
9967 template <
int dim,
int spacedim>
9980 template <
int dim,
int spacedim>
9985 return flat_manifold;
9992template <
int dim,
int spacedim>
9997template <
int dim,
int spacedim>
9999 const MeshSmoothing smooth_grid,
10000 const bool check_for_distorted_cells)
10001 : smooth_grid(smooth_grid)
10002 , anisotropic_refinement(false)
10003 , check_for_distorted_cells(check_for_distorted_cells)
10007 vertex_to_boundary_id_map_1d =
10008 std::make_unique<std::map<unsigned int, types::boundary_id>>();
10009 vertex_to_manifold_id_map_1d =
10010 std::make_unique<std::map<unsigned int, types::manifold_id>>();
10014 signals.create.connect(signals.any_change);
10015 signals.post_refinement.connect(signals.any_change);
10016 signals.clear.connect(signals.any_change);
10017 signals.mesh_movement.connect(signals.any_change);
10022template <
int dim,
int spacedim>
10026 , smooth_grid(tria.smooth_grid)
10027 , reference_cells(std::move(tria.reference_cells))
10028 , periodic_face_pairs_level_0(std::move(tria.periodic_face_pairs_level_0))
10029 , periodic_face_map(std::move(tria.periodic_face_map))
10030 , levels(std::move(tria.levels))
10031 , faces(std::move(tria.faces))
10032 ,
vertices(std::move(tria.vertices))
10033 , vertices_used(std::move(tria.vertices_used))
10034 , manifold(std::move(tria.manifold))
10035 , anisotropic_refinement(tria.anisotropic_refinement)
10036 , check_for_distorted_cells(tria.check_for_distorted_cells)
10037 , number_cache(std::move(tria.number_cache))
10038 , vertex_to_boundary_id_map_1d(std::move(tria.vertex_to_boundary_id_map_1d))
10039 , vertex_to_manifold_id_map_1d(std::move(tria.vertex_to_manifold_id_map_1d))
10044 this->policy = tria.policy->clone();
10048template <
int dim,
int spacedim>
10055 smooth_grid = tria.smooth_grid;
10056 reference_cells = std::move(tria.reference_cells);
10057 periodic_face_pairs_level_0 = std::move(tria.periodic_face_pairs_level_0);
10058 periodic_face_map = std::move(tria.periodic_face_map);
10059 levels = std::move(tria.levels);
10060 faces = std::move(tria.faces);
10061 vertices = std::move(tria.vertices);
10062 vertices_used = std::move(tria.vertices_used);
10063 manifold = std::move(tria.manifold);
10064 anisotropic_refinement = tria.anisotropic_refinement;
10065 number_cache = tria.number_cache;
10066 vertex_to_boundary_id_map_1d = std::move(tria.vertex_to_boundary_id_map_1d);
10067 vertex_to_manifold_id_map_1d = std::move(tria.vertex_to_manifold_id_map_1d);
10072 this->policy = tria.policy->clone();
10079template <
int dim,
int spacedim>
10096 AssertNothrow((dim == 1) || (vertex_to_boundary_id_map_1d ==
nullptr),
10101 AssertNothrow((dim == 1) || (vertex_to_manifold_id_map_1d ==
nullptr),
10107template <
int dim,
int spacedim>
10115 clear_despite_subscriptions();
10116 periodic_face_pairs_level_0.clear();
10117 periodic_face_map.clear();
10118 reference_cells.clear();
10122template <
int dim,
int spacedim>
10126 return MPI_COMM_SELF;
10131template <
int dim,
int spacedim>
10134 const MeshSmoothing mesh_smoothing)
10137 ExcTriangulationNotEmpty(
vertices.size(), levels.size()));
10138 smooth_grid = mesh_smoothing;
10143template <
int dim,
int spacedim>
10147 return smooth_grid;
10152template <
int dim,
int spacedim>
10160 manifold[m_number] = manifold_object.
clone();
10165template <
int dim,
int spacedim>
10172 manifold.erase(m_number);
10176template <
int dim,
int spacedim>
10184template <
int dim,
int spacedim>
10192 "Error: set_all_manifold_ids() can not be called on an empty Triangulation."));
10194 for (
const auto &cell : this->active_cell_iterators())
10199template <
int dim,
int spacedim>
10207 "Error: set_all_manifold_ids_on_boundary() can not be called on an empty Triangulation."));
10209 for (
const auto &cell : this->active_cell_iterators())
10211 if (cell->face(f)->at_boundary())
10216template <
int dim,
int spacedim>
10225 "Error: set_all_manifold_ids_on_boundary() can not be called on an empty Triangulation."));
10227 bool boundary_found =
false;
10229 for (
const auto &cell : this->active_cell_iterators())
10233 if (cell->face(f)->at_boundary() &&
10234 cell->face(f)->boundary_id() == b_id)
10236 boundary_found =
true;
10237 cell->face(f)->set_manifold_id(m_number);
10242 for (
unsigned int e = 0; e < GeometryInfo<dim>::lines_per_cell; ++
e)
10243 if (cell->line(
e)->at_boundary() &&
10244 cell->line(
e)->boundary_id() == b_id)
10246 boundary_found =
true;
10247 cell->line(
e)->set_manifold_id(m_number);
10251 (void)boundary_found;
10252 Assert(boundary_found, ExcBoundaryIdNotFound(b_id));
10257template <
int dim,
int spacedim>
10264 const auto it = manifold.find(m_number);
10266 if (it != manifold.end())
10269 return *(it->second);
10274 return internal::TriangulationImplementation::
10275 get_default_flat_manifold<dim, spacedim>();
10280template <
int dim,
int spacedim>
10281std::vector<types::boundary_id>
10288 std::vector<types::boundary_id> boundary_ids;
10289 for (std::map<unsigned int, types::boundary_id>::const_iterator p =
10290 vertex_to_boundary_id_map_1d->begin();
10291 p != vertex_to_boundary_id_map_1d->end();
10293 boundary_ids.push_back(p->second);
10295 return boundary_ids;
10299 std::set<types::boundary_id> b_ids;
10300 for (
auto cell : active_cell_iterators())
10301 if (cell->is_locally_owned())
10302 for (
const unsigned int face : cell->face_indices())
10303 if (cell->at_boundary(face))
10304 b_ids.insert(cell->face(face)->boundary_id());
10305 std::vector<types::boundary_id> boundary_ids(b_ids.begin(), b_ids.end());
10306 return boundary_ids;
10312template <
int dim,
int spacedim>
10313std::vector<types::manifold_id>
10316 std::set<types::manifold_id> m_ids;
10317 for (
auto cell : active_cell_iterators())
10318 if (cell->is_locally_owned())
10320 m_ids.insert(cell->manifold_id());
10321 for (
const auto &face : cell->face_iterators())
10322 m_ids.insert(face->manifold_id());
10324 for (
const unsigned int l : cell->line_indices())
10325 m_ids.insert(cell->line(
l)->manifold_id());
10327 return {m_ids.begin(), m_ids.end()};
10333template <
int dim,
int spacedim>
10338 Assert((
vertices.size() == 0) && (levels.size() == 0) && (faces ==
nullptr),
10339 ExcTriangulationNotEmpty(
vertices.size(), levels.size()));
10341 (dim == 1 || other_tria.
faces !=
nullptr),
10343 "When calling Triangulation::copy_triangulation(), "
10344 "the target triangulation must be empty but the source "
10345 "triangulation (the argument to this function) must contain "
10346 "something. Here, it seems like the source does not "
10347 "contain anything at all."));
10358 faces = std::make_unique<internal::TriangulationImplementation::TriaFaces>(
10359 *other_tria.
faces);
10361 for (
const auto &p : other_tria.
manifold)
10362 set_manifold(p.first, *p.second);
10365 levels.reserve(other_tria.
levels.size());
10368 std::make_unique<internal::TriangulationImplementation::TriaLevel>(
10375 vertex_to_boundary_id_map_1d =
10376 std::make_unique<std::map<unsigned int, types::boundary_id>>(
10379 vertex_to_manifold_id_map_1d =
10380 std::make_unique<std::map<unsigned int, types::manifold_id>>(
10385 this->policy = other_tria.
policy->clone();
10388 other_tria.
signals.copy(*
this);
10399template <
int dim,
int spacedim>
10406 std::vector<CellData<dim>> reordered_cells(cells);
10410 reorder_compatibility(reordered_cells, reordered_subcelldata);
10418template <
int dim,
int spacedim>
10422 this->update_reference_cells();
10424 if (this->all_reference_cells_are_hyper_cube())
10444template <
int dim,
int spacedim>
10451 Assert((
vertices.size() == 0) && (levels.size() == 0) && (faces ==
nullptr),
10452 ExcTriangulationNotEmpty(
vertices.size(), levels.size()));
10467 clear_despite_subscriptions();
10475 reset_cell_vertex_indices_cache();
10477 *
this, levels.size(), number_cache);
10478 reset_active_cell_indices();
10479 reset_global_cell_indices();
10484 if (check_for_distorted_cells)
10486 DistortedCellList distorted_cells = collect_distorted_coarse_cells(*
this);
10490 AssertThrow(distorted_cells.distorted_cells.size() == 0, distorted_cells);
10523 if (dim < spacedim)
10531 bool values[][2] = {{
false,
true}, {
true,
false}};
10534 correct(i, j) = (
values[i][j]);
10539 bool values[][4] = {{
false,
true,
true,
false},
10540 {
true,
false,
false,
true},
10541 {
true,
false,
false,
true},
10542 {
false,
true,
true,
false}};
10545 correct(i, j) = (
values[i][j]);
10553 std::list<active_cell_iterator> this_round, next_round;
10554 active_cell_iterator neighbor;
10556 this_round.push_back(begin_active());
10557 begin_active()->set_direction_flag(
true);
10558 begin_active()->set_user_flag();
10560 while (this_round.size() > 0)
10562 for (
typename std::list<active_cell_iterator>::iterator cell =
10563 this_round.begin();
10564 cell != this_round.end();
10567 for (
const unsigned int i : (*cell)->face_indices())
10569 if (!((*cell)->face(i)->at_boundary()))
10571 neighbor = (*cell)->neighbor(i);
10573 unsigned int cf = (*cell)->face_index(i);
10574 unsigned int j = 0;
10575 while (neighbor->face_index(j) != cf)
10583 if (neighbor->user_flag_set())
10587 Assert(!(correct(i, j) ^
10588 (neighbor->direction_flag() ==
10589 (*cell)->direction_flag())),
10590 ExcNonOrientableTriangulation());
10594 next_round.push_back(neighbor);
10595 neighbor->set_user_flag();
10596 if ((correct(i, j) ^ (neighbor->direction_flag() ==
10597 (*cell)->direction_flag())))
10598 neighbor->set_direction_flag(
10599 !neighbor->direction_flag());
10609 if (next_round.size() == 0)
10610 for (
const auto &cell : this->active_cell_iterators())
10611 if (cell->user_flag_set() ==
false)
10613 next_round.push_back(cell);
10614 cell->set_direction_flag(
true);
10615 cell->set_user_flag();
10619 this_round = next_round;
10620 next_round.
clear();
10630template <
int dim,
int spacedim>
10641 auto cell_infos = construction_data.
cell_infos;
10644 for (
auto &cell_info : cell_infos)
10650 const CellId a_id(a.id);
10651 const CellId b_id(b.id);
10653 const auto a_coarse_cell_index =
10654 this->coarse_cell_id_to_coarse_cell_index(a_id.get_coarse_cell_id());
10655 const auto b_coarse_cell_index =
10656 this->coarse_cell_id_to_coarse_cell_index(b_id.get_coarse_cell_id());
10663 if (a_coarse_cell_index != b_coarse_cell_index)
10664 return a_coarse_cell_index < b_coarse_cell_index;
10666 return a_id < b_id;
10672 for (
unsigned int level = 0;
10673 level < cell_infos.size() && !cell_infos[
level].empty();
10680 auto cell_info = cell_infos[
level].begin();
10681 for (; cell_info != cell_infos[
level].end(); ++cell_info)
10683 while (cell_info->id != cell->id().template to_binary<dim>())
10686 for (
const auto quad : cell->face_indices())
10687 cell->quad(quad)->set_manifold_id(
10688 cell_info->manifold_quad_ids[quad]);
10691 for (
const auto line : cell->line_indices())
10692 cell->line(line)->set_manifold_id(
10693 cell_info->manifold_line_ids[line]);
10695 cell->set_manifold_id(cell_info->manifold_id);
10700 if (
level + 1 != cell_infos.size())
10705 auto fine_cell_info = cell_infos[
level + 1].begin();
10708 for (; fine_cell_info != cell_infos[
level + 1].end();
10713 !coarse_cell->id().is_parent_of(
CellId(fine_cell_info->id)))
10717 coarse_cell->set_refine_flag();
10722 spacedim>::execute_coarsening_and_refinement();
10727 for (
unsigned int level = 0;
10728 level < cell_infos.size() && !cell_infos[
level].empty();
10732 auto cell_info = cell_infos[
level].begin();
10733 for (; cell_info != cell_infos[
level].end(); ++cell_info)
10736 while (cell_info->id != cell->id().template to_binary<dim>())
10740 for (
auto pair : cell_info->boundary_ids)
10742 Assert(cell->at_boundary(pair.first),
10743 ExcMessage(
"Cell face is not on the boundary!"));
10744 cell->face(pair.first)->set_boundary_id(pair.second);
10751template <
int dim,
int spacedim>
10756 ExcMessage(
"Only works for dim == spacedim-1"));
10757 for (
const auto &cell : this->active_cell_iterators())
10758 cell->set_direction_flag(!cell->direction_flag());
10763template <
int dim,
int spacedim>
10768 ExcMessage(
"Error: An empty Triangulation can not be refined."));
10770 for (
const auto &cell : this->active_cell_iterators())
10772 cell->clear_coarsen_flag();
10773 cell->set_refine_flag();
10779template <
int dim,
int spacedim>
10783 for (
unsigned int i = 0; i < times; ++i)
10785 set_all_refine_flags();
10786 execute_coarsening_and_refinement();
10792template <
int dim,
int spacedim>
10796 for (
unsigned int i = 0; i < times; ++i)
10798 for (
const auto &cell : this->active_cell_iterators())
10800 cell->clear_refine_flag();
10801 cell->set_coarsen_flag();
10803 execute_coarsening_and_refinement();
10812template <
int dim,
int spacedim>
10817 std::vector<bool>::iterator i = v.begin();
10819 for (
const auto &cell : this->active_cell_iterators())
10820 for (
unsigned int j = 0; j < dim; ++j, ++i)
10821 if (cell->refine_flag_set() & (1 << j))
10829template <
int dim,
int spacedim>
10833 std::vector<bool> v;
10834 save_refine_flags(v);
10843template <
int dim,
int spacedim>
10847 std::vector<bool> v;
10849 load_refine_flags(v);
10854template <
int dim,
int spacedim>
10860 std::vector<bool>::const_iterator i = v.begin();
10861 for (
const auto &cell : this->active_cell_iterators())
10863 unsigned int ref_case = 0;
10865 for (
unsigned int j = 0; j < dim; ++j, ++i)
10867 ref_case += 1 << j;
10869 ExcGridReadError());
10873 cell->clear_refine_flag();
10881template <
int dim,
int spacedim>
10886 std::vector<bool>::iterator i = v.begin();
10887 for (
const auto &cell : this->active_cell_iterators())
10889 *i = cell->coarsen_flag_set();
10898template <
int dim,
int spacedim>
10902 std::vector<bool> v;
10903 save_coarsen_flags(v);
10912template <
int dim,
int spacedim>
10916 std::vector<bool> v;
10921 load_coarsen_flags(v);
10926template <
int dim,
int spacedim>
10932 std::vector<bool>::const_iterator i = v.begin();
10933 for (
const auto &cell : this->active_cell_iterators())
10936 cell->set_coarsen_flag();
10938 cell->clear_coarsen_flag();
10946template <
int dim,
int spacedim>
10950 return anisotropic_refinement;
10962 clear_user_data(std::vector<std::unique_ptr<
10965 for (
auto &
level : levels)
10966 level->cells.clear_user_data();
10974 if (faces->
dim == 2)
10980 if (faces->
dim == 3)
10989template <
int dim,
int spacedim>
10994 ::clear_user_data(levels);
10995 ::clear_user_data(faces.get());
11003 clear_user_flags_line(
11006 std::unique_ptr<internal::TriangulationImplementation::TriaLevel>>
11012 for (
const auto &
level : levels)
11013 level->cells.clear_user_flags();
11015 else if (dim == 2 || dim == 3)
11027template <
int dim,
int spacedim>
11031 ::clear_user_flags_line(dim, levels, faces.get());
11039 clear_user_flags_quad(
11042 std::unique_ptr<internal::TriangulationImplementation::TriaLevel>>
11052 for (
const auto &
level : levels)
11053 level->cells.clear_user_flags();
11067template <
int dim,
int spacedim>
11071 ::clear_user_flags_quad(dim, levels, faces.get());
11079 clear_user_flags_hex(
11082 std::unique_ptr<internal::TriangulationImplementation::TriaLevel>>
11096 for (
const auto &
level : levels)
11097 level->cells.clear_user_flags();
11107template <
int dim,
int spacedim>
11111 ::clear_user_flags_hex(dim, levels, faces.get());
11116template <
int dim,
int spacedim>
11120 clear_user_flags_line();
11121 clear_user_flags_quad();
11122 clear_user_flags_hex();
11127template <
int dim,
int spacedim>
11131 save_user_flags_line(out);
11134 save_user_flags_quad(out);
11137 save_user_flags_hex(out);
11145template <
int dim,
int spacedim>
11153 std::vector<bool> tmp;
11155 save_user_flags_line(tmp);
11156 v.insert(v.end(), tmp.begin(), tmp.end());
11160 save_user_flags_quad(tmp);
11161 v.insert(v.end(), tmp.begin(), tmp.end());
11166 save_user_flags_hex(tmp);
11167 v.insert(v.end(), tmp.begin(), tmp.end());
11176template <
int dim,
int spacedim>
11180 load_user_flags_line(in);
11183 load_user_flags_quad(in);
11186 load_user_flags_hex(in);
11194template <
int dim,
int spacedim>
11199 std::vector<bool> tmp;
11203 tmp.insert(tmp.end(), v.begin(), v.begin() + n_lines());
11205 load_user_flags_line(tmp);
11210 tmp.insert(tmp.end(),
11211 v.begin() + n_lines(),
11212 v.begin() + n_lines() + n_quads());
11213 load_user_flags_quad(tmp);
11219 tmp.insert(tmp.end(),
11220 v.begin() + n_lines() + n_quads(),
11221 v.begin() + n_lines() + n_quads() + n_hexs());
11222 load_user_flags_hex(tmp);
11231template <
int dim,
int spacedim>
11235 v.resize(n_lines(),
false);
11236 std::vector<bool>::iterator i = v.begin();
11237 line_iterator line = begin_line(), endl = end_line();
11238 for (; line != endl; ++line, ++i)
11239 *i = line->user_flag_set();
11246template <
int dim,
int spacedim>
11250 std::vector<bool> v;
11251 save_user_flags_line(v);
11260template <
int dim,
int spacedim>
11264 std::vector<bool> v;
11269 load_user_flags_line(v);
11274template <
int dim,
int spacedim>
11278 Assert(v.size() == n_lines(), ExcGridReadError());
11280 line_iterator line = begin_line(), endl = end_line();
11281 std::vector<bool>::const_iterator i = v.begin();
11282 for (; line != endl; ++line, ++i)
11284 line->set_user_flag();
11286 line->clear_user_flag();
11294 template <
typename Iterator>
11296 get_user_flag(
const Iterator &i)
11298 return i->user_flag_set();
11303 template <
int structdim,
int dim,
int spacedim>
11313 template <
typename Iterator>
11315 set_user_flag(
const Iterator &i)
11317 i->set_user_flag();
11322 template <
int structdim,
int dim,
int spacedim>
11331 template <
typename Iterator>
11333 clear_user_flag(
const Iterator &i)
11335 i->clear_user_flag();
11340 template <
int structdim,
int dim,
int spacedim>
11350template <
int dim,
int spacedim>
11354 v.resize(n_quads(),
false);
11358 std::vector<bool>::iterator i = v.begin();
11359 quad_iterator quad = begin_quad(), endq = end_quad();
11360 for (; quad != endq; ++quad, ++i)
11361 *i = get_user_flag(quad);
11369template <
int dim,
int spacedim>
11373 std::vector<bool> v;
11374 save_user_flags_quad(v);
11383template <
int dim,
int spacedim>
11387 std::vector<bool> v;
11392 load_user_flags_quad(v);
11397template <
int dim,
int spacedim>
11401 Assert(v.size() == n_quads(), ExcGridReadError());
11405 quad_iterator quad = begin_quad(), endq = end_quad();
11406 std::vector<bool>::const_iterator i = v.begin();
11407 for (; quad != endq; ++quad, ++i)
11409 set_user_flag(quad);
11411 clear_user_flag(quad);
11419template <
int dim,
int spacedim>
11423 v.resize(n_hexs(),
false);
11427 std::vector<bool>::iterator i = v.begin();
11428 hex_iterator hex = begin_hex(), endh = end_hex();
11429 for (; hex != endh; ++hex, ++i)
11430 *i = get_user_flag(hex);
11438template <
int dim,
int spacedim>
11442 std::vector<bool> v;
11443 save_user_flags_hex(v);
11452template <
int dim,
int spacedim>
11456 std::vector<bool> v;
11461 load_user_flags_hex(v);
11466template <
int dim,
int spacedim>
11470 Assert(v.size() == n_hexs(), ExcGridReadError());
11474 hex_iterator hex = begin_hex(), endh = end_hex();
11475 std::vector<bool>::const_iterator i = v.begin();
11476 for (; hex != endh; ++hex, ++i)
11478 set_user_flag(hex);
11480 clear_user_flag(hex);
11488template <
int dim,
int spacedim>
11491 std::vector<unsigned int> &v)
const
11497 std::vector<unsigned int> tmp;
11499 save_user_indices_line(tmp);
11500 v.insert(v.end(), tmp.begin(), tmp.end());
11504 save_user_indices_quad(tmp);
11505 v.insert(v.end(), tmp.begin(), tmp.end());
11510 save_user_indices_hex(tmp);
11511 v.insert(v.end(), tmp.begin(), tmp.end());
11520template <
int dim,
int spacedim>
11523 const std::vector<unsigned int> &v)
11526 std::vector<unsigned int> tmp;
11530 tmp.insert(tmp.end(), v.begin(), v.begin() + n_lines());
11532 load_user_indices_line(tmp);
11537 tmp.insert(tmp.end(),
11538 v.begin() + n_lines(),
11539 v.begin() + n_lines() + n_quads());
11540 load_user_indices_quad(tmp);
11546 tmp.insert(tmp.end(),
11547 v.begin() + n_lines() + n_quads(),
11548 v.begin() + n_lines() + n_quads() + n_hexs());
11549 load_user_indices_hex(tmp);
11560 template <
typename Iterator>
11562 get_user_index(
const Iterator &i)
11564 return i->user_index();
11569 template <
int structdim,
int dim,
int spacedim>
11580 template <
typename Iterator>
11582 set_user_index(
const Iterator &i,
const unsigned int x)
11584 i->set_user_index(x);
11589 template <
int structdim,
int dim,
int spacedim>
11593 const unsigned int)
11600template <
int dim,
int spacedim>
11603 std::vector<unsigned int> &v)
const
11605 v.resize(n_lines(), 0);
11606 std::vector<unsigned int>::iterator i = v.begin();
11607 line_iterator line = begin_line(), endl = end_line();
11608 for (; line != endl; ++line, ++i)
11609 *i = line->user_index();
11614template <
int dim,
int spacedim>
11617 const std::vector<unsigned int> &v)
11619 Assert(v.size() == n_lines(), ExcGridReadError());
11621 line_iterator line = begin_line(), endl = end_line();
11622 std::vector<unsigned int>::const_iterator i = v.begin();
11623 for (; line != endl; ++line, ++i)
11624 line->set_user_index(*i);
11628template <
int dim,
int spacedim>
11631 std::vector<unsigned int> &v)
const
11633 v.resize(n_quads(), 0);
11637 std::vector<unsigned int>::iterator i = v.begin();
11638 quad_iterator quad = begin_quad(), endq = end_quad();
11639 for (; quad != endq; ++quad, ++i)
11640 *i = get_user_index(quad);
11646template <
int dim,
int spacedim>
11649 const std::vector<unsigned int> &v)
11651 Assert(v.size() == n_quads(), ExcGridReadError());
11655 quad_iterator quad = begin_quad(), endq = end_quad();
11656 std::vector<unsigned int>::const_iterator i = v.begin();
11657 for (; quad != endq; ++quad, ++i)
11658 set_user_index(quad, *i);
11663template <
int dim,
int spacedim>
11666 std::vector<unsigned int> &v)
const
11668 v.resize(n_hexs(), 0);
11672 std::vector<unsigned int>::iterator i = v.begin();
11673 hex_iterator hex = begin_hex(), endh = end_hex();
11674 for (; hex != endh; ++hex, ++i)
11675 *i = get_user_index(hex);
11681template <
int dim,
int spacedim>
11684 const std::vector<unsigned int> &v)
11686 Assert(v.size() == n_hexs(), ExcGridReadError());
11690 hex_iterator hex = begin_hex(), endh = end_hex();
11691 std::vector<unsigned int>::const_iterator i = v.begin();
11692 for (; hex != endh; ++hex, ++i)
11693 set_user_index(hex, *i);
11704 template <
typename Iterator>
11706 get_user_pointer(
const Iterator &i)
11708 return i->user_pointer();
11713 template <
int structdim,
int dim,
int spacedim>
11724 template <
typename Iterator>
11726 set_user_pointer(
const Iterator &i,
void *x)
11728 i->set_user_pointer(x);
11733 template <
int structdim,
int dim,
int spacedim>
11744template <
int dim,
int spacedim>
11752 std::vector<void *> tmp;
11754 save_user_pointers_line(tmp);
11755 v.insert(v.end(), tmp.begin(), tmp.end());
11759 save_user_pointers_quad(tmp);
11760 v.insert(v.end(), tmp.begin(), tmp.end());
11765 save_user_pointers_hex(tmp);
11766 v.insert(v.end(), tmp.begin(), tmp.end());
11775template <
int dim,
int spacedim>
11780 std::vector<void *> tmp;
11784 tmp.insert(tmp.end(), v.begin(), v.begin() + n_lines());
11786 load_user_pointers_line(tmp);
11791 tmp.insert(tmp.end(),
11792 v.begin() + n_lines(),
11793 v.begin() + n_lines() + n_quads());
11794 load_user_pointers_quad(tmp);
11800 tmp.insert(tmp.end(),
11801 v.begin() + n_lines() + n_quads(),
11802 v.begin() + n_lines() + n_quads() + n_hexs());
11803 load_user_pointers_hex(tmp);
11812template <
int dim,
int spacedim>
11815 std::vector<void *> &v)
const
11817 v.resize(n_lines(),
nullptr);
11818 std::vector<void *>::iterator i = v.begin();
11819 line_iterator line = begin_line(), endl = end_line();
11820 for (; line != endl; ++line, ++i)
11821 *i = line->user_pointer();
11826template <
int dim,
int spacedim>
11829 const std::vector<void *> &v)
11831 Assert(v.size() == n_lines(), ExcGridReadError());
11833 line_iterator line = begin_line(), endl = end_line();
11834 std::vector<void *>::const_iterator i = v.begin();
11835 for (; line != endl; ++line, ++i)
11836 line->set_user_pointer(*i);
11841template <
int dim,
int spacedim>
11844 std::vector<void *> &v)
const
11846 v.resize(n_quads(),
nullptr);
11850 std::vector<void *>::iterator i = v.begin();
11851 quad_iterator quad = begin_quad(), endq = end_quad();
11852 for (; quad != endq; ++quad, ++i)
11853 *i = get_user_pointer(quad);
11859template <
int dim,
int spacedim>
11862 const std::vector<void *> &v)
11864 Assert(v.size() == n_quads(), ExcGridReadError());
11868 quad_iterator quad = begin_quad(), endq = end_quad();
11869 std::vector<void *>::const_iterator i = v.begin();
11870 for (; quad != endq; ++quad, ++i)
11871 set_user_pointer(quad, *i);
11876template <
int dim,
int spacedim>
11879 std::vector<void *> &v)
const
11881 v.resize(n_hexs(),
nullptr);
11885 std::vector<void *>::iterator i = v.begin();
11886 hex_iterator hex = begin_hex(), endh = end_hex();
11887 for (; hex != endh; ++hex, ++i)
11888 *i = get_user_pointer(hex);
11894template <
int dim,
int spacedim>
11897 const std::vector<void *> &v)
11899 Assert(v.size() == n_hexs(), ExcGridReadError());
11903 hex_iterator hex = begin_hex(), endh = end_hex();
11904 std::vector<void *>::const_iterator i = v.begin();
11905 for (; hex != endh; ++hex, ++i)
11906 set_user_pointer(hex, *i);
11915template <
int dim,
int spacedim>
11922 return begin_raw_line(
level);
11924 return begin_raw_quad(
level);
11926 return begin_raw_hex(
level);
11929 return raw_cell_iterator();
11935template <
int dim,
int spacedim>
11942 return begin_line(
level);
11944 return begin_quad(
level);
11946 return begin_hex(
level);
11949 return cell_iterator();
11955template <
int dim,
int spacedim>
11962 return begin_active_line(
level);
11964 return begin_active_quad(
level);
11966 return begin_active_hex(
level);
11969 return active_cell_iterator();
11975template <
int dim,
int spacedim>
11979 const unsigned int level = levels.size() - 1;
11980 if (levels[
level]->cells.n_objects() == 0)
11987 levels[
level]->cells.n_objects() - 1);
11990 if (ri->used() ==
true)
11993 if (ri->used() ==
true)
12000template <
int dim,
int spacedim>
12005 cell_iterator cell = last();
12010 if (cell->is_active() ==
true)
12013 if (cell->is_active() ==
true)
12021template <
int dim,
int spacedim>
12025 cell_iterator cell(
12031 cell->has_children(),
12033 "CellId is invalid for this triangulation.\n"
12034 "Either the provided CellId does not correspond to a cell in this "
12035 "triangulation object, or, in case you are using a parallel "
12036 "triangulation, may correspond to an artificial cell that is less "
12037 "refined on this processor."));
12038 cell = cell->child(
static_cast<unsigned int>(child_index));
12046template <
int dim,
int spacedim>
12057template <
int dim,
int spacedim>
12069 if (
level >= levels.size())
12072 ExcInvalidLevel(
level, n_global_levels()));
12079 if (
level < levels.size() - 1)
12080 return begin_raw(
level + 1);
12086template <
int dim,
int spacedim>
12098 if (
level >= levels.size())
12101 ExcInvalidLevel(
level, n_global_levels()));
12108 if (
level < levels.size() - 1)
12115template <
int dim,
int spacedim>
12127 if (
level >= levels.size())
12130 ExcInvalidLevel(
level, n_global_levels()));
12137 return (
level >= levels.size() - 1 ? active_cell_iterator(
end()) :
12138 begin_active(
level + 1));
12143template <
int dim,
int spacedim>
12152template <
int dim,
int spacedim>
12163template <
int dim,
int spacedim>
12166 const unsigned int level)
const
12174template <
int dim,
int spacedim>
12177 const unsigned int level)
const
12188template <
int dim,
int spacedim>
12196 return raw_face_iterator();
12198 return begin_line();
12200 return begin_quad();
12203 return face_iterator();
12209template <
int dim,
int spacedim>
12217 return raw_face_iterator();
12219 return begin_active_line();
12221 return begin_active_quad();
12224 return active_face_iterator();
12230template <
int dim,
int spacedim>
12238 return raw_face_iterator();
12245 return raw_face_iterator();
12251template <
int dim,
int spacedim>
12257 begin_active_face(), end_face());
12263template <
int dim,
int spacedim>
12267 vertex_iterator i =
12272 while (i->used() ==
false)
12280template <
int dim,
int spacedim>
12285 return begin_vertex();
12290template <
int dim,
int spacedim>
12305template <
int dim,
int spacedim>
12317 if (
level >= levels.size())
12320 ExcInvalidLevel(
level, n_global_levels()));
12331 if (
level >= levels.size() || levels[
level]->cells.n_objects() == 0)
12334 return raw_line_iterator(
12339 return raw_line_iterator(
12345template <
int dim,
int spacedim>
12350 raw_line_iterator ri = begin_raw_line(
level);
12353 while (ri->used() ==
false)
12361template <
int dim,
int spacedim>
12366 line_iterator i = begin_line(
level);
12369 while (i->has_children())
12377template <
int dim,
int spacedim>
12391template <
int dim,
int spacedim>
12403 if (
level >= levels.size())
12406 ExcInvalidLevel(
level, n_global_levels()));
12414 return raw_hex_iterator();
12421 if (
level >= levels.size() || levels[
level]->cells.n_objects() == 0)
12424 return raw_quad_iterator(
12432 return raw_quad_iterator(
12439 return raw_hex_iterator();
12445template <
int dim,
int spacedim>
12450 raw_quad_iterator ri = begin_raw_quad(
level);
12453 while (ri->used() ==
false)
12461template <
int dim,
int spacedim>
12466 quad_iterator i = begin_quad(
level);
12469 while (i->has_children())
12477template <
int dim,
int spacedim>
12490template <
int dim,
int spacedim>
12502 if (
level >= levels.size())
12505 ExcInvalidLevel(
level, n_global_levels()));
12514 return raw_hex_iterator();
12521 if (
level >= levels.size() || levels[
level]->cells.n_objects() == 0)
12524 return raw_hex_iterator(
12530 return raw_hex_iterator();
12536template <
int dim,
int spacedim>
12541 raw_hex_iterator ri = begin_raw_hex(
level);
12544 while (ri->used() ==
false)
12552template <
int dim,
int spacedim>
12557 hex_iterator i = begin_hex(
level);
12560 while (i->has_children())
12568template <
int dim,
int spacedim>
12584 namespace TriangulationImplementation
12586 inline unsigned int
12593 inline unsigned int
12601 inline unsigned int
12608 inline unsigned int
12616 inline unsigned int
12623 inline unsigned int
12634template <
int dim,
int spacedim>
12642template <
int dim,
int spacedim>
12649template <
int dim,
int spacedim>
12658template <
int dim,
int spacedim>
12665 return n_used_vertices();
12677template <
int dim,
int spacedim>
12684 return n_vertices();
12686 return n_raw_lines();
12688 return n_raw_quads();
12696template <
int dim,
int spacedim>
12703 return n_used_vertices();
12705 return n_active_lines();
12707 return n_active_quads();
12715template <
int dim,
int spacedim>
12722 return n_raw_lines(
level);
12724 return n_raw_quads(
level);
12726 return n_raw_hexs(
level);
12735template <
int dim,
int spacedim>
12742 return n_lines(
level);
12744 return n_quads(
level);
12746 return n_hexs(
level);
12755template <
int dim,
int spacedim>
12762 return n_active_lines(
level);
12764 return n_active_quads(
level);
12766 return n_active_hexs(
level);
12774template <
int dim,
int spacedim>
12778 for (
unsigned int lvl = 0; lvl < n_global_levels() - 1; lvl++)
12786template <
int dim,
int spacedim>
12790 return number_cache.n_lines;
12795template <
int dim,
int spacedim>
12802 return levels[
level]->cells.n_objects();
12810template <
int dim,
int spacedim>
12824template <
int dim,
int spacedim>
12830 return number_cache.n_lines_level[
level];
12834template <
int dim,
int spacedim>
12838 return number_cache.n_active_lines;
12842template <
int dim,
int spacedim>
12849 return number_cache.n_active_lines_level[
level];
12999template <
int dim,
int spacedim>
13003 return number_cache.n_quads;
13007template <
int dim,
int spacedim>
13013 return number_cache.n_quads_level[
level];
13023 return levels[
level]->cells.n_objects();
13033 return levels[
level]->cells.n_objects();
13047template <
int dim,
int spacedim>
13066template <
int dim,
int spacedim>
13070 return number_cache.n_active_quads;
13074template <
int dim,
int spacedim>
13081 return number_cache.n_active_quads_level[
level];
13085template <
int dim,
int spacedim>
13094template <
int dim,
int spacedim>
13103template <
int dim,
int spacedim>
13111template <
int dim,
int spacedim>
13120template <
int dim,
int spacedim>
13132 return number_cache.n_hexes;
13143 return number_cache.n_hexes_level[
level];
13153 return levels[
level]->cells.n_objects();
13161 return number_cache.n_active_hexes;
13172 return number_cache.n_active_hexes_level[
level];
13177template <
int dim,
int spacedim>
13181 return std::count(vertices_used.begin(), vertices_used.end(),
true);
13186template <
int dim,
int spacedim>
13187const std::vector<bool> &
13190 return vertices_used;
13220template <
int dim,
int spacedim>
13224 cell_iterator cell =
begin(0),
13225 endc = (n_levels() > 1 ?
begin(1) : cell_iterator(
end()));
13228 unsigned int max_vertex_index = 0;
13229 for (; cell != endc; ++cell)
13231 if (cell->vertex_index(vertex) > max_vertex_index)
13232 max_vertex_index = cell->vertex_index(vertex);
13238 std::vector<unsigned short int> usage_count(max_vertex_index + 1, 0);
13242 for (cell =
begin(); cell != endc; ++cell)
13244 ++usage_count[cell->vertex_index(vertex)];
13247 static_cast<unsigned int>(
13248 *std::max_element(usage_count.begin(), usage_count.end())));
13253template <
int dim,
int spacedim>
13262template <
int dim,
int spacedim>
13271template <
int dim,
int spacedim>
13280template <
int dim,
int spacedim>
13284 &periodicity_vector)
13286 periodic_face_pairs_level_0.insert(periodic_face_pairs_level_0.end(),
13287 periodicity_vector.begin(),
13288 periodicity_vector.end());
13291 update_periodic_face_map();
13296template <
int dim,
int spacedim>
13297const typename std::map<
13298 std::pair<typename Triangulation<dim, spacedim>::cell_iterator,
unsigned int>,
13299 std::pair<std::pair<typename Triangulation<dim, spacedim>::cell_iterator,
13304 return periodic_face_map;
13309template <
int dim,
int spacedim>
13323 if (smooth_grid & limit_level_difference_at_vertices)
13327 signals.pre_refinement();
13329 execute_coarsening();
13331 const DistortedCellList cells_with_distorted_children = execute_refinement();
13333 reset_cell_vertex_indices_cache();
13338 if (smooth_grid & limit_level_difference_at_vertices)
13343 this->policy->update_neighbors(*
this);
13344 reset_active_cell_indices();
13346 reset_global_cell_indices();
13349 signals.post_refinement();
13351 AssertThrow(cells_with_distorted_children.distorted_cells.size() == 0,
13352 cells_with_distorted_children);
13354 update_periodic_face_map();
13359template <
int dim,
int spacedim>
13363 unsigned int active_cell_index = 0;
13364 for (raw_cell_iterator cell = begin_raw(); cell !=
end(); ++cell)
13365 if ((cell->used() ==
false) || cell->has_children())
13369 cell->set_active_cell_index(active_cell_index);
13370 ++active_cell_index;
13378template <
int dim,
int spacedim>
13384 for (
const auto &cell : active_cell_iterators())
13385 cell->set_global_active_cell_index(
cell_index++);
13388 for (
unsigned int l = 0;
l < levels.size(); ++
l)
13391 for (
const auto &cell : cell_iterators_on_level(
l))
13392 cell->set_global_level_cell_index(
cell_index++);
13398template <
int dim,
int spacedim>
13402 for (
unsigned int l = 0;
l < levels.size(); ++
l)
13404 constexpr unsigned int max_vertices_per_cell = 1 << dim;
13405 std::vector<unsigned int> &cache = levels[
l]->cell_vertex_indices_cache;
13407 cache.resize(levels[
l]->refine_flags.size() * max_vertices_per_cell,
13409 for (
const auto &cell : cell_iterators_on_level(
l))
13411 const unsigned int my_index = cell->index() * max_vertices_per_cell;
13412 for (
const unsigned int i : cell->vertex_indices())
13413 cache[my_index + i] = internal::TriaAccessorImplementation::
13414 Implementation::vertex_index(*cell, i);
13421template <
int dim,
int spacedim>
13426 periodic_face_map.clear();
13428 typename std::vector<
13430 for (it = periodic_face_pairs_level_0.begin();
13431 it != periodic_face_pairs_level_0.end();
13434 update_periodic_face_map_recursively<dim, spacedim>(it->cell[0],
13439 periodic_face_map);
13442 std::bitset<3> inverted_orientation;
13444 bool orientation, flip, rotation;
13445 orientation = it->orientation[0];
13446 rotation = it->orientation[2];
13447 flip = orientation ? rotation ^ it->orientation[1] : it->orientation[1];
13448 inverted_orientation[0] = orientation;
13449 inverted_orientation[1] = flip;
13450 inverted_orientation[2] = rotation;
13452 update_periodic_face_map_recursively<dim, spacedim>(it->cell[1],
13456 inverted_orientation,
13457 periodic_face_map);
13461 typename std::map<std::pair<cell_iterator, unsigned int>,
13462 std::pair<std::pair<cell_iterator, unsigned int>,
13463 std::bitset<3>>>::const_iterator it_test;
13464 for (it_test = periodic_face_map.begin(); it_test != periodic_face_map.end();
13468 it_test->first.first;
13470 it_test->second.first.first;
13471 if (cell_1->level() == cell_2->level())
13475 Assert(periodic_face_map[it_test->second.first].first ==
13484template <
int dim,
int spacedim>
13488 std::set<ReferenceCell> reference_cells_set;
13489 for (
auto cell : active_cell_iterators())
13490 if (cell->is_locally_owned())
13491 reference_cells_set.insert(cell->reference_cell());
13493 std::vector<ReferenceCell> reference_cells(reference_cells_set.begin(),
13494 reference_cells_set.end());
13496 this->reference_cells = reference_cells;
13501template <
int dim,
int spacedim>
13502const std::vector<ReferenceCell> &
13505 return this->reference_cells;
13510template <
int dim,
int spacedim>
13514 Assert(this->reference_cells.size() > 0,
13515 ExcMessage(
"You can't ask about the kinds of reference "
13516 "cells used by this triangulation if the "
13517 "triangulation doesn't yet have any cells in it."));
13518 return (this->reference_cells.size() == 1 &&
13519 this->reference_cells[0] == ReferenceCells::get_hypercube<dim>());
13524template <
int dim,
int spacedim>
13532 vertices_used.clear();
13541template <
int dim,
int spacedim>
13545 const DistortedCellList cells_with_distorted_children =
13546 this->policy->execute_refinement(*
this, check_for_distorted_cells);
13552 *
this, levels.size(), number_cache);
13555 for (
const auto &
level : levels)
13562 for (
const auto &cell : this->cell_iterators())
13566 return cells_with_distorted_children;
13571template <
int dim,
int spacedim>
13579 std::vector<unsigned int> line_cell_count =
13580 count_cells_bounded_by_line(*
this);
13581 std::vector<unsigned int> quad_cell_count =
13582 count_cells_bounded_by_quad(*
this);
13594 clear_user_flags();
13596 for (
const auto &cell : this->cell_iterators())
13597 if (!cell->is_active())
13598 if (cell->child(0)->coarsen_flag_set())
13600 cell->set_user_flag();
13601 for (
unsigned int child = 0; child < cell->n_children(); ++child)
13603 Assert(cell->child(child)->coarsen_flag_set(),
13605 cell->child(child)->clear_coarsen_flag();
13620 cell_iterator cell =
begin(), endc =
end();
13621 if (levels.size() >= 2)
13622 for (cell = last(); cell != endc; --cell)
13623 if (cell->level() <=
static_cast<int>(levels.size() - 2) &&
13624 cell->user_flag_set())
13627 signals.pre_coarsening_on_cell(cell);
13629 this->policy->delete_children(*
this,
13637 *
this, levels.size(), number_cache);
13641 for (cell =
begin(); cell != endc; ++cell)
13648template <
int dim,
int spacedim>
13666 save_coarsen_flags(previous_coarsen_flags);
13668 std::vector<int> vertex_level(
vertices.size(), 0);
13670 bool continue_iterating =
true;
13674 if (smooth_grid & limit_level_difference_at_vertices)
13676 Assert(!anisotropic_refinement,
13677 ExcMessage(
"In case of anisotropic refinement the "
13678 "limit_level_difference_at_vertices flag for "
13679 "mesh smoothing must not be set!"));
13683 std::fill(vertex_level.begin(), vertex_level.end(), 0);
13684 for (
const auto &cell : this->active_cell_iterators())
13686 if (cell->refine_flag_set())
13687 for (
const unsigned int vertex :
13689 vertex_level[cell->vertex_index(vertex)] =
13690 std::max(vertex_level[cell->vertex_index(vertex)],
13691 cell->level() + 1);
13692 else if (!cell->coarsen_flag_set())
13693 for (
const unsigned int vertex :
13695 vertex_level[cell->vertex_index(vertex)] =
13696 std::max(vertex_level[cell->vertex_index(vertex)],
13707 for (
const unsigned int vertex :
13709 vertex_level[cell->vertex_index(vertex)] =
13710 std::max(vertex_level[cell->vertex_index(vertex)],
13711 cell->level() - 1);
13725 active_cell_iterator cell = begin_active(), endc =
end();
13726 for (cell = last_active(); cell != endc; --cell)
13727 if (cell->refine_flag_set() ==
false)
13729 for (
const unsigned int vertex :
13731 if (vertex_level[cell->vertex_index(vertex)] >=
13735 cell->clear_coarsen_flag();
13740 if (vertex_level[cell->vertex_index(vertex)] >
13743 cell->set_refine_flag();
13745 for (
const unsigned int v :
13747 vertex_level[cell->vertex_index(v)] =
13748 std::max(vertex_level[cell->vertex_index(v)],
13749 cell->level() + 1);
13771 clear_user_flags();
13774 for (
const auto &acell : this->active_cell_iterators_on_level(0))
13775 acell->clear_coarsen_flag();
13777 for (
const auto &cell : this->cell_iterators())
13780 if (cell->is_active())
13783 const unsigned int n_children = cell->n_children();
13784 unsigned int flagged_children = 0;
13785 for (
unsigned int child = 0; child < n_children; ++child)
13786 if (cell->child(child)->is_active() &&
13787 cell->child(child)->coarsen_flag_set())
13789 ++flagged_children;
13791 cell->child(child)->clear_coarsen_flag();
13796 if (flagged_children == n_children)
13797 cell->set_user_flag();
13803 for (
auto &cell : this->cell_iterators())
13824 cell_iterator cell =
begin(), endc =
end();
13825 for (cell = last(); cell != endc; --cell)
13826 if (cell->user_flag_set())
13829 if (this->policy->coarsening_allowed(cell))
13830 for (
unsigned int c = 0; c < cell->n_children(); ++c)
13832 Assert(cell->child(c)->refine_flag_set() ==
false,
13835 cell->child(c)->set_coarsen_flag();
13840 clear_user_flags();
13846 save_coarsen_flags(current_coarsen_flags);
13848 continue_iterating = (current_coarsen_flags != previous_coarsen_flags);
13849 previous_coarsen_flags = current_coarsen_flags;
13851 while (continue_iterating ==
true);
13862 std::vector<bool> flags_before;
13863 save_coarsen_flags(flags_before);
13866 fix_coarsen_flags();
13868 std::vector<bool> flags_after;
13869 save_coarsen_flags(flags_after);
13871 return (flags_before != flags_after);
13881 std::vector<bool> flags_before;
13882 save_coarsen_flags(flags_before);
13885 fix_coarsen_flags();
13887 std::vector<bool> flags_after;
13888 save_coarsen_flags(flags_after);
13890 return (flags_before != flags_after);
13900 std::vector<bool> flags_before;
13901 save_coarsen_flags(flags_before);
13904 fix_coarsen_flags();
13906 std::vector<bool> flags_after;
13907 save_coarsen_flags(flags_after);
13909 return (flags_before != flags_after);
13920 template <
int dim,
int spacedim>
13922 possibly_do_not_produce_unrefined_islands(
13927 unsigned int n_neighbors = 0;
13930 unsigned int count = 0;
13938 if (face_will_be_refined_by_neighbor(cell, n))
13945 if (count == n_neighbors ||
13946 (count >= n_neighbors - 1 &&
13949 for (
unsigned int c = 0; c < cell->n_children(); ++c)
13950 cell->child(c)->clear_coarsen_flag();
13953 if (!cell->at_boundary(face) &&
13954 (!cell->neighbor(face)->is_active()) &&
13955 (cell_will_be_coarsened(cell->neighbor(face))))
13956 possibly_do_not_produce_unrefined_islands<dim, spacedim>(
13957 cell->neighbor(face));
13972 template <
int dim,
int spacedim>
13974 possibly_refine_unrefined_island(
13976 const bool allow_anisotropic_smoothing)
13991 if (allow_anisotropic_smoothing ==
false)
13994 unsigned int refined_neighbors = 0, unrefined_neighbors = 0;
13996 if (!cell->at_boundary(face))
13998 if (face_will_be_refined_by_neighbor(cell, face))
13999 ++refined_neighbors;
14001 ++unrefined_neighbors;
14004 if (unrefined_neighbors < refined_neighbors)
14006 cell->clear_coarsen_flag();
14007 cell->set_refine_flag();
14012 if (unrefined_neighbors > 0)
14014 if (!cell->at_boundary(face) &&
14015 (face_will_be_refined_by_neighbor(cell, face) ==
false) &&
14016 (cell->neighbor(face)->has_children() ==
false) &&
14017 (cell->neighbor(face)->refine_flag_set() ==
false))
14018 possibly_refine_unrefined_island<dim, spacedim>(
14019 cell->neighbor(face), allow_anisotropic_smoothing);
14031 for (
unsigned int face_pair = 0;
14032 face_pair < GeometryInfo<dim>::faces_per_cell / 2;
14041 for (
unsigned int face_index = 0; face_index < 2; ++face_index)
14043 unsigned int face = 2 * face_pair + face_index;
14050 face_will_be_refined_by_neighbor<dim, spacedim>(
14051 cell, face, expected_face_ref_case);
14065 directional_cell_refinement_case =
14066 (directional_cell_refinement_case &
14069 expected_face_ref_case,
14071 cell->face_orientation(face),
14072 cell->face_flip(face),
14073 cell->face_rotation(face)));
14079 Assert(directional_cell_refinement_case <
14082 smoothing_cell_refinement_case =
14083 smoothing_cell_refinement_case | directional_cell_refinement_case;
14088 if (smoothing_cell_refinement_case)
14090 cell->clear_coarsen_flag();
14091 cell->set_refine_flag(cell->refine_flag_set() |
14092 smoothing_cell_refinement_case);
14099template <
int dim,
int spacedim>
14105 std::vector<bool> flags_before[2];
14106 save_coarsen_flags(flags_before[0]);
14107 save_refine_flags(flags_before[1]);
14125 std::vector<bool> flags_before_loop[2] = {flags_before[0], flags_before[1]};
14202 if (((smooth_grid & coarsest_level_1) || (smooth_grid & patch_level_1)) &&
14205 for (
const auto &cell : active_cell_iterators_on_level(1))
14206 cell->clear_coarsen_flag();
14209 bool mesh_changed_in_this_loop =
false;
14218 if (smooth_grid & do_not_produce_unrefined_islands &&
14219 !(smooth_grid & patch_level_1))
14221 for (
const auto &cell : cell_iterators())
14225 if (!cell->is_active() && cell_will_be_coarsened(cell))
14226 possibly_do_not_produce_unrefined_islands<dim, spacedim>(cell);
14250 if (smooth_grid & (eliminate_refined_inner_islands |
14251 eliminate_refined_boundary_islands) &&
14252 !(smooth_grid & patch_level_1))
14254 for (
const auto &cell : cell_iterators())
14255 if (!cell->is_active() ||
14256 (cell->is_active() && cell->refine_flag_set() &&
14257 cell->is_locally_owned()))
14264 bool all_children_active =
true;
14265 if (!cell->is_active())
14266 for (
unsigned int c = 0; c < cell->n_children(); ++c)
14267 if (!cell->child(c)->is_active() ||
14268 cell->child(c)->is_ghost() ||
14269 cell->child(c)->is_artificial())
14271 all_children_active =
false;
14275 if (all_children_active)
14282 unsigned int unrefined_neighbors = 0, total_neighbors = 0;
14293 bool at_periodic_boundary =
false;
14295 for (
const unsigned int n :
14298 const cell_iterator neighbor = cell->neighbor(n);
14303 if (!face_will_be_refined_by_neighbor(cell, n))
14304 ++unrefined_neighbors;
14306 else if (cell->has_periodic_neighbor(n))
14309 at_periodic_boundary =
true;
14324 if ((unrefined_neighbors == total_neighbors) &&
14325 ((!cell->at_boundary() &&
14326 (smooth_grid & eliminate_refined_inner_islands)) ||
14327 (cell->at_boundary() && !at_periodic_boundary &&
14329 eliminate_refined_boundary_islands))) &&
14330 (total_neighbors != 0))
14332 if (!cell->is_active())
14333 for (
unsigned int c = 0; c < cell->n_children(); ++c)
14335 cell->child(c)->clear_refine_flag();
14336 cell->child(c)->set_coarsen_flag();
14339 cell->clear_refine_flag();
14354 if (smooth_grid & limit_level_difference_at_vertices)
14356 Assert(!anisotropic_refinement,
14357 ExcMessage(
"In case of anisotropic refinement the "
14358 "limit_level_difference_at_vertices flag for "
14359 "mesh smoothing must not be set!"));
14363 std::vector<int> vertex_level(
vertices.size(), 0);
14364 for (
const auto &cell : active_cell_iterators())
14366 if (cell->refine_flag_set())
14367 for (
const unsigned int vertex :
14369 vertex_level[cell->vertex_index(vertex)] =
14370 std::max(vertex_level[cell->vertex_index(vertex)],
14371 cell->level() + 1);
14372 else if (!cell->coarsen_flag_set())
14373 for (
const unsigned int vertex :
14375 vertex_level[cell->vertex_index(vertex)] =
14376 std::max(vertex_level[cell->vertex_index(vertex)],
14385 for (
const unsigned int vertex :
14387 vertex_level[cell->vertex_index(vertex)] =
14388 std::max(vertex_level[cell->vertex_index(vertex)],
14389 cell->level() - 1);
14403 for (active_cell_iterator cell = last_active(); cell !=
end(); --cell)
14404 if (cell->refine_flag_set() ==
false)
14406 for (
const unsigned int vertex :
14408 if (vertex_level[cell->vertex_index(vertex)] >=
14412 cell->clear_coarsen_flag();
14417 if (vertex_level[cell->vertex_index(vertex)] >
14420 cell->set_refine_flag();
14422 for (
const unsigned int v :
14424 vertex_level[cell->vertex_index(v)] =
14425 std::max(vertex_level[cell->vertex_index(v)],
14426 cell->level() + 1);
14447 if (smooth_grid & eliminate_unrefined_islands)
14449 for (active_cell_iterator cell = last_active(); cell !=
end(); --cell)
14452 if (cell->refine_flag_set() !=
14454 possibly_refine_unrefined_island<dim, spacedim>(
14455 cell, (smooth_grid & allow_anisotropic_smoothing) != 0);
14483 if (smooth_grid & patch_level_1)
14493 for (
const auto &cell : cell_iterators())
14494 if (!cell->is_active())
14500 if (cell->child(0)->has_children() ==
true)
14507 for (
unsigned int i = 0; i < cell->n_children(); ++i)
14508 combined_ref_case =
14509 combined_ref_case | cell->child(i)->refine_flag_set();
14511 for (
unsigned int i = 0; i < cell->n_children(); ++i)
14513 cell_iterator child = cell->child(i);
14515 child->clear_coarsen_flag();
14516 child->set_refine_flag(combined_ref_case);
14529 for (
const auto &cell : cell_iterators())
14535 if (cell->is_active() || cell->child(0)->is_active())
14542 const unsigned int n_children = cell->n_children();
14543 bool has_active_grandchildren =
false;
14545 for (
unsigned int i = 0; i < n_children; ++i)
14546 if (cell->child(i)->child(0)->is_active())
14548 has_active_grandchildren =
true;
14552 if (has_active_grandchildren ==
false)
14558 unsigned int n_grandchildren = 0;
14561 unsigned int n_coarsen_flags = 0;
14566 for (
unsigned int c = 0; c < n_children; ++c)
14571 cell_iterator child = cell->child(c);
14573 const unsigned int nn_children = child->n_children();
14574 n_grandchildren += nn_children;
14579 if (child->child(0)->is_active())
14580 for (
unsigned int cc = 0; cc < nn_children; ++cc)
14581 if (child->child(cc)->coarsen_flag_set())
14596 if ((n_coarsen_flags != n_grandchildren) && (n_coarsen_flags > 0))
14597 for (
unsigned int c = 0; c < n_children; ++c)
14599 const cell_iterator child = cell->child(c);
14600 if (child->child(0)->is_active())
14601 for (
unsigned int cc = 0; cc < child->n_children(); ++cc)
14602 child->child(cc)->clear_coarsen_flag();
14613 this->policy->prevent_distorted_boundary_cells(*
this);
14629 bool changed =
true;
14633 active_cell_iterator cell = last_active(), endc =
end();
14635 for (; cell != endc; --cell)
14636 if (cell->refine_flag_set())
14639 for (
const auto i : cell->face_indices())
14644 const bool has_periodic_neighbor =
14645 cell->has_periodic_neighbor(i);
14646 const bool has_neighbor_or_periodic_neighbor =
14647 !cell->at_boundary(i) || has_periodic_neighbor;
14648 if (has_neighbor_or_periodic_neighbor &&
14650 cell->refine_flag_set(), i) !=
14663 if (cell->neighbor_or_periodic_neighbor(i)->is_active())
14665 if ((!has_periodic_neighbor &&
14666 cell->neighbor_is_coarser(i)) ||
14667 (has_periodic_neighbor &&
14668 cell->periodic_neighbor_is_coarser(i)))
14670 if (cell->neighbor_or_periodic_neighbor(i)
14671 ->coarsen_flag_set())
14672 cell->neighbor_or_periodic_neighbor(i)
14673 ->clear_coarsen_flag();
14690 allow_anisotropic_smoothing)
14692 has_periodic_neighbor ?
14693 cell->periodic_neighbor(i)
14694 ->flag_for_face_refinement(
14696 ->periodic_neighbor_of_coarser_periodic_neighbor(
14701 ->flag_for_face_refinement(
14703 ->neighbor_of_coarser_neighbor(
14710 ->neighbor_or_periodic_neighbor(
14712 ->refine_flag_set())
14714 cell->neighbor_or_periodic_neighbor(i)
14715 ->set_refine_flag();
14847 std::pair<unsigned int, unsigned int>
14849 has_periodic_neighbor ?
14851 ->periodic_neighbor_of_coarser_periodic_neighbor(
14853 cell->neighbor_of_coarser_neighbor(i);
14854 unsigned int refined_along_x = 0,
14855 refined_along_y = 0,
14856 to_be_refined_along_x = 0,
14857 to_be_refined_along_y = 0;
14859 const int this_face_index =
14860 cell->face_index(i);
14869 const auto parent_face = [&]() {
14870 if (has_periodic_neighbor)
14872 const auto neighbor =
14873 cell->periodic_neighbor(i);
14874 const auto parent_face_no =
14876 ->periodic_neighbor_of_periodic_neighbor(
14879 neighbor->periodic_neighbor(
14881 return parent->face(parent_face_no);
14884 return cell->neighbor(i)->face(
14888 if ((this_face_index ==
14889 parent_face->child_index(0)) ||
14890 (this_face_index ==
14891 parent_face->child_index(1)))
14900 parent_face->refinement_case();
14918 cell->refine_flag_set(),
14920 cell->face_orientation(i),
14921 cell->face_flip(i),
14922 cell->face_rotation(i));
14925 ++to_be_refined_along_x;
14928 ++to_be_refined_along_y;
14933 allow_anisotropic_smoothing) ||
14934 cell->neighbor_or_periodic_neighbor(i)
14935 ->refine_flag_set())
14937 if (refined_along_x +
14938 to_be_refined_along_x >
14942 ->neighbor_or_periodic_neighbor(i)
14943 ->flag_for_face_refinement(
14947 if (refined_along_y +
14948 to_be_refined_along_y >
14952 ->neighbor_or_periodic_neighbor(i)
14953 ->flag_for_face_refinement(
14961 ->neighbor_or_periodic_neighbor(i)
14962 ->refine_flag_set() !=
14964 dim>::isotropic_refinement)
14966 cell->neighbor_or_periodic_neighbor(i)
14967 ->set_refine_flag();
14973 cell->neighbor_or_periodic_neighbor(i);
14976 nb->refine_flag_set(),
14978 nb->face_orientation(nb_indices.first),
14979 nb->face_flip(nb_indices.first),
14980 nb->face_rotation(nb_indices.first));
14982 !(refined_along_x ||
14983 to_be_refined_along_x))
14984 changed |= cell->flag_for_face_refinement(
14988 !(refined_along_y ||
14989 to_be_refined_along_y))
14990 changed |= cell->flag_for_face_refinement(
14997 cell->neighbor_or_periodic_neighbor(i)
14998 ->clear_coarsen_flag();
14999 const unsigned int nb_nb =
15000 has_periodic_neighbor ?
15002 ->periodic_neighbor_of_periodic_neighbor(
15004 cell->neighbor_of_neighbor(i);
15005 const cell_iterator neighbor =
15006 cell->neighbor_or_periodic_neighbor(i);
15009 neighbor->refine_flag_set(),
15011 neighbor->face_orientation(nb_nb),
15012 neighbor->face_flip(nb_nb),
15013 neighbor->face_rotation(nb_nb));
15016 cell->refine_flag_set(),
15018 cell->face_orientation(i),
15019 cell->face_flip(i),
15020 cell->face_rotation(i));
15025 if ((face_ref_case ==
15027 needed_face_ref_case ==
15031 needed_face_ref_case ==
15034 changed = cell->flag_for_face_refinement(
15036 neighbor->flag_for_face_refinement(
15037 nb_nb, needed_face_ref_case);
15044 face_ref_case = cell->face(i)->refinement_case(),
15045 needed_face_ref_case =
15047 cell->refine_flag_set(),
15049 cell->face_orientation(i),
15050 cell->face_flip(i),
15051 cell->face_rotation(i));
15056 needed_face_ref_case ==
15059 needed_face_ref_case ==
15062 cell->flag_for_face_refinement(i,
15075 this->policy->prepare_refinement_dim_dependent(*
this);
15082 fix_coarsen_flags();
15085 std::vector<bool> flags_after_loop[2];
15086 save_coarsen_flags(flags_after_loop[0]);
15087 save_refine_flags(flags_after_loop[1]);
15091 mesh_changed_in_this_loop =
15092 ((flags_before_loop[0] != flags_after_loop[0]) ||
15093 (flags_before_loop[1] != flags_after_loop[1]));
15097 flags_before_loop[0].swap(flags_after_loop[0]);
15098 flags_before_loop[1].swap(flags_after_loop[1]);
15100 while (mesh_changed_in_this_loop);
15106 return ((flags_before[0] != flags_before_loop[0]) ||
15107 (flags_before[1] != flags_before_loop[1]));
15112template <
int dim,
int spacedim>
15115 const unsigned int magic_number1,
15116 const std::vector<bool> &v,
15117 const unsigned int magic_number2,
15118 std::ostream & out)
15120 const unsigned int N = v.size();
15121 unsigned char * flags =
new unsigned char[
N / 8 + 1];
15122 for (
unsigned int i = 0; i <
N / 8 + 1; ++i)
15125 for (
unsigned int position = 0; position <
N; ++position)
15126 flags[position / 8] |= (v[position] ? (1 << (position % 8)) : 0);
15135 out << magic_number1 <<
' ' <<
N << std::endl;
15136 for (
unsigned int i = 0; i <
N / 8 + 1; ++i)
15137 out <<
static_cast<unsigned int>(flags[i]) <<
' ';
15139 out << std::endl << magic_number2 << std::endl;
15147template <
int dim,
int spacedim>
15150 std::vector<bool> &v,
15151 const unsigned int magic_number2,
15156 unsigned int magic_number;
15157 in >> magic_number;
15158 AssertThrow(magic_number == magic_number1, ExcGridReadError());
15164 unsigned char * flags =
new unsigned char[
N / 8 + 1];
15165 unsigned short int tmp;
15166 for (
unsigned int i = 0; i <
N / 8 + 1; ++i)
15172 for (
unsigned int position = 0; position !=
N; ++position)
15173 v[position] = (flags[position / 8] & (1 << (position % 8)));
15175 in >> magic_number;
15176 AssertThrow(magic_number == magic_number2, ExcGridReadError());
15185template <
int dim,
int spacedim>
15189 std::size_t mem = 0;
15191 for (
const auto &
level : levels)
15195 mem +=
sizeof(manifold);
15196 mem +=
sizeof(smooth_grid);
15198 mem +=
sizeof(faces);
15207template <
int dim,
int spacedim>
15213#include "tria.inst"
ArrayView< const std::uint8_t > get_child_indices() const
types::coarse_cell_id get_coarse_cell_id() const
virtual std::unique_ptr< Manifold< dim, spacedim > > clone() const =0
Subscriptor & operator=(const Subscriptor &)
virtual void add_periodicity(const std::vector< GridTools::PeriodicFacePair< cell_iterator > > &)
virtual types::global_cell_index n_global_active_cells() const
quad_iterator begin_quad(const unsigned int level=0) const
typename IteratorSelector::raw_line_iterator raw_line_iterator
active_vertex_iterator begin_active_vertex() const
virtual MPI_Comm get_communicator() const
void load_user_indices_quad(const std::vector< unsigned int > &v)
unsigned int n_quads() const
Triangulation & operator=(Triangulation< dim, spacedim > &&tria) noexcept
void load_user_indices(const std::vector< unsigned int > &v)
std::vector< bool > vertices_used
bool anisotropic_refinement
active_quad_iterator begin_active_quad(const unsigned int level=0) const
bool get_anisotropic_refinement_flag() const
virtual const MeshSmoothing & get_mesh_smoothing() const
virtual void copy_triangulation(const Triangulation< dim, spacedim > &other_tria)
std::unique_ptr< std::map< unsigned int, types::manifold_id > > vertex_to_manifold_id_map_1d
void save_user_pointers_quad(std::vector< void * > &v) const
void save_user_flags_hex(std::ostream &out) const
void clear_user_flags_quad()
unsigned int n_faces() const
active_hex_iterator begin_active_hex(const unsigned int level=0) const
static void read_bool_vector(const unsigned int magic_number1, std::vector< bool > &v, const unsigned int magic_number2, std::istream &in)
bool all_reference_cells_are_hyper_cube() const
void load_user_flags_line(std::istream &in)
raw_hex_iterator begin_raw_hex(const unsigned int level=0) const
void save_user_flags_line(std::ostream &out) const
active_cell_iterator last_active() const
void reset_global_cell_indices()
face_iterator end_face() const
void reset_active_cell_indices()
cell_iterator create_cell_iterator(const CellId &cell_id) const
cell_iterator begin(const unsigned int level=0) const
const std::map< std::pair< cell_iterator, unsigned int >, std::pair< std::pair< cell_iterator, unsigned int >, std::bitset< 3 > > > & get_periodic_face_map() const
void save_user_pointers_line(std::vector< void * > &v) const
void load_refine_flags(std::istream &in)
void save_user_indices_line(std::vector< unsigned int > &v) const
raw_cell_iterator begin_raw(const unsigned int level=0) const
unsigned int n_lines() const
virtual void set_mesh_smoothing(const MeshSmoothing mesh_smoothing)
unsigned int n_raw_lines() const
virtual std::size_t memory_consumption() const
std::vector< Point< spacedim > > vertices
raw_quad_iterator begin_raw_quad(const unsigned int level=0) const
virtual types::subdomain_id locally_owned_subdomain() const
unsigned int n_raw_faces() const
unsigned int n_active_faces() const
virtual void create_triangulation(const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
const bool check_for_distorted_cells
raw_cell_iterator end_raw(const unsigned int level) const
line_iterator end_line() const
std::unique_ptr< std::map< unsigned int, types::boundary_id > > vertex_to_boundary_id_map_1d
void load_user_flags_quad(std::istream &in)
unsigned int n_active_cells() const
virtual void update_reference_cells()
std::vector< ReferenceCell > reference_cells
void update_periodic_face_map()
void clear_despite_subscriptions()
void coarsen_global(const unsigned int times=1)
Triangulation(const MeshSmoothing smooth_grid=none, const bool check_for_distorted_cells=false)
void save_user_flags(std::ostream &out) const
void refine_global(const unsigned int times=1)
void load_user_flags_hex(std::istream &in)
void load_user_pointers_quad(const std::vector< void * > &v)
virtual void create_triangulation_compatibility(const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
std::unique_ptr<::internal::TriangulationImplementation::TriaFaces > faces
unsigned int n_used_vertices() const
void reset_cell_vertex_indices_cache()
unsigned int n_active_lines() const
void load_user_indices_line(const std::vector< unsigned int > &v)
void clear_user_flags_hex()
void save_user_pointers_hex(std::vector< void * > &v) const
const std::vector< ReferenceCell > & get_reference_cells() const
void load_user_pointers(const std::vector< void * > &v)
::internal::TriangulationImplementation::NumberCache< dim > number_cache
void save_user_indices_hex(std::vector< unsigned int > &v) const
DistortedCellList execute_refinement()
active_line_iterator begin_active_line(const unsigned int level=0) const
void save_user_indices_quad(std::vector< unsigned int > &v) const
void load_user_pointers_hex(const std::vector< void * > &v)
cell_iterator end() const
virtual bool has_hanging_nodes() const
unsigned int n_raw_cells(const unsigned int level) const
void load_coarsen_flags(std::istream &out)
quad_iterator end_quad() const
line_iterator begin_line(const unsigned int level=0) const
unsigned int max_adjacent_cells() const
vertex_iterator begin_vertex() const
unsigned int n_hexs() const
vertex_iterator end_vertex() const
void load_user_pointers_line(const std::vector< void * > &v)
hex_iterator end_hex() const
hex_iterator begin_hex(const unsigned int level=0) const
virtual void execute_coarsening_and_refinement()
active_cell_iterator end_active(const unsigned int level) const
cell_iterator last() const
unsigned int n_active_quads() const
void load_user_indices_hex(const std::vector< unsigned int > &v)
unsigned int n_raw_quads() const
std::map< types::manifold_id, std::unique_ptr< const Manifold< dim, spacedim > > > manifold
void save_user_pointers(std::vector< void * > &v) const
face_iterator begin_face() const
unsigned int n_cells() const
virtual bool prepare_coarsening_and_refinement()
const std::vector< bool > & get_used_vertices() const
MeshSmoothing smooth_grid
void save_refine_flags(std::ostream &out) const
std::unique_ptr< ::internal::TriangulationImplementation::Policy< dim, spacedim > > policy
Triangulation< dim, spacedim > & get_triangulation()
void save_user_flags_quad(std::ostream &out) const
virtual ~Triangulation() override
unsigned int n_vertices() const
void save_user_indices(std::vector< unsigned int > &v) const
std::vector< std::unique_ptr<::internal::TriangulationImplementation::TriaLevel > > levels
unsigned int n_raw_hexs(const unsigned int level) const
void set_all_refine_flags()
unsigned int n_active_hexs() const
virtual std::vector< types::boundary_id > get_boundary_ids() const
void load_user_flags(std::istream &in)
void save_coarsen_flags(std::ostream &out) const
active_face_iterator begin_active_face() const
void clear_user_flags_line()
raw_line_iterator begin_raw_line(const unsigned int level=0) const
static void write_bool_vector(const unsigned int magic_number1, const std::vector< bool > &v, const unsigned int magic_number2, std::ostream &out)
void flip_all_direction_flags()
active_cell_iterator begin_active(const unsigned int level=0) const
void execute_coarsening()
void prevent_distorted_boundary_cells(Triangulation< dim, spacedim > &triangulation) override
void prepare_refinement_dim_dependent(Triangulation< dim, spacedim > &triangulation) override
void delete_children(Triangulation< dim, spacedim > &tria, typename Triangulation< dim, spacedim >::cell_iterator &cell, std::vector< unsigned int > &line_cell_count, std::vector< unsigned int > &quad_cell_count) override
void update_neighbors(Triangulation< dim, spacedim > &tria) override
bool coarsening_allowed(const typename Triangulation< dim, spacedim >::cell_iterator &cell) override
Triangulation< dim, spacedim >::DistortedCellList execute_refinement(Triangulation< dim, spacedim > &triangulation, const bool check_for_distorted_cells) override
std::unique_ptr< Policy< dim, spacedim > > clone() override
virtual std::unique_ptr< Policy< dim, spacedim > > clone()=0
virtual void update_neighbors(Triangulation< dim, spacedim > &tria)=0
virtual void prepare_refinement_dim_dependent(Triangulation< dim, spacedim > &triangulation)=0
virtual void prevent_distorted_boundary_cells(Triangulation< dim, spacedim > &triangulation)=0
virtual Triangulation< dim, spacedim >::DistortedCellList execute_refinement(Triangulation< dim, spacedim > &triangulation, const bool check_for_distorted_cells)=0
virtual bool coarsening_allowed(const typename Triangulation< dim, spacedim >::cell_iterator &cell)=0
virtual void delete_children(Triangulation< dim, spacedim > &triangulation, typename Triangulation< dim, spacedim >::cell_iterator &cell, std::vector< unsigned int > &line_cell_count, std::vector< unsigned int > &quad_cell_count)=0
virtual ~Policy()=default
std::vector<::ReferenceCell > quad_reference_cell
std::vector< unsigned char > quads_line_orientations
std::vector<::ReferenceCell > reference_cell
std::vector< std::pair< int, int > > neighbors
std::vector< types::global_cell_index > global_active_cell_indices
std::vector< types::global_cell_index > global_level_cell_indices
std::vector< int > parents
std::vector< unsigned char > face_orientations
std::vector< types::subdomain_id > level_subdomain_ids
std::vector< bool > coarsen_flags
std::vector< std::uint8_t > refine_flags
std::vector< types::subdomain_id > subdomain_ids
std::vector< unsigned int > active_cell_indices
std::vector< bool > direction_flags
std::vector< types::manifold_id > manifold_id
void clear_user_data(const unsigned int i)
std::vector< int > children
unsigned int next_free_pair
std::vector< bool > user_flags
bool reverse_order_next_free_single
unsigned int next_free_single
unsigned int n_objects() const
std::vector< BoundaryOrMaterialId > boundary_or_material_id
std::vector< std::uint8_t > refinement_cases
std::vector< UserData > user_data
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
IteratorRange< active_cell_iterator > active_cell_iterators_on_level(const unsigned int level) const
IteratorRange< active_face_iterator > active_face_iterators() const
IteratorRange< active_cell_iterator > active_cell_iterators() const
IteratorRange< cell_iterator > cell_iterators_on_level(const unsigned int level) const
IteratorRange< cell_iterator > cell_iterators() const
static ::ExceptionBase & ExcInternalErrorOnCell(int arg1)
static ::ExceptionBase & ExcIO()
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
static ::ExceptionBase & ExcInteriorQuadCantBeBoundary(int arg1, int arg2, int arg3, int arg4, types::boundary_id arg5)
static ::ExceptionBase & ExcQuadInexistant(int arg1, int arg2, int arg3, int arg4)
static ::ExceptionBase & ExcNotImplemented()
static ::ExceptionBase & ExcInconsistentLineInfoOfLine(int arg1, int arg2, std::string arg3)
static ::ExceptionBase & ExcCellHasNegativeMeasure(int arg1)
#define Assert(cond, exc)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
static ::ExceptionBase & ExcGridHasInvalidCell(int arg1)
static ::ExceptionBase & ExcMemoryInexact(int arg1, int arg2)
#define DeclException2(Exception2, type1, type2, outsequence)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcLineInexistant(int arg1, int arg2)
static ::ExceptionBase & ExcMultiplySetLineInfoOfLine(int arg1, int arg2)
#define AssertNothrow(cond, exc)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcInteriorLineCantBeBoundary(int arg1, int arg2, types::boundary_id arg3)
static ::ExceptionBase & ExcFacesHaveNoLevel()
#define DeclException3(Exception3, type1, type2, type3, outsequence)
#define DeclException1(Exception1, type1, outsequence)
static ::ExceptionBase & ExcInvalidVertexIndex(int arg1, int arg2, int arg3)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define DeclException5( Exception5, type1, type2, type3, type4, type5, outsequence)
#define AssertThrow(cond, exc)
static ::ExceptionBase & ExcInconsistentQuadInfoOfQuad(int arg1, int arg2, int arg3, int arg4, std::string arg5)
TriaIterator< CellAccessor< dim, spacedim > > cell_iterator
void loop(ITERATOR begin, typename identity< ITERATOR >::type end, DOFINFO &dinfo, INFOBOX &info, const std::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &cell_worker, const std::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &boundary_worker, const std::function< void(DOFINFO &, DOFINFO &, typename INFOBOX::CellInfo &, typename INFOBOX::CellInfo &)> &face_worker, ASSEMBLER &assembler, const LoopControl &lctrl=LoopControl())
void set_all_manifold_ids_on_boundary(const types::manifold_id number)
const Manifold< dim, spacedim > & get_manifold(const types::manifold_id number) const
virtual std::vector< types::manifold_id > get_manifold_ids() const
void reset_manifold(const types::manifold_id manifold_number)
void set_manifold(const types::manifold_id number, const Manifold< dim, spacedim > &manifold_object)
void reset_all_manifolds()
void set_all_manifold_ids(const types::manifold_id number)
Task< RT > new_task(const std::function< RT()> &function)
const unsigned int mn_tria_refine_flags_end
const unsigned int mn_tria_coarsen_flags_end
const unsigned int mn_tria_refine_flags_begin
const unsigned int mn_tria_hex_user_flags_end
const unsigned int mn_tria_line_user_flags_begin
const unsigned int mn_tria_line_user_flags_end
const unsigned int mn_tria_quad_user_flags_end
const unsigned int mn_tria_coarsen_flags_begin
const unsigned int mn_tria_hex_user_flags_begin
const unsigned int mn_tria_quad_user_flags_begin
const Mapping< dim, spacedim > & get_default_linear_mapping(const Triangulation< dim, spacedim > &triangulation)
Expression fabs(const Expression &x)
void create_triangulation(Triangulation< dim, dim > &tria, const AdditionalData &additional_data=AdditionalData())
@ valid
Iterator points to a valid object.
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
void swap(MemorySpaceData< Number, MemorySpace > &, MemorySpaceData< Number, MemorySpace > &)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
constexpr const ReferenceCell Quadrilateral
constexpr const ReferenceCell Invalid
constexpr const ReferenceCell Triangle
constexpr const ReferenceCell Hexahedron
VectorType::value_type * end(VectorType &V)
VectorType::value_type * begin(VectorType &V)
Iterator lower_bound(Iterator first, Iterator last, const T &val)
Point< 1 > transform_real_to_unit_cell(const std::array< Point< spacedim >, GeometryInfo< 1 >::vertices_per_cell > &vertices, const Point< spacedim > &p)
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 3 > &c)
unsigned int n_active_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
const Manifold< dim, spacedim > & get_default_flat_manifold()
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
void reserve_space(TriaFaces &tria_faces, const unsigned int new_quads_in_pairs, const unsigned int new_quads_single)
void monitor_memory(const TriaObjects &tria_object, const unsigned int)
unsigned int n_active_cells(const internal::TriangulationImplementation::NumberCache< 3 > &c)
void monitor_memory(const TriaLevel &tria_level, const unsigned int true_dimension)
const types::boundary_id internal_face_boundary_id
const types::subdomain_id invalid_subdomain_id
static const unsigned int invalid_unsigned_int
const types::manifold_id flat_manifold_id
const types::global_dof_index invalid_dof_index
TriangulationBase< dim, spacedim > Triangulation
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation
static unsigned int child_cell_on_face(const RefinementCase< dim > &ref_case, const unsigned int face, const unsigned int subface, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false, const RefinementCase< dim - 1 > &face_refinement_case=RefinementCase< dim - 1 >::isotropic_refinement)
static RefinementCase< dim - 1 > face_refinement_case(const RefinementCase< dim > &cell_refinement_case, const unsigned int face_no, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
static RefinementCase< dim > min_cell_refinement_case_for_face_refinement(const RefinementCase< dim - 1 > &face_refinement_case, const unsigned int face_no, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
static unsigned int n_children(const RefinementCase< dim > &refinement_case)
static void alternating_form_at_vertices(const Point< spacedim >(&vertices)[vertices_per_cell], Tensor< spacedim - dim, spacedim >(&forms)[vertices_per_cell])
std::vector< CellData< 2 > > boundary_quads
bool check_consistency(const unsigned int dim) const
std::vector< CellData< 1 > > boundary_lines
std::vector< std::vector< CellData< dim > > > cell_infos
std::vector<::CellData< dim > > coarse_cells
std::vector< Point< spacedim > > coarse_cell_vertices
virtual ~DistortedCellList() noexcept override
std::list< typename Triangulation< dim, spacedim >::cell_iterator > distorted_cells
std::vector< std::size_t > ptr
static void update_neighbors(Triangulation< 1, spacedim > &)
static bool coarsening_allowed(const typename Triangulation< dim, spacedim >::cell_iterator &cell)
static Triangulation< dim, spacedim >::DistortedCellList execute_refinement(Triangulation< dim, spacedim > &triangulation, const bool check_for_distorted_cells)
static void update_neighbors(Triangulation< dim, spacedim > &triangulation)
static void delete_children(Triangulation< dim, spacedim > &triangulation, typename Triangulation< dim, spacedim >::cell_iterator &cell, std::vector< unsigned int > &line_cell_count, std::vector< unsigned int > &quad_cell_count)
static void prepare_refinement_dim_dependent(Triangulation< dim, spacedim > &triangulation)
static void prevent_distorted_boundary_cells(Triangulation< dim, spacedim > &triangulation)
static void compute_number_cache(const Triangulation< dim, spacedim > &triangulation, const unsigned int level_objects, internal::TriangulationImplementation::NumberCache< 3 > &number_cache)
static void reserve_space_(TriaObjects &obj, const unsigned int size)
static void reserve_space_(TriaFaces &faces, const unsigned structdim, const unsigned int size)
static void prevent_distorted_boundary_cells(Triangulation< 1, spacedim > &)
static void update_neighbors(Triangulation< dim, spacedim > &triangulation)
static void prepare_refinement_dim_dependent(const Triangulation< dim, spacedim > &)
static void delete_children(Triangulation< 3, spacedim > &triangulation, typename Triangulation< 3, spacedim >::cell_iterator &cell, std::vector< unsigned int > &line_cell_count, std::vector< unsigned int > &quad_cell_count)
static void reserve_space_(TriaLevel &level, const unsigned int spacedim, const unsigned int size, const bool orientation_needed)
static void update_neighbors(Triangulation< 1, spacedim > &)
static Triangulation< 3, spacedim >::DistortedCellList execute_refinement(Triangulation< 3, spacedim > &triangulation, const bool check_for_distorted_cells)
static void process_subcelldata(const CRS< T > &crs, TriaObjects &obj, const std::vector< CellData< structdim > > &boundary_objects_in)
static Triangulation< dim, spacedim >::DistortedCellList execute_refinement_isotropic(Triangulation< dim, spacedim > &triangulation, const bool check_for_distorted_cells)
static void create_children(Triangulation< 2, spacedim > &triangulation, unsigned int &next_unused_vertex, typename Triangulation< 2, spacedim >::raw_line_iterator &next_unused_line, typename Triangulation< 2, spacedim >::raw_cell_iterator &next_unused_cell, const typename Triangulation< 2, spacedim >::cell_iterator &cell)
static void compute_number_cache(const Triangulation< dim, spacedim > &triangulation, const unsigned int level_objects, internal::TriangulationImplementation::NumberCache< 2 > &number_cache)
static void prevent_distorted_boundary_cells(Triangulation< dim, spacedim > &triangulation)
static void compute_number_cache(const Triangulation< dim, spacedim > &triangulation, const unsigned int level_objects, internal::TriangulationImplementation::NumberCache< 1 > &number_cache)
static bool coarsening_allowed(const typename Triangulation< dim, spacedim >::cell_iterator &cell)
static void delete_children(Triangulation< 1, spacedim > &triangulation, typename Triangulation< 1, spacedim >::cell_iterator &cell, std::vector< unsigned int > &, std::vector< unsigned int > &)
static void prepare_refinement_dim_dependent(Triangulation< 3, spacedim > &triangulation)
static void delete_children(Triangulation< 2, spacedim > &triangulation, typename Triangulation< 2, spacedim >::cell_iterator &cell, std::vector< unsigned int > &line_cell_count, std::vector< unsigned int > &)
static Triangulation< 1, spacedim >::DistortedCellList execute_refinement(Triangulation< 1, spacedim > &triangulation, const bool)
static void create_triangulation(const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata, Triangulation< dim, spacedim > &tria)
static Triangulation< 2, spacedim >::DistortedCellList execute_refinement(Triangulation< 2, spacedim > &triangulation, const bool check_for_distorted_cells)
std::vector< unsigned int > n_lines_level
unsigned int n_active_lines
std::vector< unsigned int > n_active_lines_level
std::vector< unsigned int > n_active_quads_level
unsigned int n_active_quads
std::vector< unsigned int > n_quads_level
unsigned int n_active_hexes
std::vector< unsigned int > n_hexes_level
std::vector< unsigned int > n_active_hexes_level