5910 const bool check_for_distorted_cells)
5912 static const int dim = 3;
5914 using raw_line_iterator =
5916 using raw_quad_iterator =
5927 for (
const auto &cell :
triangulation.active_cell_iterators_on_level(
5929 if (cell->refine_flag_set())
5955 unsigned int needed_vertices = 0;
5956 unsigned int needed_lines_single = 0;
5957 unsigned int needed_quads_single = 0;
5958 unsigned int needed_lines_pair = 0;
5959 unsigned int needed_quads_pair = 0;
5962 unsigned int new_cells = 0;
5964 for (
const auto &cell :
5966 if (cell->refine_flag_set())
5969 Assert(cell->refine_flag_set() ==
5975 new_cells += cell->reference_cell().n_isotropic_children();
5980 needed_lines_single += 6;
5981 needed_quads_single += 12;
5983 else if (cell->reference_cell() ==
5986 needed_lines_single += 1;
5987 needed_quads_single += 8;
5998 for (
const auto face : cell->face_indices())
5999 if (cell->face(face)->n_children() == 0)
6000 cell->face(face)->set_user_flag();
6002 Assert(cell->face(face)->n_children() ==
6003 cell->reference_cell()
6004 .face_reference_cell(face)
6005 .n_isotropic_children(),
6008 for (
const auto line : cell->line_indices())
6009 if (cell->line(line)->has_children() ==
false)
6010 cell->line(line)->set_user_flag();
6012 Assert(cell->line(line)->n_children() == 2,
6016 const unsigned int used_cells =
6022 used_cells + new_cells,
6036 if (quad->user_flag_set() ==
false)
6041 needed_quads_pair += 4;
6042 needed_lines_pair += 4;
6043 needed_vertices += 1;
6047 needed_quads_pair += 4;
6048 needed_lines_single += 3;
6061 if (line->user_flag_set() ==
false)
6064 needed_lines_pair += 2;
6065 needed_vertices += 1;
6070 needed_lines_single);
6073 needed_quads_single);
6076 needed_quads_single);
6080 needed_vertices += std::count(
triangulation.vertices_used.begin(),
6101 for (
const auto &cell :
triangulation.active_cell_iterators())
6102 if (!cell->refine_flag_set())
6103 for (
unsigned int line_n = 0; line_n < cell->n_lines(); ++line_n)
6104 if (cell->line(line_n)->has_children())
6105 for (
unsigned int c = 0; c < 2; ++c)
6106 Assert(cell->line(line_n)->child(c)->user_flag_set() ==
false,
6110 unsigned int current_vertex = 0;
6114 auto get_next_unused_vertex = [](
const unsigned int current_vertex,
6115 std::vector<bool> &vertices_used) {
6116 unsigned int next_vertex = current_vertex;
6117 while (next_vertex < vertices_used.size() &&
6118 vertices_used[next_vertex] ==
true)
6121 vertices_used[next_vertex] =
true;
6131 raw_line_iterator next_unused_line =
triangulation.begin_raw_line();
6133 for (; line != endl; ++line)
6135 if (line->user_flag_set() ==
false)
6139 triangulation.faces->lines.template next_free_pair_object<1>(
6147 line->set_children(0, next_unused_line->index());
6149 const std::array<raw_line_iterator, 2> children{
6150 {next_unused_line, ++next_unused_line}};
6156 get_next_unused_vertex(current_vertex,
6158 triangulation.vertices[current_vertex] = line->center(
true);
6160 children[0]->set_bounding_object_indices(
6161 {line->vertex_index(0), current_vertex});
6162 children[1]->set_bounding_object_indices(
6163 {current_vertex, line->vertex_index(1)});
6165 const auto manifold_id = line->manifold_id();
6166 const auto boundary_id = line->boundary_id();
6167 for (
const auto &child : children)
6169 child->set_used_flag();
6170 child->clear_children();
6172 child->clear_user_flag();
6173 child->set_boundary_id_internal(boundary_id);
6174 child->set_manifold_id(manifold_id);
6177 line->clear_user_flag();
6187 for (; quad != endq; ++quad)
6189 if (quad->user_flag_set() ==
false)
6192 const auto reference_face_type = quad->reference_cell();
6196 std::array<raw_line_iterator, 4> new_lines;
6199 for (
unsigned int l = 0; l < 2; ++l)
6201 auto next_unused_line =
6204 new_lines[2 * l] = next_unused_line;
6205 new_lines[2 * l + 1] = ++next_unused_line;
6210 for (
unsigned int l = 0; l < 3; ++l)
6220 for (
const unsigned int line : quad->line_indices())
6228 std::array<raw_quad_iterator, 4> new_quads;
6229 for (
unsigned int q = 0; q < 2; ++q)
6231 auto next_unused_quad =
6235 new_quads[2 * q] = next_unused_quad;
6236 new_quads[2 * q + 1] = ++next_unused_quad;
6238 quad->set_children(2 * q, new_quads[2 * q]->
index());
6242 for (
const auto &quad : new_quads)
6254 for (
const auto i : quad->vertex_indices())
6257 for (
const auto i : quad->line_indices())
6263 get_next_unused_vertex(current_vertex,
6268 quad->center(
true,
true);
6272 std::array<raw_line_iterator, 12> lines;
6273 unsigned int n_lines = 0;
6274 for (
unsigned int l = 0; l < quad->
n_lines(); ++l)
6275 for (
unsigned int c = 0; c < 2; ++c)
6277 static constexpr ::ndarray<unsigned int, 2, 2>
index =
6284 quad->line(l)->child(
index[c][quad->line_orientation(l)]);
6287 for (
unsigned int l = 0; l < quad->
n_lines(); ++l)
6288 lines[n_lines++] = new_lines[l];
6290 std::array<int, 12> line_indices;
6291 for (
unsigned int i = 0; i < n_lines; ++i)
6292 line_indices[i] = lines[i]->
index();
6294 static constexpr ::ndarray<unsigned int, 12, 2>
6295 line_vertices_quad{{{{0, 4}},
6308 static constexpr ::ndarray<unsigned int, 4, 4>
6309 quad_lines_quad{{{{0, 8, 4, 10}},
6314 static constexpr ::ndarray<unsigned int, 12, 2>
6315 line_vertices_tri{{{{0, 3}},
6328 static constexpr ::ndarray<unsigned int, 4, 4>
6329 quad_lines_tri{{{{0, 8, 5, X}},
6334 static constexpr ::ndarray<unsigned int, 4, 4, 2>
6335 quad_line_vertices_tri{
6336 {{{{{0, 3}}, {{3, 5}}, {{5, 0}}, {{X, X}}}},
6337 {{{{3, 1}}, {{1, 4}}, {{4, 3}}, {{X, X}}}},
6338 {{{{5, 4}}, {{4, 2}}, {{2, 5}}, {{X, X}}}},
6339 {{{{3, 4}}, {{4, 5}}, {{5, 3}}, {{X, X}}}}}};
6341 const auto &line_vertices =
6343 line_vertices_quad :
6345 const auto &quad_lines =
6350 for (
unsigned int i = 0, j = 2 * quad->
n_lines();
6354 auto &new_line = new_lines[i];
6355 new_line->set_bounding_object_indices(
6358 new_line->set_used_flag();
6359 new_line->clear_user_flag();
6360 new_line->clear_user_data();
6361 new_line->clear_children();
6362 new_line->set_boundary_id_internal(quad->boundary_id());
6363 new_line->set_manifold_id(quad->manifold_id());
6367 for (
unsigned int i = 0; i < new_quads.size(); ++i)
6369 auto &new_quad = new_quads[i];
6374 reference_face_type);
6377 new_quad->set_bounding_object_indices(
6378 {line_indices[quad_lines[i][0]],
6379 line_indices[quad_lines[i][1]],
6380 line_indices[quad_lines[i][2]]});
6382 new_quad->set_bounding_object_indices(
6383 {line_indices[quad_lines[i][0]],
6384 line_indices[quad_lines[i][1]],
6385 line_indices[quad_lines[i][2]],
6386 line_indices[quad_lines[i][3]]});
6390 new_quad->set_used_flag();
6391 new_quad->clear_user_flag();
6392 new_quad->clear_user_data();
6393 new_quad->clear_children();
6394 new_quad->set_boundary_id_internal(quad->boundary_id());
6395 new_quad->set_manifold_id(quad->manifold_id());
6398 std::set<unsigned int> s;
6406 for (
const auto f : new_quad->line_indices())
6408 const std::array<unsigned int, 2> vertices_0 = {
6409 {lines[quad_lines[i][f]]->vertex_index(0),
6410 lines[quad_lines[i][f]]->vertex_index(1)}};
6412 const std::array<unsigned int, 2> vertices_1 = {
6416 const auto orientation =
6422 for (
const auto i : vertices_0)
6424 for (
const auto i : vertices_1)
6428 new_quad->set_line_orientation(
6432 default_combined_face_orientation());
6444 static constexpr ::ndarray<unsigned int, 4, 2>
6445 quad_child_boundary_lines{
6446 {{{0, 2}}, {{1, 3}}, {{0, 1}}, {{2, 3}}}};
6448 for (
unsigned int i = 0; i < 4; ++i)
6449 for (
unsigned int j = 0; j < 2; ++j)
6450 new_quads[quad_child_boundary_lines[i][j]]
6451 ->set_line_orientation(i, quad->line_orientation(i));
6454 quad->clear_user_flag();
6459 cells_with_distorted_children;
6469 hex->level() >=
static_cast<int>(
level),
6473 hex->level() ==
static_cast<int>(
level);
6476 if (hex->refine_flag_set() ==
6480 const auto &reference_cell_type = hex->reference_cell();
6483 hex->clear_refine_flag();
6484 hex->set_refinement_case(ref_case);
6486 unsigned int n_new_lines = 0;
6487 unsigned int n_new_quads = 0;
6488 unsigned int n_new_hexes = 0;
6505 std::array<raw_line_iterator, 6> new_lines;
6506 for (
unsigned int i = 0; i < n_new_lines; ++i)
6513 new_lines[i]->set_used_flag();
6514 new_lines[i]->clear_user_flag();
6515 new_lines[i]->clear_user_data();
6516 new_lines[i]->clear_children();
6517 new_lines[i]->set_boundary_id_internal(
6519 new_lines[i]->set_manifold_id(hex->manifold_id());
6522 std::array<raw_quad_iterator, 12> new_quads;
6523 for (
unsigned int i = 0; i < n_new_quads; ++i)
6529 auto &new_quad = new_quads[i];
6535 reference_cell_type.face_reference_cell(0));
6538 new_quad->set_used_flag();
6539 new_quad->clear_user_flag();
6540 new_quad->clear_user_data();
6541 new_quad->clear_children();
6542 new_quad->set_boundary_id_internal(
6544 new_quad->set_manifold_id(hex->manifold_id());
6545 for (
const auto j : new_quads[i]->line_indices())
6546 new_quad->set_line_orientation(j,
true);
6555 for (
unsigned int i = 0; i < n_new_hexes; ++i)
6564 new_hexes[i] = next_unused_hex;
6566 auto &new_hex = new_hexes[i];
6570 ->reference_cell[new_hex->index()] =
6571 reference_cell_type;
6574 new_hex->set_used_flag();
6575 new_hex->clear_user_flag();
6576 new_hex->clear_user_data();
6577 new_hex->clear_children();
6578 new_hex->set_material_id(hex->material_id());
6579 new_hex->set_manifold_id(hex->manifold_id());
6580 new_hex->set_subdomain_id(hex->subdomain_id());
6583 new_hex->set_parent(hex->index());
6588 for (
const auto f : new_hex->face_indices())
6589 new_hex->set_combined_face_orientation(
6593 for (
unsigned int i = 0; i < n_new_hexes / 2; ++i)
6594 hex->set_children(2 * i, new_hexes[2 * i]->index());
6606 const unsigned int n_vertices =
6608 for (
unsigned int i = 0; i < n_vertices; ++i)
6611 const std::array<unsigned int, 12> line_indices =
6612 TriaAccessorImplementation::Implementation::
6613 get_line_indices_of_cell(*hex);
6625 for (
unsigned int l = 0; l < n_lines; ++l)
6635 for (
const unsigned int i : hex->face_indices())
6637 hex->face(i)->child(0)->vertex_index(3);
6641 get_next_unused_vertex(current_vertex,
6646 hex->center(
true,
true);
6650 unsigned int chosen_line_tetrahedron = 0;
6654 static constexpr ::ndarray<unsigned int, 6, 2>
6655 new_line_vertices = {{{{22, 26}},
6661 for (
unsigned int i = 0; i < n_new_lines; ++i)
6662 new_lines[i]->set_bounding_object_indices(
6672 static constexpr ::ndarray<unsigned int, 3, 2>
6673 new_line_vertices = {{{{6, 8}}, {{5, 7}}, {{4, 9}}}};
6676 double min_distance =
6677 std::numeric_limits<double>::infinity();
6678 for (
unsigned int i = 0; i < new_line_vertices.size();
6681 const double current_distance =
6686 if (current_distance < min_distance)
6688 chosen_line_tetrahedron = i;
6689 min_distance = current_distance;
6693 new_lines[0]->set_bounding_object_indices(
6695 [new_line_vertices[chosen_line_tetrahedron][0]],
6697 [new_line_vertices[chosen_line_tetrahedron][1]]});
6702 boost::container::small_vector<raw_line_iterator, 30>
6707 relevant_lines.resize(30);
6708 for (
unsigned int f = 0, k = 0; f < 6; ++f)
6709 for (
unsigned int c = 0; c < 4; ++c, ++k)
6712 ndarray<unsigned int, 4, 2>
6714 {{{0, 1}}, {{3, 0}}, {{0, 3}}, {{3, 2}}}};
6720 standard_to_real_face_vertex(
6722 hex->face_orientation(f),
6724 hex->face_rotation(f)))
6726 standard_to_real_face_line(
6728 hex->face_orientation(f),
6730 hex->face_rotation(f)));
6733 for (
unsigned int i = 0, k = 24; i < 6; ++i, ++k)
6734 relevant_lines[k] = new_lines[i];
6749 relevant_lines.resize(13);
6752 for (
unsigned int f = 0; f < 4; ++f)
6753 for (
unsigned int l = 0; l < 3; ++l, ++k)
6757 array<std::array<unsigned int, 3>, 6>
6758 table = {{{{1, 0, 2}},
6765 const unsigned char combined_orientation =
6766 hex->combined_face_orientation(f);
6770 ->line(table[combined_orientation][l]);
6773 relevant_lines[k++] = new_lines[0];
6779 boost::container::small_vector<unsigned int, 30>
6780 relevant_line_indices(relevant_lines.size());
6781 for (
unsigned int i = 0; i < relevant_line_indices.size();
6783 relevant_line_indices[i] = relevant_lines[i]->
index();
6785 static constexpr ::ndarray<unsigned int, 12, 4>
6786 new_quad_lines_hex = {{{{10, 28, 16, 24}},
6797 {{25, 7, 27, 13}}}};
6814 static constexpr ::ndarray<unsigned int, 3, 12, 4>
6815 new_quad_lines_tet = {{
6855 static constexpr ::ndarray<unsigned int, 12, 4, 2>
6857 {{{{{10, 22}}, {{24, 26}}, {{10, 24}}, {{22, 26}}}},
6858 {{{{24, 26}}, {{11, 23}}, {{24, 11}}, {{26, 23}}}},
6859 {{{{22, 14}}, {{26, 25}}, {{22, 26}}, {{14, 25}}}},
6860 {{{{26, 25}}, {{23, 15}}, {{26, 23}}, {{25, 15}}}},
6861 {{{{8, 24}}, {{20, 26}}, {{8, 20}}, {{24, 26}}}},
6862 {{{{20, 26}}, {{12, 25}}, {{20, 12}}, {{26, 25}}}},
6863 {{{{24, 9}}, {{26, 21}}, {{24, 26}}, {{9, 21}}}},
6864 {{{{26, 21}}, {{25, 13}}, {{26, 25}}, {{21, 13}}}},
6865 {{{{16, 20}}, {{22, 26}}, {{16, 22}}, {{20, 26}}}},
6866 {{{{22, 26}}, {{17, 21}}, {{22, 17}}, {{26, 21}}}},
6867 {{{{20, 18}}, {{26, 23}}, {{20, 26}}, {{18, 23}}}},
6868 {{{{26, 23}}, {{21, 19}}, {{26, 21}}, {{23, 19}}}}}};
6873 static constexpr ::ndarray<unsigned int, 3, 12, 4, 2>
6876 {{{{{{6, 4}}, {{4, 7}}, {{7, 6}}, {{X, X}}}},
6877 {{{{4, 5}}, {{5, 8}}, {{8, 4}}, {{X, X}}}},
6878 {{{{5, 6}}, {{6, 9}}, {{9, 5}}, {{X, X}}}},
6879 {{{{7, 8}}, {{8, 9}}, {{9, 7}}, {{X, X}}}},
6880 {{{{4, 6}}, {{6, 8}}, {{8, 4}}, {{X, X}}}},
6881 {{{{6, 5}}, {{5, 8}}, {{8, 6}}, {{X, X}}}},
6882 {{{{8, 7}}, {{7, 6}}, {{6, 8}}, {{X, X}}}},
6883 {{{{9, 6}}, {{6, 8}}, {{8, 9}}, {{X, X}}}},
6884 {{{{X, X}}, {{X, X}}, {{X, X}}, {{X, X}}}},
6885 {{{{X, X}}, {{X, X}}, {{X, X}}, {{X, X}}}},
6886 {{{{X, X}}, {{X, X}}, {{X, X}}, {{X, X}}}},
6887 {{{{X, X}}, {{X, X}}, {{X, X}}, {{X, X}}}}}},
6889 {{{{{{6, 4}}, {{4, 7}}, {{7, 6}}, {{X, X}}}},
6890 {{{{4, 5}}, {{5, 8}}, {{8, 4}}, {{X, X}}}},
6891 {{{{5, 6}}, {{6, 9}}, {{9, 5}}, {{X, X}}}},
6892 {{{{7, 8}}, {{8, 9}}, {{9, 7}}, {{X, X}}}},
6893 {{{{5, 4}}, {{4, 7}}, {{7, 5}}, {{X, X}}}},
6894 {{{{6, 5}}, {{5, 7}}, {{7, 6}}, {{X, X}}}},
6895 {{{{8, 7}}, {{7, 5}}, {{5, 8}}, {{X, X}}}},
6896 {{{{7, 9}}, {{9, 5}}, {{5, 7}}, {{X, X}}}},
6897 {{{{X, X}}, {{X, X}}, {{X, X}}, {{X, X}}}},
6898 {{{{X, X}}, {{X, X}}, {{X, X}}, {{X, X}}}},
6899 {{{{X, X}}, {{X, X}}, {{X, X}}, {{X, X}}}},
6900 {{{{X, X}}, {{X, X}}, {{X, X}}, {{X, X}}}}}},
6902 {{{{{{6, 4}}, {{4, 7}}, {{7, 6}}, {{X, X}}}},
6903 {{{{4, 5}}, {{5, 8}}, {{8, 4}}, {{X, X}}}},
6904 {{{{5, 6}}, {{6, 9}}, {{9, 5}}, {{X, X}}}},
6905 {{{{7, 8}}, {{8, 9}}, {{9, 7}}, {{X, X}}}},
6906 {{{{5, 4}}, {{4, 9}}, {{9, 5}}, {{X, X}}}},
6907 {{{{4, 6}}, {{6, 9}}, {{9, 4}}, {{X, X}}}},
6908 {{{{7, 4}}, {{4, 9}}, {{9, 7}}, {{X, X}}}},
6909 {{{{4, 8}}, {{8, 9}}, {{9, 4}}, {{X, X}}}},
6910 {{{{X, X}}, {{X, X}}, {{X, X}}, {{X, X}}}},
6911 {{{{X, X}}, {{X, X}}, {{X, X}}, {{X, X}}}},
6912 {{{{X, X}}, {{X, X}}, {{X, X}}, {{X, X}}}},
6913 {{{{X, X}}, {{X, X}}, {{X, X}}, {{X, X}}}}}}}};
6915 const auto &new_quad_lines =
6917 new_quad_lines_hex :
6918 new_quad_lines_tet[chosen_line_tetrahedron];
6923 table_tet[chosen_line_tetrahedron];
6925 static constexpr ::ndarray<unsigned int, 4, 2>
6926 representative_lines{
6927 {{{0, 2}}, {{2, 0}}, {{3, 3}}, {{1, 1}}}};
6929 for (
unsigned int q = 0; q < n_new_quads; ++q)
6931 auto &new_quad = new_quads[q];
6933 if (new_quad->n_lines() == 3)
6934 new_quad->set_bounding_object_indices(
6935 {relevant_line_indices[new_quad_lines[q][0]],
6936 relevant_line_indices[new_quad_lines[q][1]],
6937 relevant_line_indices[new_quad_lines[q][2]]});
6938 else if (new_quad->n_lines() == 4)
6939 new_quad->set_bounding_object_indices(
6940 {relevant_line_indices[new_quad_lines[q][0]],
6941 relevant_line_indices[new_quad_lines[q][1]],
6942 relevant_line_indices[new_quad_lines[q][2]],
6943 relevant_line_indices[new_quad_lines[q][3]]});
6951 const unsigned int n_compute_lines =
6955 for (
unsigned int line = 0; line < n_compute_lines;
6958 const unsigned int l =
6959 (reference_cell_type ==
6961 representative_lines[q % 4][0] :
6964 const std::array<unsigned int, 2> vertices_0 = {
6965 {relevant_lines[new_quad_lines[q][l]]
6967 relevant_lines[new_quad_lines[q][l]]
6968 ->vertex_index(1)}};
6970 const std::array<unsigned int, 2> vertices_1 = {
6974 const auto orientation =
6979 new_quad->set_line_orientation(
6983 default_combined_face_orientation());
6988 if (reference_cell_type ==
6990 new_quads[representative_lines[q % 4][1] + q -
6992 ->set_line_orientation(
6996 default_combined_face_orientation());
7003 std::array<int, 36> quad_indices;
7007 for (
unsigned int i = 0; i < n_new_quads; ++i)
7008 quad_indices[i] = new_quads[i]->
index();
7010 for (
unsigned int f = 0, k = n_new_quads; f < 6; ++f)
7011 for (
unsigned int c = 0; c < 4; ++c, ++k)
7013 hex->face(f)->isotropic_child_index(
7016 hex->face_orientation(f),
7018 hex->face_rotation(f)));
7028 for (
unsigned int i = 0; i < n_new_quads; ++i)
7029 quad_indices[i] = new_quads[i]->
index();
7031 for (
unsigned int f = 0, k = n_new_quads; f < 4; ++f)
7032 for (
unsigned int c = 0; c < 4; ++c, ++k)
7034 const unsigned char combined_orientation =
7035 hex->combined_face_orientation(f);
7036 quad_indices[k] = hex->face(f)->child_index(
7039 .standard_to_real_face_vertex(
7040 c, f, combined_orientation));
7048 static constexpr ::ndarray<unsigned int, 8, 6>
7050 {{12, 0, 20, 4, 28, 8}},
7051 {{0, 16, 22, 6, 29, 9}},
7052 {{13, 1, 4, 24, 30, 10}},
7053 {{1, 17, 6, 26, 31, 11}},
7054 {{14, 2, 21, 5, 8, 32}},
7055 {{2, 18, 23, 7, 9, 33}},
7056 {{15, 3, 5, 25, 10, 34}},
7057 {{3, 19, 7, 27, 11, 35}}
7068 static constexpr ::ndarray<unsigned int, 3, 8, 6>
7070 {{{{8, 13, 16, 0, X, X}},
7071 {{9, 12, 1, 21, X, X}},
7072 {{10, 2, 17, 20, X, X}},
7073 {{3, 14, 18, 22, X, X}},
7074 {{11, 1, 4, 5, X, X}},
7075 {{15, 0, 4, 6, X, X}},
7076 {{19, 7, 6, 3, X, X}},
7077 {{23, 5, 2, 7, X, X}}}},
7080 {{8, 13, 16, 0, X, X}},
7081 {{9, 12, 1, 21, X, X}},
7082 {{10, 2, 17, 20, X, X}},
7083 {{3, 14, 18, 22, X, X}},
7084 {{11, 4, 0, 5, X, X}},
7085 {{15, 4, 1, 6, X, X}},
7086 {{19, 2, 5, 7, X, X}},
7087 {{23, 6, 7, 3, X, X}},
7091 {{8, 13, 16, 0, X, X}},
7092 {{9, 12, 1, 21, X, X}},
7093 {{10, 2, 17, 20, X, X}},
7094 {{3, 14, 18, 22, X, X}},
7095 {{11, 4, 5, 2, X, X}},
7096 {{15, 6, 7, 3, X, X}},
7097 {{19, 5, 0, 6, X, X}},
7098 {{23, 1, 4, 7, X, X}},
7103 static constexpr ::ndarray<unsigned int, 4, 3>
7104 reference_cell_face_vertices = {
7105 {{{0, 1, 2}}, {{1, 0, 3}}, {{0, 2, 3}}, {{2, 1, 3}}}};
7113 static constexpr ::ndarray<unsigned int, 3, 8, 4>
7114 cell_vertices_tet = {{
7143 const auto &cell_quads =
7146 cell_quads_tet[chosen_line_tetrahedron];
7148 for (
unsigned int c = 0;
7149 c < GeometryInfo<dim>::max_children_per_cell;
7152 auto &new_hex = new_hexes[c];
7154 if (new_hex->n_faces() == 4)
7156 new_hex->set_bounding_object_indices(
7157 {quad_indices[cell_quads[c][0]],
7158 quad_indices[cell_quads[c][1]],
7159 quad_indices[cell_quads[c][2]],
7160 quad_indices[cell_quads[c][3]]});
7165 for (
const auto f : new_hex->face_indices())
7167 const auto &face = new_hex->face(f);
7169 Assert(face->n_vertices() == 3,
7172 const std::array<unsigned int, 3> vertices_0 = {
7173 {face->vertex_index(0),
7174 face->vertex_index(1),
7175 face->vertex_index(2)}};
7177 const auto &new_hex_vertices =
7178 cell_vertices_tet[chosen_line_tetrahedron][c];
7179 const auto face_f_vertices =
7180 reference_cell_face_vertices[f];
7182 const std::array<unsigned int, 3> vertices_1 = {
7185 [new_hex_vertices[face_f_vertices[0]]],
7187 [new_hex_vertices[face_f_vertices[1]]],
7189 [new_hex_vertices[face_f_vertices[2]]],
7192 new_hex->set_combined_face_orientation(
7194 face->reference_cell()
7195 .get_combined_orientation(
7200 else if (new_hex->n_faces() == 6)
7201 new_hex->set_bounding_object_indices(
7202 {quad_indices[cell_quads[c][0]],
7203 quad_indices[cell_quads[c][1]],
7204 quad_indices[cell_quads[c][2]],
7205 quad_indices[cell_quads[c][3]],
7206 quad_indices[cell_quads[c][4]],
7207 quad_indices[cell_quads[c][5]]});
7216 static constexpr ::ndarray<unsigned int, 6, 4>
7217 face_to_child_indices_hex{{{{0, 2, 4, 6}},
7224 for (
const auto f : hex->face_indices())
7226 const unsigned char combined_orientation =
7227 hex->combined_face_orientation(f);
7228 for (
unsigned int c = 0; c < 4; ++c)
7229 new_hexes[face_to_child_indices_hex[f][c]]
7230 ->set_combined_face_orientation(
7231 f, combined_orientation);
7236 if (check_for_distorted_cells &&
7237 has_distorted_children<dim, spacedim>(hex))
7246 return cells_with_distorted_children;
7256 const bool check_for_distorted_cells)
7258 const unsigned int dim = 3;
7261 bool flag_isotropic_mesh =
true;
7265 for (; cell != endc; ++cell)
7275 flag_isotropic_mesh =
false;
7279 if (flag_isotropic_mesh)
7281 check_for_distorted_cells);
7292 for (
const auto &cell :
triangulation.active_cell_iterators_on_level(
7294 if (cell->refine_flag_set())
7311 line->clear_user_flag();
7316 quad->clear_user_flag();
7339 unsigned int needed_vertices = 0;
7340 unsigned int needed_lines_single = 0;
7341 unsigned int needed_quads_single = 0;
7342 unsigned int needed_lines_pair = 0;
7343 unsigned int needed_quads_pair = 0;
7348 unsigned int new_cells = 0;
7350 for (
const auto &acell :
7352 if (acell->refine_flag_set())
7362 ++needed_quads_single;
7370 ++needed_lines_single;
7371 needed_quads_single += 4;
7378 needed_lines_single += 6;
7379 needed_quads_single += 12;
7393 for (
const unsigned int face :
7397 aface = acell->face(face);
7404 acell->face_orientation(face),
7405 acell->face_flip(face),
7406 acell->face_rotation(face));
7411 if (face_ref_case ==
7414 if (aface->n_active_descendants() < 4)
7417 aface->set_user_flag();
7419 else if (aface->refinement_case() != face_ref_case)
7430 Assert(aface->refinement_case() ==
7432 dim - 1>::isotropic_refinement ||
7433 aface->refinement_case() ==
7436 aface->set_user_index(face_ref_case);
7442 for (
unsigned int line = 0;
7443 line < GeometryInfo<dim>::lines_per_cell;
7447 !acell->line(line)->has_children())
7448 acell->line(line)->set_user_flag();
7454 const unsigned int used_cells =
7464 used_cells + new_cells,
7478 if (quad->user_flag_set())
7484 needed_quads_pair += 4;
7485 needed_lines_pair += 4;
7486 needed_vertices += 1;
7488 if (quad->user_index())
7492 needed_quads_pair += 2;
7493 needed_lines_single += 1;
7506 if (quad->has_children())
7508 Assert(quad->refinement_case() ==
7511 if ((face_refinement_cases[quad->user_index()] ==
7513 (quad->child(0)->line_index(1) + 1 !=
7514 quad->child(2)->line_index(1))) ||
7515 (face_refinement_cases[quad->user_index()] ==
7517 (quad->child(0)->line_index(3) + 1 !=
7518 quad->child(1)->line_index(3))))
7519 needed_lines_pair += 2;
7528 if (line->user_flag_set())
7530 needed_lines_pair += 2;
7531 needed_vertices += 1;
7537 needed_lines_single);
7541 needed_quads_single);
7544 needed_quads_single);
7548 needed_vertices += std::count(
triangulation.vertices_used.begin(),
7572 for (
const auto &cell :
triangulation.active_cell_iterators())
7573 if (!cell->refine_flag_set())
7574 for (
unsigned int line = 0;
7575 line < GeometryInfo<dim>::lines_per_cell;
7577 if (cell->line(line)->has_children())
7578 for (
unsigned int c = 0; c < 2; ++c)
7579 Assert(cell->line(line)->child(c)->user_flag_set() ==
false,
7591 unsigned int next_unused_vertex = 0;
7602 for (; line != endl; ++line)
7603 if (line->user_flag_set())
7609 while (
triangulation.vertices_used[next_unused_vertex] ==
true)
7610 ++next_unused_vertex;
7614 "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."));
7617 triangulation.vertices[next_unused_vertex] = line->center(
true);
7631 line->set_children(0, next_unused_line->index());
7635 children[2] = {next_unused_line, ++next_unused_line};
7642 children[0]->set_bounding_object_indices(
7643 {line->vertex_index(0), next_unused_vertex});
7644 children[1]->set_bounding_object_indices(
7645 {next_unused_vertex, line->vertex_index(1)});
7647 children[0]->set_used_flag();
7648 children[1]->set_used_flag();
7649 children[0]->clear_children();
7650 children[1]->clear_children();
7653 children[0]->clear_user_flag();
7654 children[1]->clear_user_flag();
7656 children[0]->set_boundary_id_internal(line->boundary_id());
7657 children[1]->set_boundary_id_internal(line->boundary_id());
7659 children[0]->set_manifold_id(line->manifold_id());
7660 children[1]->set_manifold_id(line->manifold_id());
7665 line->clear_user_flag();
7695 for (
unsigned int loop = 0; loop < 2; ++loop)
7708 for (; quad != endq; ++quad)
7710 if (quad->user_index())
7713 face_refinement_cases[quad->user_index()];
7722 if (aniso_quad_ref_case == quad->refinement_case())
7725 Assert(quad->refinement_case() ==
7727 quad->refinement_case() ==
7732 Assert(quad->user_index() ==
7734 quad->user_index() ==
7764 quad->line(2)->child(0)->vertex_index(1);
7766 quad->line(3)->child(0)->vertex_index(1);
7771 quad->line(0)->child(0)->vertex_index(1);
7773 quad->line(1)->child(0)->vertex_index(1);
7776 new_line->set_bounding_object_indices(
7778 new_line->set_used_flag();
7779 new_line->clear_user_flag();
7781 new_line->clear_children();
7782 new_line->set_boundary_id_internal(quad->boundary_id());
7783 new_line->set_manifold_id(quad->manifold_id());
7791 const unsigned int index[2][2] = {
7803 new_quads[0] = next_unused_quad;
7807 new_quads[1] = next_unused_quad;
7812 new_quads[0]->set_bounding_object_indices(
7813 {
static_cast<int>(quad->line_index(0)),
7816 ->child(
index[0][quad->line_orientation(2)])
7819 ->child(
index[0][quad->line_orientation(3)])
7821 new_quads[1]->set_bounding_object_indices(
7823 static_cast<int>(quad->line_index(1)),
7825 ->child(
index[1][quad->line_orientation(2)])
7828 ->child(
index[1][quad->line_orientation(3)])
7833 new_quads[0]->set_bounding_object_indices(
7835 ->child(
index[0][quad->line_orientation(0)])
7838 ->child(
index[0][quad->line_orientation(1)])
7840 static_cast<int>(quad->line_index(2)),
7841 new_line->index()});
7842 new_quads[1]->set_bounding_object_indices(
7844 ->child(
index[1][quad->line_orientation(0)])
7847 ->child(
index[1][quad->line_orientation(1)])
7850 static_cast<int>(quad->line_index(3))});
7853 for (
const auto &new_quad : new_quads)
7855 new_quad->set_used_flag();
7856 new_quad->clear_user_flag();
7858 new_quad->clear_children();
7859 new_quad->set_boundary_id_internal(quad->boundary_id());
7860 new_quad->set_manifold_id(quad->manifold_id());
7864 for (
unsigned int j = 0;
7865 j < GeometryInfo<dim>::lines_per_face;
7867 new_quad->set_line_orientation(j,
true);
7873 new_quads[0]->set_line_orientation(
7874 0, quad->line_orientation(0));
7875 new_quads[0]->set_line_orientation(
7876 2, quad->line_orientation(2));
7877 new_quads[1]->set_line_orientation(
7878 1, quad->line_orientation(1));
7879 new_quads[1]->set_line_orientation(
7880 3, quad->line_orientation(3));
7883 new_quads[0]->set_line_orientation(
7884 3, quad->line_orientation(3));
7885 new_quads[1]->set_line_orientation(
7886 2, quad->line_orientation(2));
7890 new_quads[0]->set_line_orientation(
7891 1, quad->line_orientation(1));
7892 new_quads[1]->set_line_orientation(
7893 0, quad->line_orientation(0));
7899 if (quad->refinement_case() ==
7922 if (aniso_quad_ref_case ==
7925 old_child[0] = quad->child(0)->line(1);
7926 old_child[1] = quad->child(2)->line(1);
7930 Assert(aniso_quad_ref_case ==
7934 old_child[0] = quad->child(0)->line(3);
7935 old_child[1] = quad->child(1)->line(3);
7938 if (old_child[0]->
index() + 1 != old_child[1]->
index())
7944 spacedim>::raw_line_iterator
7947 new_child[0] = new_child[1] =
7949 .template next_free_pair_object<1>(
7953 new_child[0]->set_used_flag();
7954 new_child[1]->set_used_flag();
7956 const int old_index_0 = old_child[0]->index(),
7957 old_index_1 = old_child[1]->index(),
7958 new_index_0 = new_child[0]->index(),
7959 new_index_1 = new_child[1]->index();
7963 for (
unsigned int q = 0;
7966 for (
unsigned int l = 0;
7967 l < GeometryInfo<dim>::lines_per_face;
7970 const int this_index =
7972 .get_bounding_object_indices(q)[l];
7973 if (this_index == old_index_0)
7975 .get_bounding_object_indices(q)[l] =
7977 else if (this_index == old_index_1)
7979 .get_bounding_object_indices(q)[l] =
7984 for (
unsigned int i = 0; i < 2; ++i)
7986 Assert(!old_child[i]->has_children(),
7989 new_child[i]->set_bounding_object_indices(
7990 {old_child[i]->vertex_index(0),
7991 old_child[i]->vertex_index(1)});
7992 new_child[i]->set_boundary_id_internal(
7993 old_child[i]->boundary_id());
7994 new_child[i]->set_manifold_id(
7995 old_child[i]->manifold_id());
7996 new_child[i]->set_user_index(
7997 old_child[i]->user_index());
7998 if (old_child[i]->user_flag_set())
7999 new_child[i]->set_user_flag();
8001 new_child[i]->clear_user_flag();
8003 new_child[i]->clear_children();
8005 old_child[i]->clear_user_flag();
8006 old_child[i]->clear_user_index();
8007 old_child[i]->clear_used_flag();
8013 if (aniso_quad_ref_case ==
8016 new_line->set_children(
8017 0, quad->child(0)->line_index(1));
8018 Assert(new_line->child(1) ==
8019 quad->child(2)->line(1),
8056 quad_iterator switch_1 = quad->child(1),
8057 switch_2 = quad->child(2);
8058 const int switch_1_index = switch_1->index();
8059 const int switch_2_index = switch_2->index();
8060 for (
unsigned int l = 0;
8063 for (
unsigned int h = 0;
8067 for (
const unsigned int q :
8070 const int face_index =
8072 ->cells.get_bounding_object_indices(
8074 if (face_index == switch_1_index)
8076 ->cells.get_bounding_object_indices(
8077 h)[q] = switch_2_index;
8078 else if (face_index == switch_2_index)
8080 ->cells.get_bounding_object_indices(
8081 h)[q] = switch_1_index;
8085 const unsigned int switch_1_lines[4] = {
8086 switch_1->line_index(0),
8087 switch_1->line_index(1),
8088 switch_1->line_index(2),
8089 switch_1->line_index(3)};
8090 const bool switch_1_line_orientations[4] = {
8091 switch_1->line_orientation(0),
8092 switch_1->line_orientation(1),
8093 switch_1->line_orientation(2),
8094 switch_1->line_orientation(3)};
8096 switch_1->boundary_id();
8097 const unsigned int switch_1_user_index =
8098 switch_1->user_index();
8099 const bool switch_1_user_flag =
8100 switch_1->user_flag_set();
8102 switch_1_refinement_case =
8103 switch_1->refinement_case();
8104 const int switch_1_first_child_pair =
8105 (switch_1_refinement_case ?
8106 switch_1->child_index(0) :
8108 const int switch_1_second_child_pair =
8109 (switch_1_refinement_case ==
8111 switch_1->child_index(2) :
8114 switch_1->set_bounding_object_indices(
8115 {switch_2->line_index(0),
8116 switch_2->line_index(1),
8117 switch_2->line_index(2),
8118 switch_2->line_index(3)});
8119 switch_1->set_line_orientation(
8120 0, switch_2->line_orientation(0));
8121 switch_1->set_line_orientation(
8122 1, switch_2->line_orientation(1));
8123 switch_1->set_line_orientation(
8124 2, switch_2->line_orientation(2));
8125 switch_1->set_line_orientation(
8126 3, switch_2->line_orientation(3));
8127 switch_1->set_boundary_id_internal(
8128 switch_2->boundary_id());
8129 switch_1->set_manifold_id(switch_2->manifold_id());
8130 switch_1->set_user_index(switch_2->user_index());
8131 if (switch_2->user_flag_set())
8132 switch_1->set_user_flag();
8134 switch_1->clear_user_flag();
8135 switch_1->clear_refinement_case();
8136 switch_1->set_refinement_case(
8137 switch_2->refinement_case());
8138 switch_1->clear_children();
8139 if (switch_2->refinement_case())
8140 switch_1->set_children(0,
8141 switch_2->child_index(0));
8142 if (switch_2->refinement_case() ==
8144 switch_1->set_children(2,
8145 switch_2->child_index(2));
8147 switch_2->set_bounding_object_indices(
8151 switch_1_lines[3]});
8152 switch_2->set_line_orientation(
8153 0, switch_1_line_orientations[0]);
8154 switch_2->set_line_orientation(
8155 1, switch_1_line_orientations[1]);
8156 switch_2->set_line_orientation(
8157 2, switch_1_line_orientations[2]);
8158 switch_2->set_line_orientation(
8159 3, switch_1_line_orientations[3]);
8160 switch_2->set_boundary_id_internal(
8161 switch_1_boundary_id);
8162 switch_2->set_manifold_id(switch_1->manifold_id());
8163 switch_2->set_user_index(switch_1_user_index);
8164 if (switch_1_user_flag)
8165 switch_2->set_user_flag();
8167 switch_2->clear_user_flag();
8168 switch_2->clear_refinement_case();
8169 switch_2->set_refinement_case(
8170 switch_1_refinement_case);
8171 switch_2->clear_children();
8172 switch_2->set_children(0,
8173 switch_1_first_child_pair);
8174 switch_2->set_children(2,
8175 switch_1_second_child_pair);
8177 new_quads[0]->set_refinement_case(
8179 new_quads[0]->set_children(0, quad->child_index(0));
8180 new_quads[1]->set_refinement_case(
8182 new_quads[1]->set_children(0, quad->child_index(2));
8186 new_quads[0]->set_refinement_case(
8188 new_quads[0]->set_children(0, quad->child_index(0));
8189 new_quads[1]->set_refinement_case(
8191 new_quads[1]->set_children(0, quad->child_index(2));
8192 new_line->set_children(
8193 0, quad->child(0)->line_index(3));
8194 Assert(new_line->child(1) ==
8195 quad->child(1)->line(3),
8198 quad->clear_children();
8202 quad->set_children(0, new_quads[0]->
index());
8204 quad->set_refinement_case(aniso_quad_ref_case);
8211 if (quad->user_flag_set())
8223 ++next_unused_vertex;
8227 "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."));
8235 quad->refinement_case();
8241 quad->child(0)->set_user_index(
8243 quad->child(1)->set_user_index(
8249 middle_line = quad->child(0)->line(1);
8251 middle_line = quad->child(0)->line(3);
8258 if (!middle_line->has_children())
8266 middle_line->center(
true);
8274 .template next_free_pair_object<1>(
8279 middle_line->set_children(
8280 0, next_unused_line->index());
8284 raw_line_iterator children[2] = {
8285 next_unused_line, ++next_unused_line};
8293 children[0]->set_bounding_object_indices(
8294 {middle_line->vertex_index(0),
8295 next_unused_vertex});
8296 children[1]->set_bounding_object_indices(
8297 {next_unused_vertex,
8298 middle_line->vertex_index(1)});
8300 children[0]->set_used_flag();
8301 children[1]->set_used_flag();
8302 children[0]->clear_children();
8303 children[1]->clear_children();
8306 children[0]->clear_user_flag();
8307 children[1]->clear_user_flag();
8309 children[0]->set_boundary_id_internal(
8310 middle_line->boundary_id());
8311 children[1]->set_boundary_id_internal(
8312 middle_line->boundary_id());
8314 children[0]->set_manifold_id(
8315 middle_line->manifold_id());
8316 children[1]->set_manifold_id(
8317 middle_line->manifold_id());
8323 quad->clear_user_flag();
8353 quad->center(
true,
true);
8362 for (
unsigned int i = 0; i < 4; ++i)
8375 new_lines[i] = next_unused_line;
8399 quad->line(0)->child(0)->vertex_index(1),
8400 quad->line(1)->child(0)->vertex_index(1),
8401 quad->line(2)->child(0)->vertex_index(1),
8402 quad->line(3)->child(0)->vertex_index(1),
8403 next_unused_vertex};
8405 new_lines[0]->set_bounding_object_indices(
8407 new_lines[1]->set_bounding_object_indices(
8409 new_lines[2]->set_bounding_object_indices(
8411 new_lines[3]->set_bounding_object_indices(
8414 for (
const auto &new_line : new_lines)
8416 new_line->set_used_flag();
8417 new_line->clear_user_flag();
8419 new_line->clear_children();
8420 new_line->set_boundary_id_internal(quad->boundary_id());
8421 new_line->set_manifold_id(quad->manifold_id());
8440 const unsigned int index[2][2] = {
8444 const int line_indices[12] = {
8446 ->child(
index[0][quad->line_orientation(0)])
8449 ->child(
index[1][quad->line_orientation(0)])
8452 ->child(
index[0][quad->line_orientation(1)])
8455 ->child(
index[1][quad->line_orientation(1)])
8458 ->child(
index[0][quad->line_orientation(2)])
8461 ->child(
index[1][quad->line_orientation(2)])
8464 ->child(
index[0][quad->line_orientation(3)])
8467 ->child(
index[1][quad->line_orientation(3)])
8469 new_lines[0]->index(),
8470 new_lines[1]->index(),
8471 new_lines[2]->index(),
8472 new_lines[3]->index()};
8484 new_quads[0] = next_unused_quad;
8488 new_quads[1] = next_unused_quad;
8494 new_quads[2] = next_unused_quad;
8498 new_quads[3] = next_unused_quad;
8502 quad->set_children(0, new_quads[0]->
index());
8503 quad->set_children(2, new_quads[2]->
index());
8506 new_quads[0]->set_bounding_object_indices(
8511 new_quads[1]->set_bounding_object_indices(
8516 new_quads[2]->set_bounding_object_indices(
8521 new_quads[3]->set_bounding_object_indices(
8526 for (
const auto &new_quad : new_quads)
8528 new_quad->set_used_flag();
8529 new_quad->clear_user_flag();
8531 new_quad->clear_children();
8532 new_quad->set_boundary_id_internal(quad->boundary_id());
8533 new_quad->set_manifold_id(quad->manifold_id());
8537 for (
unsigned int j = 0;
8538 j < GeometryInfo<dim>::lines_per_face;
8540 new_quad->set_line_orientation(j,
true);
8546 new_quads[0]->set_line_orientation(
8547 0, quad->line_orientation(0));
8548 new_quads[0]->set_line_orientation(
8549 2, quad->line_orientation(2));
8550 new_quads[1]->set_line_orientation(
8551 1, quad->line_orientation(1));
8552 new_quads[1]->set_line_orientation(
8553 2, quad->line_orientation(2));
8554 new_quads[2]->set_line_orientation(
8555 0, quad->line_orientation(0));
8556 new_quads[2]->set_line_orientation(
8557 3, quad->line_orientation(3));
8558 new_quads[3]->set_line_orientation(
8559 1, quad->line_orientation(1));
8560 new_quads[3]->set_line_orientation(
8561 3, quad->line_orientation(3));
8565 quad->clear_user_flag();
8576 cells_with_distorted_children;
8590 for (; hex != endh; ++hex)
8591 if (hex->refine_flag_set())
8599 hex->clear_refine_flag();
8600 hex->set_refinement_case(ref_case);
8611 unsigned int n_new_lines = 0;
8612 unsigned int n_new_quads = 0;
8613 unsigned int n_new_hexes = 0;
8644 new_lines(n_new_lines);
8645 for (
unsigned int i = 0; i < n_new_lines; ++i)
8652 new_lines[i]->set_used_flag();
8653 new_lines[i]->clear_user_flag();
8654 new_lines[i]->clear_user_data();
8655 new_lines[i]->clear_children();
8657 new_lines[i]->set_boundary_id_internal(
8661 new_lines[i]->set_manifold_id(hex->manifold_id());
8668 new_quads(n_new_quads);
8669 for (
unsigned int i = 0; i < n_new_quads; ++i)
8676 new_quads[i]->set_used_flag();
8677 new_quads[i]->clear_user_flag();
8678 new_quads[i]->clear_user_data();
8679 new_quads[i]->clear_children();
8681 new_quads[i]->set_boundary_id_internal(
8685 new_quads[i]->set_manifold_id(hex->manifold_id());
8688 for (
unsigned int j = 0;
8689 j < GeometryInfo<dim>::lines_per_face;
8691 new_quads[i]->set_line_orientation(j,
true);
8700 new_hexes(n_new_hexes);
8701 for (
unsigned int i = 0; i < n_new_hexes; ++i)
8710 new_hexes[i] = next_unused_hex;
8713 new_hexes[i]->set_used_flag();
8714 new_hexes[i]->clear_user_flag();
8715 new_hexes[i]->clear_user_data();
8716 new_hexes[i]->clear_children();
8719 new_hexes[i]->set_material_id(hex->material_id());
8720 new_hexes[i]->set_manifold_id(hex->manifold_id());
8721 new_hexes[i]->set_subdomain_id(subdomainid);
8724 new_hexes[i]->set_parent(hex->index());
8736 for (
const unsigned int f :
8738 new_hexes[i]->set_combined_face_orientation(
8743 for (
unsigned int i = 0; i < n_new_hexes / 2; ++i)
8744 hex->set_children(2 * i, new_hexes[2 * i]->index());
8751 const bool f_or[6] = {hex->face_orientation(0),
8752 hex->face_orientation(1),
8753 hex->face_orientation(2),
8754 hex->face_orientation(3),
8755 hex->face_orientation(4),
8756 hex->face_orientation(5)};
8759 const bool f_fl[6] = {hex->face_flip(0),
8767 const bool f_ro[6] = {hex->face_rotation(0),
8768 hex->face_rotation(1),
8769 hex->face_rotation(2),
8770 hex->face_rotation(3),
8771 hex->face_rotation(4),
8772 hex->face_rotation(5)};
8775 const unsigned char f_co[6] = {
8776 hex->combined_face_orientation(0),
8777 hex->combined_face_orientation(1),
8778 hex->combined_face_orientation(2),
8779 hex->combined_face_orientation(3),
8780 hex->combined_face_orientation(4),
8781 hex->combined_face_orientation(5)};
8791 const unsigned int child_at_origin[2][2][2] = {
8878 raw_line_iterator lines[4] = {
8879 hex->face(2)->child(0)->line(
8880 (hex->face(2)->refinement_case() ==
8884 hex->face(3)->child(0)->line(
8885 (hex->face(3)->refinement_case() ==
8889 hex->face(4)->child(0)->line(
8890 (hex->face(4)->refinement_case() ==
8894 hex->face(5)->child(0)->line(
8895 (hex->face(5)->refinement_case() ==
8901 unsigned int line_indices[4];
8902 for (
unsigned int i = 0; i < 4; ++i)
8903 line_indices[i] = lines[i]->
index();
8910 bool line_orientation[4];
8916 const unsigned int middle_vertices[2] = {
8917 hex->line(2)->child(0)->vertex_index(1),
8918 hex->line(7)->child(0)->vertex_index(1)};
8920 for (
unsigned int i = 0; i < 4; ++i)
8921 if (lines[i]->vertex_index(i % 2) ==
8922 middle_vertices[i % 2])
8923 line_orientation[i] =
true;
8928 Assert(lines[i]->vertex_index((i + 1) % 2) ==
8929 middle_vertices[i % 2],
8931 line_orientation[i] =
false;
8936 new_quads[0]->set_bounding_object_indices(
8942 new_quads[0]->set_line_orientation(
8943 0, line_orientation[0]);
8944 new_quads[0]->set_line_orientation(
8945 1, line_orientation[1]);
8946 new_quads[0]->set_line_orientation(
8947 2, line_orientation[2]);
8948 new_quads[0]->set_line_orientation(
8949 3, line_orientation[3]);
8982 const int quad_indices[11] = {
8983 new_quads[0]->index(),
8985 hex->face(0)->index(),
8987 hex->face(1)->index(),
8989 hex->face(2)->child_index(
8990 child_at_origin[hex->face(2)->refinement_case() -
8991 1][f_fl[2]][f_ro[2]]),
8992 hex->face(2)->child_index(
8994 child_at_origin[hex->face(2)->refinement_case() -
8995 1][f_fl[2]][f_ro[2]]),
8997 hex->face(3)->child_index(
8998 child_at_origin[hex->face(3)->refinement_case() -
8999 1][f_fl[3]][f_ro[3]]),
9000 hex->face(3)->child_index(
9002 child_at_origin[hex->face(3)->refinement_case() -
9003 1][f_fl[3]][f_ro[3]]),
9005 hex->face(4)->child_index(
9006 child_at_origin[hex->face(4)->refinement_case() -
9007 1][f_fl[4]][f_ro[4]]),
9008 hex->face(4)->child_index(
9010 child_at_origin[hex->face(4)->refinement_case() -
9011 1][f_fl[4]][f_ro[4]]),
9013 hex->face(5)->child_index(
9014 child_at_origin[hex->face(5)->refinement_case() -
9015 1][f_fl[5]][f_ro[5]]),
9016 hex->face(5)->child_index(
9018 child_at_origin[hex->face(5)->refinement_case() -
9019 1][f_fl[5]][f_ro[5]])
9023 new_hexes[0]->set_bounding_object_indices(
9030 new_hexes[1]->set_bounding_object_indices(
9105 raw_line_iterator lines[4] = {
9106 hex->face(0)->child(0)->line(
9107 (hex->face(0)->refinement_case() ==
9111 hex->face(1)->child(0)->line(
9112 (hex->face(1)->refinement_case() ==
9116 hex->face(4)->child(0)->line(
9117 (hex->face(4)->refinement_case() ==
9121 hex->face(5)->child(0)->line(
9122 (hex->face(5)->refinement_case() ==
9128 unsigned int line_indices[4];
9129 for (
unsigned int i = 0; i < 4; ++i)
9130 line_indices[i] = lines[i]->
index();
9137 bool line_orientation[4];
9143 const unsigned int middle_vertices[2] = {
9144 hex->line(0)->child(0)->vertex_index(1),
9145 hex->line(5)->child(0)->vertex_index(1)};
9147 for (
unsigned int i = 0; i < 4; ++i)
9148 if (lines[i]->vertex_index(i % 2) ==
9149 middle_vertices[i % 2])
9150 line_orientation[i] =
true;
9154 Assert(lines[i]->vertex_index((i + 1) % 2) ==
9155 middle_vertices[i % 2],
9157 line_orientation[i] =
false;
9162 new_quads[0]->set_bounding_object_indices(
9168 new_quads[0]->set_line_orientation(
9169 0, line_orientation[2]);
9170 new_quads[0]->set_line_orientation(
9171 1, line_orientation[3]);
9172 new_quads[0]->set_line_orientation(
9173 2, line_orientation[0]);
9174 new_quads[0]->set_line_orientation(
9175 3, line_orientation[1]);
9208 const int quad_indices[11] = {
9209 new_quads[0]->index(),
9211 hex->face(0)->child_index(
9212 child_at_origin[hex->face(0)->refinement_case() -
9213 1][f_fl[0]][f_ro[0]]),
9214 hex->face(0)->child_index(
9216 child_at_origin[hex->face(0)->refinement_case() -
9217 1][f_fl[0]][f_ro[0]]),
9219 hex->face(1)->child_index(
9220 child_at_origin[hex->face(1)->refinement_case() -
9221 1][f_fl[1]][f_ro[1]]),
9222 hex->face(1)->child_index(
9224 child_at_origin[hex->face(1)->refinement_case() -
9225 1][f_fl[1]][f_ro[1]]),
9227 hex->face(2)->index(),
9229 hex->face(3)->index(),
9231 hex->face(4)->child_index(
9232 child_at_origin[hex->face(4)->refinement_case() -
9233 1][f_fl[4]][f_ro[4]]),
9234 hex->face(4)->child_index(
9236 child_at_origin[hex->face(4)->refinement_case() -
9237 1][f_fl[4]][f_ro[4]]),
9239 hex->face(5)->child_index(
9240 child_at_origin[hex->face(5)->refinement_case() -
9241 1][f_fl[5]][f_ro[5]]),
9242 hex->face(5)->child_index(
9244 child_at_origin[hex->face(5)->refinement_case() -
9245 1][f_fl[5]][f_ro[5]])
9249 new_hexes[0]->set_bounding_object_indices(
9256 new_hexes[1]->set_bounding_object_indices(
9333 raw_line_iterator lines[4] = {
9334 hex->face(0)->child(0)->line(
9335 (hex->face(0)->refinement_case() ==
9339 hex->face(1)->child(0)->line(
9340 (hex->face(1)->refinement_case() ==
9344 hex->face(2)->child(0)->line(
9345 (hex->face(2)->refinement_case() ==
9349 hex->face(3)->child(0)->line(
9350 (hex->face(3)->refinement_case() ==
9356 unsigned int line_indices[4];
9357 for (
unsigned int i = 0; i < 4; ++i)
9358 line_indices[i] = lines[i]->
index();
9365 bool line_orientation[4];
9371 const unsigned int middle_vertices[2] = {
9372 middle_vertex_index<dim, spacedim>(hex->line(8)),
9373 middle_vertex_index<dim, spacedim>(hex->line(11))};
9375 for (
unsigned int i = 0; i < 4; ++i)
9376 if (lines[i]->vertex_index(i % 2) ==
9377 middle_vertices[i % 2])
9378 line_orientation[i] =
true;
9382 Assert(lines[i]->vertex_index((i + 1) % 2) ==
9383 middle_vertices[i % 2],
9385 line_orientation[i] =
false;
9390 new_quads[0]->set_bounding_object_indices(
9396 new_quads[0]->set_line_orientation(
9397 0, line_orientation[0]);
9398 new_quads[0]->set_line_orientation(
9399 1, line_orientation[1]);
9400 new_quads[0]->set_line_orientation(
9401 2, line_orientation[2]);
9402 new_quads[0]->set_line_orientation(
9403 3, line_orientation[3]);
9437 const int quad_indices[11] = {
9438 new_quads[0]->index(),
9440 hex->face(0)->child_index(
9441 child_at_origin[hex->face(0)->refinement_case() -
9442 1][f_fl[0]][f_ro[0]]),
9443 hex->face(0)->child_index(
9445 child_at_origin[hex->face(0)->refinement_case() -
9446 1][f_fl[0]][f_ro[0]]),
9448 hex->face(1)->child_index(
9449 child_at_origin[hex->face(1)->refinement_case() -
9450 1][f_fl[1]][f_ro[1]]),
9451 hex->face(1)->child_index(
9453 child_at_origin[hex->face(1)->refinement_case() -
9454 1][f_fl[1]][f_ro[1]]),
9456 hex->face(2)->child_index(
9457 child_at_origin[hex->face(2)->refinement_case() -
9458 1][f_fl[2]][f_ro[2]]),
9459 hex->face(2)->child_index(
9461 child_at_origin[hex->face(2)->refinement_case() -
9462 1][f_fl[2]][f_ro[2]]),
9464 hex->face(3)->child_index(
9465 child_at_origin[hex->face(3)->refinement_case() -
9466 1][f_fl[3]][f_ro[3]]),
9467 hex->face(3)->child_index(
9469 child_at_origin[hex->face(3)->refinement_case() -
9470 1][f_fl[3]][f_ro[3]]),
9472 hex->face(4)->index(),
9474 hex->face(5)->index()
9477 new_hexes[0]->set_bounding_object_indices(
9484 new_hexes[1]->set_bounding_object_indices(
9516 new_lines[0]->set_bounding_object_indices(
9517 {middle_vertex_index<dim, spacedim>(hex->face(4)),
9518 middle_vertex_index<dim, spacedim>(hex->face(5))});
9586 spacedim>::raw_line_iterator lines[13] = {
9587 hex->face(0)->child(0)->line(
9588 (hex->face(0)->refinement_case() ==
9592 hex->face(1)->child(0)->line(
9593 (hex->face(1)->refinement_case() ==
9597 hex->face(2)->child(0)->line(
9598 (hex->face(2)->refinement_case() ==
9602 hex->face(3)->child(0)->line(
9603 (hex->face(3)->refinement_case() ==
9611 0, f_or[4], f_fl[4], f_ro[4]))
9614 1, f_or[4], f_fl[4], f_ro[4])),
9618 3, f_or[4], f_fl[4], f_ro[4]))
9621 0, f_or[4], f_fl[4], f_ro[4])),
9625 0, f_or[4], f_fl[4], f_ro[4]))
9628 3, f_or[4], f_fl[4], f_ro[4])),
9632 3, f_or[4], f_fl[4], f_ro[4]))
9635 2, f_or[4], f_fl[4], f_ro[4])),
9640 0, f_or[5], f_fl[5], f_ro[5]))
9643 1, f_or[5], f_fl[5], f_ro[5])),
9647 3, f_or[5], f_fl[5], f_ro[5]))
9650 0, f_or[5], f_fl[5], f_ro[5])),
9654 0, f_or[5], f_fl[5], f_ro[5]))
9657 3, f_or[5], f_fl[5], f_ro[5])),
9661 3, f_or[5], f_fl[5], f_ro[5]))
9664 2, f_or[5], f_fl[5], f_ro[5])),
9669 unsigned int line_indices[13];
9670 for (
unsigned int i = 0; i < 13; ++i)
9671 line_indices[i] = lines[i]->
index();
9678 bool line_orientation[13];
9682 const unsigned int middle_vertices[4] = {
9683 hex->line(0)->child(0)->vertex_index(1),
9684 hex->line(1)->child(0)->vertex_index(1),
9685 hex->line(2)->child(0)->vertex_index(1),
9686 hex->line(3)->child(0)->vertex_index(1),
9692 for (
unsigned int i = 0; i < 4; ++i)
9693 if (lines[i]->vertex_index(0) == middle_vertices[i])
9694 line_orientation[i] =
true;
9698 Assert(lines[i]->vertex_index(1) ==
9701 line_orientation[i] =
false;
9710 for (
unsigned int i = 4; i < 12; ++i)
9711 if (lines[i]->vertex_index((i + 1) % 2) ==
9712 middle_vertex_index<dim, spacedim>(
9713 hex->face(3 + i / 4)))
9714 line_orientation[i] =
true;
9719 Assert(lines[i]->vertex_index(i % 2) ==
9720 (middle_vertex_index<dim, spacedim>(
9721 hex->face(3 + i / 4))),
9723 line_orientation[i] =
false;
9728 line_orientation[12] =
true;
9753 new_quads[0]->set_bounding_object_indices(
9758 new_quads[1]->set_bounding_object_indices(
9763 new_quads[2]->set_bounding_object_indices(
9768 new_quads[3]->set_bounding_object_indices(
9774 new_quads[0]->set_line_orientation(
9775 0, line_orientation[2]);
9776 new_quads[0]->set_line_orientation(
9777 2, line_orientation[4]);
9778 new_quads[0]->set_line_orientation(
9779 3, line_orientation[8]);
9781 new_quads[1]->set_line_orientation(
9782 1, line_orientation[3]);
9783 new_quads[1]->set_line_orientation(
9784 2, line_orientation[5]);
9785 new_quads[1]->set_line_orientation(
9786 3, line_orientation[9]);
9788 new_quads[2]->set_line_orientation(
9789 0, line_orientation[6]);
9790 new_quads[2]->set_line_orientation(
9791 1, line_orientation[10]);
9792 new_quads[2]->set_line_orientation(
9793 2, line_orientation[0]);
9795 new_quads[3]->set_line_orientation(
9796 0, line_orientation[7]);
9797 new_quads[3]->set_line_orientation(
9798 1, line_orientation[11]);
9799 new_quads[3]->set_line_orientation(
9800 3, line_orientation[1]);
9833 const int quad_indices[20] = {
9834 new_quads[0]->index(),
9835 new_quads[1]->index(),
9836 new_quads[2]->index(),
9837 new_quads[3]->index(),
9839 hex->face(0)->child_index(
9840 child_at_origin[hex->face(0)->refinement_case() -
9841 1][f_fl[0]][f_ro[0]]),
9842 hex->face(0)->child_index(
9844 child_at_origin[hex->face(0)->refinement_case() -
9845 1][f_fl[0]][f_ro[0]]),
9847 hex->face(1)->child_index(
9848 child_at_origin[hex->face(1)->refinement_case() -
9849 1][f_fl[1]][f_ro[1]]),
9850 hex->face(1)->child_index(
9852 child_at_origin[hex->face(1)->refinement_case() -
9853 1][f_fl[1]][f_ro[1]]),
9855 hex->face(2)->child_index(
9856 child_at_origin[hex->face(2)->refinement_case() -
9857 1][f_fl[2]][f_ro[2]]),
9858 hex->face(2)->child_index(
9860 child_at_origin[hex->face(2)->refinement_case() -
9861 1][f_fl[2]][f_ro[2]]),
9863 hex->face(3)->child_index(
9864 child_at_origin[hex->face(3)->refinement_case() -
9865 1][f_fl[3]][f_ro[3]]),
9866 hex->face(3)->child_index(
9868 child_at_origin[hex->face(3)->refinement_case() -
9869 1][f_fl[3]][f_ro[3]]),
9871 hex->face(4)->isotropic_child_index(
9873 0, f_or[4], f_fl[4], f_ro[4])),
9874 hex->face(4)->isotropic_child_index(
9876 1, f_or[4], f_fl[4], f_ro[4])),
9877 hex->face(4)->isotropic_child_index(
9879 2, f_or[4], f_fl[4], f_ro[4])),
9880 hex->face(4)->isotropic_child_index(
9882 3, f_or[4], f_fl[4], f_ro[4])),
9884 hex->face(5)->isotropic_child_index(
9886 0, f_or[5], f_fl[5], f_ro[5])),
9887 hex->face(5)->isotropic_child_index(
9889 1, f_or[5], f_fl[5], f_ro[5])),
9890 hex->face(5)->isotropic_child_index(
9892 2, f_or[5], f_fl[5], f_ro[5])),
9893 hex->face(5)->isotropic_child_index(
9895 3, f_or[5], f_fl[5], f_ro[5]))};
9897 new_hexes[0]->set_bounding_object_indices(
9904 new_hexes[1]->set_bounding_object_indices(
9911 new_hexes[2]->set_bounding_object_indices(
9918 new_hexes[3]->set_bounding_object_indices(
9950 new_lines[0]->set_bounding_object_indices(
9951 {middle_vertex_index<dim, spacedim>(hex->face(2)),
9952 middle_vertex_index<dim, spacedim>(hex->face(3))});
10020 spacedim>::raw_line_iterator lines[13] = {
10021 hex->face(0)->child(0)->line(
10022 (hex->face(0)->refinement_case() ==
10026 hex->face(1)->child(0)->line(
10027 (hex->face(1)->refinement_case() ==
10031 hex->face(4)->child(0)->line(
10032 (hex->face(4)->refinement_case() ==
10036 hex->face(5)->child(0)->line(
10037 (hex->face(5)->refinement_case() ==
10045 0, f_or[2], f_fl[2], f_ro[2]))
10048 3, f_or[2], f_fl[2], f_ro[2])),
10052 3, f_or[2], f_fl[2], f_ro[2]))
10055 2, f_or[2], f_fl[2], f_ro[2])),
10059 0, f_or[2], f_fl[2], f_ro[2]))
10062 1, f_or[2], f_fl[2], f_ro[2])),
10066 3, f_or[2], f_fl[2], f_ro[2]))
10069 0, f_or[2], f_fl[2], f_ro[2])),
10074 0, f_or[3], f_fl[3], f_ro[3]))
10077 3, f_or[3], f_fl[3], f_ro[3])),
10081 3, f_or[3], f_fl[3], f_ro[3]))
10084 2, f_or[3], f_fl[3], f_ro[3])),
10088 0, f_or[3], f_fl[3], f_ro[3]))
10091 1, f_or[3], f_fl[3], f_ro[3])),
10095 3, f_or[3], f_fl[3], f_ro[3]))
10098 0, f_or[3], f_fl[3], f_ro[3])),
10103 unsigned int line_indices[13];
10104 for (
unsigned int i = 0; i < 13; ++i)
10105 line_indices[i] = lines[i]->
index();
10112 bool line_orientation[13];
10116 const unsigned int middle_vertices[4] = {
10117 hex->line(8)->child(0)->vertex_index(1),
10118 hex->line(9)->child(0)->vertex_index(1),
10119 hex->line(2)->child(0)->vertex_index(1),
10120 hex->line(6)->child(0)->vertex_index(1),
10125 for (
unsigned int i = 0; i < 4; ++i)
10126 if (lines[i]->vertex_index(0) == middle_vertices[i])
10127 line_orientation[i] =
true;
10131 Assert(lines[i]->vertex_index(1) ==
10132 middle_vertices[i],
10134 line_orientation[i] =
false;
10143 for (
unsigned int i = 4; i < 12; ++i)
10144 if (lines[i]->vertex_index((i + 1) % 2) ==
10145 middle_vertex_index<dim, spacedim>(
10146 hex->face(1 + i / 4)))
10147 line_orientation[i] =
true;
10152 Assert(lines[i]->vertex_index(i % 2) ==
10153 (middle_vertex_index<dim, spacedim>(
10154 hex->face(1 + i / 4))),
10156 line_orientation[i] =
false;
10161 line_orientation[12] =
true;
10187 new_quads[0]->set_bounding_object_indices(
10191 line_indices[10]});
10192 new_quads[1]->set_bounding_object_indices(
10196 line_indices[11]});
10197 new_quads[2]->set_bounding_object_indices(
10201 line_indices[12]});
10202 new_quads[3]->set_bounding_object_indices(
10208 new_quads[0]->set_line_orientation(
10209 0, line_orientation[0]);
10210 new_quads[0]->set_line_orientation(
10211 2, line_orientation[6]);
10212 new_quads[0]->set_line_orientation(
10213 3, line_orientation[10]);
10215 new_quads[1]->set_line_orientation(
10216 1, line_orientation[1]);
10217 new_quads[1]->set_line_orientation(
10218 2, line_orientation[7]);
10219 new_quads[1]->set_line_orientation(
10220 3, line_orientation[11]);
10222 new_quads[2]->set_line_orientation(
10223 0, line_orientation[4]);
10224 new_quads[2]->set_line_orientation(
10225 1, line_orientation[8]);
10226 new_quads[2]->set_line_orientation(
10227 2, line_orientation[2]);
10229 new_quads[3]->set_line_orientation(
10230 0, line_orientation[5]);
10231 new_quads[3]->set_line_orientation(
10232 1, line_orientation[9]);
10233 new_quads[3]->set_line_orientation(
10234 3, line_orientation[3]);
10268 const int quad_indices[20] = {
10269 new_quads[0]->index(),
10270 new_quads[1]->index(),
10271 new_quads[2]->index(),
10272 new_quads[3]->index(),
10274 hex->face(0)->child_index(
10275 child_at_origin[hex->face(0)->refinement_case() -
10276 1][f_fl[0]][f_ro[0]]),
10277 hex->face(0)->child_index(
10279 child_at_origin[hex->face(0)->refinement_case() -
10280 1][f_fl[0]][f_ro[0]]),
10282 hex->face(1)->child_index(
10283 child_at_origin[hex->face(1)->refinement_case() -
10284 1][f_fl[1]][f_ro[1]]),
10285 hex->face(1)->child_index(
10287 child_at_origin[hex->face(1)->refinement_case() -
10288 1][f_fl[1]][f_ro[1]]),
10290 hex->face(2)->isotropic_child_index(
10292 0, f_or[2], f_fl[2], f_ro[2])),
10293 hex->face(2)->isotropic_child_index(
10295 1, f_or[2], f_fl[2], f_ro[2])),
10296 hex->face(2)->isotropic_child_index(
10298 2, f_or[2], f_fl[2], f_ro[2])),
10299 hex->face(2)->isotropic_child_index(
10301 3, f_or[2], f_fl[2], f_ro[2])),
10303 hex->face(3)->isotropic_child_index(
10305 0, f_or[3], f_fl[3], f_ro[3])),
10306 hex->face(3)->isotropic_child_index(
10308 1, f_or[3], f_fl[3], f_ro[3])),
10309 hex->face(3)->isotropic_child_index(
10311 2, f_or[3], f_fl[3], f_ro[3])),
10312 hex->face(3)->isotropic_child_index(
10314 3, f_or[3], f_fl[3], f_ro[3])),
10316 hex->face(4)->child_index(
10317 child_at_origin[hex->face(4)->refinement_case() -
10318 1][f_fl[4]][f_ro[4]]),
10319 hex->face(4)->child_index(
10321 child_at_origin[hex->face(4)->refinement_case() -
10322 1][f_fl[4]][f_ro[4]]),
10324 hex->face(5)->child_index(
10325 child_at_origin[hex->face(5)->refinement_case() -
10326 1][f_fl[5]][f_ro[5]]),
10327 hex->face(5)->child_index(
10329 child_at_origin[hex->face(5)->refinement_case() -
10330 1][f_fl[5]][f_ro[5]])};
10341 new_hexes[0]->set_bounding_object_indices(
10348 new_hexes[1]->set_bounding_object_indices(
10354 quad_indices[18]});
10355 new_hexes[2]->set_bounding_object_indices(
10362 new_hexes[3]->set_bounding_object_indices(
10368 quad_indices[19]});
10395 new_lines[0]->set_bounding_object_indices(
10397 {middle_vertex_index<dim, spacedim>(hex->face(0)),
10398 middle_vertex_index<dim, spacedim>(hex->face(1))});
10467 spacedim>::raw_line_iterator lines[13] = {
10468 hex->face(2)->child(0)->line(
10469 (hex->face(2)->refinement_case() ==
10473 hex->face(3)->child(0)->line(
10474 (hex->face(3)->refinement_case() ==
10478 hex->face(4)->child(0)->line(
10479 (hex->face(4)->refinement_case() ==
10483 hex->face(5)->child(0)->line(
10484 (hex->face(5)->refinement_case() ==
10492 0, f_or[0], f_fl[0], f_ro[0]))
10495 1, f_or[0], f_fl[0], f_ro[0])),
10499 3, f_or[0], f_fl[0], f_ro[0]))
10502 0, f_or[0], f_fl[0], f_ro[0])),
10506 0, f_or[0], f_fl[0], f_ro[0]))
10509 3, f_or[0], f_fl[0], f_ro[0])),
10513 3, f_or[0], f_fl[0], f_ro[0]))
10516 2, f_or[0], f_fl[0], f_ro[0])),
10521 0, f_or[1], f_fl[1], f_ro[1]))
10524 1, f_or[1], f_fl[1], f_ro[1])),
10528 3, f_or[1], f_fl[1], f_ro[1]))
10531 0, f_or[1], f_fl[1], f_ro[1])),
10535 0, f_or[1], f_fl[1], f_ro[1]))
10538 3, f_or[1], f_fl[1], f_ro[1])),
10542 3, f_or[1], f_fl[1], f_ro[1]))
10545 2, f_or[1], f_fl[1], f_ro[1])),
10550 unsigned int line_indices[13];
10552 for (
unsigned int i = 0; i < 13; ++i)
10553 line_indices[i] = lines[i]->
index();
10560 bool line_orientation[13];
10564 const unsigned int middle_vertices[4] = {
10565 hex->line(8)->child(0)->vertex_index(1),
10566 hex->line(10)->child(0)->vertex_index(1),
10567 hex->line(0)->child(0)->vertex_index(1),
10568 hex->line(4)->child(0)->vertex_index(1),
10573 for (
unsigned int i = 0; i < 4; ++i)
10574 if (lines[i]->vertex_index(0) == middle_vertices[i])
10575 line_orientation[i] =
true;
10579 Assert(lines[i]->vertex_index(1) ==
10580 middle_vertices[i],
10582 line_orientation[i] =
false;
10591 for (
unsigned int i = 4; i < 12; ++i)
10592 if (lines[i]->vertex_index((i + 1) % 2) ==
10593 middle_vertex_index<dim, spacedim>(
10594 hex->face(i / 4 - 1)))
10595 line_orientation[i] =
true;
10600 Assert(lines[i]->vertex_index(i % 2) ==
10601 (middle_vertex_index<dim, spacedim>(
10602 hex->face(i / 4 - 1))),
10604 line_orientation[i] =
false;
10609 line_orientation[12] =
true;
10629 new_quads[0]->set_bounding_object_indices(
10633 line_indices[12]});
10634 new_quads[1]->set_bounding_object_indices(
10639 new_quads[2]->set_bounding_object_indices(
10644 new_quads[3]->set_bounding_object_indices(
10650 new_quads[0]->set_line_orientation(
10651 0, line_orientation[6]);
10652 new_quads[0]->set_line_orientation(
10653 1, line_orientation[10]);
10654 new_quads[0]->set_line_orientation(
10655 2, line_orientation[0]);
10657 new_quads[1]->set_line_orientation(
10658 0, line_orientation[7]);
10659 new_quads[1]->set_line_orientation(
10660 1, line_orientation[11]);
10661 new_quads[1]->set_line_orientation(
10662 3, line_orientation[1]);
10664 new_quads[2]->set_line_orientation(
10665 0, line_orientation[2]);
10666 new_quads[2]->set_line_orientation(
10667 2, line_orientation[4]);
10668 new_quads[2]->set_line_orientation(
10669 3, line_orientation[8]);
10671 new_quads[3]->set_line_orientation(
10672 1, line_orientation[3]);
10673 new_quads[3]->set_line_orientation(
10674 2, line_orientation[5]);
10675 new_quads[3]->set_line_orientation(
10676 3, line_orientation[9]);
10710 const int quad_indices[20] = {
10711 new_quads[0]->index(),
10712 new_quads[1]->index(),
10713 new_quads[2]->index(),
10714 new_quads[3]->index(),
10716 hex->face(0)->isotropic_child_index(
10718 0, f_or[0], f_fl[0], f_ro[0])),
10719 hex->face(0)->isotropic_child_index(
10721 1, f_or[0], f_fl[0], f_ro[0])),
10722 hex->face(0)->isotropic_child_index(
10724 2, f_or[0], f_fl[0], f_ro[0])),
10725 hex->face(0)->isotropic_child_index(
10727 3, f_or[0], f_fl[0], f_ro[0])),
10729 hex->face(1)->isotropic_child_index(
10731 0, f_or[1], f_fl[1], f_ro[1])),
10732 hex->face(1)->isotropic_child_index(
10734 1, f_or[1], f_fl[1], f_ro[1])),
10735 hex->face(1)->isotropic_child_index(
10737 2, f_or[1], f_fl[1], f_ro[1])),
10738 hex->face(1)->isotropic_child_index(
10740 3, f_or[1], f_fl[1], f_ro[1])),
10742 hex->face(2)->child_index(
10743 child_at_origin[hex->face(2)->refinement_case() -
10744 1][f_fl[2]][f_ro[2]]),
10745 hex->face(2)->child_index(
10747 child_at_origin[hex->face(2)->refinement_case() -
10748 1][f_fl[2]][f_ro[2]]),
10750 hex->face(3)->child_index(
10751 child_at_origin[hex->face(3)->refinement_case() -
10752 1][f_fl[3]][f_ro[3]]),
10753 hex->face(3)->child_index(
10755 child_at_origin[hex->face(3)->refinement_case() -
10756 1][f_fl[3]][f_ro[3]]),
10758 hex->face(4)->child_index(
10759 child_at_origin[hex->face(4)->refinement_case() -
10760 1][f_fl[4]][f_ro[4]]),
10761 hex->face(4)->child_index(
10763 child_at_origin[hex->face(4)->refinement_case() -
10764 1][f_fl[4]][f_ro[4]]),
10766 hex->face(5)->child_index(
10767 child_at_origin[hex->face(5)->refinement_case() -
10768 1][f_fl[5]][f_ro[5]]),
10769 hex->face(5)->child_index(
10771 child_at_origin[hex->face(5)->refinement_case() -
10772 1][f_fl[5]][f_ro[5]])};
10774 new_hexes[0]->set_bounding_object_indices(
10781 new_hexes[1]->set_bounding_object_indices(
10788 new_hexes[2]->set_bounding_object_indices(
10794 quad_indices[18]});
10795 new_hexes[3]->set_bounding_object_indices(
10801 quad_indices[19]});
10833 ++next_unused_vertex;
10837 "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."));
10848 hex->center(
true,
true);
10870 middle_vertex_index<dim, spacedim>(hex->face(0)),
10871 middle_vertex_index<dim, spacedim>(hex->face(1)),
10872 middle_vertex_index<dim, spacedim>(hex->face(2)),
10873 middle_vertex_index<dim, spacedim>(hex->face(3)),
10874 middle_vertex_index<dim, spacedim>(hex->face(4)),
10875 middle_vertex_index<dim, spacedim>(hex->face(5)),
10876 next_unused_vertex};
10878 new_lines[0]->set_bounding_object_indices(
10880 new_lines[1]->set_bounding_object_indices(
10882 new_lines[2]->set_bounding_object_indices(
10884 new_lines[3]->set_bounding_object_indices(
10886 new_lines[4]->set_bounding_object_indices(
10888 new_lines[5]->set_bounding_object_indices(
10958 spacedim>::raw_line_iterator lines[30] = {
10962 0, f_or[0], f_fl[0], f_ro[0]))
10965 1, f_or[0], f_fl[0], f_ro[0])),
10969 3, f_or[0], f_fl[0], f_ro[0]))
10972 0, f_or[0], f_fl[0], f_ro[0])),
10976 0, f_or[0], f_fl[0], f_ro[0]))
10979 3, f_or[0], f_fl[0], f_ro[0])),
10983 3, f_or[0], f_fl[0], f_ro[0]))
10986 2, f_or[0], f_fl[0], f_ro[0])),
10991 0, f_or[1], f_fl[1], f_ro[1]))
10994 1, f_or[1], f_fl[1], f_ro[1])),
10998 3, f_or[1], f_fl[1], f_ro[1]))
11001 0, f_or[1], f_fl[1], f_ro[1])),
11005 0, f_or[1], f_fl[1], f_ro[1]))
11008 3, f_or[1], f_fl[1], f_ro[1])),
11012 3, f_or[1], f_fl[1], f_ro[1]))
11015 2, f_or[1], f_fl[1], f_ro[1])),
11020 0, f_or[2], f_fl[2], f_ro[2]))
11023 1, f_or[2], f_fl[2], f_ro[2])),
11027 3, f_or[2], f_fl[2], f_ro[2]))
11030 0, f_or[2], f_fl[2], f_ro[2])),
11034 0, f_or[2], f_fl[2], f_ro[2]))
11037 3, f_or[2], f_fl[2], f_ro[2])),
11041 3, f_or[2], f_fl[2], f_ro[2]))
11044 2, f_or[2], f_fl[2], f_ro[2])),
11049 0, f_or[3], f_fl[3], f_ro[3]))
11052 1, f_or[3], f_fl[3], f_ro[3])),
11056 3, f_or[3], f_fl[3], f_ro[3]))
11059 0, f_or[3], f_fl[3], f_ro[3])),
11063 0, f_or[3], f_fl[3], f_ro[3]))
11066 3, f_or[3], f_fl[3], f_ro[3])),
11070 3, f_or[3], f_fl[3], f_ro[3]))
11073 2, f_or[3], f_fl[3], f_ro[3])),
11078 0, f_or[4], f_fl[4], f_ro[4]))
11081 1, f_or[4], f_fl[4], f_ro[4])),
11085 3, f_or[4], f_fl[4], f_ro[4]))
11088 0, f_or[4], f_fl[4], f_ro[4])),
11092 0, f_or[4], f_fl[4], f_ro[4]))
11095 3, f_or[4], f_fl[4], f_ro[4])),
11099 3, f_or[4], f_fl[4], f_ro[4]))
11102 2, f_or[4], f_fl[4], f_ro[4])),
11107 0, f_or[5], f_fl[5], f_ro[5]))
11110 1, f_or[5], f_fl[5], f_ro[5])),
11114 3, f_or[5], f_fl[5], f_ro[5]))
11117 0, f_or[5], f_fl[5], f_ro[5])),
11121 0, f_or[5], f_fl[5], f_ro[5]))
11124 3, f_or[5], f_fl[5], f_ro[5])),
11128 3, f_or[5], f_fl[5], f_ro[5]))
11131 2, f_or[5], f_fl[5], f_ro[5])),
11141 unsigned int line_indices[30];
11142 for (
unsigned int i = 0; i < 30; ++i)
11143 line_indices[i] = lines[i]->
index();
11150 bool line_orientation[30];
11158 for (
unsigned int i = 0; i < 24; ++i)
11159 if (lines[i]->vertex_index((i + 1) % 2) ==
11161 line_orientation[i] =
true;
11166 Assert(lines[i]->vertex_index(i % 2) ==
11169 line_orientation[i] =
false;
11174 for (
unsigned int i = 24; i < 30; ++i)
11175 line_orientation[i] =
true;
11207 new_quads[0]->set_bounding_object_indices(
11211 line_indices[24]});
11212 new_quads[1]->set_bounding_object_indices(
11216 line_indices[25]});
11217 new_quads[2]->set_bounding_object_indices(
11221 line_indices[20]});
11222 new_quads[3]->set_bounding_object_indices(
11226 line_indices[21]});
11227 new_quads[4]->set_bounding_object_indices(
11231 line_indices[28]});
11232 new_quads[5]->set_bounding_object_indices(
11236 line_indices[29]});
11237 new_quads[6]->set_bounding_object_indices(
11242 new_quads[7]->set_bounding_object_indices(
11247 new_quads[8]->set_bounding_object_indices(
11251 line_indices[26]});
11252 new_quads[9]->set_bounding_object_indices(
11256 line_indices[27]});
11257 new_quads[10]->set_bounding_object_indices(
11261 line_indices[12]});
11262 new_quads[11]->set_bounding_object_indices(
11266 line_indices[13]});
11271 new_quads[0]->set_line_orientation(
11272 0, line_orientation[10]);
11273 new_quads[0]->set_line_orientation(
11274 2, line_orientation[16]);
11276 new_quads[1]->set_line_orientation(
11277 1, line_orientation[14]);
11278 new_quads[1]->set_line_orientation(
11279 2, line_orientation[17]);
11281 new_quads[2]->set_line_orientation(
11282 0, line_orientation[11]);
11283 new_quads[2]->set_line_orientation(
11284 3, line_orientation[20]);
11286 new_quads[3]->set_line_orientation(
11287 1, line_orientation[15]);
11288 new_quads[3]->set_line_orientation(
11289 3, line_orientation[21]);
11291 new_quads[4]->set_line_orientation(
11292 0, line_orientation[18]);
11293 new_quads[4]->set_line_orientation(
11294 2, line_orientation[0]);
11296 new_quads[5]->set_line_orientation(
11297 1, line_orientation[22]);
11298 new_quads[5]->set_line_orientation(
11299 2, line_orientation[1]);
11301 new_quads[6]->set_line_orientation(
11302 0, line_orientation[19]);
11303 new_quads[6]->set_line_orientation(
11304 3, line_orientation[4]);
11306 new_quads[7]->set_line_orientation(
11307 1, line_orientation[23]);
11308 new_quads[7]->set_line_orientation(
11309 3, line_orientation[5]);
11311 new_quads[8]->set_line_orientation(
11312 0, line_orientation[2]);
11313 new_quads[8]->set_line_orientation(
11314 2, line_orientation[8]);
11316 new_quads[9]->set_line_orientation(
11317 1, line_orientation[6]);
11318 new_quads[9]->set_line_orientation(
11319 2, line_orientation[9]);
11321 new_quads[10]->set_line_orientation(
11322 0, line_orientation[3]);
11323 new_quads[10]->set_line_orientation(
11324 3, line_orientation[12]);
11326 new_quads[11]->set_line_orientation(
11327 1, line_orientation[7]);
11328 new_quads[11]->set_line_orientation(
11329 3, line_orientation[13]);
11370 const int quad_indices[36] = {
11371 new_quads[0]->index(),
11372 new_quads[1]->index(),
11373 new_quads[2]->index(),
11374 new_quads[3]->index(),
11375 new_quads[4]->index(),
11376 new_quads[5]->index(),
11377 new_quads[6]->index(),
11378 new_quads[7]->index(),
11379 new_quads[8]->index(),
11380 new_quads[9]->index(),
11381 new_quads[10]->index(),
11382 new_quads[11]->index(),
11384 hex->face(0)->isotropic_child_index(
11386 0, f_or[0], f_fl[0], f_ro[0])),
11387 hex->face(0)->isotropic_child_index(
11389 1, f_or[0], f_fl[0], f_ro[0])),
11390 hex->face(0)->isotropic_child_index(
11392 2, f_or[0], f_fl[0], f_ro[0])),
11393 hex->face(0)->isotropic_child_index(
11395 3, f_or[0], f_fl[0], f_ro[0])),
11397 hex->face(1)->isotropic_child_index(
11399 0, f_or[1], f_fl[1], f_ro[1])),
11400 hex->face(1)->isotropic_child_index(
11402 1, f_or[1], f_fl[1], f_ro[1])),
11403 hex->face(1)->isotropic_child_index(
11405 2, f_or[1], f_fl[1], f_ro[1])),
11406 hex->face(1)->isotropic_child_index(
11408 3, f_or[1], f_fl[1], f_ro[1])),
11410 hex->face(2)->isotropic_child_index(
11412 0, f_or[2], f_fl[2], f_ro[2])),
11413 hex->face(2)->isotropic_child_index(
11415 1, f_or[2], f_fl[2], f_ro[2])),
11416 hex->face(2)->isotropic_child_index(
11418 2, f_or[2], f_fl[2], f_ro[2])),
11419 hex->face(2)->isotropic_child_index(
11421 3, f_or[2], f_fl[2], f_ro[2])),
11423 hex->face(3)->isotropic_child_index(
11425 0, f_or[3], f_fl[3], f_ro[3])),
11426 hex->face(3)->isotropic_child_index(
11428 1, f_or[3], f_fl[3], f_ro[3])),
11429 hex->face(3)->isotropic_child_index(
11431 2, f_or[3], f_fl[3], f_ro[3])),
11432 hex->face(3)->isotropic_child_index(
11434 3, f_or[3], f_fl[3], f_ro[3])),
11436 hex->face(4)->isotropic_child_index(
11438 0, f_or[4], f_fl[4], f_ro[4])),
11439 hex->face(4)->isotropic_child_index(
11441 1, f_or[4], f_fl[4], f_ro[4])),
11442 hex->face(4)->isotropic_child_index(
11444 2, f_or[4], f_fl[4], f_ro[4])),
11445 hex->face(4)->isotropic_child_index(
11447 3, f_or[4], f_fl[4], f_ro[4])),
11449 hex->face(5)->isotropic_child_index(
11451 0, f_or[5], f_fl[5], f_ro[5])),
11452 hex->face(5)->isotropic_child_index(
11454 1, f_or[5], f_fl[5], f_ro[5])),
11455 hex->face(5)->isotropic_child_index(
11457 2, f_or[5], f_fl[5], f_ro[5])),
11458 hex->face(5)->isotropic_child_index(
11460 3, f_or[5], f_fl[5], f_ro[5]))};
11463 new_hexes[0]->set_bounding_object_indices(
11470 new_hexes[1]->set_bounding_object_indices(
11477 new_hexes[2]->set_bounding_object_indices(
11483 quad_indices[10]});
11484 new_hexes[3]->set_bounding_object_indices(
11490 quad_indices[11]});
11493 new_hexes[4]->set_bounding_object_indices(
11499 quad_indices[32]});
11500 new_hexes[5]->set_bounding_object_indices(
11506 quad_indices[33]});
11507 new_hexes[6]->set_bounding_object_indices(
11513 quad_indices[34]});
11514 new_hexes[7]->set_bounding_object_indices(
11520 quad_indices[35]});
11554 for (
unsigned int s = 0;
11561 const unsigned int current_child =
11570 ref_case, f, f_or[f], f_fl[f], f_ro[f]));
11571 new_hexes[current_child]->set_combined_face_orientation(
11577 if (check_for_distorted_cells &&
11578 has_distorted_children<dim, spacedim>(hex))
11598 return cells_with_distorted_children;