400 return !cell.is_artificial();
404 const unsigned int n_raw_lines =
triangulation.n_raw_lines();
405 this->line_to_cells.resize(n_raw_lines);
413 const unsigned int line_to_children[12][2] = {{0, 2},
427 boost::container::small_vector<std::array<unsigned int, 3>, 6>>
428 line_to_inactive_cells(n_raw_lines);
433 const unsigned int cell_level = cell->
level();
435 for (
unsigned int line = 0; line < GeometryInfo<3>::lines_per_cell;
438 const unsigned int line_idx = cell->
line_index(line);
440 line_to_cells[line_idx].push_back(
443 line_to_inactive_cells[line_idx].push_back(
451 for (
unsigned int line_idx = 0; line_idx < n_raw_lines; ++line_idx)
453 if ((line_to_cells[line_idx].
size() > 0) &&
454 line_to_inactive_cells[line_idx].size() > 0)
460 line_to_inactive_cells[line_idx][0][0],
461 line_to_inactive_cells[line_idx][0][1]);
462 const unsigned int neighbor_line =
463 line_to_inactive_cells[line_idx][0][2];
465 for (
unsigned int c = 0; c < 2; ++c)
468 inactive_cell->child(line_to_children[neighbor_line][c]);
469 const unsigned int child_line_idx =
470 child->line_index(neighbor_line);
475 for (
const auto &cl : line_to_cells[line_idx])
476 line_to_cells[child_line_idx].push_back(cl);
522 const CellIterator &cell)
const
525 if ((dim == 3 && line_to_cells.empty()) ||
526 (cell->reference_cell().is_hyper_cube() ==
false))
529 if (cell->level() == 0)
532 const std::uint16_t subcell =
533 cell->parent()->child_iterator_to_index(cell);
534 const std::uint16_t
subcell_x = (subcell >> 0) & 1;
535 const std::uint16_t
subcell_y = (subcell >> 1) & 1;
536 const std::uint16_t
subcell_z = (subcell >> 2) & 1;
538 std::uint16_t face = 0;
539 std::uint16_t edge = 0;
541 for (
unsigned int direction = 0; direction < dim; ++direction)
543 const auto side = (subcell >> direction) & 1U;
544 const auto face_no = direction * 2 + side;
547 if (cell->at_boundary(face_no))
550 const auto &neighbor = cell->neighbor(face_no);
554 if (neighbor->has_children() || neighbor->is_artificial() ||
555 neighbor->level() == cell->level())
559 if (neighbor->get_fe().n_dofs_per_cell() == 0)
562 face |= 1 << direction;
566 for (
unsigned int direction = 0; direction < dim; ++direction)
567 if (face == 0 || face == (1 << direction))
569 const unsigned int line_no =
576 const unsigned int line_index = cell->line_index(line_no);
578 const auto edge_neighbor =
579 std::find_if(line_to_cells[line_index].begin(),
580 line_to_cells[line_index].end(),
581 [&cell](
const auto &edge_neighbor) {
583 &cell->get_triangulation(),
586 &cell->get_dof_handler());
587 return dof_cell.is_artificial() ==
false &&
588 dof_cell.level() < cell->level() &&
589 dof_cell.
get_fe().n_dofs_per_cell() > 0;
592 if (edge_neighbor == line_to_cells[line_index].end())
595 edge |= 1 << direction;
598 if ((face == 0) && (edge == 0))
601 const std::uint16_t inverted_subcell = (subcell ^ (dim == 2 ? 3 : 7));
604 inverted_subcell + (face << 3) + (edge << 6));
606 return refinement_configuration;
615 const CellIterator &cell,
616 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
617 const std::vector<std::vector<unsigned int>> &lexicographic_mapping,
618 const std::vector<std::vector<bool>> &supported_components,
620 std::vector<types::global_dof_index> &dof_indices)
const
622 if (std::find(supported_components[cell->active_fe_index()].begin(),
623 supported_components[cell->active_fe_index()].end(),
625 supported_components[cell->active_fe_index()].end())
628 const auto &fe = cell->get_fe();
631 std::vector<std::vector<unsigned int>>
632 component_to_system_index_face_array(fe.n_components());
634 for (
unsigned int i = 0; i < fe.n_dofs_per_face(0); ++i)
635 component_to_system_index_face_array
636 [fe.face_system_to_component_index(i, 0).first]
639 std::vector<unsigned int> idx_offset = {0};
641 for (
unsigned int base_element_index = 0;
642 base_element_index < fe.n_base_elements();
643 ++base_element_index)
644 for (
unsigned int c = 0;
645 c < fe.element_multiplicity(base_element_index);
647 idx_offset.push_back(
649 fe.base_element(base_element_index).n_dofs_per_cell());
651 std::vector<types::global_dof_index> neighbor_dofs_all(idx_offset.back());
652 std::vector<types::global_dof_index> neighbor_dofs_all_temp(
654 std::vector<types::global_dof_index> neighbor_dofs_face(
655 fe.n_dofs_per_face(0));
658 const auto get_face_idx = [](
const auto n_dofs_1d,
661 const auto j) ->
unsigned int {
662 const auto direction = face_no / 2;
663 const auto side = face_no % 2;
664 const auto offset = (side == 1) ? (n_dofs_1d - 1) : 0;
667 return (direction == 0) ? (n_dofs_1d * i + offset) :
668 (n_dofs_1d * offset + i);
673 return n_dofs_1d * n_dofs_1d * i + n_dofs_1d * j + offset;
675 return n_dofs_1d * n_dofs_1d * j + n_dofs_1d * offset + i;
677 return n_dofs_1d * n_dofs_1d * offset + n_dofs_1d * i + j;
687 const std::uint16_t kind =
688 static_cast<std::uint16_t
>(refinement_configuration);
689 const std::uint16_t subcell = (kind >> 0) & 7;
690 const std::uint16_t
subcell_x = (subcell >> 0) & 1;
691 const std::uint16_t
subcell_y = (subcell >> 1) & 1;
692 const std::uint16_t
subcell_z = (subcell >> 2) & 1;
693 const std::uint16_t face = (kind >> 3) & 7;
694 const std::uint16_t edge = (kind >> 6) & 7;
696 for (
unsigned int direction = 0; direction < dim; ++direction)
697 if ((face >> direction) & 1U)
699 const auto side = ((subcell >> direction) & 1U) == 0;
700 const auto face_no = direction * 2 + side;
703 cell->neighbor(face_no)
704 ->face(cell->neighbor_face_no(face_no))
705 ->get_dof_indices(neighbor_dofs_face,
706 cell->neighbor(face_no)->active_fe_index());
710 for (
auto &
index : neighbor_dofs_face)
713 for (
unsigned int base_element_index = 0, comp = 0;
714 base_element_index < fe.n_base_elements();
715 ++base_element_index)
716 for (
unsigned int c = 0;
717 c < fe.element_multiplicity(base_element_index);
720 if (supported_components[cell->active_fe_index()][comp] ==
724 const unsigned int n_dofs_1d =
726 .base_element(base_element_index)
729 const unsigned int dofs_per_face =
731 std::vector<types::global_dof_index> neighbor_dofs(
733 const auto lex_face_mapping =
738 for (
unsigned int i = 0; i < dofs_per_face; ++i)
739 neighbor_dofs[i] = neighbor_dofs_face
740 [component_to_system_index_face_array[comp][i]];
747 Assert(cell->combined_face_orientation(face_no) ==
753 orient_face(cell->combined_face_orientation(face_no),
763 for (
unsigned int i = 0, k = 0; i < n_dofs_1d; ++i)
764 for (
unsigned int j = 0; j < (dim == 2 ? 1 : n_dofs_1d);
766 dof_indices[get_face_idx(n_dofs_1d, face_no, i, j) +
768 neighbor_dofs[lex_face_mapping[k]];
773 for (
unsigned int direction = 0; direction < dim; ++direction)
774 if ((edge >> direction) & 1U)
776 const unsigned int line_no =
782 const unsigned int line_index = cell->line(line_no)->index();
784 const auto edge_neighbor =
785 std::find_if(line_to_cells[line_index].begin(),
786 line_to_cells[line_index].end(),
787 [&cell](
const auto &edge_array) {
789 edge_neighbor(&cell->get_triangulation(),
792 return edge_neighbor->is_artificial() ==
false &&
793 edge_neighbor->level() < cell->level();
796 if (edge_neighbor == line_to_cells[line_index].end())
800 &cell->get_triangulation(),
803 &cell->get_dof_handler());
804 const auto local_line_neighbor = (*edge_neighbor)[2];
809 for (
auto &
index : neighbor_dofs_all)
812 for (
unsigned int i = 0; i < neighbor_dofs_all_temp.size(); ++i)
813 neighbor_dofs_all_temp[i] = neighbor_dofs_all
814 [lexicographic_mapping[cell->active_fe_index()][i]];
817 cell->line_orientation(line_no) !=
818 neighbor_cell.line_orientation(local_line_neighbor);
820 for (
unsigned int base_element_index = 0, comp = 0;
821 base_element_index < fe.n_base_elements();
822 ++base_element_index)
823 for (
unsigned int c = 0;
824 c < fe.element_multiplicity(base_element_index);
827 if (supported_components[cell->active_fe_index()][comp] ==
831 const unsigned int n_dofs_1d =
833 .base_element(base_element_index)
837 for (
unsigned int i = 0; i < n_dofs_1d; ++i)
838 dof_indices[line_dof_idx(line_no, i, n_dofs_1d) +
839 idx_offset[comp]] = neighbor_dofs_all_temp
840 [line_dof_idx(local_line_neighbor,
841 flipped ? (n_dofs_1d - 1 - i) : i,
854 const CellIterator &cell,
855 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
856 const std::vector<std::vector<unsigned int>> &lexicographic_mapping,
857 std::vector<types::global_dof_index> &dof_indices,
861 const auto supported_components = compute_supported_components(
862 cell->get_dof_handler().get_fe_collection());
864 if (std::none_of(supported_components.begin(),
865 supported_components.end(),
867 return *std::max_element(a.begin(), a.end());
872 const auto refinement_configuration =
873 compute_refinement_configuration(cell);
879 update_dof_indices(cell,
881 lexicographic_mapping,
882 supported_components,
883 refinement_configuration,
887 for (
unsigned int c = 0; c < supported_components[0].size(); ++c)
888 if (supported_components[cell->active_fe_index()][c])
889 masks[c] = refinement_configuration;
915 const unsigned int n_dofs_1d,
916 std::vector<types::global_dof_index> &dofs)
const
918 const auto [orientation, rotation, flip] =
920 const int n_rotations =
921 rotation || flip ? 4 -
int(rotation) - 2 *
int(flip) : 0;
923 const unsigned int rot_mapping[4] = {2, 0, 3, 1};
927 const unsigned int dofs_per_line = n_dofs_1d - 2;
930 std::vector<types::global_dof_index> copy(dofs.size());
931 for (
int t = 0; t < n_rotations; ++t)
933 std::swap(copy, dofs);
936 for (
unsigned int i = 0; i < 4; ++i)
937 dofs[rot_mapping[i]] = copy[i];
940 unsigned int offset = 4;
941 for (
unsigned int i = 0; i < dofs_per_line; ++i)
945 copy[offset + 2 * dofs_per_line + (dofs_per_line - 1 - i)];
947 dofs[offset + dofs_per_line + i] =
948 copy[offset + 3 * dofs_per_line + (dofs_per_line - 1 - i)];
950 dofs[offset + 2 * dofs_per_line + i] =
951 copy[offset + dofs_per_line + i];
953 dofs[offset + 3 * dofs_per_line + i] = copy[offset + i];
957 offset += 4 * dofs_per_line;
959 for (
unsigned int i = 0; i < dofs_per_line; ++i)
960 for (
unsigned int j = 0; j < dofs_per_line; ++j)
961 dofs[offset + i * dofs_per_line + j] =
962 copy[offset + j * dofs_per_line + (dofs_per_line - 1 - i)];
976 unsigned int offset = 4;
977 for (
unsigned int i = 0; i < dofs_per_line; ++i)
980 dofs[offset + i] = copy[offset + 2 * dofs_per_line + i];
982 dofs[offset + dofs_per_line + i] =
983 copy[offset + 3 * dofs_per_line + i];
985 dofs[offset + 2 * dofs_per_line + i] = copy[offset + i];
987 dofs[offset + 3 * dofs_per_line + i] =
988 copy[offset + dofs_per_line + i];
992 offset += 4 * dofs_per_line;
993 for (
unsigned int i = 0; i < dofs_per_line; ++i)
994 for (
unsigned int j = 0; j < dofs_per_line; ++j)
995 dofs[offset + i * dofs_per_line + j] =
996 copy[offset + j * dofs_per_line + i];