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;
483 for (
auto &cell : cells)
485 std::swap(cell.vertices[2], cell.vertices[3]);
490 reorder_compatibility(std::vector<
CellData<3>> &cells,
494 for (
auto &cell : cells)
498 tmp[i] = cell.vertices[i];
506 std::swap(boundary_quad.vertices[2], boundary_quad.vertices[3]);
528 template <
int dim,
int spacedim>
533 if (line->has_children())
534 return line->child(0)->vertex_index(1);
539 template <
int dim,
int spacedim>
544 switch (
static_cast<unsigned char>(quad->refinement_case()))
547 return middle_vertex_index<dim, spacedim>(quad->child(0)->line(1));
550 return middle_vertex_index<dim, spacedim>(quad->child(0)->line(3));
553 return quad->child(0)->vertex_index(3);
562 template <
int dim,
int spacedim>
567 switch (
static_cast<unsigned char>(hex->refinement_case()))
570 return middle_vertex_index<dim, spacedim>(hex->child(0)->quad(1));
573 return middle_vertex_index<dim, spacedim>(hex->child(0)->quad(3));
576 return middle_vertex_index<dim, spacedim>(hex->child(0)->quad(5));
579 return middle_vertex_index<dim, spacedim>(hex->child(0)->line(11));
582 return middle_vertex_index<dim, spacedim>(hex->child(0)->line(5));
585 return middle_vertex_index<dim, spacedim>(hex->child(0)->line(7));
588 return hex->child(0)->vertex_index(7);
609 template <
class TRIANGULATION>
610 inline typename TRIANGULATION::DistortedCellList
611 collect_distorted_coarse_cells(
const TRIANGULATION &)
613 return typename TRIANGULATION::DistortedCellList();
631 for (
const auto &cell :
triangulation.cell_iterators_on_level(0))
641 if (determinants[i] <= 1e-9 *
std::pow(cell->diameter(), 1. * dim))
648 return distorted_cells;
660 has_distorted_children(
665 for (
unsigned int c = 0; c < cell->n_children(); ++c)
669 vertices[i] = cell->child(c)->vertex(i);
675 if (determinants[i] <=
676 1e-9 *
std::pow(cell->child(c)->diameter(), 1. * dim))
691 template <
int dim,
int spacedim>
693 has_distorted_children(
700 template <
int dim,
int spacedim>
702 update_periodic_face_map_recursively(
705 unsigned int n_face_1,
706 unsigned int n_face_2,
707 const std::bitset<3> & orientation,
713 std::bitset<3>>> &periodic_face_map)
716 const FaceIterator face_1 = cell_1->face(n_face_1);
717 const FaceIterator face_2 = cell_2->face(n_face_2);
719 const bool face_orientation = orientation[0];
720 const bool face_flip = orientation[1];
721 const bool face_rotation = orientation[2];
723 Assert((dim != 1) || (face_orientation ==
true && face_flip ==
false &&
724 face_rotation ==
false),
726 "(face_orientation, face_flip, face_rotation) "
727 "is invalid for 1D"));
729 Assert((dim != 2) || (face_orientation ==
true && face_rotation ==
false),
731 "(face_orientation, face_flip, face_rotation) "
732 "is invalid for 2D"));
736 Assert(face_1->at_boundary() && face_2->at_boundary(),
737 ExcMessage(
"Periodic faces must be on the boundary"));
743 Assert(dim == 1 ||
std::abs(cell_1->level() - cell_2->level()) < 2,
748 std::pair<typename Triangulation<dim, spacedim>::cell_iterator,
750 const CellFace cell_face_1(cell_1, n_face_1);
751 const CellFace cell_face_2(cell_2, n_face_2);
752 const std::pair<CellFace, std::bitset<3>> cell_face_orientation_2(
753 cell_face_2, orientation);
755 const std::pair<CellFace, std::pair<CellFace, std::bitset<3>>>
756 periodic_faces(cell_face_1, cell_face_orientation_2);
760 periodic_face_map.insert(periodic_faces);
764 if (cell_1->has_children())
766 if (cell_2->has_children())
768 update_periodic_face_map_recursively<dim, spacedim>(
769 cell_1->child(n_face_1),
770 cell_2->child(n_face_2),
778 update_periodic_face_map_recursively<dim, spacedim>(
779 cell_1->child(n_face_1),
794 static const int lookup_table_2d[2][2] =
801 static const int lookup_table_3d[2][2][2][4] =
820 if (cell_1->has_children())
822 if (cell_2->has_children())
828 Assert(face_1->n_children() ==
834 for (
unsigned int i = 0;
835 i < GeometryInfo<dim>::max_children_per_face;
843 j = lookup_table_2d[face_flip][i];
846 j = lookup_table_3d[face_orientation][face_flip]
854 unsigned int child_cell_1 =
856 cell_1->refinement_case(),
859 cell_1->face_orientation(n_face_1),
860 cell_1->face_flip(n_face_1),
861 cell_1->face_rotation(n_face_1),
862 face_1->refinement_case());
863 unsigned int child_cell_2 =
865 cell_2->refinement_case(),
868 cell_2->face_orientation(n_face_2),
869 cell_2->face_flip(n_face_2),
870 cell_2->face_rotation(n_face_2),
871 face_2->refinement_case());
873 Assert(cell_1->child(child_cell_1)->face(n_face_1) ==
876 Assert(cell_2->child(child_cell_2)->face(n_face_2) ==
882 update_periodic_face_map_recursively<dim, spacedim>(
883 cell_1->child(child_cell_1),
884 cell_2->child(child_cell_2),
893 for (
unsigned int i = 0;
894 i < GeometryInfo<dim>::max_children_per_face;
898 unsigned int child_cell_1 =
900 cell_1->refinement_case(),
903 cell_1->face_orientation(n_face_1),
904 cell_1->face_flip(n_face_1),
905 cell_1->face_rotation(n_face_1),
906 face_1->refinement_case());
909 update_periodic_face_map_recursively<dim, spacedim>(
910 cell_1->child(child_cell_1),
928 namespace TriangulationImplementation
936 using ::Triangulation;
944 <<
"Something went wrong when making cell " << arg1
945 <<
". Read the docs and the source code "
946 <<
"for more information.");
953 <<
"Something went wrong upon construction of cell "
967 <<
" has negative measure. This typically "
968 <<
"indicates some distortion in the cell, or a mistakenly "
969 <<
"swapped pair of vertices in the input to "
970 <<
"Triangulation::create_triangulation().");
982 <<
"Error while creating cell " << arg1
983 <<
": the vertex index " << arg2 <<
" must be between 0 and "
992 <<
"While trying to assign a boundary indicator to a line: "
993 <<
"the line with end vertices " << arg1 <<
" and " << arg2
994 <<
" does not exist.");
1004 <<
"While trying to assign a boundary indicator to a quad: "
1005 <<
"the quad with bounding lines " << arg1 <<
", " << arg2
1006 <<
", " << arg3 <<
", " << arg4 <<
" does not exist.");
1016 <<
"The input data for creating a triangulation contained "
1017 <<
"information about a line with indices " << arg1 <<
" and " << arg2
1018 <<
" that is described to have boundary indicator "
1019 <<
static_cast<int>(arg3)
1020 <<
". However, this is an internal line not located on the "
1021 <<
"boundary. You cannot assign a boundary indicator to it." << std::endl
1023 <<
"If this happened at a place where you call "
1024 <<
"Triangulation::create_triangulation() yourself, you need "
1025 <<
"to check the SubCellData object you pass to this function."
1028 <<
"If this happened in a place where you are reading a mesh "
1029 <<
"from a file, then you need to investigate why such a line "
1030 <<
"ended up in the input file. A typical case is a geometry "
1031 <<
"that consisted of multiple parts and for which the mesh "
1032 <<
"generator program assumes that the interface between "
1033 <<
"two parts is a boundary when that isn't supposed to be "
1034 <<
"the case, or where the mesh generator simply assigns "
1035 <<
"'geometry indicators' to lines at the perimeter of "
1036 <<
"a part that are not supposed to be interpreted as "
1037 <<
"'boundary indicators'.");
1049 <<
"The input data for creating a triangulation contained "
1050 <<
"information about a quad with indices " << arg1 <<
", " << arg2
1051 <<
", " << arg3 <<
", and " << arg4
1052 <<
" that is described to have boundary indicator "
1053 <<
static_cast<int>(arg5)
1054 <<
". However, this is an internal quad not located on the "
1055 <<
"boundary. You cannot assign a boundary indicator to it." << std::endl
1057 <<
"If this happened at a place where you call "
1058 <<
"Triangulation::create_triangulation() yourself, you need "
1059 <<
"to check the SubCellData object you pass to this function."
1062 <<
"If this happened in a place where you are reading a mesh "
1063 <<
"from a file, then you need to investigate why such a quad "
1064 <<
"ended up in the input file. A typical case is a geometry "
1065 <<
"that consisted of multiple parts and for which the mesh "
1066 <<
"generator program assumes that the interface between "
1067 <<
"two parts is a boundary when that isn't supposed to be "
1068 <<
"the case, or where the mesh generator simply assigns "
1069 <<
"'geometry indicators' to quads at the surface of "
1070 <<
"a part that are not supposed to be interpreted as "
1071 <<
"'boundary indicators'.");
1080 <<
"In SubCellData the line info of the line with vertex indices " << arg1
1081 <<
" and " << arg2 <<
" appears more than once. "
1082 <<
"This is not allowed.");
1092 <<
"In SubCellData the line info of the line with vertex indices " << arg1
1093 <<
" and " << arg2 <<
" appears multiple times with different (valid) "
1094 << arg3 <<
". This is not allowed.");
1106 <<
"In SubCellData the quad info of the quad with line indices " << arg1
1107 <<
", " << arg2 <<
", " << arg3 <<
" and " << arg4
1108 <<
" appears multiple times with different (valid) " << arg5
1109 <<
". This is not allowed.");
1120 const unsigned int new_quads_in_pairs,
1121 const unsigned int new_quads_single)
1127 unsigned int next_free_single = 0;
1128 unsigned int next_free_pair = 0;
1132 unsigned int n_quads = 0;
1133 unsigned int n_unused_pairs = 0;
1134 unsigned int n_unused_singles = 0;
1135 for (
unsigned int i = 0; i < tria_faces.
quads.
used.size(); ++i)
1139 else if (i + 1 < tria_faces.
quads.
used.size())
1144 if (next_free_single == 0)
1145 next_free_single = i;
1150 if (next_free_pair == 0)
1158 Assert(n_quads + 2 * n_unused_pairs + n_unused_singles ==
1163 const int additional_single_quads = new_quads_single - n_unused_singles;
1165 unsigned int new_size =
1166 tria_faces.
quads.
used.size() + new_quads_in_pairs - 2 * n_unused_pairs;
1167 if (additional_single_quads > 0)
1168 new_size += additional_single_quads;
1207 const unsigned int total_cells,
1208 const unsigned int dimension,
1209 const unsigned int space_dimension)
1261 if (dimension < space_dimension)
1272 tria_level.
parents.reserve((total_cells + 1) / 2);
1274 (total_cells + 1) / 2 -
1278 tria_level.
neighbors.reserve(total_cells * (2 * dimension));
1280 total_cells * (2 * dimension) -
1282 std::make_pair(-1, -1));
1284 if (tria_level.
dim == 2 || tria_level.
dim == 3)
1286 const unsigned int max_faces_per_cell = 2 * dimension;
1288 max_faces_per_cell);
1291 total_cells * max_faces_per_cell -
1313 <<
"The containers have sizes " << arg1 <<
" and " << arg2
1314 <<
", which is not as expected.");
1323 const unsigned int true_dimension)
1326 (void)true_dimension;
1353 const unsigned int new_objects_in_pairs,
1354 const unsigned int new_objects_single = 0)
1366 unsigned int n_objects = 0;
1367 unsigned int n_unused_pairs = 0;
1368 unsigned int n_unused_singles = 0;
1369 for (
unsigned int i = 0; i < tria_objects.
used.size(); ++i)
1371 if (tria_objects.
used[i])
1373 else if (i + 1 < tria_objects.
used.size())
1375 if (tria_objects.
used[i + 1])
1392 Assert(n_objects + 2 * n_unused_pairs + n_unused_singles ==
1393 tria_objects.
used.size(),
1398 const int additional_single_objects =
1399 new_objects_single - n_unused_singles;
1401 unsigned int new_size = tria_objects.
used.size() +
1402 new_objects_in_pairs - 2 * n_unused_pairs;
1403 if (additional_single_objects > 0)
1404 new_size += additional_single_objects;
1407 if (new_size > tria_objects.
n_objects())
1409 const unsigned int max_faces_per_cell =
1411 const unsigned int max_children_per_cell =
1414 tria_objects.
cells.reserve(new_size * max_faces_per_cell);
1415 tria_objects.
cells.insert(tria_objects.
cells.end(),
1420 tria_objects.
used.reserve(new_size);
1421 tria_objects.
used.insert(tria_objects.
used.end(),
1422 new_size - tria_objects.
used.size(),
1431 const unsigned int factor = max_children_per_cell / 2;
1432 tria_objects.
children.reserve(factor * new_size);
1452 tria_objects.
user_data.reserve(new_size);
1453 tria_objects.
user_data.resize(new_size);
1462 if (n_unused_singles == 0)
1470 const unsigned int new_hexes = new_objects_in_pairs;
1472 const unsigned int new_size =
1473 new_hexes + std::count(tria_objects.
used.begin(),
1474 tria_objects.
used.end(),
1478 if (new_size > tria_objects.
n_objects())
1480 const unsigned int max_faces_per_cell =
1483 tria_objects.
cells.reserve(new_size * max_faces_per_cell);
1484 tria_objects.
cells.insert(tria_objects.
cells.end(),
1489 tria_objects.
used.reserve(new_size);
1490 tria_objects.
used.insert(tria_objects.
used.end(),
1491 new_size - tria_objects.
used.size(),
1500 tria_objects.
children.reserve(4 * new_size);
1519 tria_objects.
user_data.reserve(new_size);
1520 tria_objects.
user_data.resize(new_size);
1544 tria_object.
used.size()));
1585 template <
int dim,
int spacedim>
1607 std::vector<unsigned int> & line_cell_count,
1608 std::vector<unsigned int> &quad_cell_count) = 0;
1615 const bool check_for_distorted_cells) = 0;
1644 virtual std::unique_ptr<Policy<dim, spacedim>>
1655 template <
int dim,
int spacedim,
typename T>
1662 T::update_neighbors(
tria);
1669 std::vector<unsigned int> & line_cell_count,
1670 std::vector<unsigned int> &quad_cell_count)
override
1672 T::delete_children(
tria, cell, line_cell_count, quad_cell_count);
1677 const bool check_for_distorted_cells)
override
1679 return T::execute_refinement(
triangulation, check_for_distorted_cells);
1701 return T::template coarsening_allowed<dim, spacedim>(cell);
1704 std::unique_ptr<Policy<dim, spacedim>>
1707 return std::make_unique<PolicyWrapper<dim, spacedim, T>>();
1821 template <
int dim,
int spacedim>
1825 const unsigned int level_objects,
1828 using line_iterator =
1831 number_cache.n_levels = 0;
1832 if (level_objects > 0)
1836 number_cache.n_levels =
level + 1;
1844 number_cache.n_lines = 0;
1845 number_cache.n_active_lines = 0;
1851 number_cache.n_lines_level.resize(number_cache.n_levels);
1852 number_cache.n_active_lines_level.resize(number_cache.n_levels);
1857 number_cache.n_lines_level[
level] = 0;
1858 number_cache.n_active_lines_level[
level] = 0;
1862 (
level == number_cache.n_levels - 1 ?
1865 for (; line != endc; ++line)
1867 ++number_cache.n_lines_level[
level];
1868 if (line->has_children() ==
false)
1869 ++number_cache.n_active_lines_level[
level];
1873 number_cache.n_lines += number_cache.n_lines_level[
level];
1874 number_cache.n_active_lines +=
1875 number_cache.n_active_lines_level[
level];
1881 number_cache.n_lines_level.clear();
1882 number_cache.n_active_lines_level.clear();
1886 for (; line != endc; ++line)
1888 ++number_cache.n_lines;
1889 if (line->has_children() ==
false)
1890 ++number_cache.n_active_lines;
1909 template <
int dim,
int spacedim>
1913 const unsigned int level_objects,
1924 &compute_number_cache<dim, spacedim>),
1930 using quad_iterator =
1936 number_cache.n_quads = 0;
1937 number_cache.n_active_quads = 0;
1947 unsigned int n_levels = 0;
1948 if (level_objects > 0)
1952 n_levels =
level + 1;
1954 number_cache.n_quads_level.resize(n_levels);
1955 number_cache.n_active_quads_level.resize(n_levels);
1960 number_cache.n_quads_level[
level] = 0;
1961 number_cache.n_active_quads_level[
level] = 0;
1965 (
level == n_levels - 1 ?
1968 for (; quad != endc; ++quad)
1970 ++number_cache.n_quads_level[
level];
1971 if (quad->has_children() ==
false)
1972 ++number_cache.n_active_quads_level[
level];
1976 number_cache.n_quads += number_cache.n_quads_level[
level];
1977 number_cache.n_active_quads +=
1978 number_cache.n_active_quads_level[
level];
1984 number_cache.n_quads_level.clear();
1985 number_cache.n_active_quads_level.clear();
1989 for (; quad != endc; ++quad)
1991 ++number_cache.n_quads;
1992 if (quad->has_children() ==
false)
1993 ++number_cache.n_active_quads;
1998 update_lines.
join();
2016 template <
int dim,
int spacedim>
2020 const unsigned int level_objects,
2031 &compute_number_cache<dim, spacedim>),
2037 using hex_iterator =
2043 number_cache.n_hexes = 0;
2044 number_cache.n_active_hexes = 0;
2055 unsigned int n_levels = 0;
2056 if (level_objects > 0)
2060 n_levels =
level + 1;
2062 number_cache.n_hexes_level.resize(n_levels);
2063 number_cache.n_active_hexes_level.resize(n_levels);
2068 number_cache.n_hexes_level[
level] = 0;
2069 number_cache.n_active_hexes_level[
level] = 0;
2072 endc = (
level == n_levels - 1 ?
2075 for (; hex != endc; ++hex)
2077 ++number_cache.n_hexes_level[
level];
2078 if (hex->has_children() ==
false)
2079 ++number_cache.n_active_hexes_level[
level];
2083 number_cache.n_hexes += number_cache.n_hexes_level[
level];
2084 number_cache.n_active_hexes +=
2085 number_cache.n_active_hexes_level[
level];
2091 number_cache.n_hexes_level.clear();
2092 number_cache.n_active_hexes_level.clear();
2096 for (; hex != endc; ++hex)
2098 ++number_cache.n_hexes;
2099 if (hex->has_children() ==
false)
2100 ++number_cache.n_active_hexes;
2105 update_quads_and_lines.
join();
2110 template <
int spacedim>
2116 template <
int dim,
int spacedim>
2171 static const unsigned int left_right_offset[2][6][2] = {
2180 {{0, 1}, {1, 0}, {0, 1}, {1, 0}, {0, 1}, {1, 0}}};
2191 std::vector<typename Triangulation<dim, spacedim>::cell_iterator>
2195 for (
auto f : cell->face_indices())
2200 const unsigned int offset =
2201 (cell->direction_flag() ?
2202 left_right_offset[dim - 2][f][cell->face_orientation(f)] :
2204 left_right_offset[dim - 2][f][cell->face_orientation(f)]);
2216 if (cell->is_active() && face->has_children())
2246 if (face->has_children() &&
2247 (cell->is_active() ||
2249 cell->refinement_case(), f) ==
2252 for (
unsigned int c = 0; c < face->n_children(); ++c)
2255 if (face->child(0)->has_children())
2262 if (face->child(1)->has_children())
2279 for (
auto f : cell->face_indices())
2281 const unsigned int offset =
2282 (cell->direction_flag() ?
2283 left_right_offset[dim - 2][f][cell->face_orientation(f)] :
2285 left_right_offset[dim - 2][f][cell->face_orientation(f)]);
2295 template <
int dim,
int spacedim>
2309 if (dim == spacedim)
2310 for (
unsigned int cell_no = 0; cell_no < cells.size(); ++cell_no)
2318 const double cell_measure = GridTools::cell_measure<spacedim>(
2341 const auto connectivity = build_connectivity<unsigned int>(cells);
2342 const unsigned int n_cell = cells.size();
2350 const auto & crs = connectivity.entity_to_entities(1, 0);
2351 const unsigned int n_lines = crs.ptr.size() - 1;
2357 for (
unsigned int line = 0; line < n_lines; ++line)
2358 for (
unsigned int i = crs.ptr[line], j = 0; i < crs.ptr[line + 1];
2371 const auto & crs = connectivity.entity_to_entities(2, 1);
2372 const unsigned int n_quads = crs.ptr.size() - 1;
2379 for (
unsigned int q = 0, k = 0; q < n_quads; ++q)
2382 faces.quad_reference_cell[q] = connectivity.entity_types(2)[q];
2385 for (
unsigned int i = crs.ptr[q], j = 0; i < crs.ptr[q + 1];
2393 faces.quads_line_orientations
2395 connectivity.entity_orientations(1)[k];
2406 const auto &crs = connectivity.entity_to_entities(dim, dim - 1);
2407 const auto &nei = connectivity.entity_to_entities(dim, dim);
2411 const bool orientation_needed =
2414 std::any_of(connectivity.entity_orientations(1).begin(),
2415 connectivity.entity_orientations(1).end(),
2416 [](
const auto &i) { return i == 0; }));
2423 for (
unsigned int cell = 0; cell < n_cell; ++cell)
2426 cells_0.boundary_or_material_id[cell].material_id =
2427 cells[cell].material_id;
2430 cells_0.manifold_id[cell] = cells[cell].manifold_id;
2433 level.reference_cell[cell] = connectivity.entity_types(dim)[cell];
2436 for (
unsigned int i = crs.ptr[cell], j = 0; i < crs.ptr[cell + 1];
2440 if (nei.col[i] !=
static_cast<unsigned int>(-1))
2442 j] = {0, nei.col[i]};
2449 if (orientation_needed)
2451 level.face_orientations
2453 connectivity.entity_orientations(dim - 1)[i];
2462 auto &bids_face = dim == 3 ?
2463 tria.
faces->quads.boundary_or_material_id :
2464 tria.
faces->lines.boundary_or_material_id;
2467 std::vector<unsigned int> count(bids_face.size(), 0);
2470 const auto &crs = connectivity.entity_to_entities(dim, dim - 1);
2473 for (
unsigned int cell = 0; cell < cells.size(); ++cell)
2474 for (
unsigned int i = crs.ptr[cell]; i < crs.ptr[cell + 1]; ++i)
2475 count[crs.col[i]]++;
2478 for (
unsigned int face = 0; face < count.size(); ++face)
2480 if (count[face] != 1)
2484 bids_face[face].boundary_id = 0;
2490 const auto &crs = connectivity.entity_to_entities(2, 1);
2491 for (
unsigned int i = crs.ptr[face]; i < crs.ptr[face + 1]; ++i)
2492 tria.
faces->lines.boundary_or_material_id[crs.col[i]]
2498 static const unsigned int t_tba =
static_cast<unsigned int>(-1);
2499 static const unsigned int t_inner =
static_cast<unsigned int>(-2);
2501 std::vector<unsigned int> type(
vertices.size(), t_tba);
2503 const auto &crs = connectivity.entity_to_entities(1, 0);
2505 for (
unsigned int cell = 0; cell < cells.size(); ++cell)
2506 for (
unsigned int i = crs.ptr[cell], j = 0; i < crs.ptr[cell + 1];
2508 if (type[crs.col[i]] != t_inner)
2509 type[crs.col[i]] = type[crs.col[i]] == t_tba ? j : t_inner;
2511 for (
unsigned int face = 0; face < type.size(); ++face)
2516 if (type[face] != t_inner && type[face] != t_tba)
2537 template <
int structdim,
int spacedim,
typename T>
2547 if (boundary_objects_in.size() == 0)
2551 auto boundary_objects = boundary_objects_in;
2554 for (
auto &boundary_object : boundary_objects)
2555 std::sort(boundary_object.vertices.begin(),
2556 boundary_object.vertices.end());
2559 std::sort(boundary_objects.begin(),
2560 boundary_objects.end(),
2561 [](
const auto &a,
const auto &b) {
2562 return a.vertices < b.vertices;
2565 unsigned int counter = 0;
2567 std::vector<unsigned int> key;
2570 for (
unsigned int o = 0; o < obj.
n_objects(); ++o)
2584 key.assign(crs.
col.data() + crs.
ptr[o],
2585 crs.
col.data() + crs.
ptr[o + 1]);
2586 std::sort(key.begin(), key.end());
2589 const auto subcell_object =
2590 std::lower_bound(boundary_objects.begin(),
2591 boundary_objects.end(),
2593 [&](
const auto &cell,
const auto &key) {
2594 return cell.vertices < key;
2598 if (subcell_object == boundary_objects.end() ||
2599 subcell_object->vertices != key)
2605 manifold_id = subcell_object->manifold_id;
2608 if (subcell_object->boundary_id !=
2611 (void)vertex_locations;
2615 "The input arguments for creating a triangulation "
2616 "specified a boundary id for an internal face. This "
2619 "The object in question has vertex indices " +
2620 [subcell_object]() {
2622 for (
const auto v : subcell_object->vertices)
2623 s += std::to_string(v) +
',';
2626 " which are located at positions " +
2627 [vertex_locations, subcell_object]() {
2628 std::ostringstream s;
2629 for (
const auto v : subcell_object->vertices)
2630 s <<
'(' << vertex_locations[v] <<
')';
2634 boundary_id = subcell_object->boundary_id;
2647 const unsigned structdim,
2648 const unsigned int size)
2650 const unsigned int dim = faces.
dim;
2652 const unsigned int max_faces_per_cell = 2 * structdim;
2654 if (dim == 3 && structdim == 2)
2669 const unsigned int spacedim,
2670 const unsigned int size,
2671 const bool orientation_needed)
2673 const unsigned int dim =
level.dim;
2675 const unsigned int max_faces_per_cell = 2 * dim;
2677 level.active_cell_indices.assign(size, -1);
2678 level.subdomain_ids.assign(size, 0);
2679 level.level_subdomain_ids.assign(size, 0);
2681 level.refine_flags.assign(size, 0u);
2682 level.coarsen_flags.assign(size,
false);
2684 level.parents.assign((size + 1) / 2, -1);
2687 level.direction_flags.assign(size,
true);
2689 level.neighbors.assign(size * max_faces_per_cell, {-1, -1});
2693 if (orientation_needed)
2694 level.face_orientations.assign(size * max_faces_per_cell, -1);
2696 level.global_active_cell_indices.assign(size,
2698 level.global_level_cell_indices.assign(size,
2707 const unsigned int structdim = obj.
structdim;
2709 const unsigned int max_children_per_cell = 1 << structdim;
2710 const unsigned int max_faces_per_cell = 2 * structdim;
2712 obj.
used.assign(size,
true);
2716 BoundaryOrMaterialId());
2724 obj.
children.assign(max_children_per_cell / 2 * size, -1);
2726 obj.
cells.assign(max_faces_per_cell * size, -1);
2756 template <
int spacedim>
2760 std::vector<unsigned int> &,
2761 std::vector<unsigned int> &)
2763 const unsigned int dim = 1;
2775 Assert(!cell->child(0)->has_children() &&
2776 !cell->child(1)->has_children(),
2782 if (cell->neighbor(0)->has_children())
2789 neighbor = neighbor->child(1);
2792 Assert(neighbor->neighbor(1) == cell->child(0),
2794 neighbor->set_neighbor(1, cell);
2800 if (neighbor->has_children())
2801 neighbor = neighbor->child(1);
2810 if (cell->neighbor(1)->has_children())
2817 neighbor = neighbor->child(0);
2820 Assert(neighbor->neighbor(0) == cell->child(1),
2822 neighbor->set_neighbor(0, cell);
2828 if (neighbor->has_children())
2829 neighbor = neighbor->child(0);
2839 triangulation.vertices_used[cell->child(0)->vertex_index(1)] =
false;
2845 for (
unsigned int child = 0; child < cell->n_children(); ++child)
2847 cell->child(child)->clear_user_data();
2848 cell->child(child)->clear_user_flag();
2849 cell->child(child)->clear_used_flag();
2854 cell->clear_children();
2855 cell->clear_user_flag();
2860 template <
int spacedim>
2864 std::vector<unsigned int> &line_cell_count,
2865 std::vector<unsigned int> &)
2867 const unsigned int dim = 2;
2875 std::vector<typename Triangulation<dim, spacedim>::line_iterator>
2878 lines_to_delete.reserve(4 * 2 + 4);
2883 for (
unsigned int c = 0; c < cell->n_children(); ++c)
2887 for (
unsigned int l = 0; l < GeometryInfo<dim>::lines_per_cell; ++l)
2888 --line_cell_count[child->line_index(l)];
2903 .vertices_used[cell->child(0)->line(1)->vertex_index(1)] =
false;
2905 lines_to_delete.push_back(cell->child(0)->line(1));
2906 lines_to_delete.push_back(cell->child(0)->line(3));
2907 lines_to_delete.push_back(cell->child(3)->line(0));
2908 lines_to_delete.push_back(cell->child(3)->line(2));
2912 unsigned int inner_face_no =
2917 lines_to_delete.push_back(cell->child(0)->line(inner_face_no));
2921 for (
unsigned int child = 0; child < cell->n_children(); ++child)
2923 cell->child(child)->clear_user_data();
2924 cell->child(child)->clear_user_flag();
2925 cell->child(child)->clear_used_flag();
2930 cell->clear_children();
2931 cell->clear_refinement_case();
2932 cell->clear_user_flag();
2938 for (
unsigned int line_no = 0;
2939 line_no < GeometryInfo<dim>::lines_per_cell;
2943 cell->line(line_no);
2945 if (line->has_children())
2950 Assert((line_cell_count[line->child_index(0)] == 0 &&
2951 line_cell_count[line->child_index(1)] == 0) ||
2952 (line_cell_count[line->child_index(0)] > 0 &&
2953 line_cell_count[line->child_index(1)] > 0),
2956 if (line_cell_count[line->child_index(0)] == 0)
2958 for (
unsigned int c = 0; c < 2; ++c)
2959 Assert(!line->child(c)->has_children(),
2967 .vertices_used[line->child(0)->vertex_index(1)] =
false;
2969 lines_to_delete.push_back(line->child(0));
2970 lines_to_delete.push_back(line->child(1));
2972 line->clear_children();
2984 typename std::vector<
2986 line = lines_to_delete.
begin(),
2987 endline = lines_to_delete.end();
2988 for (; line != endline; ++line)
2990 (*line)->clear_user_data();
2991 (*line)->clear_user_flag();
2992 (*line)->clear_used_flag();
2998 template <
int spacedim>
3002 std::vector<unsigned int> &line_cell_count,
3003 std::vector<unsigned int> &quad_cell_count)
3005 const unsigned int dim = 3;
3017 std::vector<typename Triangulation<dim, spacedim>::line_iterator>
3019 std::vector<typename Triangulation<dim, spacedim>::quad_iterator>
3022 lines_to_delete.reserve(12 * 2 + 6 * 4 + 6);
3023 quads_to_delete.reserve(6 * 4 + 12);
3027 for (
unsigned int c = 0; c < cell->n_children(); ++c)
3031 for (
unsigned int l = 0; l < GeometryInfo<dim>::lines_per_cell; ++l)
3032 --line_cell_count[child->line_index(l)];
3034 --quad_cell_count[child->quad_index(f)];
3048 quads_to_delete.push_back(cell->child(0)->face(1));
3051 quads_to_delete.push_back(cell->child(0)->face(3));
3054 quads_to_delete.push_back(cell->child(0)->face(5));
3057 quads_to_delete.push_back(cell->child(0)->face(1));
3058 quads_to_delete.push_back(cell->child(0)->face(3));
3059 quads_to_delete.push_back(cell->child(3)->face(0));
3060 quads_to_delete.push_back(cell->child(3)->face(2));
3062 lines_to_delete.push_back(cell->child(0)->line(11));
3065 quads_to_delete.push_back(cell->child(0)->face(1));
3066 quads_to_delete.push_back(cell->child(0)->face(5));
3067 quads_to_delete.push_back(cell->child(3)->face(0));
3068 quads_to_delete.push_back(cell->child(3)->face(4));
3070 lines_to_delete.push_back(cell->child(0)->line(5));
3073 quads_to_delete.push_back(cell->child(0)->face(3));
3074 quads_to_delete.push_back(cell->child(0)->face(5));
3075 quads_to_delete.push_back(cell->child(3)->face(2));
3076 quads_to_delete.push_back(cell->child(3)->face(4));
3078 lines_to_delete.push_back(cell->child(0)->line(7));
3081 quads_to_delete.push_back(cell->child(0)->face(1));
3082 quads_to_delete.push_back(cell->child(2)->face(1));
3083 quads_to_delete.push_back(cell->child(4)->face(1));
3084 quads_to_delete.push_back(cell->child(6)->face(1));
3086 quads_to_delete.push_back(cell->child(0)->face(3));
3087 quads_to_delete.push_back(cell->child(1)->face(3));
3088 quads_to_delete.push_back(cell->child(4)->face(3));
3089 quads_to_delete.push_back(cell->child(5)->face(3));
3091 quads_to_delete.push_back(cell->child(0)->face(5));
3092 quads_to_delete.push_back(cell->child(1)->face(5));
3093 quads_to_delete.push_back(cell->child(2)->face(5));
3094 quads_to_delete.push_back(cell->child(3)->face(5));
3096 lines_to_delete.push_back(cell->child(0)->line(5));
3097 lines_to_delete.push_back(cell->child(0)->line(7));
3098 lines_to_delete.push_back(cell->child(0)->line(11));
3099 lines_to_delete.push_back(cell->child(7)->line(0));
3100 lines_to_delete.push_back(cell->child(7)->line(2));
3101 lines_to_delete.push_back(cell->child(7)->line(8));
3107 triangulation.vertices_used[cell->child(0)->vertex_index(7)] =
3119 for (
unsigned int child = 0; child < cell->n_children(); ++child)
3121 cell->child(child)->clear_user_data();
3122 cell->child(child)->clear_user_flag();
3129 cell->child(child)->set_face_orientation(f,
true);
3130 cell->child(child)->set_face_flip(f,
false);
3131 cell->child(child)->set_face_rotation(f,
false);
3134 cell->child(child)->clear_used_flag();
3139 cell->clear_children();
3140 cell->clear_refinement_case();
3141 cell->clear_user_flag();
3154 cell->face(quad_no);
3158 quad->has_children()) ||
3163 switch (quad->refinement_case())
3175 Assert((quad_cell_count[quad->child_index(0)] == 0 &&
3176 quad_cell_count[quad->child_index(1)] == 0) ||
3177 (quad_cell_count[quad->child_index(0)] > 0 &&
3178 quad_cell_count[quad->child_index(1)] > 0),
3184 unsigned int deleted_grandchildren = 0;
3185 unsigned int number_of_child_refinements = 0;
3187 for (
unsigned int c = 0; c < 2; ++c)
3188 if (quad->child(c)->has_children())
3190 ++number_of_child_refinements;
3195 (quad_cell_count[quad->child(c)->child_index(0)] ==
3197 quad_cell_count[quad->child(c)->child_index(1)] ==
3199 (quad_cell_count[quad->child(c)->child_index(0)] >
3201 quad_cell_count[quad->child(c)->child_index(1)] >
3204 if (quad_cell_count[quad->child(c)->child_index(0)] ==
3211 Assert(quad->refinement_case() +
3212 quad->child(c)->refinement_case() ==
3220 quads_to_delete.push_back(
3221 quad->child(c)->child(0));
3222 quads_to_delete.push_back(
3223 quad->child(c)->child(1));
3224 if (quad->child(c)->refinement_case() ==
3226 lines_to_delete.push_back(
3227 quad->child(c)->child(0)->line(1));
3229 lines_to_delete.push_back(
3230 quad->child(c)->child(0)->line(3));
3231 quad->child(c)->clear_children();
3232 quad->child(c)->clear_refinement_case();
3233 ++deleted_grandchildren;
3241 if (number_of_child_refinements > 0 &&
3242 deleted_grandchildren == number_of_child_refinements)
3247 middle_line = quad->child(0)->line(1);
3249 middle_line = quad->child(0)->line(3);
3251 lines_to_delete.push_back(middle_line->child(0));
3252 lines_to_delete.push_back(middle_line->child(1));
3254 .vertices_used[middle_vertex_index<dim, spacedim>(
3255 middle_line)] =
false;
3256 middle_line->clear_children();
3261 if (quad_cell_count[quad->child_index(0)] == 0)
3267 quads_to_delete.push_back(quad->child(0));
3268 quads_to_delete.push_back(quad->child(1));
3270 lines_to_delete.push_back(quad->child(0)->line(1));
3272 lines_to_delete.push_back(quad->child(0)->line(3));
3292 if (quad->child(0)->has_children())
3293 if (quad->refinement_case() ==
3327 quad_iterator switch_1 =
3328 quad->child(0)->child(1),
3330 quad->child(1)->child(0);
3332 Assert(!switch_1->has_children(),
3334 Assert(!switch_2->has_children(),
3337 const int switch_1_index = switch_1->index();
3338 const int switch_2_index = switch_2->index();
3339 for (
unsigned int l = 0;
3342 for (
unsigned int h = 0;
3346 for (
const unsigned int q :
3351 ->cells.get_bounding_object_indices(
3353 if (
index == switch_1_index)
3355 ->cells.get_bounding_object_indices(
3356 h)[q] = switch_2_index;
3357 else if (
index == switch_2_index)
3359 ->cells.get_bounding_object_indices(
3360 h)[q] = switch_1_index;
3365 const int switch_1_lines[4] = {
3366 static_cast<signed int>(
3367 switch_1->line_index(0)),
3368 static_cast<signed int>(
3369 switch_1->line_index(1)),
3370 static_cast<signed int>(
3371 switch_1->line_index(2)),
3372 static_cast<signed int>(
3373 switch_1->line_index(3))};
3374 const bool switch_1_line_orientations[4] = {
3375 switch_1->line_orientation(0),
3376 switch_1->line_orientation(1),
3377 switch_1->line_orientation(2),
3378 switch_1->line_orientation(3)};
3380 switch_1->boundary_id();
3381 const unsigned int switch_1_user_index =
3382 switch_1->user_index();
3383 const bool switch_1_user_flag =
3384 switch_1->user_flag_set();
3386 switch_1->set_bounding_object_indices(
3387 {switch_2->line_index(0),
3388 switch_2->line_index(1),
3389 switch_2->line_index(2),
3390 switch_2->line_index(3)});
3391 switch_1->set_line_orientation(
3392 0, switch_2->line_orientation(0));
3393 switch_1->set_line_orientation(
3394 1, switch_2->line_orientation(1));
3395 switch_1->set_line_orientation(
3396 2, switch_2->line_orientation(2));
3397 switch_1->set_line_orientation(
3398 3, switch_2->line_orientation(3));
3399 switch_1->set_boundary_id_internal(
3400 switch_2->boundary_id());
3401 switch_1->set_manifold_id(
3402 switch_2->manifold_id());
3403 switch_1->set_user_index(switch_2->user_index());
3404 if (switch_2->user_flag_set())
3405 switch_1->set_user_flag();
3407 switch_1->clear_user_flag();
3409 switch_2->set_bounding_object_indices(
3413 switch_1_lines[3]});
3414 switch_2->set_line_orientation(
3415 0, switch_1_line_orientations[0]);
3416 switch_2->set_line_orientation(
3417 1, switch_1_line_orientations[1]);
3418 switch_2->set_line_orientation(
3419 2, switch_1_line_orientations[2]);
3420 switch_2->set_line_orientation(
3421 3, switch_1_line_orientations[3]);
3422 switch_2->set_boundary_id_internal(
3423 switch_1_boundary_id);
3424 switch_2->set_manifold_id(
3425 switch_1->manifold_id());
3426 switch_2->set_user_index(switch_1_user_index);
3427 if (switch_1_user_flag)
3428 switch_2->set_user_flag();
3430 switch_2->clear_user_flag();
3432 const unsigned int child_0 =
3433 quad->child(0)->child_index(0);
3434 const unsigned int child_2 =
3435 quad->child(1)->child_index(0);
3436 quad->clear_children();
3437 quad->clear_refinement_case();
3438 quad->set_refinement_case(
3440 quad->set_children(0, child_0);
3441 quad->set_children(2, child_2);
3442 std::swap(quad_cell_count[child_0 + 1],
3443 quad_cell_count[child_2]);
3458 const unsigned int child_0 =
3459 quad->child(0)->child_index(0);
3460 const unsigned int child_2 =
3461 quad->child(1)->child_index(0);
3462 quad->clear_children();
3463 quad->clear_refinement_case();
3464 quad->set_refinement_case(
3466 quad->set_children(0, child_0);
3467 quad->set_children(2, child_2);
3471 quad->clear_children();
3472 quad->clear_refinement_case();
3483 Assert((quad_cell_count[quad->child_index(0)] == 0 &&
3484 quad_cell_count[quad->child_index(1)] == 0 &&
3485 quad_cell_count[quad->child_index(2)] == 0 &&
3486 quad_cell_count[quad->child_index(3)] == 0) ||
3487 (quad_cell_count[quad->child_index(0)] > 0 &&
3488 quad_cell_count[quad->child_index(1)] > 0 &&
3489 quad_cell_count[quad->child_index(2)] > 0 &&
3490 quad_cell_count[quad->child_index(3)] > 0),
3493 if (quad_cell_count[quad->child_index(0)] == 0)
3499 lines_to_delete.push_back(quad->child(0)->line(1));
3500 lines_to_delete.push_back(quad->child(3)->line(0));
3501 lines_to_delete.push_back(quad->child(0)->line(3));
3502 lines_to_delete.push_back(quad->child(3)->line(2));
3504 for (
unsigned int child = 0; child < quad->n_children();
3506 quads_to_delete.push_back(quad->child(child));
3509 .vertices_used[quad->child(0)->vertex_index(3)] =
3512 quad->clear_children();
3513 quad->clear_refinement_case();
3532 for (
unsigned int line_no = 0;
3533 line_no < GeometryInfo<dim>::lines_per_cell;
3537 cell->line(line_no);
3541 line->has_children()) ||
3546 if (line->has_children())
3551 Assert((line_cell_count[line->child_index(0)] == 0 &&
3552 line_cell_count[line->child_index(1)] == 0) ||
3553 (line_cell_count[line->child_index(0)] > 0 &&
3554 line_cell_count[line->child_index(1)] > 0),
3557 if (line_cell_count[line->child_index(0)] == 0)
3559 for (
unsigned int c = 0; c < 2; ++c)
3560 Assert(!line->child(c)->has_children(),
3568 .vertices_used[line->child(0)->vertex_index(1)] =
false;
3570 lines_to_delete.push_back(line->child(0));
3571 lines_to_delete.push_back(line->child(1));
3573 line->clear_children();
3585 typename std::vector<
3587 line = lines_to_delete.
begin(),
3588 endline = lines_to_delete.end();
3589 for (; line != endline; ++line)
3591 (*line)->clear_user_data();
3592 (*line)->clear_user_flag();
3593 (*line)->clear_used_flag();
3596 typename std::vector<
3598 quad = quads_to_delete.
begin(),
3599 endquad = quads_to_delete.end();
3600 for (; quad != endquad; ++quad)
3602 (*quad)->clear_user_data();
3603 (*quad)->clear_children();
3604 (*quad)->clear_refinement_case();
3605 (*quad)->clear_user_flag();
3606 (*quad)->clear_used_flag();
3628 template <
int spacedim>
3632 unsigned int & next_unused_vertex,
3639 const unsigned int dim = 2;
3642 cell->clear_refine_flag();
3735 int new_vertices[9];
3736 for (
unsigned int vertex_no = 0; vertex_no < 4; ++vertex_no)
3737 new_vertices[vertex_no] = cell->vertex_index(vertex_no);
3738 for (
unsigned int line_no = 0; line_no < 4; ++line_no)
3739 if (cell->line(line_no)->has_children())
3740 new_vertices[4 + line_no] =
3741 cell->line(line_no)->child(0)->vertex_index(1);
3750 while (
triangulation.vertices_used[next_unused_vertex] ==
true)
3751 ++next_unused_vertex;
3754 "Internal error: During refinement, the triangulation "
3755 "wants to access an element of the 'vertices' array "
3756 "but it turns out that the array is not large enough."));
3759 new_vertices[8] = next_unused_vertex;
3765 cell->center(
true,
true);
3771 unsigned int lmin = 8;
3772 unsigned int lmax = 12;
3779 for (
unsigned int l = lmin; l < lmax; ++l)
3781 while (next_unused_line->used() ==
true)
3783 new_lines[l] = next_unused_line;
3801 for (
unsigned int c = 0; c < 2; ++c, ++l)
3802 new_lines[l] = cell->line(face_no)->child(c);
3805 new_lines[8]->set_bounding_object_indices(
3806 {new_vertices[6], new_vertices[8]});
3807 new_lines[9]->set_bounding_object_indices(
3808 {new_vertices[8], new_vertices[7]});
3809 new_lines[10]->set_bounding_object_indices(
3810 {new_vertices[4], new_vertices[8]});
3811 new_lines[11]->set_bounding_object_indices(
3812 {new_vertices[8], new_vertices[5]});
3821 new_lines[0] = cell->line(0);
3822 new_lines[1] = cell->line(1);
3823 new_lines[2] = cell->line(2)->child(0);
3824 new_lines[3] = cell->line(2)->child(1);
3825 new_lines[4] = cell->line(3)->child(0);
3826 new_lines[5] = cell->line(3)->child(1);
3827 new_lines[6]->set_bounding_object_indices(
3828 {new_vertices[6], new_vertices[7]});
3838 new_lines[0] = cell->line(0)->child(0);
3839 new_lines[1] = cell->line(0)->child(1);
3840 new_lines[2] = cell->line(1)->child(0);
3841 new_lines[3] = cell->line(1)->child(1);
3842 new_lines[4] = cell->line(2);
3843 new_lines[5] = cell->line(3);
3844 new_lines[6]->set_bounding_object_indices(
3845 {new_vertices[4], new_vertices[5]});
3848 for (
unsigned int l = lmin; l < lmax; ++l)
3850 new_lines[l]->set_used_flag();
3851 new_lines[l]->clear_user_flag();
3853 new_lines[l]->clear_children();
3855 new_lines[l]->set_boundary_id_internal(
3857 new_lines[l]->set_manifold_id(cell->manifold_id());
3864 while (next_unused_cell->used() ==
true)
3868 for (
unsigned int i = 0; i < n_children; ++i)
3871 subcells[i] = next_unused_cell;
3873 if (i % 2 == 1 && i < n_children - 1)
3874 while (next_unused_cell->used() ==
true)
3892 subcells[0]->set_bounding_object_indices({new_lines[0]->index(),
3893 new_lines[8]->
index(),
3894 new_lines[4]->
index(),
3895 new_lines[10]->
index()});
3896 subcells[1]->set_bounding_object_indices({new_lines[8]->index(),
3897 new_lines[2]->
index(),
3898 new_lines[5]->
index(),
3899 new_lines[11]->
index()});
3900 subcells[2]->set_bounding_object_indices({new_lines[1]->index(),
3901 new_lines[9]->
index(),
3902 new_lines[10]->
index(),
3903 new_lines[6]->
index()});
3904 subcells[3]->set_bounding_object_indices({new_lines[9]->index(),
3905 new_lines[3]->
index(),
3906 new_lines[11]->
index(),
3907 new_lines[7]->
index()});
3923 subcells[0]->set_bounding_object_indices({new_lines[0]->index(),
3924 new_lines[6]->
index(),
3925 new_lines[2]->
index(),
3926 new_lines[4]->
index()});
3927 subcells[1]->set_bounding_object_indices({new_lines[6]->index(),
3928 new_lines[1]->
index(),
3929 new_lines[3]->
index(),
3930 new_lines[5]->
index()});
3947 subcells[0]->set_bounding_object_indices({new_lines[0]->index(),
3948 new_lines[2]->
index(),
3949 new_lines[4]->
index(),
3950 new_lines[6]->
index()});
3951 subcells[1]->set_bounding_object_indices({new_lines[1]->index(),
3952 new_lines[3]->
index(),
3953 new_lines[6]->
index(),
3954 new_lines[5]->
index()});
3959 for (
unsigned int i = 0; i < n_children; ++i)
3961 subcells[i]->set_used_flag();
3962 subcells[i]->clear_refine_flag();
3963 subcells[i]->clear_user_flag();
3964 subcells[i]->clear_user_data();
3965 subcells[i]->clear_children();
3967 subcells[i]->set_material_id(cell->material_id());
3968 subcells[i]->set_manifold_id(cell->manifold_id());
3969 subcells[i]->set_subdomain_id(subdomainid);
3972 subcells[i]->set_parent(cell->index());
3978 for (
unsigned int i = 0; i < n_children / 2; ++i)
3979 cell->set_children(2 * i, subcells[2 * i]->index());
3981 cell->set_refinement_case(ref_case);
3989 for (
unsigned int c = 0; c < n_children; ++c)
3990 cell->child(c)->set_direction_flag(cell->direction_flag());
3995 template <
int dim,
int spacedim>
3998 const bool check_for_distorted_cells)
4004 for (
const auto &cell :
triangulation.active_cell_iterators_on_level(
4006 if (cell->refine_flag_set())
4019 line->clear_user_flag();
4023 unsigned int n_single_lines = 0;
4024 unsigned int n_lines_in_pairs = 0;
4025 unsigned int needed_vertices = 0;
4031 unsigned int needed_cells = 0;
4033 for (
const auto &cell :
4035 if (cell->refine_flag_set())
4037 if (cell->reference_cell() ==
4041 needed_vertices += 0;
4042 n_single_lines += 3;
4044 else if (cell->reference_cell() ==
4048 needed_vertices += 1;
4049 n_single_lines += 4;
4056 for (
const auto line_no : cell->face_indices())
4058 auto line = cell->line(line_no);
4059 if (line->has_children() ==
false)
4060 line->set_user_flag();
4065 const unsigned int used_cells =
4072 used_cells + needed_cells,
4084 if (line->user_flag_set())
4087 n_lines_in_pairs += 2;
4088 needed_vertices += 1;
4093 needed_vertices += std::count(
triangulation.vertices_used.begin(),
4103 unsigned int next_unused_vertex = 0;
4112 for (; line != endl; ++line)
4113 if (line->user_flag_set())
4119 while (
triangulation.vertices_used[next_unused_vertex] ==
true)
4120 ++next_unused_vertex;
4124 "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."));
4127 triangulation.vertices[next_unused_vertex] = line->center(
true);
4129 bool pair_found =
false;
4131 for (; next_unused_line != endl; ++next_unused_line)
4132 if (!next_unused_line->used() &&
4133 !(++next_unused_line)->used())
4141 line->set_children(0, next_unused_line->index());
4144 children[2] = {next_unused_line, ++next_unused_line};
4149 children[0]->set_bounding_object_indices(
4150 {line->vertex_index(0), next_unused_vertex});
4151 children[1]->set_bounding_object_indices(
4152 {next_unused_vertex, line->vertex_index(1)});
4154 children[0]->set_used_flag();
4155 children[1]->set_used_flag();
4156 children[0]->clear_children();
4157 children[1]->clear_children();
4160 children[0]->clear_user_flag();
4161 children[1]->clear_user_flag();
4164 children[0]->set_boundary_id_internal(line->boundary_id());
4165 children[1]->set_boundary_id_internal(line->boundary_id());
4167 children[0]->set_manifold_id(line->manifold_id());
4168 children[1]->set_manifold_id(line->manifold_id());
4170 line->clear_user_flag();
4177 cells_with_distorted_children;
4183 unsigned int &next_unused_vertex,
4184 auto & next_unused_line,
4185 auto & next_unused_cell,
4186 const auto & cell) {
4187 const auto ref_case = cell->refine_flag_set();
4188 cell->clear_refine_flag();
4190 unsigned int n_new_vertices = 0;
4194 else if (cell->reference_cell() ==
4200 std::vector<int> new_vertices(n_new_vertices);
4201 for (
unsigned int vertex_no = 0; vertex_no < cell->n_vertices();
4203 new_vertices[vertex_no] = cell->vertex_index(vertex_no);
4204 for (
unsigned int line_no = 0; line_no < cell->n_lines(); ++line_no)
4205 if (cell->line(line_no)->has_children())
4206 new_vertices[cell->n_vertices() + line_no] =
4207 cell->line(line_no)->child(0)->vertex_index(1);
4211 while (
triangulation.vertices_used[next_unused_vertex] ==
true)
4212 ++next_unused_vertex;
4216 "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."));
4219 new_vertices[8] = next_unused_vertex;
4222 cell->center(
true,
true);
4225 std::array<typename Triangulation<dim, spacedim>::raw_line_iterator,
4228 unsigned int lmin = 0;
4229 unsigned int lmax = 0;
4236 else if (cell->reference_cell() ==
4247 for (
unsigned int l = lmin; l < lmax; ++l)
4249 while (next_unused_line->used() ==
true)
4251 new_lines[l] = next_unused_line;
4262 const auto ref = [&](
const unsigned int face_no,
4263 const unsigned int vertex_no) {
4264 if (cell->line(face_no)->child(0)->vertex_index(0) ==
4265 static_cast<unsigned int>(new_vertices[vertex_no]) ||
4266 cell->line(face_no)->child(0)->vertex_index(1) ==
4267 static_cast<unsigned int>(new_vertices[vertex_no]))
4269 new_lines[2 * face_no + 0] =
4270 cell->line(face_no)->child(0);
4271 new_lines[2 * face_no + 1] =
4272 cell->line(face_no)->child(1);
4276 new_lines[2 * face_no + 0] =
4277 cell->line(face_no)->child(1);
4278 new_lines[2 * face_no + 1] =
4279 cell->line(face_no)->child(0);
4287 new_lines[6]->set_bounding_object_indices(
4288 {new_vertices[3], new_vertices[4]});
4289 new_lines[7]->set_bounding_object_indices(
4290 {new_vertices[4], new_vertices[5]});
4291 new_lines[8]->set_bounding_object_indices(
4292 {new_vertices[5], new_vertices[3]});
4294 else if (cell->reference_cell() ==
4298 for (
const unsigned int face_no : cell->face_indices())
4299 for (
unsigned int c = 0; c < 2; ++c, ++l)
4300 new_lines[l] = cell->line(face_no)->child(c);
4302 new_lines[8]->set_bounding_object_indices(
4303 {new_vertices[6], new_vertices[8]});
4304 new_lines[9]->set_bounding_object_indices(
4305 {new_vertices[8], new_vertices[7]});
4306 new_lines[10]->set_bounding_object_indices(
4307 {new_vertices[4], new_vertices[8]});
4308 new_lines[11]->set_bounding_object_indices(
4309 {new_vertices[8], new_vertices[5]});
4318 for (
unsigned int l = lmin; l < lmax; ++l)
4320 new_lines[l]->set_used_flag();
4321 new_lines[l]->clear_user_flag();
4322 new_lines[l]->clear_user_data();
4323 new_lines[l]->clear_children();
4325 new_lines[l]->set_boundary_id_internal(
4327 new_lines[l]->set_manifold_id(cell->manifold_id());
4332 while (next_unused_cell->used() ==
true)
4335 unsigned int n_children = 0;
4339 else if (cell->reference_cell() ==
4345 for (
unsigned int i = 0; i < n_children; ++i)
4348 subcells[i] = next_unused_cell;
4350 if (i % 2 == 1 && i < n_children - 1)
4351 while (next_unused_cell->used() ==
true)
4358 subcells[0]->set_bounding_object_indices({new_lines[0]->index(),
4359 new_lines[8]->
index(),
4360 new_lines[5]->
index()});
4361 subcells[1]->set_bounding_object_indices({new_lines[1]->index(),
4362 new_lines[2]->
index(),
4363 new_lines[6]->
index()});
4364 subcells[2]->set_bounding_object_indices({new_lines[7]->index(),
4365 new_lines[3]->
index(),
4366 new_lines[4]->
index()});
4367 subcells[3]->set_bounding_object_indices({new_lines[6]->index(),
4368 new_lines[7]->
index(),
4369 new_lines[8]->
index()});
4373 const auto ref = [&](
const unsigned int line_no,
4374 const unsigned int vertex_no,
4375 const unsigned int subcell_no,
4376 const unsigned int subcell_line_no) {
4377 if (new_lines[line_no]->vertex_index(1) !=
4378 static_cast<unsigned int>(new_vertices[vertex_no]))
4380 ->face_orientations[subcells[subcell_no]->index() *
4382 subcell_line_no] = 0;
4406 else if ((dim == 2) && (cell->reference_cell() ==
4409 subcells[0]->set_bounding_object_indices(
4410 {new_lines[0]->index(),
4411 new_lines[8]->
index(),
4412 new_lines[4]->
index(),
4413 new_lines[10]->
index()});
4414 subcells[1]->set_bounding_object_indices(
4415 {new_lines[8]->index(),
4416 new_lines[2]->
index(),
4417 new_lines[5]->
index(),
4418 new_lines[11]->
index()});
4419 subcells[2]->set_bounding_object_indices({new_lines[1]->index(),
4420 new_lines[9]->
index(),
4421 new_lines[10]->
index(),
4422 new_lines[6]->
index()});
4423 subcells[3]->set_bounding_object_indices({new_lines[9]->index(),
4424 new_lines[3]->
index(),
4425 new_lines[11]->
index(),
4426 new_lines[7]->
index()});
4435 for (
unsigned int i = 0; i < n_children; ++i)
4437 subcells[i]->set_used_flag();
4438 subcells[i]->clear_refine_flag();
4439 subcells[i]->clear_user_flag();
4440 subcells[i]->clear_user_data();
4441 subcells[i]->clear_children();
4444 subcells[i]->set_material_id(cell->material_id());
4445 subcells[i]->set_manifold_id(cell->manifold_id());
4446 subcells[i]->set_subdomain_id(subdomainid);
4451 ->reference_cell[subcells[i]->index()] = cell->reference_cell();
4454 subcells[i]->set_parent(cell->index());
4457 for (
unsigned int i = 0; i < n_children / 2; ++i)
4458 cell->set_children(2 * i, subcells[2 * i]->index());
4460 cell->set_refinement_case(ref_case);
4463 for (
unsigned int c = 0; c < n_children; ++c)
4464 cell->child(c)->set_direction_flag(cell->direction_flag());
4474 for (
const auto &cell :
4476 if (cell->refine_flag_set())
4484 if (cell->reference_cell() ==
4486 check_for_distorted_cells &&
4487 has_distorted_children<dim, spacedim>(cell))
4495 return cells_with_distorted_children;
4504 template <
int spacedim>
4509 const unsigned int dim = 1;
4513 for (
const auto &cell :
triangulation.active_cell_iterators_on_level(
4515 if (cell->refine_flag_set())
4528 unsigned int needed_vertices = 0;
4533 unsigned int flagged_cells = 0;
4535 for (
const auto &acell :
4537 if (acell->refine_flag_set())
4542 const unsigned int used_cells =
4562 needed_vertices += flagged_cells;
4567 needed_vertices += std::count(
triangulation.vertices_used.begin(),
4584 unsigned int next_unused_vertex = 0;
4591 for (
const auto &cell :
4593 if (cell->refine_flag_set())
4596 cell->clear_refine_flag();
4602 ++next_unused_vertex;
4606 "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."));
4621 while (next_unused_cell->used() ==
true)
4623 first_child = next_unused_cell;
4624 first_child->set_used_flag();
4625 first_child->clear_user_data();
4628 second_child = next_unused_cell;
4629 second_child->set_used_flag();
4630 second_child->clear_user_data();
4635 cell->set_children(0, first_child->index());
4636 first_child->clear_children();
4637 first_child->set_bounding_object_indices(
4638 {cell->vertex_index(0), next_unused_vertex});
4639 first_child->set_material_id(cell->material_id());
4640 first_child->set_manifold_id(cell->manifold_id());
4641 first_child->set_subdomain_id(subdomainid);
4642 first_child->set_direction_flag(cell->direction_flag());
4644 first_child->set_parent(cell->index());
4648 first_child->face(1)->set_manifold_id(cell->manifold_id());
4653 first_child->set_neighbor(1, second_child);
4655 first_child->set_neighbor(0, cell->neighbor(0));
4656 else if (cell->neighbor(0)->is_active())
4662 Assert(cell->neighbor(0)->level() <= cell->level(),
4664 first_child->set_neighbor(0, cell->neighbor(0));
4670 const unsigned int nbnb = cell->neighbor_of_neighbor(0);
4671 first_child->set_neighbor(0,
4672 cell->neighbor(0)->child(nbnb));
4677 left_neighbor = cell->neighbor(0);
4678 while (left_neighbor->has_children())
4680 left_neighbor = left_neighbor->child(nbnb);
4681 left_neighbor->set_neighbor(nbnb, first_child);
4686 second_child->clear_children();
4687 second_child->set_bounding_object_indices(
4688 {next_unused_vertex, cell->vertex_index(1)});
4689 second_child->set_neighbor(0, first_child);
4690 second_child->set_material_id(cell->material_id());
4691 second_child->set_manifold_id(cell->manifold_id());
4692 second_child->set_subdomain_id(subdomainid);
4693 second_child->set_direction_flag(cell->direction_flag());
4696 second_child->set_neighbor(1, cell->neighbor(1));
4697 else if (cell->neighbor(1)->is_active())
4699 Assert(cell->neighbor(1)->level() <= cell->level(),
4701 second_child->set_neighbor(1, cell->neighbor(1));
4706 const unsigned int nbnb = cell->neighbor_of_neighbor(1);
4707 second_child->set_neighbor(
4708 1, cell->neighbor(1)->child(nbnb));
4711 right_neighbor = cell->neighbor(1);
4712 while (right_neighbor->has_children())
4714 right_neighbor = right_neighbor->child(nbnb);
4715 right_neighbor->set_neighbor(nbnb, second_child);
4735 template <
int spacedim>
4738 const bool check_for_distorted_cells)
4740 const unsigned int dim = 2;
4746 bool do_isotropic_refinement =
true;
4747 for (
const auto &cell :
triangulation.active_cell_iterators())
4751 do_isotropic_refinement =
false;
4755 if (do_isotropic_refinement)
4757 check_for_distorted_cells);
4762 for (
const auto &cell :
triangulation.active_cell_iterators_on_level(
4764 if (cell->refine_flag_set())
4779 line->clear_user_flag();
4785 unsigned int n_single_lines = 0;
4789 unsigned int n_lines_in_pairs = 0;
4795 unsigned int needed_vertices = 0;
4800 unsigned int needed_cells = 0;
4802 for (
const auto &cell :
4804 if (cell->refine_flag_set())
4815 n_single_lines += 4;
4827 n_single_lines += 1;
4835 for (
const unsigned int line_no :
4839 cell->refine_flag_set(), line_no) ==
4843 line = cell->line(line_no);
4844 if (line->has_children() ==
false)
4845 line->set_user_flag();
4852 const unsigned int used_cells =
4862 used_cells + needed_cells,
4878 if (line->user_flag_set())
4881 n_lines_in_pairs += 2;
4882 needed_vertices += 1;
4894 needed_vertices += std::count(
triangulation.vertices_used.begin(),
4911 unsigned int next_unused_vertex = 0;
4923 for (; line != endl; ++line)
4924 if (line->user_flag_set())
4930 while (
triangulation.vertices_used[next_unused_vertex] ==
true)
4931 ++next_unused_vertex;
4935 "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."));
4938 triangulation.vertices[next_unused_vertex] = line->center(
true);
4943 bool pair_found =
false;
4945 for (; next_unused_line != endl; ++next_unused_line)
4946 if (!next_unused_line->used() &&
4947 !(++next_unused_line)->used())
4960 line->set_children(0, next_unused_line->index());
4964 children[2] = {next_unused_line, ++next_unused_line};
4970 children[0]->set_bounding_object_indices(
4971 {line->vertex_index(0), next_unused_vertex});
4972 children[1]->set_bounding_object_indices(
4973 {next_unused_vertex, line->vertex_index(1)});
4975 children[0]->set_used_flag();
4976 children[1]->set_used_flag();
4977 children[0]->clear_children();
4978 children[1]->clear_children();
4981 children[0]->clear_user_flag();
4982 children[1]->clear_user_flag();
4985 children[0]->set_boundary_id_internal(line->boundary_id());
4986 children[1]->set_boundary_id_internal(line->boundary_id());
4988 children[0]->set_manifold_id(line->manifold_id());
4989 children[1]->set_manifold_id(line->manifold_id());
4993 line->clear_user_flag();
5005 cells_with_distorted_children;
5019 for (
const auto &cell :
5021 if (cell->refine_flag_set())
5031 if (check_for_distorted_cells &&
5032 has_distorted_children<dim, spacedim>(cell))
5040 return cells_with_distorted_children;
5044 template <
int spacedim>
5047 const bool check_for_distorted_cells)
5049 static const int dim = 3;
5060 for (
const auto &cell :
triangulation.active_cell_iterators_on_level(
5062 if (cell->refine_flag_set())
5078 line->clear_user_flag();
5084 quad->clear_user_flag();
5098 unsigned int needed_vertices = 0;
5099 unsigned int needed_lines_single = 0;
5100 unsigned int needed_quads_single = 0;
5101 unsigned int needed_lines_pair = 0;
5102 unsigned int needed_quads_pair = 0;
5105 unsigned int new_cells = 0;
5107 for (
const auto &cell :
5109 if (cell->refine_flag_set())
5112 Assert(cell->refine_flag_set() ==
5118 new_cells += cell->reference_cell().n_isotropic_children();
5123 needed_lines_single += 6;
5124 needed_quads_single += 12;
5126 else if (cell->reference_cell() ==
5129 needed_lines_single += 1;
5130 needed_quads_single += 8;
5141 for (
const auto face : cell->face_indices())
5142 if (cell->face(face)->n_children() == 0)
5143 cell->face(face)->set_user_flag();
5145 Assert(cell->face(face)->n_children() ==
5146 cell->reference_cell()
5147 .face_reference_cell(face)
5148 .n_isotropic_children(),
5151 for (
const auto line : cell->line_indices())
5152 if (cell->line(line)->has_children() ==
false)
5153 cell->line(line)->set_user_flag();
5155 Assert(cell->line(line)->n_children() == 2,
5159 const unsigned int used_cells =
5165 used_cells + new_cells,
5179 if (quad->user_flag_set() ==
false)
5184 needed_quads_pair += 4;
5185 needed_lines_pair += 4;
5186 needed_vertices += 1;
5190 needed_quads_pair += 4;
5191 needed_lines_single += 3;
5204 if (line->user_flag_set() ==
false)
5207 needed_lines_pair += 2;
5208 needed_vertices += 1;
5213 needed_lines_single);
5216 needed_quads_single);
5219 needed_quads_single);
5223 needed_vertices += std::count(
triangulation.vertices_used.begin(),
5244 for (
const auto &cell :
triangulation.active_cell_iterators())
5245 if (!cell->refine_flag_set())
5246 for (
unsigned int line_n = 0; line_n < cell->n_lines(); ++line_n)
5247 if (cell->line(line_n)->has_children())
5248 for (
unsigned int c = 0; c < 2; ++c)
5249 Assert(cell->line(line_n)->child(c)->user_flag_set() ==
false,
5253 unsigned int current_vertex = 0;
5257 auto get_next_unused_vertex = [](
const unsigned int current_vertex,
5258 std::vector<bool> &vertices_used) {
5259 unsigned int next_vertex = current_vertex;
5260 while (next_vertex < vertices_used.size() &&
5261 vertices_used[next_vertex] ==
true)
5264 vertices_used[next_vertex] =
true;
5277 for (; line != endl; ++line)
5279 if (line->user_flag_set() ==
false)
5283 get_next_unused_vertex(current_vertex,
5285 triangulation.vertices[current_vertex] = line->center(
true);
5288 triangulation.faces->lines.template next_free_pair_object<1>(
5296 line->set_children(0, next_unused_line->index());
5299 children[2] = {next_unused_line, ++next_unused_line};
5304 children[0]->set_bounding_object_indices(
5305 {line->vertex_index(0), current_vertex});
5306 children[1]->set_bounding_object_indices(
5307 {current_vertex, line->vertex_index(1)});
5309 children[0]->set_used_flag();
5310 children[1]->set_used_flag();
5311 children[0]->clear_children();
5312 children[1]->clear_children();
5315 children[0]->clear_user_flag();
5316 children[1]->clear_user_flag();
5318 children[0]->set_boundary_id_internal(line->boundary_id());
5319 children[1]->set_boundary_id_internal(line->boundary_id());
5321 children[0]->set_manifold_id(line->manifold_id());
5322 children[1]->set_manifold_id(line->manifold_id());
5324 line->clear_user_flag();
5338 for (; quad != endq; ++quad)
5340 if (quad->user_flag_set() ==
false)
5343 const auto reference_face_type = quad->reference_cell();
5349 get_next_unused_vertex(current_vertex,
5352 quad->center(
true,
true);
5356 boost::container::small_vector<
5361 for (
unsigned int i = 0; i < new_lines.size(); ++i)
5381 new_lines[i] = next_unused_line;
5395 triangulation.faces->quads.template next_free_pair_object<2>(
5398 new_quads[0] = next_unused_quad;
5402 new_quads[1] = next_unused_quad;
5406 triangulation.faces->quads.template next_free_pair_object<2>(
5408 new_quads[2] = next_unused_quad;
5412 new_quads[3] = next_unused_quad;
5415 quad->set_children(0, new_quads[0]->
index());
5416 quad->set_children(2, new_quads[2]->
index());
5425 for (
const auto i : quad->vertex_indices())
5428 for (
const auto i : quad->line_indices())
5430 quad->line(i)->child(0)->vertex_index(1);
5435 boost::container::small_vector<
5444 for (
unsigned int l = 0; l < quad->
n_lines(); ++l)
5445 for (
unsigned int c = 0; c < 2; ++c)
5447 static constexpr std::array<std::array<unsigned int, 2>,
5454 lines[k++] = quad->line(l)->child(
5455 index[c][quad->line_orientation(l)]);
5458 for (
unsigned int l = 0; l < new_lines.size(); ++l)
5459 lines[k++] = new_lines[l];
5462 boost::container::small_vector<int, 12> line_indices(
5464 for (
unsigned int i = 0; i < line_indices.size(); ++i)
5465 line_indices[i] = lines[i]->
index();
5467 static constexpr std::array<std::array<unsigned int, 2>, 12>
5468 line_vertices_quad{{{{0, 4}},
5481 static constexpr std::array<std::array<unsigned int, 4>, 4>
5482 quad_lines_quad{{{{0, 8, 4, 10}},
5487 static constexpr std::
5488 array<std::array<std::array<unsigned int, 2>, 4>, 4>
5489 quad_line_vertices_quad{
5490 {{{{{0, 4}}, {{6, 8}}, {{0, 6}}, {{4, 8}}}},
5491 {{{{6, 8}}, {{1, 5}}, {{6, 1}}, {{8, 5}}}},
5492 {{{{4, 2}}, {{8, 7}}, {{4, 8}}, {{2, 7}}}},
5493 {{{{8, 7}}, {{5, 3}}, {{8, 5}}, {{7, 3}}}}}};
5495 static constexpr std::array<std::array<unsigned int, 2>, 12>
5496 line_vertices_tri{{{{0, 3}},
5509 static constexpr std::array<std::array<unsigned int, 4>, 4>
5510 quad_lines_tri{{{{0, 8, 5, X}},
5515 static constexpr std::
5516 array<std::array<std::array<unsigned int, 2>, 4>, 4>
5517 quad_line_vertices_tri{
5518 {{{{{0, 3}}, {{3, 5}}, {{5, 0}}, {{X, X}}}},
5519 {{{{3, 1}}, {{1, 4}}, {{4, 3}}, {{X, X}}}},
5520 {{{{5, 4}}, {{4, 2}}, {{2, 5}}, {{X, X}}}},
5521 {{{{3, 4}}, {{4, 5}}, {{5, 3}}, {{X, X}}}}}};
5523 const auto &line_vertices =
5525 line_vertices_quad :
5527 const auto &quad_lines =
5531 const auto &quad_line_vertices =
5533 quad_line_vertices_quad :
5534 quad_line_vertices_tri;
5537 for (
unsigned int i = 0, j = lines.size() - new_lines.size();
5538 i < new_lines.size();
5541 auto &new_line = new_lines[i];
5542 new_line->set_bounding_object_indices(
5545 new_line->set_used_flag();
5546 new_line->clear_user_flag();
5547 new_line->clear_user_data();
5548 new_line->clear_children();
5549 new_line->set_boundary_id_internal(quad->boundary_id());
5550 new_line->set_manifold_id(quad->manifold_id());
5554 for (
unsigned int i = 0; i < new_quads.size(); ++i)
5556 auto &new_quad = new_quads[i];
5560 triangulation.faces->quad_reference_cell[new_quad->index()] =
5561 reference_face_type;
5563 if (new_quad->n_lines() == 3)
5564 new_quad->set_bounding_object_indices(
5565 {line_indices[quad_lines[i][0]],
5566 line_indices[quad_lines[i][1]],
5567 line_indices[quad_lines[i][2]]});
5568 else if (new_quad->n_lines() == 4)
5569 new_quad->set_bounding_object_indices(
5570 {line_indices[quad_lines[i][0]],
5571 line_indices[quad_lines[i][1]],
5572 line_indices[quad_lines[i][2]],
5573 line_indices[quad_lines[i][3]]});
5577 new_quad->set_used_flag();
5578 new_quad->clear_user_flag();
5579 new_quad->clear_user_data();
5580 new_quad->clear_children();
5581 new_quad->set_boundary_id_internal(quad->boundary_id());
5582 new_quad->set_manifold_id(quad->manifold_id());
5585 std::set<unsigned int> s;
5589 for (
const auto f : new_quad->line_indices())
5591 std::array<unsigned int, 2> vertices_0, vertices_1;
5593 for (
unsigned int v = 0; v < 2; ++v)
5595 lines[quad_lines[i][f]]->vertex_index(v);
5597 for (
unsigned int v = 0; v < 2; ++v)
5601 const auto orientation =
5606 for (
const auto i : vertices_0)
5608 for (
const auto i : vertices_1)
5612 new_quad->set_line_orientation(f, orientation);
5622 quad->clear_user_flag();
5627 cells_with_distorted_children;
5638 for (; hex != endh; ++hex)
5640 if (hex->refine_flag_set() ==
5644 const auto &reference_cell_type = hex->reference_cell();
5647 hex->clear_refine_flag();
5648 hex->set_refinement_case(ref_case);
5650 unsigned int n_new_lines = 0;
5651 unsigned int n_new_quads = 0;
5652 unsigned int n_new_hexes = 0;
5673 get_next_unused_vertex(current_vertex,
5676 hex->center(
true,
true);
5679 boost::container::small_vector<
5682 new_lines(n_new_lines);
5683 for (
unsigned int i = 0; i < n_new_lines; ++i)
5690 new_lines[i]->set_used_flag();
5691 new_lines[i]->clear_user_flag();
5692 new_lines[i]->clear_user_data();
5693 new_lines[i]->clear_children();
5694 new_lines[i]->set_boundary_id_internal(
5696 new_lines[i]->set_manifold_id(hex->manifold_id());
5699 boost::container::small_vector<
5702 new_quads(n_new_quads);
5703 for (
unsigned int i = 0; i < n_new_quads; ++i)
5709 auto &new_quad = new_quads[i];
5714 ->quad_reference_cell[new_quad->index()] =
5720 new_quad->set_used_flag();
5721 new_quad->clear_user_flag();
5722 new_quad->clear_user_data();
5723 new_quad->clear_children();
5724 new_quad->set_boundary_id_internal(
5726 new_quad->set_manifold_id(hex->manifold_id());
5727 for (
const auto j : new_quads[i]->line_indices())
5728 new_quad->set_line_orientation(j,
true);
5737 for (
unsigned int i = 0; i < n_new_hexes; ++i)
5746 new_hexes[i] = next_unused_hex;
5748 auto &new_hex = new_hexes[i];
5752 ->reference_cell[new_hex->index()] =
5753 reference_cell_type;
5756 new_hex->set_used_flag();
5757 new_hex->clear_user_flag();
5758 new_hex->clear_user_data();
5759 new_hex->clear_children();
5760 new_hex->set_material_id(hex->material_id());
5761 new_hex->set_manifold_id(hex->manifold_id());
5762 new_hex->set_subdomain_id(hex->subdomain_id());
5765 new_hex->set_parent(hex->index());
5777 for (
const auto f : new_hex->face_indices())
5779 new_hex->set_face_orientation(f,
true);
5780 new_hex->set_face_flip(f,
false);
5781 new_hex->set_face_rotation(f,
false);
5784 for (
unsigned int i = 0; i < n_new_hexes / 2; ++i)
5785 hex->set_children(2 * i, new_hexes[2 * i]->index());
5795 for (
const unsigned int i : hex->vertex_indices())
5798 for (
const unsigned int i : hex->line_indices())
5800 hex->line(i)->child(0)->vertex_index(1);
5804 for (
const unsigned int i : hex->face_indices())
5806 middle_vertex_index<dim, spacedim>(hex->face(i));
5814 static constexpr std::array<std::array<unsigned int, 2>, 6>
5815 new_line_vertices_hex = {{{{22, 26}},
5822 static constexpr std::array<std::array<unsigned int, 2>, 6>
5823 new_line_vertices_tet = {{{{6, 8}},
5830 const auto &new_line_vertices =
5832 new_line_vertices_hex :
5833 new_line_vertices_tet;
5835 for (
unsigned int i = 0; i < new_lines.size(); ++i)
5836 new_lines[i]->set_bounding_object_indices(
5843 boost::container::small_vector<
5850 relevant_lines.resize(30);
5851 for (
unsigned int f = 0, k = 0; f < 6; ++f)
5852 for (
unsigned int c = 0; c < 4; ++c, ++k)
5854 static constexpr std::
5855 array<std::array<unsigned int, 2>, 4>
5857 {{{0, 1}}, {{3, 0}}, {{0, 3}}, {{3, 2}}}};
5863 standard_to_real_face_vertex(
5865 hex->face_orientation(f),
5867 hex->face_rotation(f)))
5869 standard_to_real_face_line(
5871 hex->face_orientation(f),
5873 hex->face_rotation(f)));
5876 for (
unsigned int i = 0, k = 24; i < 6; ++i, ++k)
5877 relevant_lines[k] = new_lines[i];
5881 relevant_lines.resize(13);
5884 for (
unsigned int f = 0; f < 4; ++f)
5885 for (
unsigned int l = 0;
l < 3; ++
l, ++k)
5889 array<std::array<unsigned int, 3>, 6>
5890 table = {{{{1, 0, 2}},
5905 dim>::faces_per_cell +
5909 relevant_lines[k++] = new_lines[0];
5916 boost::container::small_vector<unsigned int, 30>
5917 relevant_line_indices(relevant_lines.size());
5918 for (
unsigned int i = 0; i < relevant_line_indices.size();
5920 relevant_line_indices[i] = relevant_lines[i]->
index();
5922 static constexpr std::array<std::array<unsigned int, 4>, 12>
5923 new_quad_lines_hex = {{{{10, 28, 16, 24}},
5934 {{25, 7, 27, 13}}}};
5936 static constexpr std::array<std::array<unsigned int, 4>, 12>
5937 new_quad_lines_tet = {{{{2, 3, 8, X}},
5950 static constexpr std::
5951 array<std::array<std::array<unsigned int, 2>, 4>, 12>
5953 {{{{{10, 22}}, {{24, 26}}, {{10, 24}}, {{22, 26}}}},
5954 {{{{24, 26}}, {{11, 23}}, {{24, 11}}, {{26, 23}}}},
5955 {{{{22, 14}}, {{26, 25}}, {{22, 26}}, {{14, 25}}}},
5956 {{{{26, 25}}, {{23, 15}}, {{26, 23}}, {{25, 15}}}},
5957 {{{{8, 24}}, {{20, 26}}, {{8, 20}}, {{24, 26}}}},
5958 {{{{20, 26}}, {{12, 25}}, {{20, 12}}, {{26, 25}}}},
5959 {{{{24, 9}}, {{26, 21}}, {{24, 26}}, {{9, 21}}}},
5960 {{{{26, 21}}, {{25, 13}}, {{26, 25}}, {{21, 13}}}},
5961 {{{{16, 20}}, {{22, 26}}, {{16, 22}}, {{20, 26}}}},
5962 {{{{22, 26}}, {{17, 21}}, {{22, 17}}, {{26, 21}}}},
5963 {{{{20, 18}}, {{26, 23}}, {{20, 26}}, {{18, 23}}}},
5964 {{{{26, 23}}, {{21, 19}}, {{26, 21}}, {{23, 19}}}}}};
5966 static constexpr std::
5967 array<std::array<std::array<unsigned int, 2>, 4>, 12>
5969 {{{{{6, 4}}, {{4, 7}}, {{7, 6}}, {{X, X}}}},
5970 {{{{4, 5}}, {{5, 8}}, {{8, 4}}, {{X, X}}}},
5971 {{{{5, 6}}, {{6, 9}}, {{9, 5}}, {{X, X}}}},
5972 {{{{7, 8}}, {{8, 9}}, {{9, 7}}, {{X, X}}}},
5973 {{{{4, 6}}, {{6, 8}}, {{8, 4}}, {{X, X}}}},
5974 {{{{6, 5}}, {{5, 8}}, {{8, 6}}, {{X, X}}}},
5975 {{{{8, 7}}, {{7, 6}}, {{6, 8}}, {{X, X}}}},
5976 {{{{9, 6}}, {{6, 8}}, {{8, 9}}, {{X, X}}}},
5977 {{{{X, X}}, {{X, X}}, {{X, X}}, {{X, X}}}},
5978 {{{{X, X}}, {{X, X}}, {{X, X}}, {{X, X}}}},
5979 {{{{X, X}}, {{X, X}}, {{X, X}}, {{X, X}}}},
5980 {{{{X, X}}, {{X, X}}, {{X, X}}, {{X, X}}}}}};
5982 const auto &new_quad_lines =
5984 new_quad_lines_hex :
5992 for (
unsigned int q = 0; q < new_quads.size(); ++q)
5994 for (
unsigned int l = 0;
l < 3; ++
l)
5996 std::array<unsigned int, 2> vertices_0, vertices_1;
5998 for (
unsigned int v = 0; v < 2; ++v)
6000 relevant_lines[new_quad_lines[q][l]]
6003 for (
unsigned int v = 0; v < 2; ++v)
6008 for (
unsigned int q = 0; q < new_quads.size(); ++q)
6010 auto &new_quad = new_quads[q];
6012 if (new_quad->n_lines() == 3)
6013 new_quad->set_bounding_object_indices(
6014 {relevant_line_indices[new_quad_lines[q][0]],
6015 relevant_line_indices[new_quad_lines[q][1]],
6016 relevant_line_indices[new_quad_lines[q][2]]});
6017 else if (new_quad->n_lines() == 4)
6018 new_quad->set_bounding_object_indices(
6019 {relevant_line_indices[new_quad_lines[q][0]],
6020 relevant_line_indices[new_quad_lines[q][1]],
6021 relevant_line_indices[new_quad_lines[q][2]],
6022 relevant_line_indices[new_quad_lines[q][3]]});
6026 for (
const auto l : new_quad->line_indices())
6028 std::array<unsigned int, 2> vertices_0, vertices_1;
6030 for (
unsigned int v = 0; v < 2; ++v)
6032 relevant_lines[new_quad_lines[q][l]]
6035 for (
unsigned int v = 0; v < 2; ++v)
6038 const auto orientation =
6040 vertices_0, vertices_1);
6042 new_quad->set_line_orientation(l, orientation);
6049 std::array<int, 36> quad_indices;
6053 for (
unsigned int i = 0; i < new_quads.size(); ++i)
6054 quad_indices[i] = new_quads[i]->
index();
6056 for (
unsigned int f = 0, k = new_quads.size(); f < 6;
6058 for (
unsigned int c = 0; c < 4; ++c, ++k)
6060 hex->face(f)->isotropic_child_index(
6063 hex->face_orientation(f),
6065 hex->face_rotation(f)));
6069 for (
unsigned int i = 0; i < new_quads.size(); ++i)
6070 quad_indices[i] = new_quads[i]->
index();
6072 for (
unsigned int f = 0, k = new_quads.size(); f < 4;
6074 for (
unsigned int c = 0; c < 4; ++c, ++k)
6076 quad_indices[k] = hex->face(f)->child_index(
6080 .standard_to_real_face_vertex(
6095 static constexpr std::array<std::array<unsigned int, 6>, 8>
6097 {{12, 0, 20, 4, 28, 8}},
6098 {{0, 16, 22, 6, 29, 9}},
6099 {{13, 1, 4, 24, 30, 10}},
6100 {{1, 17, 6, 26, 31, 11}},
6101 {{14, 2, 21, 5, 8, 32}},
6102 {{2, 18, 23, 7, 9, 33}},
6103 {{15, 3, 5, 25, 10, 34}},
6104 {{3, 19, 7, 27, 11, 35}}
6107 static constexpr std::array<std::array<unsigned int, 6>, 8>
6108 cell_quads_tet{{{{8, 13, 16, 0, X, X}},
6109 {{9, 12, 1, 21, X, X}},
6110 {{10, 2, 17, 20, X, X}},
6111 {{3, 14, 18, 22, X, X}},
6112 {{11, 1, 4, 5, X, X}},
6113 {{15, 0, 4, 6, X, X}},
6114 {{19, 7, 6, 3, X, X}},
6115 {{23, 5, 2, 7, X, X}}}};
6117 static constexpr std::
6118 array<std::array<std::array<unsigned int, 4>, 6>, 8>
6119 cell_face_vertices_hex{{{{{{0, 8, 16, 20}},
6124 {{16, 22, 20, 26}}}},
6125 {{{{10, 24, 22, 26}},
6130 {{22, 17, 26, 21}}}},
6136 {{20, 26, 18, 23}}}},
6137 {{{{24, 11, 26, 23}},
6142 {{26, 21, 23, 19}}}},
6143 {{{{16, 20, 4, 12}},
6148 {{4, 14, 12, 25}}}},
6149 {{{{22, 26, 14, 25}},
6154 {{14, 5, 25, 13}}}},
6155 {{{{20, 18, 12, 6}},
6160 {{12, 25, 6, 15}}}},
6161 {{{{26, 23, 25, 15}},
6166 {{25, 13, 15, 7}}}}}};
6168 static constexpr std::
6169 array<std::array<std::array<unsigned int, 4>, 6>, 8>
6170 cell_face_vertices_tet{{{{{{0, 4, 6, X}},
6219 const auto &cell_quads =
6224 const auto &cell_face_vertices =
6226 cell_face_vertices_hex :
6227 cell_face_vertices_tet;
6229 for (
unsigned int c = 0;
6230 c < GeometryInfo<dim>::max_children_per_cell;
6233 auto &new_hex = new_hexes[c];
6235 if (new_hex->n_faces() == 4)
6236 new_hex->set_bounding_object_indices(
6237 {quad_indices[cell_quads[c][0]],
6238 quad_indices[cell_quads[c][1]],
6239 quad_indices[cell_quads[c][2]],
6240 quad_indices[cell_quads[c][3]]});
6241 else if (new_hex->n_faces() == 6)
6242 new_hex->set_bounding_object_indices(
6243 {quad_indices[cell_quads[c][0]],
6244 quad_indices[cell_quads[c][1]],
6245 quad_indices[cell_quads[c][2]],
6246 quad_indices[cell_quads[c][3]],
6247 quad_indices[cell_quads[c][4]],
6248 quad_indices[cell_quads[c][5]]});
6252 for (
const auto f : new_hex->face_indices())
6254 std::array<unsigned int, 4> vertices_0, vertices_1;
6256 const auto &face = new_hex->face(f);
6258 for (
const auto i : face->vertex_indices())
6259 vertices_0[i] = face->vertex_index(i);
6261 for (
const auto i : face->vertex_indices())
6265 const auto orientation =
6266 face->reference_cell().compute_orientation(
6267 vertices_1, vertices_0);
6269 new_hex->set_face_orientation(
6271 new_hex->set_face_flip(
6273 new_hex->set_face_rotation(
6280 if (check_for_distorted_cells &&
6281 has_distorted_children<dim, spacedim>(hex))
6290 return cells_with_distorted_children;
6297 template <
int spacedim>
6300 const bool check_for_distorted_cells)
6302 const unsigned int dim = 3;
6305 bool flag_isotropic_mesh =
true;
6309 for (; cell != endc; ++cell)
6319 flag_isotropic_mesh =
false;
6323 if (flag_isotropic_mesh)
6325 check_for_distorted_cells);
6336 for (
const auto &cell :
triangulation.active_cell_iterators_on_level(
6338 if (cell->refine_flag_set())
6355 line->clear_user_flag();
6360 quad->clear_user_flag();
6383 unsigned int needed_vertices = 0;
6384 unsigned int needed_lines_single = 0;
6385 unsigned int needed_quads_single = 0;
6386 unsigned int needed_lines_pair = 0;
6387 unsigned int needed_quads_pair = 0;
6392 unsigned int new_cells = 0;
6394 for (
const auto &acell :
6396 if (acell->refine_flag_set())
6406 ++needed_quads_single;
6414 ++needed_lines_single;
6415 needed_quads_single += 4;
6422 needed_lines_single += 6;
6423 needed_quads_single += 12;
6437 for (
const unsigned int face :
6441 aface = acell->face(face);
6448 acell->face_orientation(face),
6449 acell->face_flip(face),
6450 acell->face_rotation(face));
6455 if (face_ref_case ==
6458 if (aface->n_active_descendants() < 4)
6461 aface->set_user_flag();
6463 else if (aface->refinement_case() != face_ref_case)
6474 Assert(aface->refinement_case() ==
6476 dim - 1>::isotropic_refinement ||
6477 aface->refinement_case() ==
6480 aface->set_user_index(face_ref_case);
6486 for (
unsigned int line = 0;
6487 line < GeometryInfo<dim>::lines_per_cell;
6491 !acell->line(line)->has_children())
6492 acell->line(line)->set_user_flag();
6498 const unsigned int used_cells =
6508 used_cells + new_cells,
6522 if (quad->user_flag_set())
6528 needed_quads_pair += 4;
6529 needed_lines_pair += 4;
6530 needed_vertices += 1;
6532 if (quad->user_index())
6536 needed_quads_pair += 2;
6537 needed_lines_single += 1;
6550 if (quad->has_children())
6552 Assert(quad->refinement_case() ==
6555 if ((face_refinement_cases[quad->user_index()] ==
6557 (quad->child(0)->line_index(1) + 1 !=
6558 quad->child(2)->line_index(1))) ||
6559 (face_refinement_cases[quad->user_index()] ==
6561 (quad->child(0)->line_index(3) + 1 !=
6562 quad->child(1)->line_index(3))))
6563 needed_lines_pair += 2;
6572 if (line->user_flag_set())
6574 needed_lines_pair += 2;
6575 needed_vertices += 1;
6581 needed_lines_single);
6585 needed_quads_single);
6588 needed_quads_single);
6592 needed_vertices += std::count(
triangulation.vertices_used.begin(),
6616 for (
const auto &cell :
triangulation.active_cell_iterators())
6617 if (!cell->refine_flag_set())
6618 for (
unsigned int line = 0;
6619 line < GeometryInfo<dim>::lines_per_cell;
6621 if (cell->line(line)->has_children())
6622 for (
unsigned int c = 0; c < 2; ++c)
6623 Assert(cell->line(line)->child(c)->user_flag_set() ==
false,
6635 unsigned int next_unused_vertex = 0;
6646 for (; line != endl; ++line)
6647 if (line->user_flag_set())
6653 while (
triangulation.vertices_used[next_unused_vertex] ==
true)
6654 ++next_unused_vertex;
6658 "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."));
6661 triangulation.vertices[next_unused_vertex] = line->center(
true);
6667 triangulation.faces->lines.template next_free_pair_object<1>(
6675 line->set_children(0, next_unused_line->index());
6679 children[2] = {next_unused_line, ++next_unused_line};
6686 children[0]->set_bounding_object_indices(
6687 {line->vertex_index(0), next_unused_vertex});
6688 children[1]->set_bounding_object_indices(
6689 {next_unused_vertex, line->vertex_index(1)});
6691 children[0]->set_used_flag();
6692 children[1]->set_used_flag();
6693 children[0]->clear_children();
6694 children[1]->clear_children();
6697 children[0]->clear_user_flag();
6698 children[1]->clear_user_flag();
6700 children[0]->set_boundary_id_internal(line->boundary_id());
6701 children[1]->set_boundary_id_internal(line->boundary_id());
6703 children[0]->set_manifold_id(line->manifold_id());
6704 children[1]->set_manifold_id(line->manifold_id());
6709 line->clear_user_flag();
6739 for (
unsigned int loop = 0; loop < 2; ++loop)
6752 for (; quad != endq; ++quad)
6754 if (quad->user_index())
6757 face_refinement_cases[quad->user_index()];
6766 if (aniso_quad_ref_case == quad->refinement_case())
6769 Assert(quad->refinement_case() ==
6771 quad->refinement_case() ==
6776 Assert(quad->user_index() ==
6778 quad->user_index() ==
6808 quad->line(2)->child(0)->vertex_index(1);
6810 quad->line(3)->child(0)->vertex_index(1);
6815 quad->line(0)->child(0)->vertex_index(1);
6817 quad->line(1)->child(0)->vertex_index(1);
6820 new_line->set_bounding_object_indices(
6822 new_line->set_used_flag();
6823 new_line->clear_user_flag();
6825 new_line->clear_children();
6826 new_line->set_boundary_id_internal(quad->boundary_id());
6827 new_line->set_manifold_id(quad->manifold_id());
6835 const unsigned int index[2][2] = {
6847 new_quads[0] = next_unused_quad;
6851 new_quads[1] = next_unused_quad;
6856 new_quads[0]->set_bounding_object_indices(
6857 {
static_cast<int>(quad->line_index(0)),
6860 ->child(
index[0][quad->line_orientation(2)])
6863 ->child(
index[0][quad->line_orientation(3)])
6865 new_quads[1]->set_bounding_object_indices(
6867 static_cast<int>(quad->line_index(1)),
6869 ->child(
index[1][quad->line_orientation(2)])
6872 ->child(
index[1][quad->line_orientation(3)])
6877 new_quads[0]->set_bounding_object_indices(
6879 ->child(
index[0][quad->line_orientation(0)])
6882 ->child(
index[0][quad->line_orientation(1)])
6884 static_cast<int>(quad->line_index(2)),
6885 new_line->index()});
6886 new_quads[1]->set_bounding_object_indices(
6888 ->child(
index[1][quad->line_orientation(0)])
6891 ->child(
index[1][quad->line_orientation(1)])
6894 static_cast<int>(quad->line_index(3))});
6897 for (
const auto &new_quad : new_quads)
6899 new_quad->set_used_flag();
6900 new_quad->clear_user_flag();
6902 new_quad->clear_children();
6903 new_quad->set_boundary_id_internal(quad->boundary_id());
6904 new_quad->set_manifold_id(quad->manifold_id());
6908 for (
unsigned int j = 0;
6909 j < GeometryInfo<dim>::lines_per_face;
6911 new_quad->set_line_orientation(j,
true);
6917 new_quads[0]->set_line_orientation(
6918 0, quad->line_orientation(0));
6919 new_quads[0]->set_line_orientation(
6920 2, quad->line_orientation(2));
6921 new_quads[1]->set_line_orientation(
6922 1, quad->line_orientation(1));
6923 new_quads[1]->set_line_orientation(
6924 3, quad->line_orientation(3));
6927 new_quads[0]->set_line_orientation(
6928 3, quad->line_orientation(3));
6929 new_quads[1]->set_line_orientation(
6930 2, quad->line_orientation(2));
6934 new_quads[0]->set_line_orientation(
6935 1, quad->line_orientation(1));
6936 new_quads[1]->set_line_orientation(
6937 0, quad->line_orientation(0));
6943 if (quad->refinement_case() ==
6966 if (aniso_quad_ref_case ==
6969 old_child[0] = quad->child(0)->line(1);
6970 old_child[1] = quad->child(2)->line(1);
6974 Assert(aniso_quad_ref_case ==
6978 old_child[0] = quad->child(0)->line(3);
6979 old_child[1] = quad->child(1)->line(3);
6982 if (old_child[0]->
index() + 1 != old_child[1]->
index())
6988 spacedim>::raw_line_iterator
6991 new_child[0] = new_child[1] =
6993 .template next_free_pair_object<1>(
6997 new_child[0]->set_used_flag();
6998 new_child[1]->set_used_flag();
7000 const int old_index_0 = old_child[0]->index(),
7001 old_index_1 = old_child[1]->index(),
7002 new_index_0 = new_child[0]->index(),
7003 new_index_1 = new_child[1]->index();
7007 for (
unsigned int q = 0;
7010 for (
unsigned int l = 0;
7011 l < GeometryInfo<dim>::lines_per_face;
7014 const int this_index =
7016 .get_bounding_object_indices(q)[l];
7017 if (this_index == old_index_0)
7019 .get_bounding_object_indices(q)[l] =
7021 else if (this_index == old_index_1)
7023 .get_bounding_object_indices(q)[l] =
7028 for (
unsigned int i = 0; i < 2; ++i)
7030 Assert(!old_child[i]->has_children(),
7033 new_child[i]->set_bounding_object_indices(
7034 {old_child[i]->vertex_index(0),
7035 old_child[i]->vertex_index(1)});
7036 new_child[i]->set_boundary_id_internal(
7037 old_child[i]->boundary_id());
7038 new_child[i]->set_manifold_id(
7039 old_child[i]->manifold_id());
7040 new_child[i]->set_user_index(
7041 old_child[i]->user_index());
7042 if (old_child[i]->user_flag_set())
7043 new_child[i]->set_user_flag();
7045 new_child[i]->clear_user_flag();
7047 new_child[i]->clear_children();
7049 old_child[i]->clear_user_flag();
7050 old_child[i]->clear_user_index();
7051 old_child[i]->clear_used_flag();
7057 if (aniso_quad_ref_case ==
7060 new_line->set_children(
7061 0, quad->child(0)->line_index(1));
7062 Assert(new_line->child(1) ==
7063 quad->child(2)->line(1),
7100 quad_iterator switch_1 = quad->child(1),
7101 switch_2 = quad->child(2);
7102 const int switch_1_index = switch_1->index();
7103 const int switch_2_index = switch_2->index();
7104 for (
unsigned int l = 0;
7107 for (
unsigned int h = 0;
7111 for (
const unsigned int q :
7114 const int face_index =
7116 ->cells.get_bounding_object_indices(
7118 if (face_index == switch_1_index)
7120 ->cells.get_bounding_object_indices(
7121 h)[q] = switch_2_index;
7122 else if (face_index == switch_2_index)
7124 ->cells.get_bounding_object_indices(
7125 h)[q] = switch_1_index;
7129 const unsigned int switch_1_lines[4] = {
7130 switch_1->line_index(0),
7131 switch_1->line_index(1),
7132 switch_1->line_index(2),
7133 switch_1->line_index(3)};
7134 const bool switch_1_line_orientations[4] = {
7135 switch_1->line_orientation(0),
7136 switch_1->line_orientation(1),
7137 switch_1->line_orientation(2),
7138 switch_1->line_orientation(3)};
7140 switch_1->boundary_id();
7141 const unsigned int switch_1_user_index =
7142 switch_1->user_index();
7143 const bool switch_1_user_flag =
7144 switch_1->user_flag_set();
7146 switch_1_refinement_case =
7147 switch_1->refinement_case();
7148 const int switch_1_first_child_pair =
7149 (switch_1_refinement_case ?
7150 switch_1->child_index(0) :
7152 const int switch_1_second_child_pair =
7153 (switch_1_refinement_case ==
7155 switch_1->child_index(2) :
7158 switch_1->set_bounding_object_indices(
7159 {switch_2->line_index(0),
7160 switch_2->line_index(1),
7161 switch_2->line_index(2),
7162 switch_2->line_index(3)});
7163 switch_1->set_line_orientation(
7164 0, switch_2->line_orientation(0));
7165 switch_1->set_line_orientation(
7166 1, switch_2->line_orientation(1));
7167 switch_1->set_line_orientation(
7168 2, switch_2->line_orientation(2));
7169 switch_1->set_line_orientation(
7170 3, switch_2->line_orientation(3));
7171 switch_1->set_boundary_id_internal(
7172 switch_2->boundary_id());
7173 switch_1->set_manifold_id(switch_2->manifold_id());
7174 switch_1->set_user_index(switch_2->user_index());
7175 if (switch_2->user_flag_set())
7176 switch_1->set_user_flag();
7178 switch_1->clear_user_flag();
7179 switch_1->clear_refinement_case();
7180 switch_1->set_refinement_case(
7181 switch_2->refinement_case());
7182 switch_1->clear_children();
7183 if (switch_2->refinement_case())
7184 switch_1->set_children(0,
7185 switch_2->child_index(0));
7186 if (switch_2->refinement_case() ==
7188 switch_1->set_children(2,
7189 switch_2->child_index(2));
7191 switch_2->set_bounding_object_indices(
7195 switch_1_lines[3]});
7196 switch_2->set_line_orientation(
7197 0, switch_1_line_orientations[0]);
7198 switch_2->set_line_orientation(
7199 1, switch_1_line_orientations[1]);
7200 switch_2->set_line_orientation(
7201 2, switch_1_line_orientations[2]);
7202 switch_2->set_line_orientation(
7203 3, switch_1_line_orientations[3]);
7204 switch_2->set_boundary_id_internal(
7205 switch_1_boundary_id);
7206 switch_2->set_manifold_id(switch_1->manifold_id());
7207 switch_2->set_user_index(switch_1_user_index);
7208 if (switch_1_user_flag)
7209 switch_2->set_user_flag();
7211 switch_2->clear_user_flag();
7212 switch_2->clear_refinement_case();
7213 switch_2->set_refinement_case(
7214 switch_1_refinement_case);
7215 switch_2->clear_children();
7216 switch_2->set_children(0,
7217 switch_1_first_child_pair);
7218 switch_2->set_children(2,
7219 switch_1_second_child_pair);
7221 new_quads[0]->set_refinement_case(
7223 new_quads[0]->set_children(0, quad->child_index(0));
7224 new_quads[1]->set_refinement_case(
7226 new_quads[1]->set_children(0, quad->child_index(2));
7230 new_quads[0]->set_refinement_case(
7232 new_quads[0]->set_children(0, quad->child_index(0));
7233 new_quads[1]->set_refinement_case(
7235 new_quads[1]->set_children(0, quad->child_index(2));
7236 new_line->set_children(
7237 0, quad->child(0)->line_index(3));
7238 Assert(new_line->child(1) ==
7239 quad->child(1)->line(3),
7242 quad->clear_children();
7246 quad->set_children(0, new_quads[0]->
index());
7248 quad->set_refinement_case(aniso_quad_ref_case);
7255 if (quad->user_flag_set())
7267 ++next_unused_vertex;
7271 "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."));
7279 quad->refinement_case();
7285 quad->child(0)->set_user_index(
7287 quad->child(1)->set_user_index(
7293 middle_line = quad->child(0)->line(1);
7295 middle_line = quad->child(0)->line(3);
7302 if (!middle_line->has_children())
7310 middle_line->center(
true);
7318 .template next_free_pair_object<1>(
7323 middle_line->set_children(
7324 0, next_unused_line->index());
7328 raw_line_iterator children[2] = {
7329 next_unused_line, ++next_unused_line};
7337 children[0]->set_bounding_object_indices(
7338 {middle_line->vertex_index(0),
7339 next_unused_vertex});
7340 children[1]->set_bounding_object_indices(
7341 {next_unused_vertex,
7342 middle_line->vertex_index(1)});
7344 children[0]->set_used_flag();
7345 children[1]->set_used_flag();
7346 children[0]->clear_children();
7347 children[1]->clear_children();
7350 children[0]->clear_user_flag();
7351 children[1]->clear_user_flag();
7353 children[0]->set_boundary_id_internal(
7354 middle_line->boundary_id());
7355 children[1]->set_boundary_id_internal(
7356 middle_line->boundary_id());
7358 children[0]->set_manifold_id(
7359 middle_line->manifold_id());
7360 children[1]->set_manifold_id(
7361 middle_line->manifold_id());
7367 quad->clear_user_flag();
7397 quad->center(
true,
true);
7406 for (
unsigned int i = 0; i < 4; ++i)
7419 new_lines[i] = next_unused_line;
7443 quad->line(0)->child(0)->vertex_index(1),
7444 quad->line(1)->child(0)->vertex_index(1),
7445 quad->line(2)->child(0)->vertex_index(1),
7446 quad->line(3)->child(0)->vertex_index(1),
7447 next_unused_vertex};
7449 new_lines[0]->set_bounding_object_indices(
7451 new_lines[1]->set_bounding_object_indices(
7453 new_lines[2]->set_bounding_object_indices(
7455 new_lines[3]->set_bounding_object_indices(
7458 for (
const auto &new_line : new_lines)
7460 new_line->set_used_flag();
7461 new_line->clear_user_flag();
7463 new_line->clear_children();
7464 new_line->set_boundary_id_internal(quad->boundary_id());
7465 new_line->set_manifold_id(quad->manifold_id());
7484 const unsigned int index[2][2] = {
7488 const int line_indices[12] = {
7490 ->child(
index[0][quad->line_orientation(0)])
7493 ->child(
index[1][quad->line_orientation(0)])
7496 ->child(
index[0][quad->line_orientation(1)])
7499 ->child(
index[1][quad->line_orientation(1)])
7502 ->child(
index[0][quad->line_orientation(2)])
7505 ->child(
index[1][quad->line_orientation(2)])
7508 ->child(
index[0][quad->line_orientation(3)])
7511 ->child(
index[1][quad->line_orientation(3)])
7513 new_lines[0]->index(),
7514 new_lines[1]->index(),
7515 new_lines[2]->index(),
7516 new_lines[3]->index()};
7528 new_quads[0] = next_unused_quad;
7532 new_quads[1] = next_unused_quad;
7538 new_quads[2] = next_unused_quad;
7542 new_quads[3] = next_unused_quad;
7546 quad->set_children(0, new_quads[0]->
index());
7547 quad->set_children(2, new_quads[2]->
index());
7550 new_quads[0]->set_bounding_object_indices(
7555 new_quads[1]->set_bounding_object_indices(
7560 new_quads[2]->set_bounding_object_indices(
7565 new_quads[3]->set_bounding_object_indices(
7570 for (
const auto &new_quad : new_quads)
7572 new_quad->set_used_flag();
7573 new_quad->clear_user_flag();
7575 new_quad->clear_children();
7576 new_quad->set_boundary_id_internal(quad->boundary_id());
7577 new_quad->set_manifold_id(quad->manifold_id());
7581 for (
unsigned int j = 0;
7582 j < GeometryInfo<dim>::lines_per_face;
7584 new_quad->set_line_orientation(j,
true);
7590 new_quads[0]->set_line_orientation(
7591 0, quad->line_orientation(0));
7592 new_quads[0]->set_line_orientation(
7593 2, quad->line_orientation(2));
7594 new_quads[1]->set_line_orientation(
7595 1, quad->line_orientation(1));
7596 new_quads[1]->set_line_orientation(
7597 2, quad->line_orientation(2));
7598 new_quads[2]->set_line_orientation(
7599 0, quad->line_orientation(0));
7600 new_quads[2]->set_line_orientation(
7601 3, quad->line_orientation(3));
7602 new_quads[3]->set_line_orientation(
7603 1, quad->line_orientation(1));
7604 new_quads[3]->set_line_orientation(
7605 3, quad->line_orientation(3));
7609 quad->clear_user_flag();
7620 cells_with_distorted_children;
7634 for (; hex != endh; ++hex)
7635 if (hex->refine_flag_set())
7643 hex->clear_refine_flag();
7644 hex->set_refinement_case(ref_case);
7655 unsigned int n_new_lines = 0;
7656 unsigned int n_new_quads = 0;
7657 unsigned int n_new_hexes = 0;
7688 new_lines(n_new_lines);
7689 for (
unsigned int i = 0; i < n_new_lines; ++i)
7696 new_lines[i]->set_used_flag();
7697 new_lines[i]->clear_user_flag();
7698 new_lines[i]->clear_user_data();
7699 new_lines[i]->clear_children();
7701 new_lines[i]->set_boundary_id_internal(
7705 new_lines[i]->set_manifold_id(hex->manifold_id());
7712 new_quads(n_new_quads);
7713 for (
unsigned int i = 0; i < n_new_quads; ++i)
7720 new_quads[i]->set_used_flag();
7721 new_quads[i]->clear_user_flag();
7722 new_quads[i]->clear_user_data();
7723 new_quads[i]->clear_children();
7725 new_quads[i]->set_boundary_id_internal(
7729 new_quads[i]->set_manifold_id(hex->manifold_id());
7732 for (
unsigned int j = 0;
7733 j < GeometryInfo<dim>::lines_per_face;
7735 new_quads[i]->set_line_orientation(j,
true);
7744 new_hexes(n_new_hexes);
7745 for (
unsigned int i = 0; i < n_new_hexes; ++i)
7754 new_hexes[i] = next_unused_hex;
7757 new_hexes[i]->set_used_flag();
7758 new_hexes[i]->clear_user_flag();
7759 new_hexes[i]->clear_user_data();
7760 new_hexes[i]->clear_children();
7763 new_hexes[i]->set_material_id(hex->material_id());
7764 new_hexes[i]->set_manifold_id(hex->manifold_id());
7765 new_hexes[i]->set_subdomain_id(subdomainid);
7768 new_hexes[i]->set_parent(hex->index());
7780 for (
const unsigned int f :
7783 new_hexes[i]->set_face_orientation(f,
true);
7784 new_hexes[i]->set_face_flip(f,
false);
7785 new_hexes[i]->set_face_rotation(f,
false);
7789 for (
unsigned int i = 0; i < n_new_hexes / 2; ++i)
7790 hex->set_children(2 * i, new_hexes[2 * i]->index());
7797 const bool f_or[6] = {hex->face_orientation(0),
7798 hex->face_orientation(1),
7799 hex->face_orientation(2),
7800 hex->face_orientation(3),
7801 hex->face_orientation(4),
7802 hex->face_orientation(5)};
7805 const bool f_fl[6] = {hex->face_flip(0),
7813 const bool f_ro[6] = {hex->face_rotation(0),
7814 hex->face_rotation(1),
7815 hex->face_rotation(2),
7816 hex->face_rotation(3),
7817 hex->face_rotation(4),
7818 hex->face_rotation(5)};
7828 const unsigned int child_at_origin[2][2][2] = {
7915 raw_line_iterator lines[4] = {
7916 hex->face(2)->child(0)->line(
7917 (hex->face(2)->refinement_case() ==
7921 hex->face(3)->child(0)->line(
7922 (hex->face(3)->refinement_case() ==
7926 hex->face(4)->child(0)->line(
7927 (hex->face(4)->refinement_case() ==
7931 hex->face(5)->child(0)->line(
7932 (hex->face(5)->refinement_case() ==
7938 unsigned int line_indices[4];
7939 for (
unsigned int i = 0; i < 4; ++i)
7940 line_indices[i] = lines[i]->
index();
7947 bool line_orientation[4];
7953 const unsigned int middle_vertices[2] = {
7954 hex->line(2)->child(0)->vertex_index(1),
7955 hex->line(7)->child(0)->vertex_index(1)};
7957 for (
unsigned int i = 0; i < 4; ++i)
7958 if (lines[i]->vertex_index(i % 2) ==
7959 middle_vertices[i % 2])
7960 line_orientation[i] =
true;
7965 Assert(lines[i]->vertex_index((i + 1) % 2) ==
7966 middle_vertices[i % 2],
7968 line_orientation[i] =
false;
7973 new_quads[0]->set_bounding_object_indices(
7979 new_quads[0]->set_line_orientation(
7980 0, line_orientation[0]);
7981 new_quads[0]->set_line_orientation(
7982 1, line_orientation[1]);
7983 new_quads[0]->set_line_orientation(
7984 2, line_orientation[2]);
7985 new_quads[0]->set_line_orientation(
7986 3, line_orientation[3]);
8019 const int quad_indices[11] = {
8020 new_quads[0]->index(),
8022 hex->face(0)->index(),
8024 hex->face(1)->index(),
8026 hex->face(2)->child_index(
8027 child_at_origin[hex->face(2)->refinement_case() -
8028 1][f_fl[2]][f_ro[2]]),
8029 hex->face(2)->child_index(
8031 child_at_origin[hex->face(2)->refinement_case() -
8032 1][f_fl[2]][f_ro[2]]),
8034 hex->face(3)->child_index(
8035 child_at_origin[hex->face(3)->refinement_case() -
8036 1][f_fl[3]][f_ro[3]]),
8037 hex->face(3)->child_index(
8039 child_at_origin[hex->face(3)->refinement_case() -
8040 1][f_fl[3]][f_ro[3]]),
8042 hex->face(4)->child_index(
8043 child_at_origin[hex->face(4)->refinement_case() -
8044 1][f_fl[4]][f_ro[4]]),
8045 hex->face(4)->child_index(
8047 child_at_origin[hex->face(4)->refinement_case() -
8048 1][f_fl[4]][f_ro[4]]),
8050 hex->face(5)->child_index(
8051 child_at_origin[hex->face(5)->refinement_case() -
8052 1][f_fl[5]][f_ro[5]]),
8053 hex->face(5)->child_index(
8055 child_at_origin[hex->face(5)->refinement_case() -
8056 1][f_fl[5]][f_ro[5]])
8060 new_hexes[0]->set_bounding_object_indices(
8067 new_hexes[1]->set_bounding_object_indices(
8142 raw_line_iterator lines[4] = {
8143 hex->face(0)->child(0)->line(
8144 (hex->face(0)->refinement_case() ==
8148 hex->face(1)->child(0)->line(
8149 (hex->face(1)->refinement_case() ==
8153 hex->face(4)->child(0)->line(
8154 (hex->face(4)->refinement_case() ==
8158 hex->face(5)->child(0)->line(
8159 (hex->face(5)->refinement_case() ==
8165 unsigned int line_indices[4];
8166 for (
unsigned int i = 0; i < 4; ++i)
8167 line_indices[i] = lines[i]->
index();
8174 bool line_orientation[4];
8180 const unsigned int middle_vertices[2] = {
8181 hex->line(0)->child(0)->vertex_index(1),
8182 hex->line(5)->child(0)->vertex_index(1)};
8184 for (
unsigned int i = 0; i < 4; ++i)
8185 if (lines[i]->vertex_index(i % 2) ==
8186 middle_vertices[i % 2])
8187 line_orientation[i] =
true;
8191 Assert(lines[i]->vertex_index((i + 1) % 2) ==
8192 middle_vertices[i % 2],
8194 line_orientation[i] =
false;
8199 new_quads[0]->set_bounding_object_indices(
8205 new_quads[0]->set_line_orientation(
8206 0, line_orientation[2]);
8207 new_quads[0]->set_line_orientation(
8208 1, line_orientation[3]);
8209 new_quads[0]->set_line_orientation(
8210 2, line_orientation[0]);
8211 new_quads[0]->set_line_orientation(
8212 3, line_orientation[1]);
8245 const int quad_indices[11] = {
8246 new_quads[0]->index(),
8248 hex->face(0)->child_index(
8249 child_at_origin[hex->face(0)->refinement_case() -
8250 1][f_fl[0]][f_ro[0]]),
8251 hex->face(0)->child_index(
8253 child_at_origin[hex->face(0)->refinement_case() -
8254 1][f_fl[0]][f_ro[0]]),
8256 hex->face(1)->child_index(
8257 child_at_origin[hex->face(1)->refinement_case() -
8258 1][f_fl[1]][f_ro[1]]),
8259 hex->face(1)->child_index(
8261 child_at_origin[hex->face(1)->refinement_case() -
8262 1][f_fl[1]][f_ro[1]]),
8264 hex->face(2)->index(),
8266 hex->face(3)->index(),
8268 hex->face(4)->child_index(
8269 child_at_origin[hex->face(4)->refinement_case() -
8270 1][f_fl[4]][f_ro[4]]),
8271 hex->face(4)->child_index(
8273 child_at_origin[hex->face(4)->refinement_case() -
8274 1][f_fl[4]][f_ro[4]]),
8276 hex->face(5)->child_index(
8277 child_at_origin[hex->face(5)->refinement_case() -
8278 1][f_fl[5]][f_ro[5]]),
8279 hex->face(5)->child_index(
8281 child_at_origin[hex->face(5)->refinement_case() -
8282 1][f_fl[5]][f_ro[5]])
8286 new_hexes[0]->set_bounding_object_indices(
8293 new_hexes[1]->set_bounding_object_indices(
8370 raw_line_iterator lines[4] = {
8371 hex->face(0)->child(0)->line(
8372 (hex->face(0)->refinement_case() ==
8376 hex->face(1)->child(0)->line(
8377 (hex->face(1)->refinement_case() ==
8381 hex->face(2)->child(0)->line(
8382 (hex->face(2)->refinement_case() ==
8386 hex->face(3)->child(0)->line(
8387 (hex->face(3)->refinement_case() ==
8393 unsigned int line_indices[4];
8394 for (
unsigned int i = 0; i < 4; ++i)
8395 line_indices[i] = lines[i]->
index();
8402 bool line_orientation[4];
8408 const unsigned int middle_vertices[2] = {
8409 middle_vertex_index<dim, spacedim>(hex->line(8)),
8410 middle_vertex_index<dim, spacedim>(hex->line(11))};
8412 for (
unsigned int i = 0; i < 4; ++i)
8413 if (lines[i]->vertex_index(i % 2) ==
8414 middle_vertices[i % 2])
8415 line_orientation[i] =
true;
8419 Assert(lines[i]->vertex_index((i + 1) % 2) ==
8420 middle_vertices[i % 2],
8422 line_orientation[i] =
false;
8427 new_quads[0]->set_bounding_object_indices(
8433 new_quads[0]->set_line_orientation(
8434 0, line_orientation[0]);
8435 new_quads[0]->set_line_orientation(
8436 1, line_orientation[1]);
8437 new_quads[0]->set_line_orientation(
8438 2, line_orientation[2]);
8439 new_quads[0]->set_line_orientation(
8440 3, line_orientation[3]);
8474 const int quad_indices[11] = {
8475 new_quads[0]->index(),
8477 hex->face(0)->child_index(
8478 child_at_origin[hex->face(0)->refinement_case() -
8479 1][f_fl[0]][f_ro[0]]),
8480 hex->face(0)->child_index(
8482 child_at_origin[hex->face(0)->refinement_case() -
8483 1][f_fl[0]][f_ro[0]]),
8485 hex->face(1)->child_index(
8486 child_at_origin[hex->face(1)->refinement_case() -
8487 1][f_fl[1]][f_ro[1]]),
8488 hex->face(1)->child_index(
8490 child_at_origin[hex->face(1)->refinement_case() -
8491 1][f_fl[1]][f_ro[1]]),
8493 hex->face(2)->child_index(
8494 child_at_origin[hex->face(2)->refinement_case() -
8495 1][f_fl[2]][f_ro[2]]),
8496 hex->face(2)->child_index(
8498 child_at_origin[hex->face(2)->refinement_case() -
8499 1][f_fl[2]][f_ro[2]]),
8501 hex->face(3)->child_index(
8502 child_at_origin[hex->face(3)->refinement_case() -
8503 1][f_fl[3]][f_ro[3]]),
8504 hex->face(3)->child_index(
8506 child_at_origin[hex->face(3)->refinement_case() -
8507 1][f_fl[3]][f_ro[3]]),
8509 hex->face(4)->index(),
8511 hex->face(5)->index()
8514 new_hexes[0]->set_bounding_object_indices(
8521 new_hexes[1]->set_bounding_object_indices(
8553 new_lines[0]->set_bounding_object_indices(
8554 {middle_vertex_index<dim, spacedim>(hex->face(4)),
8555 middle_vertex_index<dim, spacedim>(hex->face(5))});
8623 spacedim>::raw_line_iterator lines[13] = {
8624 hex->face(0)->child(0)->line(
8625 (hex->face(0)->refinement_case() ==
8629 hex->face(1)->child(0)->line(
8630 (hex->face(1)->refinement_case() ==
8634 hex->face(2)->child(0)->line(
8635 (hex->face(2)->refinement_case() ==
8639 hex->face(3)->child(0)->line(
8640 (hex->face(3)->refinement_case() ==
8648 0, f_or[4], f_fl[4], f_ro[4]))
8651 1, f_or[4], f_fl[4], f_ro[4])),
8655 3, f_or[4], f_fl[4], f_ro[4]))
8658 0, f_or[4], f_fl[4], f_ro[4])),
8662 0, f_or[4], f_fl[4], f_ro[4]))
8665 3, f_or[4], f_fl[4], f_ro[4])),
8669 3, f_or[4], f_fl[4], f_ro[4]))
8672 2, f_or[4], f_fl[4], f_ro[4])),
8677 0, f_or[5], f_fl[5], f_ro[5]))
8680 1, f_or[5], f_fl[5], f_ro[5])),
8684 3, f_or[5], f_fl[5], f_ro[5]))
8687 0, f_or[5], f_fl[5], f_ro[5])),
8691 0, f_or[5], f_fl[5], f_ro[5]))
8694 3, f_or[5], f_fl[5], f_ro[5])),
8698 3, f_or[5], f_fl[5], f_ro[5]))
8701 2, f_or[5], f_fl[5], f_ro[5])),
8706 unsigned int line_indices[13];
8707 for (
unsigned int i = 0; i < 13; ++i)
8708 line_indices[i] = lines[i]->
index();
8715 bool line_orientation[13];
8719 const unsigned int middle_vertices[4] = {
8720 hex->line(0)->child(0)->vertex_index(1),
8721 hex->line(1)->child(0)->vertex_index(1),
8722 hex->line(2)->child(0)->vertex_index(1),
8723 hex->line(3)->child(0)->vertex_index(1),
8729 for (
unsigned int i = 0; i < 4; ++i)
8730 if (lines[i]->vertex_index(0) == middle_vertices[i])
8731 line_orientation[i] =
true;
8735 Assert(lines[i]->vertex_index(1) ==
8738 line_orientation[i] =
false;
8747 for (
unsigned int i = 4; i < 12; ++i)
8748 if (lines[i]->vertex_index((i + 1) % 2) ==
8749 middle_vertex_index<dim, spacedim>(
8750 hex->face(3 + i / 4)))
8751 line_orientation[i] =
true;
8756 Assert(lines[i]->vertex_index(i % 2) ==
8757 (middle_vertex_index<dim, spacedim>(
8758 hex->face(3 + i / 4))),
8760 line_orientation[i] =
false;
8765 line_orientation[12] =
true;
8790 new_quads[0]->set_bounding_object_indices(
8795 new_quads[1]->set_bounding_object_indices(
8800 new_quads[2]->set_bounding_object_indices(
8805 new_quads[3]->set_bounding_object_indices(
8811 new_quads[0]->set_line_orientation(
8812 0, line_orientation[2]);
8813 new_quads[0]->set_line_orientation(
8814 2, line_orientation[4]);
8815 new_quads[0]->set_line_orientation(
8816 3, line_orientation[8]);
8818 new_quads[1]->set_line_orientation(
8819 1, line_orientation[3]);
8820 new_quads[1]->set_line_orientation(
8821 2, line_orientation[5]);
8822 new_quads[1]->set_line_orientation(
8823 3, line_orientation[9]);
8825 new_quads[2]->set_line_orientation(
8826 0, line_orientation[6]);
8827 new_quads[2]->set_line_orientation(
8828 1, line_orientation[10]);
8829 new_quads[2]->set_line_orientation(
8830 2, line_orientation[0]);
8832 new_quads[3]->set_line_orientation(
8833 0, line_orientation[7]);
8834 new_quads[3]->set_line_orientation(
8835 1, line_orientation[11]);
8836 new_quads[3]->set_line_orientation(
8837 3, line_orientation[1]);
8870 const int quad_indices[20] = {
8871 new_quads[0]->index(),
8872 new_quads[1]->index(),
8873 new_quads[2]->index(),
8874 new_quads[3]->index(),
8876 hex->face(0)->child_index(
8877 child_at_origin[hex->face(0)->refinement_case() -
8878 1][f_fl[0]][f_ro[0]]),
8879 hex->face(0)->child_index(
8881 child_at_origin[hex->face(0)->refinement_case() -
8882 1][f_fl[0]][f_ro[0]]),
8884 hex->face(1)->child_index(
8885 child_at_origin[hex->face(1)->refinement_case() -
8886 1][f_fl[1]][f_ro[1]]),
8887 hex->face(1)->child_index(
8889 child_at_origin[hex->face(1)->refinement_case() -
8890 1][f_fl[1]][f_ro[1]]),
8892 hex->face(2)->child_index(
8893 child_at_origin[hex->face(2)->refinement_case() -
8894 1][f_fl[2]][f_ro[2]]),
8895 hex->face(2)->child_index(
8897 child_at_origin[hex->face(2)->refinement_case() -
8898 1][f_fl[2]][f_ro[2]]),
8900 hex->face(3)->child_index(
8901 child_at_origin[hex->face(3)->refinement_case() -
8902 1][f_fl[3]][f_ro[3]]),
8903 hex->face(3)->child_index(
8905 child_at_origin[hex->face(3)->refinement_case() -
8906 1][f_fl[3]][f_ro[3]]),
8908 hex->face(4)->isotropic_child_index(
8910 0, f_or[4], f_fl[4], f_ro[4])),
8911 hex->face(4)->isotropic_child_index(
8913 1, f_or[4], f_fl[4], f_ro[4])),
8914 hex->face(4)->isotropic_child_index(
8916 2, f_or[4], f_fl[4], f_ro[4])),
8917 hex->face(4)->isotropic_child_index(
8919 3, f_or[4], f_fl[4], f_ro[4])),
8921 hex->face(5)->isotropic_child_index(
8923 0, f_or[5], f_fl[5], f_ro[5])),
8924 hex->face(5)->isotropic_child_index(
8926 1, f_or[5], f_fl[5], f_ro[5])),
8927 hex->face(5)->isotropic_child_index(
8929 2, f_or[5], f_fl[5], f_ro[5])),
8930 hex->face(5)->isotropic_child_index(
8932 3, f_or[5], f_fl[5], f_ro[5]))};
8934 new_hexes[0]->set_bounding_object_indices(
8941 new_hexes[1]->set_bounding_object_indices(
8948 new_hexes[2]->set_bounding_object_indices(
8955 new_hexes[3]->set_bounding_object_indices(
8987 new_lines[0]->set_bounding_object_indices(
8988 {middle_vertex_index<dim, spacedim>(hex->face(2)),
8989 middle_vertex_index<dim, spacedim>(hex->face(3))});
9057 spacedim>::raw_line_iterator lines[13] = {
9058 hex->face(0)->child(0)->line(
9059 (hex->face(0)->refinement_case() ==
9063 hex->face(1)->child(0)->line(
9064 (hex->face(1)->refinement_case() ==
9068 hex->face(4)->child(0)->line(
9069 (hex->face(4)->refinement_case() ==
9073 hex->face(5)->child(0)->line(
9074 (hex->face(5)->refinement_case() ==
9082 0, f_or[2], f_fl[2], f_ro[2]))
9085 3, f_or[2], f_fl[2], f_ro[2])),
9089 3, f_or[2], f_fl[2], f_ro[2]))
9092 2, f_or[2], f_fl[2], f_ro[2])),
9096 0, f_or[2], f_fl[2], f_ro[2]))
9099 1, f_or[2], f_fl[2], f_ro[2])),
9103 3, f_or[2], f_fl[2], f_ro[2]))
9106 0, f_or[2], f_fl[2], f_ro[2])),
9111 0, f_or[3], f_fl[3], f_ro[3]))
9114 3, f_or[3], f_fl[3], f_ro[3])),
9118 3, f_or[3], f_fl[3], f_ro[3]))
9121 2, f_or[3], f_fl[3], f_ro[3])),
9125 0, f_or[3], f_fl[3], f_ro[3]))
9128 1, f_or[3], f_fl[3], f_ro[3])),
9132 3, f_or[3], f_fl[3], f_ro[3]))
9135 0, f_or[3], f_fl[3], f_ro[3])),
9140 unsigned int line_indices[13];
9141 for (
unsigned int i = 0; i < 13; ++i)
9142 line_indices[i] = lines[i]->
index();
9149 bool line_orientation[13];
9153 const unsigned int middle_vertices[4] = {
9154 hex->line(8)->child(0)->vertex_index(1),
9155 hex->line(9)->child(0)->vertex_index(1),
9156 hex->line(2)->child(0)->vertex_index(1),
9157 hex->line(6)->child(0)->vertex_index(1),
9162 for (
unsigned int i = 0; i < 4; ++i)
9163 if (lines[i]->vertex_index(0) == middle_vertices[i])
9164 line_orientation[i] =
true;
9168 Assert(lines[i]->vertex_index(1) ==
9171 line_orientation[i] =
false;
9180 for (
unsigned int i = 4; i < 12; ++i)
9181 if (lines[i]->vertex_index((i + 1) % 2) ==
9182 middle_vertex_index<dim, spacedim>(
9183 hex->face(1 + i / 4)))
9184 line_orientation[i] =
true;
9189 Assert(lines[i]->vertex_index(i % 2) ==
9190 (middle_vertex_index<dim, spacedim>(
9191 hex->face(1 + i / 4))),
9193 line_orientation[i] =
false;
9198 line_orientation[12] =
true;
9224 new_quads[0]->set_bounding_object_indices(
9229 new_quads[1]->set_bounding_object_indices(
9234 new_quads[2]->set_bounding_object_indices(
9239 new_quads[3]->set_bounding_object_indices(
9245 new_quads[0]->set_line_orientation(
9246 0, line_orientation[0]);
9247 new_quads[0]->set_line_orientation(
9248 2, line_orientation[6]);
9249 new_quads[0]->set_line_orientation(
9250 3, line_orientation[10]);
9252 new_quads[1]->set_line_orientation(
9253 1, line_orientation[1]);
9254 new_quads[1]->set_line_orientation(
9255 2, line_orientation[7]);
9256 new_quads[1]->set_line_orientation(
9257 3, line_orientation[11]);
9259 new_quads[2]->set_line_orientation(
9260 0, line_orientation[4]);
9261 new_quads[2]->set_line_orientation(
9262 1, line_orientation[8]);
9263 new_quads[2]->set_line_orientation(
9264 2, line_orientation[2]);
9266 new_quads[3]->set_line_orientation(
9267 0, line_orientation[5]);
9268 new_quads[3]->set_line_orientation(
9269 1, line_orientation[9]);
9270 new_quads[3]->set_line_orientation(
9271 3, line_orientation[3]);
9305 const int quad_indices[20] = {
9306 new_quads[0]->index(),
9307 new_quads[1]->index(),
9308 new_quads[2]->index(),
9309 new_quads[3]->index(),
9311 hex->face(0)->child_index(
9312 child_at_origin[hex->face(0)->refinement_case() -
9313 1][f_fl[0]][f_ro[0]]),
9314 hex->face(0)->child_index(
9316 child_at_origin[hex->face(0)->refinement_case() -
9317 1][f_fl[0]][f_ro[0]]),
9319 hex->face(1)->child_index(
9320 child_at_origin[hex->face(1)->refinement_case() -
9321 1][f_fl[1]][f_ro[1]]),
9322 hex->face(1)->child_index(
9324 child_at_origin[hex->face(1)->refinement_case() -
9325 1][f_fl[1]][f_ro[1]]),
9327 hex->face(2)->isotropic_child_index(
9329 0, f_or[2], f_fl[2], f_ro[2])),
9330 hex->face(2)->isotropic_child_index(
9332 1, f_or[2], f_fl[2], f_ro[2])),
9333 hex->face(2)->isotropic_child_index(
9335 2, f_or[2], f_fl[2], f_ro[2])),
9336 hex->face(2)->isotropic_child_index(
9338 3, f_or[2], f_fl[2], f_ro[2])),
9340 hex->face(3)->isotropic_child_index(
9342 0, f_or[3], f_fl[3], f_ro[3])),
9343 hex->face(3)->isotropic_child_index(
9345 1, f_or[3], f_fl[3], f_ro[3])),
9346 hex->face(3)->isotropic_child_index(
9348 2, f_or[3], f_fl[3], f_ro[3])),
9349 hex->face(3)->isotropic_child_index(
9351 3, f_or[3], f_fl[3], f_ro[3])),
9353 hex->face(4)->child_index(
9354 child_at_origin[hex->face(4)->refinement_case() -
9355 1][f_fl[4]][f_ro[4]]),
9356 hex->face(4)->child_index(
9358 child_at_origin[hex->face(4)->refinement_case() -
9359 1][f_fl[4]][f_ro[4]]),
9361 hex->face(5)->child_index(
9362 child_at_origin[hex->face(5)->refinement_case() -
9363 1][f_fl[5]][f_ro[5]]),
9364 hex->face(5)->child_index(
9366 child_at_origin[hex->face(5)->refinement_case() -
9367 1][f_fl[5]][f_ro[5]])};
9378 new_hexes[0]->set_bounding_object_indices(
9385 new_hexes[1]->set_bounding_object_indices(
9392 new_hexes[2]->set_bounding_object_indices(
9399 new_hexes[3]->set_bounding_object_indices(
9432 new_lines[0]->set_bounding_object_indices(
9434 {middle_vertex_index<dim, spacedim>(hex->face(0)),
9435 middle_vertex_index<dim, spacedim>(hex->face(1))});
9504 spacedim>::raw_line_iterator lines[13] = {
9505 hex->face(2)->child(0)->line(
9506 (hex->face(2)->refinement_case() ==
9510 hex->face(3)->child(0)->line(
9511 (hex->face(3)->refinement_case() ==
9515 hex->face(4)->child(0)->line(
9516 (hex->face(4)->refinement_case() ==
9520 hex->face(5)->child(0)->line(
9521 (hex->face(5)->refinement_case() ==
9529 0, f_or[0], f_fl[0], f_ro[0]))
9532 1, f_or[0], f_fl[0], f_ro[0])),
9536 3, f_or[0], f_fl[0], f_ro[0]))
9539 0, f_or[0], f_fl[0], f_ro[0])),
9543 0, f_or[0], f_fl[0], f_ro[0]))
9546 3, f_or[0], f_fl[0], f_ro[0])),
9550 3, f_or[0], f_fl[0], f_ro[0]))
9553 2, f_or[0], f_fl[0], f_ro[0])),
9558 0, f_or[1], f_fl[1], f_ro[1]))
9561 1, f_or[1], f_fl[1], f_ro[1])),
9565 3, f_or[1], f_fl[1], f_ro[1]))
9568 0, f_or[1], f_fl[1], f_ro[1])),
9572 0, f_or[1], f_fl[1], f_ro[1]))
9575 3, f_or[1], f_fl[1], f_ro[1])),
9579 3, f_or[1], f_fl[1], f_ro[1]))
9582 2, f_or[1], f_fl[1], f_ro[1])),
9587 unsigned int line_indices[13];
9589 for (
unsigned int i = 0; i < 13; ++i)
9590 line_indices[i] = lines[i]->
index();
9597 bool line_orientation[13];
9601 const unsigned int middle_vertices[4] = {
9602 hex->line(8)->child(0)->vertex_index(1),
9603 hex->line(10)->child(0)->vertex_index(1),
9604 hex->line(0)->child(0)->vertex_index(1),
9605 hex->line(4)->child(0)->vertex_index(1),
9610 for (
unsigned int i = 0; i < 4; ++i)
9611 if (lines[i]->vertex_index(0) == middle_vertices[i])
9612 line_orientation[i] =
true;
9616 Assert(lines[i]->vertex_index(1) ==
9619 line_orientation[i] =
false;
9628 for (
unsigned int i = 4; i < 12; ++i)
9629 if (lines[i]->vertex_index((i + 1) % 2) ==
9630 middle_vertex_index<dim, spacedim>(
9631 hex->face(i / 4 - 1)))
9632 line_orientation[i] =
true;
9637 Assert(lines[i]->vertex_index(i % 2) ==
9638 (middle_vertex_index<dim, spacedim>(
9639 hex->face(i / 4 - 1))),
9641 line_orientation[i] =
false;
9646 line_orientation[12] =
true;
9666 new_quads[0]->set_bounding_object_indices(
9671 new_quads[1]->set_bounding_object_indices(
9676 new_quads[2]->set_bounding_object_indices(
9681 new_quads[3]->set_bounding_object_indices(
9687 new_quads[0]->set_line_orientation(
9688 0, line_orientation[6]);
9689 new_quads[0]->set_line_orientation(
9690 1, line_orientation[10]);
9691 new_quads[0]->set_line_orientation(
9692 2, line_orientation[0]);
9694 new_quads[1]->set_line_orientation(
9695 0, line_orientation[7]);
9696 new_quads[1]->set_line_orientation(
9697 1, line_orientation[11]);
9698 new_quads[1]->set_line_orientation(
9699 3, line_orientation[1]);
9701 new_quads[2]->set_line_orientation(
9702 0, line_orientation[2]);
9703 new_quads[2]->set_line_orientation(
9704 2, line_orientation[4]);
9705 new_quads[2]->set_line_orientation(
9706 3, line_orientation[8]);
9708 new_quads[3]->set_line_orientation(
9709 1, line_orientation[3]);
9710 new_quads[3]->set_line_orientation(
9711 2, line_orientation[5]);
9712 new_quads[3]->set_line_orientation(
9713 3, line_orientation[9]);
9747 const int quad_indices[20] = {
9748 new_quads[0]->index(),
9749 new_quads[1]->index(),
9750 new_quads[2]->index(),
9751 new_quads[3]->index(),
9753 hex->face(0)->isotropic_child_index(
9755 0, f_or[0], f_fl[0], f_ro[0])),
9756 hex->face(0)->isotropic_child_index(
9758 1, f_or[0], f_fl[0], f_ro[0])),
9759 hex->face(0)->isotropic_child_index(
9761 2, f_or[0], f_fl[0], f_ro[0])),
9762 hex->face(0)->isotropic_child_index(
9764 3, f_or[0], f_fl[0], f_ro[0])),
9766 hex->face(1)->isotropic_child_index(
9768 0, f_or[1], f_fl[1], f_ro[1])),
9769 hex->face(1)->isotropic_child_index(
9771 1, f_or[1], f_fl[1], f_ro[1])),
9772 hex->face(1)->isotropic_child_index(
9774 2, f_or[1], f_fl[1], f_ro[1])),
9775 hex->face(1)->isotropic_child_index(
9777 3, f_or[1], f_fl[1], f_ro[1])),
9779 hex->face(2)->child_index(
9780 child_at_origin[hex->face(2)->refinement_case() -
9781 1][f_fl[2]][f_ro[2]]),
9782 hex->face(2)->child_index(
9784 child_at_origin[hex->face(2)->refinement_case() -
9785 1][f_fl[2]][f_ro[2]]),
9787 hex->face(3)->child_index(
9788 child_at_origin[hex->face(3)->refinement_case() -
9789 1][f_fl[3]][f_ro[3]]),
9790 hex->face(3)->child_index(
9792 child_at_origin[hex->face(3)->refinement_case() -
9793 1][f_fl[3]][f_ro[3]]),
9795 hex->face(4)->child_index(
9796 child_at_origin[hex->face(4)->refinement_case() -
9797 1][f_fl[4]][f_ro[4]]),
9798 hex->face(4)->child_index(
9800 child_at_origin[hex->face(4)->refinement_case() -
9801 1][f_fl[4]][f_ro[4]]),
9803 hex->face(5)->child_index(
9804 child_at_origin[hex->face(5)->refinement_case() -
9805 1][f_fl[5]][f_ro[5]]),
9806 hex->face(5)->child_index(
9808 child_at_origin[hex->face(5)->refinement_case() -
9809 1][f_fl[5]][f_ro[5]])};
9811 new_hexes[0]->set_bounding_object_indices(
9818 new_hexes[1]->set_bounding_object_indices(
9825 new_hexes[2]->set_bounding_object_indices(
9832 new_hexes[3]->set_bounding_object_indices(
9870 ++next_unused_vertex;
9874 "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."));
9885 hex->center(
true,
true);
9907 middle_vertex_index<dim, spacedim>(hex->face(0)),
9908 middle_vertex_index<dim, spacedim>(hex->face(1)),
9909 middle_vertex_index<dim, spacedim>(hex->face(2)),
9910 middle_vertex_index<dim, spacedim>(hex->face(3)),
9911 middle_vertex_index<dim, spacedim>(hex->face(4)),
9912 middle_vertex_index<dim, spacedim>(hex->face(5)),
9913 next_unused_vertex};
9915 new_lines[0]->set_bounding_object_indices(
9917 new_lines[1]->set_bounding_object_indices(
9919 new_lines[2]->set_bounding_object_indices(
9921 new_lines[3]->set_bounding_object_indices(
9923 new_lines[4]->set_bounding_object_indices(
9925 new_lines[5]->set_bounding_object_indices(
9995 spacedim>::raw_line_iterator lines[30] = {
9999 0, f_or[0], f_fl[0], f_ro[0]))
10002 1, f_or[0], f_fl[0], f_ro[0])),
10006 3, f_or[0], f_fl[0], f_ro[0]))
10009 0, f_or[0], f_fl[0], f_ro[0])),
10013 0, f_or[0], f_fl[0], f_ro[0]))
10016 3, f_or[0], f_fl[0], f_ro[0])),
10020 3, f_or[0], f_fl[0], f_ro[0]))
10023 2, f_or[0], f_fl[0], f_ro[0])),
10028 0, f_or[1], f_fl[1], f_ro[1]))
10031 1, f_or[1], f_fl[1], f_ro[1])),
10035 3, f_or[1], f_fl[1], f_ro[1]))
10038 0, f_or[1], f_fl[1], f_ro[1])),
10042 0, f_or[1], f_fl[1], f_ro[1]))
10045 3, f_or[1], f_fl[1], f_ro[1])),
10049 3, f_or[1], f_fl[1], f_ro[1]))
10052 2, f_or[1], f_fl[1], f_ro[1])),
10057 0, f_or[2], f_fl[2], f_ro[2]))
10060 1, f_or[2], f_fl[2], f_ro[2])),
10064 3, f_or[2], f_fl[2], f_ro[2]))
10067 0, f_or[2], f_fl[2], f_ro[2])),
10071 0, f_or[2], f_fl[2], f_ro[2]))
10074 3, f_or[2], f_fl[2], f_ro[2])),
10078 3, f_or[2], f_fl[2], f_ro[2]))
10081 2, f_or[2], f_fl[2], f_ro[2])),
10086 0, f_or[3], f_fl[3], f_ro[3]))
10089 1, f_or[3], f_fl[3], f_ro[3])),
10093 3, f_or[3], f_fl[3], f_ro[3]))
10096 0, f_or[3], f_fl[3], f_ro[3])),
10100 0, f_or[3], f_fl[3], f_ro[3]))
10103 3, f_or[3], f_fl[3], f_ro[3])),
10107 3, f_or[3], f_fl[3], f_ro[3]))
10110 2, f_or[3], f_fl[3], f_ro[3])),
10115 0, f_or[4], f_fl[4], f_ro[4]))
10118 1, f_or[4], f_fl[4], f_ro[4])),
10122 3, f_or[4], f_fl[4], f_ro[4]))
10125 0, f_or[4], f_fl[4], f_ro[4])),
10129 0, f_or[4], f_fl[4], f_ro[4]))
10132 3, f_or[4], f_fl[4], f_ro[4])),
10136 3, f_or[4], f_fl[4], f_ro[4]))
10139 2, f_or[4], f_fl[4], f_ro[4])),
10144 0, f_or[5], f_fl[5], f_ro[5]))
10147 1, f_or[5], f_fl[5], f_ro[5])),
10151 3, f_or[5], f_fl[5], f_ro[5]))
10154 0, f_or[5], f_fl[5], f_ro[5])),
10158 0, f_or[5], f_fl[5], f_ro[5]))
10161 3, f_or[5], f_fl[5], f_ro[5])),
10165 3, f_or[5], f_fl[5], f_ro[5]))
10168 2, f_or[5], f_fl[5], f_ro[5])),
10178 unsigned int line_indices[30];
10179 for (
unsigned int i = 0; i < 30; ++i)
10180 line_indices[i] = lines[i]->
index();
10187 bool line_orientation[30];
10195 for (
unsigned int i = 0; i < 24; ++i)
10196 if (lines[i]->vertex_index((i + 1) % 2) ==
10198 line_orientation[i] =
true;
10203 Assert(lines[i]->vertex_index(i % 2) ==
10206 line_orientation[i] =
false;
10211 for (
unsigned int i = 24; i < 30; ++i)
10212 line_orientation[i] =
true;
10244 new_quads[0]->set_bounding_object_indices(
10248 line_indices[24]});
10249 new_quads[1]->set_bounding_object_indices(
10253 line_indices[25]});
10254 new_quads[2]->set_bounding_object_indices(
10258 line_indices[20]});
10259 new_quads[3]->set_bounding_object_indices(
10263 line_indices[21]});
10264 new_quads[4]->set_bounding_object_indices(
10268 line_indices[28]});
10269 new_quads[5]->set_bounding_object_indices(
10273 line_indices[29]});
10274 new_quads[6]->set_bounding_object_indices(
10279 new_quads[7]->set_bounding_object_indices(
10284 new_quads[8]->set_bounding_object_indices(
10288 line_indices[26]});
10289 new_quads[9]->set_bounding_object_indices(
10293 line_indices[27]});
10294 new_quads[10]->set_bounding_object_indices(
10298 line_indices[12]});
10299 new_quads[11]->set_bounding_object_indices(
10303 line_indices[13]});
10308 new_quads[0]->set_line_orientation(
10309 0, line_orientation[10]);
10310 new_quads[0]->set_line_orientation(
10311 2, line_orientation[16]);
10313 new_quads[1]->set_line_orientation(
10314 1, line_orientation[14]);
10315 new_quads[1]->set_line_orientation(
10316 2, line_orientation[17]);
10318 new_quads[2]->set_line_orientation(
10319 0, line_orientation[11]);
10320 new_quads[2]->set_line_orientation(
10321 3, line_orientation[20]);
10323 new_quads[3]->set_line_orientation(
10324 1, line_orientation[15]);
10325 new_quads[3]->set_line_orientation(
10326 3, line_orientation[21]);
10328 new_quads[4]->set_line_orientation(
10329 0, line_orientation[18]);
10330 new_quads[4]->set_line_orientation(
10331 2, line_orientation[0]);
10333 new_quads[5]->set_line_orientation(
10334 1, line_orientation[22]);
10335 new_quads[5]->set_line_orientation(
10336 2, line_orientation[1]);
10338 new_quads[6]->set_line_orientation(
10339 0, line_orientation[19]);
10340 new_quads[6]->set_line_orientation(
10341 3, line_orientation[4]);
10343 new_quads[7]->set_line_orientation(
10344 1, line_orientation[23]);
10345 new_quads[7]->set_line_orientation(
10346 3, line_orientation[5]);
10348 new_quads[8]->set_line_orientation(
10349 0, line_orientation[2]);
10350 new_quads[8]->set_line_orientation(
10351 2, line_orientation[8]);
10353 new_quads[9]->set_line_orientation(
10354 1, line_orientation[6]);
10355 new_quads[9]->set_line_orientation(
10356 2, line_orientation[9]);
10358 new_quads[10]->set_line_orientation(
10359 0, line_orientation[3]);
10360 new_quads[10]->set_line_orientation(
10361 3, line_orientation[12]);
10363 new_quads[11]->set_line_orientation(
10364 1, line_orientation[7]);
10365 new_quads[11]->set_line_orientation(
10366 3, line_orientation[13]);
10407 const int quad_indices[36] = {
10408 new_quads[0]->index(),
10409 new_quads[1]->index(),
10410 new_quads[2]->index(),
10411 new_quads[3]->index(),
10412 new_quads[4]->index(),
10413 new_quads[5]->index(),
10414 new_quads[6]->index(),
10415 new_quads[7]->index(),
10416 new_quads[8]->index(),
10417 new_quads[9]->index(),
10418 new_quads[10]->index(),
10419 new_quads[11]->index(),
10421 hex->face(0)->isotropic_child_index(
10423 0, f_or[0], f_fl[0], f_ro[0])),
10424 hex->face(0)->isotropic_child_index(
10426 1, f_or[0], f_fl[0], f_ro[0])),
10427 hex->face(0)->isotropic_child_index(
10429 2, f_or[0], f_fl[0], f_ro[0])),
10430 hex->face(0)->isotropic_child_index(
10432 3, f_or[0], f_fl[0], f_ro[0])),
10434 hex->face(1)->isotropic_child_index(
10436 0, f_or[1], f_fl[1], f_ro[1])),
10437 hex->face(1)->isotropic_child_index(
10439 1, f_or[1], f_fl[1], f_ro[1])),
10440 hex->face(1)->isotropic_child_index(
10442 2, f_or[1], f_fl[1], f_ro[1])),
10443 hex->face(1)->isotropic_child_index(
10445 3, f_or[1], f_fl[1], f_ro[1])),
10447 hex->face(2)->isotropic_child_index(
10449 0, f_or[2], f_fl[2], f_ro[2])),
10450 hex->face(2)->isotropic_child_index(
10452 1, f_or[2], f_fl[2], f_ro[2])),
10453 hex->face(2)->isotropic_child_index(
10455 2, f_or[2], f_fl[2], f_ro[2])),
10456 hex->face(2)->isotropic_child_index(
10458 3, f_or[2], f_fl[2], f_ro[2])),
10460 hex->face(3)->isotropic_child_index(
10462 0, f_or[3], f_fl[3], f_ro[3])),
10463 hex->face(3)->isotropic_child_index(
10465 1, f_or[3], f_fl[3], f_ro[3])),
10466 hex->face(3)->isotropic_child_index(
10468 2, f_or[3], f_fl[3], f_ro[3])),
10469 hex->face(3)->isotropic_child_index(
10471 3, f_or[3], f_fl[3], f_ro[3])),
10473 hex->face(4)->isotropic_child_index(
10475 0, f_or[4], f_fl[4], f_ro[4])),
10476 hex->face(4)->isotropic_child_index(
10478 1, f_or[4], f_fl[4], f_ro[4])),
10479 hex->face(4)->isotropic_child_index(
10481 2, f_or[4], f_fl[4], f_ro[4])),
10482 hex->face(4)->isotropic_child_index(
10484 3, f_or[4], f_fl[4], f_ro[4])),
10486 hex->face(5)->isotropic_child_index(
10488 0, f_or[5], f_fl[5], f_ro[5])),
10489 hex->face(5)->isotropic_child_index(
10491 1, f_or[5], f_fl[5], f_ro[5])),
10492 hex->face(5)->isotropic_child_index(
10494 2, f_or[5], f_fl[5], f_ro[5])),
10495 hex->face(5)->isotropic_child_index(
10497 3, f_or[5], f_fl[5], f_ro[5]))};
10500 new_hexes[0]->set_bounding_object_indices(
10507 new_hexes[1]->set_bounding_object_indices(
10514 new_hexes[2]->set_bounding_object_indices(
10520 quad_indices[10]});
10521 new_hexes[3]->set_bounding_object_indices(
10527 quad_indices[11]});
10530 new_hexes[4]->set_bounding_object_indices(
10536 quad_indices[32]});
10537 new_hexes[5]->set_bounding_object_indices(
10543 quad_indices[33]});
10544 new_hexes[6]->set_bounding_object_indices(
10550 quad_indices[34]});
10551 new_hexes[7]->set_bounding_object_indices(
10557 quad_indices[35]});
10591 for (
unsigned int s = 0;
10598 const unsigned int current_child =
10607 ref_case, f, f_or[f], f_fl[f], f_ro[f]));
10608 new_hexes[current_child]->set_face_orientation(f,
10610 new_hexes[current_child]->set_face_flip(f, f_fl[f]);
10611 new_hexes[current_child]->set_face_rotation(f, f_ro[f]);
10616 if (check_for_distorted_cells &&
10617 has_distorted_children<dim, spacedim>(hex))
10637 return cells_with_distorted_children;
10653 template <
int spacedim>
10660 template <
int dim,
int spacedim>
10667 if (spacedim > dim)
10671 if (cell->at_boundary() && cell->refine_flag_set() &&
10672 cell->refine_flag_set() !=
10679 for (
const unsigned int face_no :
10681 if (cell->face(face_no)->at_boundary())
10692 spacedim>::face_iterator
10693 face = cell->face(face_no);
10700 cell->reference_cell()
10703 .transform_real_to_unit_cell(cell, new_bound);
10713 const double dist =
10714 std::fabs(new_unit[face_no / 2] - face_no % 2);
10719 const double allowed = 0.25;
10721 if (dist > allowed)
10722 cell->flag_for_face_refinement(face_no);
10741 template <
int dim,
int spacedim>
10746 ExcMessage(
"Wrong function called -- there should "
10747 "be a specialization."));
10751 template <
int spacedim>
10756 const unsigned int dim = 3;
10768 bool mesh_changed =
false;
10772 mesh_changed =
false;
10783 if (cell->refine_flag_set())
10785 for (
unsigned int line = 0; line < cell->n_lines(); ++line)
10787 cell->refine_flag_set(), line) ==
10791 cell->line(line)->set_user_flag();
10793 else if (cell->has_children() &&
10794 !cell->child(0)->coarsen_flag_set())
10796 for (
unsigned int line = 0; line < cell->n_lines(); ++line)
10798 cell->refinement_case(), line) ==
10802 cell->line(line)->set_user_flag();
10804 else if (cell->has_children() &&
10805 cell->child(0)->coarsen_flag_set())
10806 cell->set_user_flag();
10817 for (
unsigned int line = 0; line < cell->n_lines(); ++line)
10819 if (cell->line(line)->has_children())
10828 bool offending_line_found =
false;
10830 for (
unsigned int c = 0; c < 2; ++c)
10832 Assert(cell->line(line)->child(c)->has_children() ==
10836 if (cell->line(line)->child(c)->user_flag_set() &&
10838 cell->refine_flag_set(), line) ==
10842 cell->clear_coarsen_flag();
10849 allow_anisotropic_smoothing)
10850 cell->flag_for_line_refinement(line);
10852 cell->set_refine_flag();
10854 for (
unsigned int l = 0; l < cell->n_lines(); ++l)
10856 cell->refine_flag_set(), line) ==
10859 cell->line(l)->set_user_flag();
10862 offending_line_found =
true;
10868 for (
unsigned int l = 0; l < cell->n_lines(); ++l)
10869 if (!cell->line(l)->has_children() &&
10871 cell->refine_flag_set(), l) !=
10873 cell->line(l)->set_user_flag();
10879 if (offending_line_found)
10881 mesh_changed =
true;
10903 if (cell->user_flag_set())
10904 for (
unsigned int line = 0; line < cell->n_lines(); ++line)
10905 if (cell->line(line)->has_children() &&
10906 (cell->line(line)->child(0)->user_flag_set() ||
10907 cell->line(line)->child(1)->user_flag_set()))
10909 for (
unsigned int c = 0; c < cell->n_children(); ++c)
10910 cell->child(c)->clear_coarsen_flag();
10911 cell->clear_user_flag();
10912 for (
unsigned int l = 0; l < cell->n_lines(); ++l)
10914 cell->refinement_case(), l) ==
10918 cell->line(l)->set_user_flag();
10919 mesh_changed =
true;
10924 while (mesh_changed ==
true);
10935 template <
int dim,
int spacedim>
10955 const unsigned int n_subfaces =
10958 if (n_subfaces == 0 || cell->at_boundary(n))
10960 for (
unsigned int c = 0; c < n_subfaces; ++c)
10963 child = cell->child(
10967 child_neighbor = child->neighbor(n);
10968 if (!child->neighbor_is_coarser(n))
10981 if ((child_neighbor->has_children() &&
10982 !child_neighbor->user_flag_set()) ||
10991 child_neighbor->refine_flag_set())
11005 template <
int spacedim>
11010 template <
int dim,
int spacedim>
11013 std::vector<std::pair<unsigned int, unsigned int>>
adjacent_cells(
11015 {numbers::invalid_unsigned_int, numbers::invalid_unsigned_int});
11017 const auto set_entry = [&](
const auto &face_index,
const auto &cell) {
11018 const std::pair<unsigned int, unsigned int> cell_pair = {
11019 cell->level(), cell->index()};
11020 unsigned int index;
11027 index = 2 * face_index + 0;
11036 index = 2 * face_index + 1;
11042 const auto get_entry =
11043 [&](
const auto &face_index,
11047 if (test == std::pair<unsigned int, unsigned int>(cell->level(),
11061 for (
const auto &face : cell->face_iterators())
11063 set_entry(face->index(), cell);
11065 if (cell->is_active() && face->has_children())
11066 for (
unsigned int c = 0; c < face->n_children(); ++c)
11067 set_entry(face->child(c)->index(), cell);
11071 for (
auto f : cell->face_indices())
11072 cell->set_neighbor(f, get_entry(cell->face(f)->index(), cell));
11075 template <
int dim,
int spacedim>
11080 std::vector<unsigned int> & line_cell_count,
11081 std::vector<unsigned int> & quad_cell_count)
11086 (void)line_cell_count;
11087 (void)quad_cell_count;
11090 template <
int dim,
int spacedim>
11093 const bool check_for_distorted_cells)
11095 return Implementation::execute_refinement_isotropic(
11099 template <
int dim,
int spacedim>
11108 template <
int dim,
int spacedim>
11113 Implementation::prepare_refinement_dim_dependent(
triangulation);
11116 template <
int dim,
int spacedim>
11129 template <
int dim,
int spacedim>
11134 return flat_manifold;
11141template <
int dim,
int spacedim>
11146template <
int dim,
int spacedim>
11148 const MeshSmoothing smooth_grid,
11149 const bool check_for_distorted_cells)
11150 : smooth_grid(smooth_grid)
11151 , anisotropic_refinement(false)
11152 , check_for_distorted_cells(check_for_distorted_cells)
11156 vertex_to_boundary_id_map_1d =
11157 std::make_unique<std::map<unsigned int, types::boundary_id>>();
11158 vertex_to_manifold_id_map_1d =
11159 std::make_unique<std::map<unsigned int, types::manifold_id>>();
11163 signals.create.connect(signals.any_change);
11164 signals.post_refinement.connect(signals.any_change);
11165 signals.clear.connect(signals.any_change);
11166 signals.mesh_movement.connect(signals.any_change);
11171template <
int dim,
int spacedim>
11197template <
int dim,
int spacedim>
11228template <
int dim,
int spacedim>
11245 AssertNothrow((dim == 1) || (vertex_to_boundary_id_map_1d ==
nullptr),
11250 AssertNothrow((dim == 1) || (vertex_to_manifold_id_map_1d ==
nullptr),
11256template <
int dim,
int spacedim>
11264 clear_despite_subscriptions();
11265 periodic_face_pairs_level_0.clear();
11266 periodic_face_map.clear();
11267 reference_cells.clear();
11271template <
int dim,
int spacedim>
11275 return MPI_COMM_SELF;
11280template <
int dim,
int spacedim>
11283 const MeshSmoothing mesh_smoothing)
11286 ExcTriangulationNotEmpty(
vertices.size(), levels.size()));
11287 smooth_grid = mesh_smoothing;
11292template <
int dim,
int spacedim>
11296 return smooth_grid;
11301template <
int dim,
int spacedim>
11309 manifolds[m_number] = manifold_object.
clone();
11314template <
int dim,
int spacedim>
11321 manifolds.erase(m_number);
11325template <
int dim,
int spacedim>
11333template <
int dim,
int spacedim>
11341 "Error: set_all_manifold_ids() can not be called on an empty Triangulation."));
11343 for (
const auto &cell : this->active_cell_iterators())
11344 cell->set_all_manifold_ids(m_number);
11348template <
int dim,
int spacedim>
11356 "Error: set_all_manifold_ids_on_boundary() can not be called on an empty Triangulation."));
11358 for (
const auto &cell : this->active_cell_iterators())
11360 if (cell->face(f)->at_boundary())
11361 cell->face(f)->set_all_manifold_ids(m_number);
11365template <
int dim,
int spacedim>
11374 "Error: set_all_manifold_ids_on_boundary() can not be called on an empty Triangulation."));
11376 bool boundary_found =
false;
11378 for (
const auto &cell : this->active_cell_iterators())
11382 if (cell->face(f)->at_boundary() &&
11383 cell->face(f)->boundary_id() == b_id)
11385 boundary_found =
true;
11386 cell->face(f)->set_manifold_id(m_number);
11391 for (
unsigned int e = 0; e < GeometryInfo<dim>::lines_per_cell; ++
e)
11392 if (cell->line(e)->at_boundary() &&
11393 cell->line(e)->boundary_id() == b_id)
11395 boundary_found =
true;
11396 cell->line(e)->set_manifold_id(m_number);
11400 (void)boundary_found;
11401 Assert(boundary_found, ExcBoundaryIdNotFound(b_id));
11406template <
int dim,
int spacedim>
11413 const auto it = manifolds.find(m_number);
11415 if (it != manifolds.end())
11418 return *(it->second);
11423 return internal::TriangulationImplementation::
11424 get_default_flat_manifold<dim, spacedim>();
11429template <
int dim,
int spacedim>
11430std::vector<types::boundary_id>
11437 std::vector<types::boundary_id> boundary_ids;
11438 for (std::map<unsigned int, types::boundary_id>::const_iterator p =
11439 vertex_to_boundary_id_map_1d->begin();
11440 p != vertex_to_boundary_id_map_1d->end();
11442 boundary_ids.push_back(p->second);
11444 return boundary_ids;
11448 std::set<types::boundary_id> b_ids;
11449 for (
auto cell : active_cell_iterators())
11450 if (cell->is_locally_owned())
11451 for (
const unsigned int face : cell->face_indices())
11452 if (cell->at_boundary(face))
11453 b_ids.insert(cell->face(face)->boundary_id());
11454 std::vector<types::boundary_id> boundary_ids(b_ids.begin(), b_ids.end());
11455 return boundary_ids;
11461template <
int dim,
int spacedim>
11462std::vector<types::manifold_id>
11465 std::set<types::manifold_id> m_ids;
11466 for (
auto cell : active_cell_iterators())
11467 if (cell->is_locally_owned())
11469 m_ids.insert(cell->manifold_id());
11470 for (
const auto &face : cell->face_iterators())
11471 m_ids.insert(face->manifold_id());
11473 for (
const unsigned int l : cell->line_indices())
11474 m_ids.insert(cell->line(l)->manifold_id());
11476 return {m_ids.begin(), m_ids.end()};
11482template <
int dim,
int spacedim>
11487 Assert((
vertices.size() == 0) && (levels.size() == 0) && (faces ==
nullptr),
11488 ExcTriangulationNotEmpty(
vertices.size(), levels.size()));
11490 (dim == 1 || other_tria.
faces !=
nullptr),
11492 "When calling Triangulation::copy_triangulation(), "
11493 "the target triangulation must be empty but the source "
11494 "triangulation (the argument to this function) must contain "
11495 "something. Here, it seems like the source does not "
11496 "contain anything at all."));
11507 faces = std::make_unique<internal::TriangulationImplementation::TriaFaces>(
11508 *other_tria.
faces);
11510 for (
const auto &p : other_tria.
manifolds)
11511 set_manifold(p.first, *p.second);
11514 levels.reserve(other_tria.
levels.size());
11517 std::make_unique<internal::TriangulationImplementation::TriaLevel>(
11524 vertex_to_boundary_id_map_1d =
11525 std::make_unique<std::map<unsigned int, types::boundary_id>>(
11528 vertex_to_manifold_id_map_1d =
11529 std::make_unique<std::map<unsigned int, types::manifold_id>>(
11534 this->policy = other_tria.
policy->clone();
11548template <
int dim,
int spacedim>
11555 std::vector<CellData<dim>> reordered_cells(cells);
11559 reorder_compatibility(reordered_cells, reordered_subcelldata);
11567template <
int dim,
int spacedim>
11571 this->update_reference_cells();
11573 if (this->all_reference_cells_are_hyper_cube())
11593template <
int dim,
int spacedim>
11600 Assert((
vertices.size() == 0) && (levels.size() == 0) && (faces ==
nullptr),
11601 ExcTriangulationNotEmpty(
vertices.size(), levels.size()));
11616 clear_despite_subscriptions();
11624 reset_cell_vertex_indices_cache();
11626 *
this, levels.size(), number_cache);
11627 reset_active_cell_indices();
11628 reset_global_cell_indices();
11633 if (check_for_distorted_cells)
11635 DistortedCellList distorted_cells = collect_distorted_coarse_cells(*
this);
11639 AssertThrow(distorted_cells.distorted_cells.size() == 0, distorted_cells);
11672 if (dim < spacedim && all_reference_cells_are_hyper_cube())
11680 bool values[][2] = {{
false,
true}, {
true,
false}};
11683 correct(i, j) = (
values[i][j]);
11688 bool values[][4] = {{
false,
true,
true,
false},
11689 {
true,
false,
false,
true},
11690 {
true,
false,
false,
true},
11691 {
false,
true,
true,
false}};
11694 correct(i, j) = (
values[i][j]);
11702 std::list<active_cell_iterator> this_round, next_round;
11703 active_cell_iterator neighbor;
11705 this_round.push_back(begin_active());
11706 begin_active()->set_direction_flag(
true);
11707 begin_active()->set_user_flag();
11709 while (this_round.size() > 0)
11711 for (
typename std::list<active_cell_iterator>::iterator cell =
11712 this_round.begin();
11713 cell != this_round.end();
11716 for (
const unsigned int i : (*cell)->face_indices())
11718 if (!((*cell)->face(i)->at_boundary()))
11720 neighbor = (*cell)->neighbor(i);
11722 unsigned int cf = (*cell)->face_index(i);
11723 unsigned int j = 0;
11724 while (neighbor->face_index(j) != cf)
11732 if (neighbor->user_flag_set())
11736 Assert(!(correct(i, j) ^
11737 (neighbor->direction_flag() ==
11738 (*cell)->direction_flag())),
11739 ExcNonOrientableTriangulation());
11743 next_round.push_back(neighbor);
11744 neighbor->set_user_flag();
11745 if ((correct(i, j) ^ (neighbor->direction_flag() ==
11746 (*cell)->direction_flag())))
11747 neighbor->set_direction_flag(
11748 !neighbor->direction_flag());
11758 if (next_round.size() == 0)
11759 for (
const auto &cell : this->active_cell_iterators())
11760 if (cell->user_flag_set() ==
false)
11762 next_round.push_back(cell);
11763 cell->set_direction_flag(
true);
11764 cell->set_user_flag();
11768 this_round = next_round;
11769 next_round.clear();
11779template <
int dim,
int spacedim>
11799 const CellId a_id(a.id);
11800 const CellId b_id(b.id);
11802 const auto a_coarse_cell_index =
11803 this->coarse_cell_id_to_coarse_cell_index(a_id.get_coarse_cell_id());
11804 const auto b_coarse_cell_index =
11805 this->coarse_cell_id_to_coarse_cell_index(b_id.get_coarse_cell_id());
11812 if (a_coarse_cell_index != b_coarse_cell_index)
11813 return a_coarse_cell_index < b_coarse_cell_index;
11815 return a_id < b_id;
11821 for (
unsigned int level = 0;
11832 while (cell_info->id != cell->id().template to_binary<dim>())
11835 for (
const auto quad : cell->face_indices())
11836 cell->quad(quad)->set_manifold_id(
11837 cell_info->manifold_quad_ids[quad]);
11840 for (
const auto line : cell->line_indices())
11841 cell->line(line)->set_manifold_id(
11842 cell_info->manifold_line_ids[line]);
11844 cell->set_manifold_id(cell_info->manifold_id);
11862 !coarse_cell->id().is_parent_of(
CellId(fine_cell_info->id)))
11866 coarse_cell->set_refine_flag();
11871 spacedim>::execute_coarsening_and_refinement();
11876 for (
unsigned int level = 0;
11885 while (cell_info->id != cell->id().template to_binary<dim>())
11889 for (
auto pair : cell_info->boundary_ids)
11890 if (cell->face(pair.first)->at_boundary())
11891 cell->face(pair.first)->set_boundary_id(pair.second);
11897template <
int dim,
int spacedim>
11902 ExcMessage(
"Only works for dim == spacedim-1"));
11903 for (
const auto &cell : this->active_cell_iterators())
11904 cell->set_direction_flag(!cell->direction_flag());
11909template <
int dim,
int spacedim>
11914 ExcMessage(
"Error: An empty Triangulation can not be refined."));
11916 for (
const auto &cell : this->active_cell_iterators())
11918 cell->clear_coarsen_flag();
11919 cell->set_refine_flag();
11925template <
int dim,
int spacedim>
11929 for (
unsigned int i = 0; i < times; ++i)
11931 set_all_refine_flags();
11932 execute_coarsening_and_refinement();
11938template <
int dim,
int spacedim>
11942 for (
unsigned int i = 0; i < times; ++i)
11944 for (
const auto &cell : this->active_cell_iterators())
11946 cell->clear_refine_flag();
11947 cell->set_coarsen_flag();
11949 execute_coarsening_and_refinement();
11958template <
int dim,
int spacedim>
11963 std::vector<bool>::iterator i = v.begin();
11965 for (
const auto &cell : this->active_cell_iterators())
11966 for (
unsigned int j = 0; j < dim; ++j, ++i)
11967 if (cell->refine_flag_set() & (1 << j))
11975template <
int dim,
int spacedim>
11979 std::vector<bool> v;
11980 save_refine_flags(v);
11989template <
int dim,
int spacedim>
11993 std::vector<bool> v;
11995 load_refine_flags(v);
12000template <
int dim,
int spacedim>
12006 std::vector<bool>::const_iterator i = v.begin();
12007 for (
const auto &cell : this->active_cell_iterators())
12009 unsigned int ref_case = 0;
12011 for (
unsigned int j = 0; j < dim; ++j, ++i)
12013 ref_case += 1 << j;
12015 ExcGridReadError());
12019 cell->clear_refine_flag();
12027template <
int dim,
int spacedim>
12032 std::vector<bool>::iterator i = v.begin();
12033 for (
const auto &cell : this->active_cell_iterators())
12035 *i = cell->coarsen_flag_set();
12044template <
int dim,
int spacedim>
12048 std::vector<bool> v;
12049 save_coarsen_flags(v);
12058template <
int dim,
int spacedim>
12062 std::vector<bool> v;
12067 load_coarsen_flags(v);
12072template <
int dim,
int spacedim>
12078 std::vector<bool>::const_iterator i = v.begin();
12079 for (
const auto &cell : this->active_cell_iterators())
12082 cell->set_coarsen_flag();
12084 cell->clear_coarsen_flag();
12092template <
int dim,
int spacedim>
12096 return anisotropic_refinement;
12108 clear_user_data(std::vector<std::unique_ptr<
12111 for (
auto &
level : levels)
12112 level->cells.clear_user_data();
12120 if (faces->
dim == 2)
12126 if (faces->
dim == 3)
12135template <
int dim,
int spacedim>
12140 ::clear_user_data(levels);
12142 ::clear_user_data(faces.get());
12150 clear_user_flags_line(
12153 std::unique_ptr<internal::TriangulationImplementation::TriaLevel>>
12159 for (
const auto &
level : levels)
12160 level->cells.clear_user_flags();
12162 else if (dim == 2 || dim == 3)
12174template <
int dim,
int spacedim>
12178 ::clear_user_flags_line(dim, levels, faces.get());
12186 clear_user_flags_quad(
12189 std::unique_ptr<internal::TriangulationImplementation::TriaLevel>>
12199 for (
const auto &
level : levels)
12200 level->cells.clear_user_flags();
12214template <
int dim,
int spacedim>
12218 ::clear_user_flags_quad(dim, levels, faces.get());
12226 clear_user_flags_hex(
12229 std::unique_ptr<internal::TriangulationImplementation::TriaLevel>>
12243 for (
const auto &
level : levels)
12244 level->cells.clear_user_flags();
12254template <
int dim,
int spacedim>
12258 ::clear_user_flags_hex(dim, levels, faces.get());
12263template <
int dim,
int spacedim>
12267 clear_user_flags_line();
12268 clear_user_flags_quad();
12269 clear_user_flags_hex();
12274template <
int dim,
int spacedim>
12278 save_user_flags_line(out);
12281 save_user_flags_quad(out);
12284 save_user_flags_hex(out);
12292template <
int dim,
int spacedim>
12300 std::vector<bool> tmp;
12302 save_user_flags_line(tmp);
12303 v.insert(v.end(), tmp.begin(), tmp.end());
12307 save_user_flags_quad(tmp);
12308 v.insert(v.end(), tmp.begin(), tmp.end());
12313 save_user_flags_hex(tmp);
12314 v.insert(v.end(), tmp.begin(), tmp.end());
12323template <
int dim,
int spacedim>
12327 load_user_flags_line(in);
12330 load_user_flags_quad(in);
12333 load_user_flags_hex(in);
12341template <
int dim,
int spacedim>
12346 std::vector<bool> tmp;
12350 tmp.insert(tmp.end(), v.begin(), v.begin() + n_lines());
12352 load_user_flags_line(tmp);
12357 tmp.insert(tmp.end(),
12358 v.begin() + n_lines(),
12359 v.begin() + n_lines() + n_quads());
12360 load_user_flags_quad(tmp);
12366 tmp.insert(tmp.end(),
12367 v.begin() + n_lines() + n_quads(),
12368 v.begin() + n_lines() + n_quads() + n_hexs());
12369 load_user_flags_hex(tmp);
12378template <
int dim,
int spacedim>
12382 v.resize(n_lines(),
false);
12383 std::vector<bool>::iterator i = v.begin();
12384 line_iterator line = begin_line(), endl = end_line();
12385 for (; line != endl; ++line, ++i)
12386 *i = line->user_flag_set();
12393template <
int dim,
int spacedim>
12397 std::vector<bool> v;
12398 save_user_flags_line(v);
12407template <
int dim,
int spacedim>
12411 std::vector<bool> v;
12416 load_user_flags_line(v);
12421template <
int dim,
int spacedim>
12425 Assert(v.size() == n_lines(), ExcGridReadError());
12427 line_iterator line = begin_line(), endl = end_line();
12428 std::vector<bool>::const_iterator i = v.begin();
12429 for (; line != endl; ++line, ++i)
12431 line->set_user_flag();
12433 line->clear_user_flag();
12441 template <
typename Iterator>
12443 get_user_flag(
const Iterator &i)
12445 return i->user_flag_set();
12450 template <
int structdim,
int dim,
int spacedim>
12460 template <
typename Iterator>
12462 set_user_flag(
const Iterator &i)
12464 i->set_user_flag();
12469 template <
int structdim,
int dim,
int spacedim>
12478 template <
typename Iterator>
12480 clear_user_flag(
const Iterator &i)
12482 i->clear_user_flag();
12487 template <
int structdim,
int dim,
int spacedim>
12497template <
int dim,
int spacedim>
12501 v.resize(n_quads(),
false);
12505 std::vector<bool>::iterator i = v.begin();
12506 quad_iterator quad = begin_quad(), endq = end_quad();
12507 for (; quad != endq; ++quad, ++i)
12508 *i = get_user_flag(quad);
12516template <
int dim,
int spacedim>
12520 std::vector<bool> v;
12521 save_user_flags_quad(v);
12530template <
int dim,
int spacedim>
12534 std::vector<bool> v;
12539 load_user_flags_quad(v);
12544template <
int dim,
int spacedim>
12548 Assert(v.size() == n_quads(), ExcGridReadError());
12552 quad_iterator quad = begin_quad(), endq = end_quad();
12553 std::vector<bool>::const_iterator i = v.begin();
12554 for (; quad != endq; ++quad, ++i)
12556 set_user_flag(quad);
12558 clear_user_flag(quad);
12566template <
int dim,
int spacedim>
12570 v.resize(n_hexs(),
false);
12574 std::vector<bool>::iterator i = v.begin();
12575 hex_iterator hex = begin_hex(), endh = end_hex();
12576 for (; hex != endh; ++hex, ++i)
12577 *i = get_user_flag(hex);
12585template <
int dim,
int spacedim>
12589 std::vector<bool> v;
12590 save_user_flags_hex(v);
12599template <
int dim,
int spacedim>
12603 std::vector<bool> v;
12608 load_user_flags_hex(v);
12613template <
int dim,
int spacedim>
12617 Assert(v.size() == n_hexs(), ExcGridReadError());
12621 hex_iterator hex = begin_hex(), endh = end_hex();
12622 std::vector<bool>::const_iterator i = v.begin();
12623 for (; hex != endh; ++hex, ++i)
12625 set_user_flag(hex);
12627 clear_user_flag(hex);
12635template <
int dim,
int spacedim>
12638 std::vector<unsigned int> &v)
const
12644 std::vector<unsigned int> tmp;
12646 save_user_indices_line(tmp);
12647 v.insert(v.end(), tmp.begin(), tmp.end());
12651 save_user_indices_quad(tmp);
12652 v.insert(v.end(), tmp.begin(), tmp.end());
12657 save_user_indices_hex(tmp);
12658 v.insert(v.end(), tmp.begin(), tmp.end());
12667template <
int dim,
int spacedim>
12670 const std::vector<unsigned int> &v)
12673 std::vector<unsigned int> tmp;
12677 tmp.insert(tmp.end(), v.begin(), v.begin() + n_lines());
12679 load_user_indices_line(tmp);
12684 tmp.insert(tmp.end(),
12685 v.begin() + n_lines(),
12686 v.begin() + n_lines() + n_quads());
12687 load_user_indices_quad(tmp);
12693 tmp.insert(tmp.end(),
12694 v.begin() + n_lines() + n_quads(),
12695 v.begin() + n_lines() + n_quads() + n_hexs());
12696 load_user_indices_hex(tmp);
12707 template <
typename Iterator>
12709 get_user_index(
const Iterator &i)
12711 return i->user_index();
12716 template <
int structdim,
int dim,
int spacedim>
12727 template <
typename Iterator>
12729 set_user_index(
const Iterator &i,
const unsigned int x)
12731 i->set_user_index(x);
12736 template <
int structdim,
int dim,
int spacedim>
12740 const unsigned int)
12747template <
int dim,
int spacedim>
12750 std::vector<unsigned int> &v)
const
12752 v.resize(n_lines(), 0);
12753 std::vector<unsigned int>::iterator i = v.begin();
12754 line_iterator line = begin_line(), endl = end_line();
12755 for (; line != endl; ++line, ++i)
12756 *i = line->user_index();
12761template <
int dim,
int spacedim>
12764 const std::vector<unsigned int> &v)
12766 Assert(v.size() == n_lines(), ExcGridReadError());
12768 line_iterator line = begin_line(), endl = end_line();
12769 std::vector<unsigned int>::const_iterator i = v.begin();
12770 for (; line != endl; ++line, ++i)
12771 line->set_user_index(*i);
12775template <
int dim,
int spacedim>
12778 std::vector<unsigned int> &v)
const
12780 v.resize(n_quads(), 0);
12784 std::vector<unsigned int>::iterator i = v.begin();
12785 quad_iterator quad = begin_quad(), endq = end_quad();
12786 for (; quad != endq; ++quad, ++i)
12787 *i = get_user_index(quad);
12793template <
int dim,
int spacedim>
12796 const std::vector<unsigned int> &v)
12798 Assert(v.size() == n_quads(), ExcGridReadError());
12802 quad_iterator quad = begin_quad(), endq = end_quad();
12803 std::vector<unsigned int>::const_iterator i = v.begin();
12804 for (; quad != endq; ++quad, ++i)
12805 set_user_index(quad, *i);
12810template <
int dim,
int spacedim>
12813 std::vector<unsigned int> &v)
const
12815 v.resize(n_hexs(), 0);
12819 std::vector<unsigned int>::iterator i = v.begin();
12820 hex_iterator hex = begin_hex(), endh = end_hex();
12821 for (; hex != endh; ++hex, ++i)
12822 *i = get_user_index(hex);
12828template <
int dim,
int spacedim>
12831 const std::vector<unsigned int> &v)
12833 Assert(v.size() == n_hexs(), ExcGridReadError());
12837 hex_iterator hex = begin_hex(), endh = end_hex();
12838 std::vector<unsigned int>::const_iterator i = v.begin();
12839 for (; hex != endh; ++hex, ++i)
12840 set_user_index(hex, *i);
12851 template <
typename Iterator>
12853 get_user_pointer(
const Iterator &i)
12855 return i->user_pointer();
12860 template <
int structdim,
int dim,
int spacedim>
12871 template <
typename Iterator>
12873 set_user_pointer(
const Iterator &i,
void *x)
12875 i->set_user_pointer(x);
12880 template <
int structdim,
int dim,
int spacedim>
12891template <
int dim,
int spacedim>
12899 std::vector<void *> tmp;
12901 save_user_pointers_line(tmp);
12902 v.insert(v.end(), tmp.begin(), tmp.end());
12906 save_user_pointers_quad(tmp);
12907 v.insert(v.end(), tmp.begin(), tmp.end());
12912 save_user_pointers_hex(tmp);
12913 v.insert(v.end(), tmp.begin(), tmp.end());
12922template <
int dim,
int spacedim>
12927 std::vector<void *> tmp;
12931 tmp.insert(tmp.end(), v.begin(), v.begin() + n_lines());
12933 load_user_pointers_line(tmp);
12938 tmp.insert(tmp.end(),
12939 v.begin() + n_lines(),
12940 v.begin() + n_lines() + n_quads());
12941 load_user_pointers_quad(tmp);
12947 tmp.insert(tmp.end(),
12948 v.begin() + n_lines() + n_quads(),
12949 v.begin() + n_lines() + n_quads() + n_hexs());
12950 load_user_pointers_hex(tmp);
12959template <
int dim,
int spacedim>
12962 std::vector<void *> &v)
const
12964 v.resize(n_lines(),
nullptr);
12965 std::vector<void *>::iterator i = v.begin();
12966 line_iterator line = begin_line(), endl = end_line();
12967 for (; line != endl; ++line, ++i)
12968 *i = line->user_pointer();
12973template <
int dim,
int spacedim>
12976 const std::vector<void *> &v)
12978 Assert(v.size() == n_lines(), ExcGridReadError());
12980 line_iterator line = begin_line(), endl = end_line();
12981 std::vector<void *>::const_iterator i = v.begin();
12982 for (; line != endl; ++line, ++i)
12983 line->set_user_pointer(*i);
12988template <
int dim,
int spacedim>
12991 std::vector<void *> &v)
const
12993 v.resize(n_quads(),
nullptr);
12997 std::vector<void *>::iterator i = v.begin();
12998 quad_iterator quad = begin_quad(), endq = end_quad();
12999 for (; quad != endq; ++quad, ++i)
13000 *i = get_user_pointer(quad);
13006template <
int dim,
int spacedim>
13009 const std::vector<void *> &v)
13011 Assert(v.size() == n_quads(), ExcGridReadError());
13015 quad_iterator quad = begin_quad(), endq = end_quad();
13016 std::vector<void *>::const_iterator i = v.begin();
13017 for (; quad != endq; ++quad, ++i)
13018 set_user_pointer(quad, *i);
13023template <
int dim,
int spacedim>
13026 std::vector<void *> &v)
const
13028 v.resize(n_hexs(),
nullptr);
13032 std::vector<void *>::iterator i = v.begin();
13033 hex_iterator hex = begin_hex(), endh = end_hex();
13034 for (; hex != endh; ++hex, ++i)
13035 *i = get_user_pointer(hex);
13041template <
int dim,
int spacedim>
13044 const std::vector<void *> &v)
13046 Assert(v.size() == n_hexs(), ExcGridReadError());
13050 hex_iterator hex = begin_hex(), endh = end_hex();
13051 std::vector<void *>::const_iterator i = v.begin();
13052 for (; hex != endh; ++hex, ++i)
13053 set_user_pointer(hex, *i);
13062template <
int dim,
int spacedim>
13069 return begin_raw_line(
level);
13071 return begin_raw_quad(
level);
13073 return begin_raw_hex(
level);
13076 return raw_cell_iterator();
13082template <
int dim,
int spacedim>
13089 return begin_line(
level);
13091 return begin_quad(
level);
13093 return begin_hex(
level);
13096 return cell_iterator();
13102template <
int dim,
int spacedim>
13109 return begin_active_line(
level);
13111 return begin_active_quad(
level);
13113 return begin_active_hex(
level);
13116 return active_cell_iterator();
13122template <
int dim,
int spacedim>
13126 const unsigned int level = levels.size() - 1;
13127 if (levels[
level]->cells.n_objects() == 0)
13134 levels[
level]->cells.n_objects() - 1);
13137 if (ri->used() ==
true)
13140 if (ri->used() ==
true)
13147template <
int dim,
int spacedim>
13152 cell_iterator cell = last();
13157 if (cell->is_active() ==
true)
13160 if (cell->is_active() ==
true)
13168template <
int dim,
int spacedim>
13172 cell_iterator cell(
13178 cell->has_children(),
13180 "CellId is invalid for this triangulation.\n"
13181 "Either the provided CellId does not correspond to a cell in this "
13182 "triangulation object, or, in case you are using a parallel "
13183 "triangulation, may correspond to an artificial cell that is less "
13184 "refined on this processor."));
13185 cell = cell->child(
static_cast<unsigned int>(child_index));
13193template <
int dim,
int spacedim>
13204template <
int dim,
int spacedim>
13216 if (
level >= levels.size())
13219 ExcInvalidLevel(
level, n_global_levels()));
13226 if (
level < levels.size() - 1)
13227 return begin_raw(
level + 1);
13233template <
int dim,
int spacedim>
13245 if (
level >= levels.size())
13248 ExcInvalidLevel(
level, n_global_levels()));
13255 if (
level < levels.size() - 1)
13262template <
int dim,
int spacedim>
13274 if (
level >= levels.size())
13277 ExcInvalidLevel(
level, n_global_levels()));
13284 return (
level >= levels.size() - 1 ? active_cell_iterator(
end()) :
13285 begin_active(
level + 1));
13290template <
int dim,
int spacedim>
13299template <
int dim,
int spacedim>
13310template <
int dim,
int spacedim>
13313 const unsigned int level)
const
13321template <
int dim,
int spacedim>
13324 const unsigned int level)
const
13335template <
int dim,
int spacedim>
13343 return raw_face_iterator();
13345 return begin_line();
13347 return begin_quad();
13350 return face_iterator();
13356template <
int dim,
int spacedim>
13364 return raw_face_iterator();
13366 return begin_active_line();
13368 return begin_active_quad();
13371 return active_face_iterator();
13377template <
int dim,
int spacedim>
13385 return raw_face_iterator();
13392 return raw_face_iterator();
13398template <
int dim,
int spacedim>
13404 begin_active_face(), end_face());
13410template <
int dim,
int spacedim>
13414 vertex_iterator i =
13419 while (i->used() ==
false)
13427template <
int dim,
int spacedim>
13432 return begin_vertex();
13437template <
int dim,
int spacedim>
13452template <
int dim,
int spacedim>
13464 if (
level >= levels.size())
13467 ExcInvalidLevel(
level, n_global_levels()));
13478 if (
level >= levels.size() || levels[
level]->cells.n_objects() == 0)
13481 return raw_line_iterator(
13486 return raw_line_iterator(
13492template <
int dim,
int spacedim>
13497 raw_line_iterator ri = begin_raw_line(
level);
13500 while (ri->used() ==
false)
13508template <
int dim,
int spacedim>
13513 line_iterator i = begin_line(
level);
13516 while (i->has_children())
13524template <
int dim,
int spacedim>
13538template <
int dim,
int spacedim>
13550 if (
level >= levels.size())
13553 ExcInvalidLevel(
level, n_global_levels()));
13561 return raw_hex_iterator();
13568 if (
level >= levels.size() || levels[
level]->cells.n_objects() == 0)
13571 return raw_quad_iterator(
13579 return raw_quad_iterator(
13586 return raw_hex_iterator();
13592template <
int dim,
int spacedim>
13597 raw_quad_iterator ri = begin_raw_quad(
level);
13600 while (ri->used() ==
false)
13608template <
int dim,
int spacedim>
13613 quad_iterator i = begin_quad(
level);
13616 while (i->has_children())
13624template <
int dim,
int spacedim>
13637template <
int dim,
int spacedim>
13649 if (
level >= levels.size())
13652 ExcInvalidLevel(
level, n_global_levels()));
13661 return raw_hex_iterator();
13668 if (
level >= levels.size() || levels[
level]->cells.n_objects() == 0)
13671 return raw_hex_iterator(
13677 return raw_hex_iterator();
13683template <
int dim,
int spacedim>
13688 raw_hex_iterator ri = begin_raw_hex(
level);
13691 while (ri->used() ==
false)
13699template <
int dim,
int spacedim>
13704 hex_iterator i = begin_hex(
level);
13707 while (i->has_children())
13715template <
int dim,
int spacedim>
13731 namespace TriangulationImplementation
13733 inline unsigned int
13740 inline unsigned int
13744 return c.n_active_lines;
13748 inline unsigned int
13755 inline unsigned int
13759 return c.n_active_quads;
13763 inline unsigned int
13770 inline unsigned int
13774 return c.n_active_hexes;
13781template <
int dim,
int spacedim>
13789template <
int dim,
int spacedim>
13796template <
int dim,
int spacedim>
13803template <
int dim,
int spacedim>
13810template <
int dim,
int spacedim>
13817 return n_used_vertices();
13829template <
int dim,
int spacedim>
13836 return n_vertices();
13838 return n_raw_lines();
13840 return n_raw_quads();
13848template <
int dim,
int spacedim>
13855 return n_used_vertices();
13857 return n_active_lines();
13859 return n_active_quads();
13867template <
int dim,
int spacedim>
13874 return n_raw_lines(
level);
13876 return n_raw_quads(
level);
13878 return n_raw_hexs(
level);
13887template <
int dim,
int spacedim>
13894 return n_lines(
level);
13896 return n_quads(
level);
13898 return n_hexs(
level);
13907template <
int dim,
int spacedim>
13914 return n_active_lines(
level);
13916 return n_active_quads(
level);
13918 return n_active_hexs(
level);
13926template <
int dim,
int spacedim>
13930 for (
unsigned int lvl = 0; lvl < n_global_levels() - 1; ++lvl)
13938template <
int dim,
int spacedim>
13942 return number_cache.n_lines;
13947template <
int dim,
int spacedim>
13954 return levels[
level]->cells.n_objects();
13957 Assert(
false, ExcFacesHaveNoLevel());
13962template <
int dim,
int spacedim>
13976template <
int dim,
int spacedim>
13981 Assert(dim == 1, ExcFacesHaveNoLevel());
13982 return number_cache.n_lines_level[
level];
13986template <
int dim,
int spacedim>
13990 return number_cache.n_active_lines;
13994template <
int dim,
int spacedim>
13999 Assert(dim == 1, ExcFacesHaveNoLevel());
14001 return number_cache.n_active_lines_level[
level];
14151template <
int dim,
int spacedim>
14155 return number_cache.n_quads;
14159template <
int dim,
int spacedim>
14163 Assert(dim == 2, ExcFacesHaveNoLevel());
14165 return number_cache.n_quads_level[
level];
14175 return levels[
level]->cells.n_objects();
14185 return levels[
level]->cells.n_objects();
14193 Assert(
false, ExcFacesHaveNoLevel());
14199template <
int dim,
int spacedim>
14218template <
int dim,
int spacedim>
14222 return number_cache.n_active_quads;
14226template <
int dim,
int spacedim>
14231 Assert(dim == 2, ExcFacesHaveNoLevel());
14233 return number_cache.n_active_quads_level[
level];
14237template <
int dim,
int spacedim>
14246template <
int dim,
int spacedim>
14255template <
int dim,
int spacedim>
14263template <
int dim,
int spacedim>
14272template <
int dim,
int spacedim>
14284 return number_cache.n_hexes;
14295 return number_cache.n_hexes_level[
level];
14305 return levels[
level]->cells.n_objects();
14313 return number_cache.n_active_hexes;
14324 return number_cache.n_active_hexes_level[
level];
14329template <
int dim,
int spacedim>
14333 return std::count(vertices_used.begin(), vertices_used.end(),
true);
14338template <
int dim,
int spacedim>
14339const std::vector<bool> &
14342 return vertices_used;
14372template <
int dim,
int spacedim>
14376 cell_iterator cell = begin(0),
14377 endc = (n_levels() > 1 ? begin(1) : cell_iterator(end()));
14380 unsigned int max_vertex_index = 0;
14381 for (; cell != endc; ++cell)
14383 if (cell->vertex_index(vertex) > max_vertex_index)
14384 max_vertex_index = cell->vertex_index(vertex);
14390 std::vector<unsigned short int> usage_count(max_vertex_index + 1, 0);
14394 for (cell = begin(); cell != endc; ++cell)
14396 ++usage_count[cell->vertex_index(vertex)];
14399 static_cast<unsigned int>(
14400 *std::max_element(usage_count.begin(), usage_count.end())));
14405template <
int dim,
int spacedim>
14414template <
int dim,
int spacedim>
14423template <
int dim,
int spacedim>
14432template <
int dim,
int spacedim>
14436 &periodicity_vector)
14438 periodic_face_pairs_level_0.insert(periodic_face_pairs_level_0.end(),
14439 periodicity_vector.begin(),
14440 periodicity_vector.end());
14443 update_periodic_face_map();
14448template <
int dim,
int spacedim>
14449const typename std::map<
14450 std::pair<typename Triangulation<dim, spacedim>::cell_iterator,
unsigned int>,
14451 std::pair<std::pair<typename Triangulation<dim, spacedim>::cell_iterator,
14456 return periodic_face_map;
14461template <
int dim,
int spacedim>
14475 if (smooth_grid & limit_level_difference_at_vertices)
14479 signals.pre_refinement();
14481 execute_coarsening();
14483 const DistortedCellList cells_with_distorted_children = execute_refinement();
14485 reset_cell_vertex_indices_cache();
14490 if (smooth_grid & limit_level_difference_at_vertices)
14495 this->policy->update_neighbors(*
this);
14496 reset_active_cell_indices();
14498 reset_global_cell_indices();
14501 signals.post_refinement();
14503 AssertThrow(cells_with_distorted_children.distorted_cells.size() == 0,
14504 cells_with_distorted_children);
14506 update_periodic_face_map();
14511template <
int dim,
int spacedim>
14515 unsigned int active_cell_index = 0;
14516 for (raw_cell_iterator cell = begin_raw(); cell !=
end(); ++cell)
14517 if ((cell->used() ==
false) || cell->has_children())
14521 cell->set_active_cell_index(active_cell_index);
14522 ++active_cell_index;
14530template <
int dim,
int spacedim>
14536 for (
const auto &cell : active_cell_iterators())
14537 cell->set_global_active_cell_index(
cell_index++);
14540 for (
unsigned int l = 0;
l < levels.size(); ++
l)
14543 for (
const auto &cell : cell_iterators_on_level(l))
14544 cell->set_global_level_cell_index(
cell_index++);
14550template <
int dim,
int spacedim>
14554 for (
unsigned int l = 0;
l < levels.size(); ++
l)
14556 constexpr unsigned int max_vertices_per_cell = 1 << dim;
14557 std::vector<unsigned int> &cache = levels[
l]->cell_vertex_indices_cache;
14559 cache.resize(levels[l]->refine_flags.size() * max_vertices_per_cell,
14561 for (
const auto &cell : cell_iterators_on_level(l))
14563 const unsigned int my_index = cell->index() * max_vertices_per_cell;
14564 for (
const unsigned int i : cell->vertex_indices())
14565 cache[my_index + i] = internal::TriaAccessorImplementation::
14566 Implementation::vertex_index(*cell, i);
14573template <
int dim,
int spacedim>
14578 periodic_face_map.clear();
14580 typename std::vector<
14582 for (it = periodic_face_pairs_level_0.begin();
14583 it != periodic_face_pairs_level_0.end();
14586 update_periodic_face_map_recursively<dim, spacedim>(it->cell[0],
14591 periodic_face_map);
14594 std::bitset<3> inverted_orientation;
14596 bool orientation, flip, rotation;
14597 orientation = it->orientation[0];
14598 rotation = it->orientation[2];
14599 flip = orientation ? rotation ^ it->orientation[1] : it->orientation[1];
14600 inverted_orientation[0] = orientation;
14601 inverted_orientation[1] = flip;
14602 inverted_orientation[2] = rotation;
14604 update_periodic_face_map_recursively<dim, spacedim>(it->cell[1],
14608 inverted_orientation,
14609 periodic_face_map);
14613 typename std::map<std::pair<cell_iterator, unsigned int>,
14614 std::pair<std::pair<cell_iterator, unsigned int>,
14615 std::bitset<3>>>::const_iterator it_test;
14616 for (it_test = periodic_face_map.begin(); it_test != periodic_face_map.end();
14620 it_test->first.first;
14622 it_test->second.first.first;
14623 if (cell_1->level() == cell_2->level())
14627 Assert(periodic_face_map[it_test->second.first].first ==
14636template <
int dim,
int spacedim>
14640 std::set<ReferenceCell> reference_cells_set;
14641 for (
auto cell : active_cell_iterators())
14642 if (cell->is_locally_owned())
14643 reference_cells_set.insert(cell->reference_cell());
14645 this->reference_cells =
14646 std::vector<ReferenceCell>(reference_cells_set.begin(),
14647 reference_cells_set.end());
14652template <
int dim,
int spacedim>
14653const std::vector<ReferenceCell> &
14656 return this->reference_cells;
14661template <
int dim,
int spacedim>
14665 Assert(this->reference_cells.size() > 0,
14666 ExcMessage(
"You can't ask about the kinds of reference "
14667 "cells used by this triangulation if the "
14668 "triangulation doesn't yet have any cells in it."));
14669 return (this->reference_cells.size() == 1 &&
14670 this->reference_cells[0].is_hyper_cube());
14675template <
int dim,
int spacedim>
14679 Assert(this->reference_cells.size() > 0,
14680 ExcMessage(
"You can't ask about the kinds of reference "
14681 "cells used by this triangulation if the "
14682 "triangulation doesn't yet have any cells in it."));
14683 return (this->reference_cells.size() == 1 &&
14684 this->reference_cells[0].is_simplex());
14689template <
int dim,
int spacedim>
14693 Assert(this->reference_cells.size() > 0,
14694 ExcMessage(
"You can't ask about the kinds of reference "
14695 "cells used by this triangulation if the "
14696 "triangulation doesn't yet have any cells in it."));
14697 return reference_cells.size() > 1 ||
14698 ((reference_cells[0].is_hyper_cube() ==
false) &&
14699 (reference_cells[0].is_simplex() ==
false));
14704template <
int dim,
int spacedim>
14712 vertices_used.clear();
14721template <
int dim,
int spacedim>
14725 const DistortedCellList cells_with_distorted_children =
14726 this->policy->execute_refinement(*
this, check_for_distorted_cells);
14732 *
this, levels.size(), number_cache);
14735 for (
const auto &
level : levels)
14742 for (
const auto &cell : this->cell_iterators())
14746 return cells_with_distorted_children;
14751template <
int dim,
int spacedim>
14759 std::vector<unsigned int> line_cell_count =
14760 count_cells_bounded_by_line(*
this);
14761 std::vector<unsigned int> quad_cell_count =
14762 count_cells_bounded_by_quad(*
this);
14774 clear_user_flags();
14776 for (
const auto &cell : this->cell_iterators())
14777 if (!cell->is_active())
14778 if (cell->child(0)->coarsen_flag_set())
14780 cell->set_user_flag();
14781 for (
unsigned int child = 0; child < cell->n_children(); ++child)
14783 Assert(cell->child(child)->coarsen_flag_set(),
14785 cell->child(child)->clear_coarsen_flag();
14800 cell_iterator cell =
begin(), endc =
end();
14801 if (levels.size() >= 2)
14802 for (cell = last(); cell != endc; --cell)
14803 if (cell->level() <=
static_cast<int>(levels.size() - 2) &&
14804 cell->user_flag_set())
14807 signals.pre_coarsening_on_cell(cell);
14809 this->policy->delete_children(*
this,
14817 *
this, levels.size(), number_cache);
14821 for (cell =
begin(); cell != endc; ++cell)
14828template <
int dim,
int spacedim>
14846 save_coarsen_flags(previous_coarsen_flags);
14848 std::vector<int> vertex_level(
vertices.size(), 0);
14850 bool continue_iterating =
true;
14854 if (smooth_grid & limit_level_difference_at_vertices)
14856 Assert(!anisotropic_refinement,
14857 ExcMessage(
"In case of anisotropic refinement the "
14858 "limit_level_difference_at_vertices flag for "
14859 "mesh smoothing must not be set!"));
14863 std::fill(vertex_level.begin(), vertex_level.end(), 0);
14864 for (
const auto &cell : this->active_cell_iterators())
14866 if (cell->refine_flag_set())
14867 for (
const unsigned int vertex :
14869 vertex_level[cell->vertex_index(vertex)] =
14870 std::max(vertex_level[cell->vertex_index(vertex)],
14871 cell->level() + 1);
14872 else if (!cell->coarsen_flag_set())
14873 for (
const unsigned int vertex :
14875 vertex_level[cell->vertex_index(vertex)] =
14876 std::max(vertex_level[cell->vertex_index(vertex)],
14887 for (
const unsigned int vertex :
14889 vertex_level[cell->vertex_index(vertex)] =
14890 std::max(vertex_level[cell->vertex_index(vertex)],
14891 cell->level() - 1);
14905 active_cell_iterator cell = begin_active(), endc =
end();
14906 for (cell = last_active(); cell != endc; --cell)
14907 if (cell->refine_flag_set() ==
false)
14909 for (
const unsigned int vertex :
14911 if (vertex_level[cell->vertex_index(vertex)] >=
14915 cell->clear_coarsen_flag();
14920 if (vertex_level[cell->vertex_index(vertex)] >
14923 cell->set_refine_flag();
14925 for (
const unsigned int v :
14927 vertex_level[cell->vertex_index(v)] =
14928 std::max(vertex_level[cell->vertex_index(v)],
14929 cell->level() + 1);
14951 clear_user_flags();
14954 for (
const auto &acell : this->active_cell_iterators_on_level(0))
14955 acell->clear_coarsen_flag();
14957 for (
const auto &cell : this->cell_iterators())
14960 if (cell->is_active())
14963 const unsigned int n_children = cell->n_children();
14964 unsigned int flagged_children = 0;
14965 for (
unsigned int child = 0; child < n_children; ++child)
14966 if (cell->child(child)->is_active() &&
14967 cell->child(child)->coarsen_flag_set())
14969 ++flagged_children;
14971 cell->child(child)->clear_coarsen_flag();
14976 if (flagged_children == n_children)
14977 cell->set_user_flag();
14983 for (
auto &cell : this->cell_iterators())
15004 cell_iterator cell =
begin(), endc =
end();
15005 for (cell = last(); cell != endc; --cell)
15006 if (cell->user_flag_set())
15009 if (this->policy->coarsening_allowed(cell))
15010 for (
unsigned int c = 0; c < cell->n_children(); ++c)
15012 Assert(cell->child(c)->refine_flag_set() ==
false,
15015 cell->child(c)->set_coarsen_flag();
15020 clear_user_flags();
15026 save_coarsen_flags(current_coarsen_flags);
15028 continue_iterating = (current_coarsen_flags != previous_coarsen_flags);
15029 previous_coarsen_flags = current_coarsen_flags;
15031 while (continue_iterating ==
true);
15042 std::vector<bool> flags_before;
15043 save_coarsen_flags(flags_before);
15046 fix_coarsen_flags();
15048 std::vector<bool> flags_after;
15049 save_coarsen_flags(flags_after);
15051 return (flags_before != flags_after);
15061 std::vector<bool> flags_before;
15062 save_coarsen_flags(flags_before);
15065 fix_coarsen_flags();
15067 std::vector<bool> flags_after;
15068 save_coarsen_flags(flags_after);
15070 return (flags_before != flags_after);
15080 std::vector<bool> flags_before;
15081 save_coarsen_flags(flags_before);
15084 fix_coarsen_flags();
15086 std::vector<bool> flags_after;
15087 save_coarsen_flags(flags_after);
15089 return (flags_before != flags_after);
15100 template <
int dim,
int spacedim>
15102 possibly_do_not_produce_unrefined_islands(
15107 unsigned int n_neighbors = 0;
15110 unsigned int count = 0;
15118 if (face_will_be_refined_by_neighbor(cell, n))
15125 if (count == n_neighbors ||
15126 (count >= n_neighbors - 1 &&
15129 for (
unsigned int c = 0; c < cell->n_children(); ++c)
15130 cell->child(c)->clear_coarsen_flag();
15133 if (!cell->at_boundary(face) &&
15134 (!cell->neighbor(face)->is_active()) &&
15135 (cell_will_be_coarsened(cell->neighbor(face))))
15136 possibly_do_not_produce_unrefined_islands<dim, spacedim>(
15137 cell->neighbor(face));
15152 template <
int dim,
int spacedim>
15154 possibly_refine_unrefined_island(
15156 const bool allow_anisotropic_smoothing)
15171 if (allow_anisotropic_smoothing ==
false)
15174 unsigned int refined_neighbors = 0, unrefined_neighbors = 0;
15176 if (!cell->at_boundary(face))
15178 if (face_will_be_refined_by_neighbor(cell, face))
15179 ++refined_neighbors;
15181 ++unrefined_neighbors;
15184 if (unrefined_neighbors < refined_neighbors)
15186 cell->clear_coarsen_flag();
15187 cell->set_refine_flag();
15192 if (unrefined_neighbors > 0)
15194 if (!cell->at_boundary(face) &&
15195 (face_will_be_refined_by_neighbor(cell, face) ==
false) &&
15196 (cell->neighbor(face)->has_children() ==
false) &&
15197 (cell->neighbor(face)->refine_flag_set() ==
false))
15198 possibly_refine_unrefined_island<dim, spacedim>(
15199 cell->neighbor(face), allow_anisotropic_smoothing);
15211 for (
unsigned int face_pair = 0;
15212 face_pair < GeometryInfo<dim>::faces_per_cell / 2;
15221 for (
unsigned int face_index = 0; face_index < 2; ++face_index)
15223 unsigned int face = 2 * face_pair + face_index;
15230 face_will_be_refined_by_neighbor<dim, spacedim>(
15231 cell, face, expected_face_ref_case);
15245 directional_cell_refinement_case =
15246 (directional_cell_refinement_case &
15249 expected_face_ref_case,
15251 cell->face_orientation(face),
15252 cell->face_flip(face),
15253 cell->face_rotation(face)));
15259 Assert(directional_cell_refinement_case <
15262 smoothing_cell_refinement_case =
15263 smoothing_cell_refinement_case | directional_cell_refinement_case;
15268 if (smoothing_cell_refinement_case)
15270 cell->clear_coarsen_flag();
15271 cell->set_refine_flag(cell->refine_flag_set() |
15272 smoothing_cell_refinement_case);
15279template <
int dim,
int spacedim>
15285 std::vector<bool> flags_before[2];
15286 save_coarsen_flags(flags_before[0]);
15287 save_refine_flags(flags_before[1]);
15305 std::vector<bool> flags_before_loop[2] = {flags_before[0], flags_before[1]};
15382 if (((smooth_grid & coarsest_level_1) || (smooth_grid & patch_level_1)) &&
15385 for (
const auto &cell : active_cell_iterators_on_level(1))
15386 cell->clear_coarsen_flag();
15389 bool mesh_changed_in_this_loop =
false;
15398 if (smooth_grid & do_not_produce_unrefined_islands &&
15399 !(smooth_grid & patch_level_1))
15401 for (
const auto &cell : cell_iterators())
15405 if (!cell->is_active() && cell_will_be_coarsened(cell))
15406 possibly_do_not_produce_unrefined_islands<dim, spacedim>(cell);
15430 if (smooth_grid & (eliminate_refined_inner_islands |
15431 eliminate_refined_boundary_islands) &&
15432 !(smooth_grid & patch_level_1))
15434 for (
const auto &cell : cell_iterators())
15435 if (!cell->is_active() ||
15436 (cell->is_active() && cell->refine_flag_set() &&
15437 cell->is_locally_owned()))
15444 bool all_children_active =
true;
15445 if (!cell->is_active())
15446 for (
unsigned int c = 0; c < cell->n_children(); ++c)
15447 if (!cell->child(c)->is_active() ||
15448 cell->child(c)->is_ghost() ||
15449 cell->child(c)->is_artificial())
15451 all_children_active =
false;
15455 if (all_children_active)
15462 unsigned int unrefined_neighbors = 0, total_neighbors = 0;
15473 bool at_periodic_boundary =
false;
15475 for (
const unsigned int n :
15478 const cell_iterator neighbor = cell->neighbor(n);
15483 if (!face_will_be_refined_by_neighbor(cell, n))
15484 ++unrefined_neighbors;
15486 else if (cell->has_periodic_neighbor(n))
15489 at_periodic_boundary =
true;
15504 if ((unrefined_neighbors == total_neighbors) &&
15505 ((!cell->at_boundary() &&
15506 (smooth_grid & eliminate_refined_inner_islands)) ||
15507 (cell->at_boundary() && !at_periodic_boundary &&
15509 eliminate_refined_boundary_islands))) &&
15510 (total_neighbors != 0))
15512 if (!cell->is_active())
15513 for (
unsigned int c = 0; c < cell->n_children(); ++c)
15515 cell->child(c)->clear_refine_flag();
15516 cell->child(c)->set_coarsen_flag();
15519 cell->clear_refine_flag();
15534 if (smooth_grid & limit_level_difference_at_vertices)
15536 Assert(!anisotropic_refinement,
15537 ExcMessage(
"In case of anisotropic refinement the "
15538 "limit_level_difference_at_vertices flag for "
15539 "mesh smoothing must not be set!"));
15543 std::vector<int> vertex_level(
vertices.size(), 0);
15544 for (
const auto &cell : active_cell_iterators())
15546 if (cell->refine_flag_set())
15547 for (
const unsigned int vertex :
15549 vertex_level[cell->vertex_index(vertex)] =
15550 std::max(vertex_level[cell->vertex_index(vertex)],
15551 cell->level() + 1);
15552 else if (!cell->coarsen_flag_set())
15553 for (
const unsigned int vertex :
15555 vertex_level[cell->vertex_index(vertex)] =
15556 std::max(vertex_level[cell->vertex_index(vertex)],
15565 for (
const unsigned int vertex :
15567 vertex_level[cell->vertex_index(vertex)] =
15568 std::max(vertex_level[cell->vertex_index(vertex)],
15569 cell->level() - 1);
15583 for (active_cell_iterator cell = last_active(); cell !=
end(); --cell)
15584 if (cell->refine_flag_set() ==
false)
15586 for (
const unsigned int vertex :
15588 if (vertex_level[cell->vertex_index(vertex)] >=
15592 cell->clear_coarsen_flag();
15597 if (vertex_level[cell->vertex_index(vertex)] >
15600 cell->set_refine_flag();
15602 for (
const unsigned int v :
15604 vertex_level[cell->vertex_index(v)] =
15605 std::max(vertex_level[cell->vertex_index(v)],
15606 cell->level() + 1);
15627 if (smooth_grid & eliminate_unrefined_islands)
15629 for (active_cell_iterator cell = last_active(); cell !=
end(); --cell)
15632 if (cell->refine_flag_set() !=
15634 possibly_refine_unrefined_island<dim, spacedim>(
15635 cell, (smooth_grid & allow_anisotropic_smoothing) != 0);
15663 if (smooth_grid & patch_level_1)
15673 for (
const auto &cell : cell_iterators())
15674 if (!cell->is_active())
15680 if (cell->child(0)->has_children() ==
true)
15687 for (
unsigned int i = 0; i < cell->n_children(); ++i)
15688 combined_ref_case =
15689 combined_ref_case | cell->child(i)->refine_flag_set();
15691 for (
unsigned int i = 0; i < cell->n_children(); ++i)
15693 cell_iterator child = cell->child(i);
15695 child->clear_coarsen_flag();
15696 child->set_refine_flag(combined_ref_case);
15709 for (
const auto &cell : cell_iterators())
15715 if (cell->is_active() || cell->child(0)->is_active())
15722 const unsigned int n_children = cell->n_children();
15723 bool has_active_grandchildren =
false;
15725 for (
unsigned int i = 0; i < n_children; ++i)
15726 if (cell->child(i)->child(0)->is_active())
15728 has_active_grandchildren =
true;
15732 if (has_active_grandchildren ==
false)
15738 unsigned int n_grandchildren = 0;
15741 unsigned int n_coarsen_flags = 0;
15746 for (
unsigned int c = 0; c < n_children; ++c)
15751 cell_iterator child = cell->child(c);
15753 const unsigned int nn_children = child->n_children();
15754 n_grandchildren += nn_children;
15759 if (child->child(0)->is_active())
15760 for (
unsigned int cc = 0; cc < nn_children; ++cc)
15761 if (child->child(cc)->coarsen_flag_set())
15776 if ((n_coarsen_flags != n_grandchildren) && (n_coarsen_flags > 0))
15777 for (
unsigned int c = 0; c < n_children; ++c)
15779 const cell_iterator child = cell->child(c);
15780 if (child->child(0)->is_active())
15781 for (
unsigned int cc = 0; cc < child->n_children(); ++cc)
15782 child->child(cc)->clear_coarsen_flag();
15793 this->policy->prevent_distorted_boundary_cells(*
this);
15809 bool changed =
true;
15813 active_cell_iterator cell = last_active(), endc =
end();
15815 for (; cell != endc; --cell)
15816 if (cell->refine_flag_set())
15819 for (
const auto i : cell->face_indices())
15824 const bool has_periodic_neighbor =
15825 cell->has_periodic_neighbor(i);
15826 const bool has_neighbor_or_periodic_neighbor =
15827 !cell->at_boundary(i) || has_periodic_neighbor;
15828 if (has_neighbor_or_periodic_neighbor &&
15830 cell->refine_flag_set(), i) !=
15843 if (cell->neighbor_or_periodic_neighbor(i)->is_active())
15845 if ((!has_periodic_neighbor &&
15846 cell->neighbor_is_coarser(i)) ||
15847 (has_periodic_neighbor &&
15848 cell->periodic_neighbor_is_coarser(i)))
15850 if (cell->neighbor_or_periodic_neighbor(i)
15851 ->coarsen_flag_set())
15852 cell->neighbor_or_periodic_neighbor(i)
15853 ->clear_coarsen_flag();
15870 allow_anisotropic_smoothing)
15872 has_periodic_neighbor ?
15873 cell->periodic_neighbor(i)
15874 ->flag_for_face_refinement(
15876 ->periodic_neighbor_of_coarser_periodic_neighbor(
15881 ->flag_for_face_refinement(
15883 ->neighbor_of_coarser_neighbor(
15890 ->neighbor_or_periodic_neighbor(
15892 ->refine_flag_set())
15894 cell->neighbor_or_periodic_neighbor(i)
15895 ->set_refine_flag();
16027 std::pair<unsigned int, unsigned int>
16029 has_periodic_neighbor ?
16031 ->periodic_neighbor_of_coarser_periodic_neighbor(
16033 cell->neighbor_of_coarser_neighbor(i);
16034 unsigned int refined_along_x = 0,
16035 refined_along_y = 0,
16036 to_be_refined_along_x = 0,
16037 to_be_refined_along_y = 0;
16039 const int this_face_index =
16040 cell->face_index(i);
16049 const auto parent_face = [&]() {
16050 if (has_periodic_neighbor)
16052 const auto neighbor =
16053 cell->periodic_neighbor(i);
16054 const auto parent_face_no =
16056 ->periodic_neighbor_of_periodic_neighbor(
16059 neighbor->periodic_neighbor(
16061 return parent->face(parent_face_no);
16064 return cell->neighbor(i)->face(
16068 if ((this_face_index ==
16069 parent_face->child_index(0)) ||
16070 (this_face_index ==
16071 parent_face->child_index(1)))
16080 parent_face->refinement_case();
16098 cell->refine_flag_set(),
16100 cell->face_orientation(i),
16101 cell->face_flip(i),
16102 cell->face_rotation(i));
16105 ++to_be_refined_along_x;
16108 ++to_be_refined_along_y;
16113 allow_anisotropic_smoothing) ||
16114 cell->neighbor_or_periodic_neighbor(i)
16115 ->refine_flag_set())
16117 if (refined_along_x +
16118 to_be_refined_along_x >
16122 ->neighbor_or_periodic_neighbor(i)
16123 ->flag_for_face_refinement(
16127 if (refined_along_y +
16128 to_be_refined_along_y >
16132 ->neighbor_or_periodic_neighbor(i)
16133 ->flag_for_face_refinement(
16141 ->neighbor_or_periodic_neighbor(i)
16142 ->refine_flag_set() !=
16144 dim>::isotropic_refinement)
16146 cell->neighbor_or_periodic_neighbor(i)
16147 ->set_refine_flag();
16153 cell->neighbor_or_periodic_neighbor(i);
16156 nb->refine_flag_set(),
16158 nb->face_orientation(nb_indices.first),
16159 nb->face_flip(nb_indices.first),
16160 nb->face_rotation(nb_indices.first));
16162 !((refined_along_x != 0u) ||
16163 (to_be_refined_along_x != 0u)))
16164 changed |= cell->flag_for_face_refinement(
16168 !((refined_along_y != 0u) ||
16169 (to_be_refined_along_y != 0u)))
16170 changed |= cell->flag_for_face_refinement(
16177 cell->neighbor_or_periodic_neighbor(i)
16178 ->clear_coarsen_flag();
16179 const unsigned int nb_nb =
16180 has_periodic_neighbor ?
16182 ->periodic_neighbor_of_periodic_neighbor(
16184 cell->neighbor_of_neighbor(i);
16185 const cell_iterator neighbor =
16186 cell->neighbor_or_periodic_neighbor(i);
16189 neighbor->refine_flag_set(),
16191 neighbor->face_orientation(nb_nb),
16192 neighbor->face_flip(nb_nb),
16193 neighbor->face_rotation(nb_nb));
16196 cell->refine_flag_set(),
16198 cell->face_orientation(i),
16199 cell->face_flip(i),
16200 cell->face_rotation(i));
16205 if ((face_ref_case ==
16207 needed_face_ref_case ==
16211 needed_face_ref_case ==
16214 changed = cell->flag_for_face_refinement(
16216 neighbor->flag_for_face_refinement(
16217 nb_nb, needed_face_ref_case);
16224 face_ref_case = cell->face(i)->refinement_case(),
16225 needed_face_ref_case =
16227 cell->refine_flag_set(),
16229 cell->face_orientation(i),
16230 cell->face_flip(i),
16231 cell->face_rotation(i));
16236 needed_face_ref_case ==
16239 needed_face_ref_case ==
16242 cell->flag_for_face_refinement(i,
16255 this->policy->prepare_refinement_dim_dependent(*
this);
16262 fix_coarsen_flags();
16265 std::vector<bool> flags_after_loop[2];
16266 save_coarsen_flags(flags_after_loop[0]);
16267 save_refine_flags(flags_after_loop[1]);
16271 mesh_changed_in_this_loop =
16272 ((flags_before_loop[0] != flags_after_loop[0]) ||
16273 (flags_before_loop[1] != flags_after_loop[1]));
16277 flags_before_loop[0].swap(flags_after_loop[0]);
16278 flags_before_loop[1].swap(flags_after_loop[1]);
16280 while (mesh_changed_in_this_loop);
16286 return ((flags_before[0] != flags_before_loop[0]) ||
16287 (flags_before[1] != flags_before_loop[1]));
16292template <
int dim,
int spacedim>
16295 const unsigned int magic_number1,
16296 const std::vector<bool> &v,
16297 const unsigned int magic_number2,
16298 std::ostream & out)
16300 const unsigned int N = v.size();
16301 unsigned char * flags =
new unsigned char[N / 8 + 1];
16302 for (
unsigned int i = 0; i < N / 8 + 1; ++i)
16305 for (
unsigned int position = 0; position < N; ++position)
16306 flags[position / 8] |= (v[position] ? (1 << (position % 8)) : 0);
16315 out << magic_number1 <<
' ' << N << std::endl;
16316 for (
unsigned int i = 0; i < N / 8 + 1; ++i)
16317 out <<
static_cast<unsigned int>(flags[i]) <<
' ';
16319 out << std::endl << magic_number2 << std::endl;
16327template <
int dim,
int spacedim>
16330 std::vector<bool> &v,
16331 const unsigned int magic_number2,
16336 unsigned int magic_number;
16337 in >> magic_number;
16338 AssertThrow(magic_number == magic_number1, ExcGridReadError());
16344 unsigned char * flags =
new unsigned char[N / 8 + 1];
16345 unsigned short int tmp;
16346 for (
unsigned int i = 0; i < N / 8 + 1; ++i)
16352 for (
unsigned int position = 0; position != N; ++position)
16353 v[position] = ((flags[position / 8] & (1 << (position % 8))) != 0);
16355 in >> magic_number;
16356 AssertThrow(magic_number == magic_number2, ExcGridReadError());
16365template <
int dim,
int spacedim>
16369 std::size_t mem = 0;
16371 for (
const auto &
level : levels)
16375 mem +=
sizeof(manifolds);
16376 mem +=
sizeof(smooth_grid);
16378 mem +=
sizeof(faces);
16387template <
int dim,
int spacedim>
16393#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
unsigned char compute_orientation(const std::array< T, N > &vertices_0, const std::array< T, N > &vertices_1) const
Subscriptor & operator=(const Subscriptor &)
IteratorState::IteratorStates state() const
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)
virtual types::coarse_cell_id n_global_coarse_cells() const
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
std::map< std::pair< cell_iterator, unsigned int >, std::pair< std::pair< cell_iterator, unsigned int >, std::bitset< 3 > > > periodic_face_map
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
typename IteratorSelector::raw_quad_iterator raw_quad_iterator
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
std::vector< GridTools::PeriodicFacePair< cell_iterator > > periodic_face_pairs_level_0
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
bool is_mixed_mesh() 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
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
typename IteratorSelector::raw_hex_iterator raw_hex_iterator
std::map< types::manifold_id, std::unique_ptr< const Manifold< dim, spacedim > > > manifolds
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
void save_user_indices(std::vector< unsigned int > &v) const
bool all_reference_cells_are_simplex() 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)
#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)
typename IteratorSelector::hex_iterator hex_iterator
typename IteratorSelector::active_quad_iterator active_quad_iterator
typename IteratorSelector::active_hex_iterator active_hex_iterator
typename IteratorSelector::quad_iterator quad_iterator
typename IteratorSelector::line_iterator line_iterator
TriaIterator< CellAccessor< dim, spacedim > > cell_iterator
typename IteratorSelector::active_line_iterator active_line_iterator
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)
#define AssertIsNotUsed(obj)
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)
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)
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)
constexpr const ReferenceCell Tetrahedron
constexpr const ReferenceCell Quadrilateral
constexpr const ReferenceCell Invalid
constexpr const ReferenceCell Triangle
constexpr const ReferenceCell Hexahedron
constexpr const ReferenceCell Line
VectorType::value_type * end(VectorType &V)
VectorType::value_type * begin(VectorType &V)
bool get_bit(const unsigned char number, const unsigned int n)
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 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
::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
boost::signals2::signal< void(const Triangulation< dim, spacedim > &destination_tria)> copy
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 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 Triangulation< 3, spacedim >::DistortedCellList execute_refinement_isotropic(Triangulation< 3, spacedim > &triangulation, const bool check_for_distorted_cells)
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)
static void process_subcelldata(const CRS< T > &crs, TriaObjects &obj, const std::vector< CellData< structdim > > &boundary_objects_in, const std::vector< Point< spacedim > > &vertex_locations)
std::vector< std::vector< CellData< dim > > > cell_infos
const ::Triangulation< dim, spacedim > & tria