20#include <deal.II/base/mpi.templates.h>
22#include <deal.II/distributed/cell_data_transfer.templates.h>
39#include <unordered_set>
43template <
int dim,
int spacedim>
49 template <
int dim,
int spacedim>
52 PolicyBase<dim, spacedim> &policy)
54 std::string policy_name;
55 if (
dynamic_cast<const typename ::internal::DoFHandlerImplementation::
56 Policy::Sequential<dim, spacedim> *
>(&policy) ||
57 dynamic_cast<const typename ::internal::DoFHandlerImplementation::
58 Policy::Sequential<dim, spacedim> *
>(&policy))
59 policy_name =
"Policy::Sequential<";
60 else if (
dynamic_cast<
61 const typename ::internal::DoFHandlerImplementation::
62 Policy::ParallelDistributed<dim, spacedim> *
>(&policy) ||
64 const typename ::internal::DoFHandlerImplementation::
65 Policy::ParallelDistributed<dim, spacedim> *
>(&policy))
66 policy_name =
"Policy::ParallelDistributed<";
67 else if (
dynamic_cast<
68 const typename ::internal::DoFHandlerImplementation::
69 Policy::ParallelShared<dim, spacedim> *
>(&policy) ||
71 const typename ::internal::DoFHandlerImplementation::
72 Policy::ParallelShared<dim, spacedim> *
>(&policy))
73 policy_name =
"Policy::ParallelShared<";
82 namespace DoFHandlerImplementation
94 template <
int spacedim>
104 template <
int spacedim>
223 template <
int spacedim>
236 const unsigned int max_adjacent_cells =
240 if (max_adjacent_cells <= 8)
259 template <
int dim,
int spacedim>
283 template <
int dim,
int spacedim>
286 const unsigned int n_inner_dofs_per_cell)
288 for (
unsigned int i = 0; i < dof_handler.
tria->
n_levels(); ++i)
294 for (
const auto &cell :
296 if (cell->is_active() && !cell->is_artificial())
298 n_inner_dofs_per_cell;
312 for (
const auto &cell :
314 if (cell->is_active() && !cell->is_artificial())
332 template <
int dim,
int spacedim,
typename T>
335 const unsigned int structdim,
336 const unsigned int n_raw_entities,
337 const T & cell_process)
342 dof_handler.
object_dof_ptr[0][structdim].assign(n_raw_entities + 1, -1);
345 if (cell->is_active() && !cell->is_artificial())
348 [&](
const unsigned int n_dofs_per_entity,
349 const unsigned int index) {
350 auto &n_dofs_per_entity_target =
355 Assert((n_dofs_per_entity_target ==
359 n_dofs_per_entity_target == n_dofs_per_entity),
362 n_dofs_per_entity_target = n_dofs_per_entity;
367 for (
unsigned int i = 1; i < n_raw_entities + 1; ++i)
391 template <
int dim,
int spacedim>
397 const auto &fe = dof_handler.
get_fe();
401 dim == 1 ? fe.n_dofs_per_line() :
402 (dim == 2 ? fe.n_dofs_per_quad(0) :
403 fe.n_dofs_per_hex()));
409 [&](
const auto &cell,
const auto &process) {
410 for (const auto vertex_index :
411 cell->vertex_indices())
412 process(fe.n_dofs_per_vertex(),
413 cell->vertex_index(vertex_index));
417 if (dim == 2 || dim == 3)
421 [&](
const auto &cell,
const auto &process) {
422 for (const auto line_index :
423 cell->line_indices())
424 process(fe.n_dofs_per_line(),
425 cell->line(line_index)->index());
433 [&](
const auto &cell,
const auto &process) {
434 for (const auto face_index :
435 cell->face_indices())
436 process(fe.n_dofs_per_quad(face_index),
437 cell->face(face_index)->index());
441 template <
int spacedim>
448 const ::Triangulation<1, spacedim> &tria =
450 const unsigned int dofs_per_line =
452 const unsigned int n_levels = tria.n_levels();
454 for (
unsigned int i = 0; i < n_levels; ++i)
458 dof_handler.
mg_levels.back()->dof_object.dofs =
459 std::vector<types::global_dof_index>(tria.n_raw_lines(i) *
464 const unsigned int n_vertices = tria.n_vertices();
468 std::vector<unsigned int> max_level(n_vertices, 0);
469 std::vector<unsigned int> min_level(n_vertices, n_levels);
471 for (typename ::Triangulation<1, spacedim>::cell_iterator cell =
476 const unsigned int level = cell->level();
478 for (
const auto vertex : cell->vertex_indices())
480 const unsigned int vertex_index = cell->vertex_index(vertex);
482 if (min_level[vertex_index] >
level)
483 min_level[vertex_index] =
level;
485 if (max_level[vertex_index] <
level)
486 max_level[vertex_index] =
level;
490 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
491 if (tria.vertex_used(vertex))
494 Assert(max_level[vertex] >= min_level[vertex],
510 template <
int spacedim>
517 const ::FiniteElement<2, spacedim> &fe = dof_handler.
get_fe();
518 const ::Triangulation<2, spacedim> &tria =
520 const unsigned int n_levels = tria.
n_levels();
522 for (
unsigned int i = 0; i < n_levels; ++i)
527 dof_handler.
mg_levels.back()->dof_object.dofs =
528 std::vector<types::global_dof_index>(
529 tria.n_raw_quads(i) *
530 fe.n_dofs_per_quad(0 ),
535 std::make_unique<internal::DoFHandlerImplementation::DoFFaces<2>>();
537 std::vector<types::global_dof_index>(tria.n_raw_lines() *
538 fe.n_dofs_per_line(),
541 const unsigned int n_vertices = tria.n_vertices();
545 std::vector<unsigned int> max_level(n_vertices, 0);
546 std::vector<unsigned int> min_level(n_vertices, n_levels);
548 for (typename ::Triangulation<2, spacedim>::cell_iterator cell =
553 const unsigned int level = cell->level();
555 for (
const auto vertex : cell->vertex_indices())
557 const unsigned int vertex_index = cell->vertex_index(vertex);
559 if (min_level[vertex_index] >
level)
560 min_level[vertex_index] =
level;
562 if (max_level[vertex_index] <
level)
563 max_level[vertex_index] =
level;
567 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
568 if (tria.vertex_used(vertex))
571 Assert(max_level[vertex] >= min_level[vertex],
575 fe.n_dofs_per_vertex());
586 template <
int spacedim>
593 const ::FiniteElement<3, spacedim> &fe = dof_handler.
get_fe();
594 const ::Triangulation<3, spacedim> &tria =
596 const unsigned int n_levels = tria.
n_levels();
598 for (
unsigned int i = 0; i < n_levels; ++i)
603 dof_handler.
mg_levels.back()->dof_object.dofs =
604 std::vector<types::global_dof_index>(tria.n_raw_hexs(i) *
610 std::make_unique<internal::DoFHandlerImplementation::DoFFaces<3>>();
612 std::vector<types::global_dof_index>(tria.n_raw_lines() *
613 fe.n_dofs_per_line(),
619 dof_handler.
mg_faces->quads.dofs = std::vector<types::global_dof_index>(
620 tria.n_raw_quads() * fe.n_dofs_per_quad(0 ),
623 const unsigned int n_vertices = tria.n_vertices();
627 std::vector<unsigned int> max_level(n_vertices, 0);
628 std::vector<unsigned int> min_level(n_vertices, n_levels);
630 for (typename ::Triangulation<3, spacedim>::cell_iterator cell =
635 const unsigned int level = cell->level();
637 for (
const auto vertex : cell->vertex_indices())
639 const unsigned int vertex_index = cell->vertex_index(vertex);
641 if (min_level[vertex_index] >
level)
642 min_level[vertex_index] =
level;
644 if (max_level[vertex_index] <
level)
645 max_level[vertex_index] =
level;
649 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
650 if (tria.vertex_used(vertex))
653 Assert(max_level[vertex] >= min_level[vertex],
657 fe.n_dofs_per_vertex());
668 template <
int spacedim>
676 const unsigned int obj_index,
677 const unsigned int fe_index,
678 const unsigned int local_index,
679 const std::integral_constant<int, 1>)
684 return mg_level->dof_object.get_dof_index(
691 template <
int spacedim>
699 const unsigned int obj_index,
700 const unsigned int fe_index,
701 const unsigned int local_index,
702 const std::integral_constant<int, 1>)
704 return mg_faces->lines.get_dof_index(
711 template <
int spacedim>
719 const unsigned int obj_index,
720 const unsigned int fe_index,
721 const unsigned int local_index,
722 const std::integral_constant<int, 2>)
726 return mg_level->dof_object.get_dof_index(
733 template <
int spacedim>
741 const unsigned int obj_index,
742 const unsigned int fe_index,
743 const unsigned int local_index,
744 const std::integral_constant<int, 1>)
748 return mg_faces->lines.get_dof_index(
755 template <
int spacedim>
763 const unsigned int obj_index,
764 const unsigned int fe_index,
765 const unsigned int local_index,
766 const std::integral_constant<int, 2>)
770 return mg_faces->quads.get_dof_index(
777 template <
int spacedim>
785 const unsigned int obj_index,
786 const unsigned int fe_index,
787 const unsigned int local_index,
788 const std::integral_constant<int, 3>)
792 return mg_level->dof_object.get_dof_index(
799 template <
int spacedim>
807 const unsigned int obj_index,
808 const unsigned int fe_index,
809 const unsigned int local_index,
811 const std::integral_constant<int, 1>)
815 mg_level->dof_object.set_dof_index(
823 template <
int spacedim>
831 const unsigned int obj_index,
832 const unsigned int fe_index,
833 const unsigned int local_index,
835 const std::integral_constant<int, 1>)
839 mg_faces->lines.set_dof_index(
847 template <
int spacedim>
855 const unsigned int obj_index,
856 const unsigned int fe_index,
857 const unsigned int local_index,
859 const std::integral_constant<int, 2>)
863 mg_level->dof_object.set_dof_index(
871 template <
int spacedim>
879 const unsigned int obj_index,
880 const unsigned int fe_index,
881 const unsigned int local_index,
883 const std::integral_constant<int, 1>)
887 mg_faces->lines.set_dof_index(
895 template <
int spacedim>
903 const unsigned int obj_index,
904 const unsigned int fe_index,
905 const unsigned int local_index,
907 const std::integral_constant<int, 2>)
911 mg_faces->quads.set_dof_index(
919 template <
int spacedim>
927 const unsigned int obj_index,
928 const unsigned int fe_index,
929 const unsigned int local_index,
931 const std::integral_constant<int, 3>)
935 mg_level->dof_object.set_dof_index(
949 namespace DoFHandlerImplementation
962 template <
int dim,
int spacedim>
969 if (cell->is_locally_owned())
971 !cell->future_fe_index_set(),
973 "There shouldn't be any cells flagged for p-adaptation when partitioning."));
982 template <
int dim,
int spacedim>
998 std::vector<bool> locally_used_vertices(
1001 if (!cell->is_artificial())
1002 for (
const auto v : cell->vertex_indices())
1003 locally_used_vertices[cell->vertex_index(v)] =
true;
1005 std::vector<std::vector<bool>> vertex_fe_association(
1010 if (!cell->is_artificial())
1011 for (
const auto v : cell->vertex_indices())
1012 vertex_fe_association[cell->active_fe_index()]
1013 [cell->vertex_index(v)] =
true;
1021 for (
unsigned int v = 0; v < dof_handler.
tria->
n_vertices(); ++v)
1022 if (locally_used_vertices[v] ==
true)
1025 unsigned int fe = 0;
1027 if (vertex_fe_association[fe][v] ==
true)
1034 const unsigned int d = 0;
1035 const unsigned int l = 0;
1045 unsigned int vertex_slots_needed = 0;
1046 unsigned int fe_slots_needed = 0;
1048 for (
unsigned int v = 0; v < dof_handler.
tria->
n_vertices(); ++v)
1054 for (
unsigned int fe = 0;
1057 if (vertex_fe_association[fe][v] ==
true)
1060 vertex_slots_needed +=
1073 for (
unsigned int v = 0; v < dof_handler.
tria->
n_vertices(); ++v)
1078 if (vertex_fe_association[fe][v] ==
true)
1084 for (
unsigned int i = 0;
1085 i < dof_handler.
get_fe(fe).n_dofs_per_vertex();
1115 template <
int dim,
int spacedim>
1132 std::vector<typename DoFHandler<dim, spacedim>::offset_type>(
1137 std::vector<typename DoFHandler<dim, spacedim>::offset_type>(
1147 if (cell->is_active() && !cell->is_artificial())
1152 cell->get_fe().template n_dofs_per_object<dim>();
1156 cache_size += cell->get_fe().n_dofs_per_cell();
1160 std::vector<types::global_dof_index>(
1163 std::vector<types::global_dof_index>(
1174 template <
int dim,
int spacedim>
1197 std::vector<bool> saved_face_user_flags;
1204 .save_user_flags_line(saved_face_user_flags);
1207 .clear_user_flags_line();
1216 .save_user_flags_quad(saved_face_user_flags);
1219 .clear_user_flags_quad();
1228 const unsigned int d = dim - 1;
1229 const unsigned int l = 0;
1241 unsigned int n_face_slots = 0;
1244 if (!cell->is_artificial())
1245 for (
const auto face : cell->face_indices())
1246 if (cell->face(face)->user_flag_set() ==
false)
1248 unsigned int fe_slots_needed = 0;
1250 if (cell->at_boundary(face) ||
1251 cell->face(face)->has_children() ||
1252 cell->neighbor_is_coarser(face) ||
1253 (!cell->at_boundary(face) &&
1254 cell->neighbor(face)->is_artificial()) ||
1255 (!cell->at_boundary(face) &&
1256 !cell->neighbor(face)->is_artificial() &&
1257 (cell->active_fe_index() ==
1258 cell->neighbor(face)->active_fe_index())))
1260 fe_slots_needed = 1;
1262 dof_handler.
get_fe(cell->active_fe_index())
1263 .template n_dofs_per_object<dim - 1>(face);
1267 fe_slots_needed = 2;
1269 dof_handler.
get_fe(cell->active_fe_index())
1270 .
template n_dofs_per_object<dim - 1>(face) +
1272 .
get_fe(cell->neighbor(face)->active_fe_index())
1273 .
template n_dofs_per_object<dim - 1>(
1274 cell->neighbor_face_no(face));
1278 cell->face(face)->set_user_flag();
1308 .clear_user_flags_line();
1317 .clear_user_flags_quad();
1327 if (!cell->is_artificial())
1328 for (
const auto face : cell->face_indices())
1329 if (!cell->face(face)->user_flag_set())
1332 if (cell->at_boundary(face) ||
1333 cell->face(face)->has_children() ||
1334 cell->neighbor_is_coarser(face) ||
1335 (!cell->at_boundary(face) &&
1336 cell->neighbor(face)->is_artificial()) ||
1337 (!cell->at_boundary(face) &&
1338 !cell->neighbor(face)->is_artificial() &&
1339 (cell->active_fe_index() ==
1340 cell->neighbor(face)->active_fe_index())))
1342 const unsigned int fe = cell->active_fe_index();
1343 const unsigned int n_dofs =
1345 .template n_dofs_per_object<dim - 1>(face);
1346 const unsigned int offset =
1353 for (
unsigned int i = 0; i < n_dofs; i++)
1359 unsigned int fe_1 = cell->active_fe_index();
1360 unsigned int face_no_1 = face;
1362 cell->neighbor(face)->active_fe_index();
1363 unsigned int face_no_2 = cell->neighbor_face_no(face);
1371 const unsigned int n_dofs_1 =
1373 .template n_dofs_per_object<dim - 1>(face_no_1);
1375 const unsigned int n_dofs_2 =
1377 .template n_dofs_per_object<dim - 1>(face_no_2);
1379 const unsigned int offset =
1384 cell->active_fe_index());
1398 for (
unsigned int i = 0; i < n_dofs_1 + n_dofs_2; i++)
1404 cell->face(face)->set_user_flag();
1407 for (
unsigned int i = 1;
1420 .load_user_flags_line(saved_face_user_flags);
1429 .load_user_flags_quad(saved_face_user_flags);
1448 template <
int spacedim>
1454 ExcMessage(
"The current Triangulation must not be empty."));
1472 template <
int spacedim>
1478 ExcMessage(
"The current Triangulation must not be empty."));
1498 template <
int spacedim>
1504 ExcMessage(
"The current Triangulation must not be empty."));
1533 std::vector<std::vector<bool>> line_fe_association(
1538 if (!cell->is_artificial())
1539 for (
const auto l : cell->line_indices())
1540 line_fe_association[cell->active_fe_index()]
1541 [cell->line_index(
l)] =
true;
1553 if (line_fe_association[fe][line] ==
true)
1555 line_is_used[line] =
true;
1561 const unsigned int d = 1;
1562 const unsigned int l = 0;
1572 unsigned int line_slots_needed = 0;
1573 unsigned int fe_slots_needed = 0;
1580 if (line_is_used[line] ==
true)
1582 for (
unsigned int fe = 0;
1585 if (line_fe_association[fe][line] ==
true)
1588 line_slots_needed +=
1607 if (line_is_used[line] ==
true)
1609 for (
unsigned int fe = 0;
1612 if (line_fe_association[fe][line] ==
true)
1618 for (
unsigned int i = 0;
1619 i < dof_handler.
get_fe(fe).n_dofs_per_line();
1633 fe_slots_needed + 1);
1655 template <
int dim,
int spacedim>
1663 using active_fe_index_type =
1664 typename ::DoFHandler<dim, spacedim>::active_fe_index_type;
1666 if (const ::parallel::shared::Triangulation<dim, spacedim> *tr =
1668 const ::parallel::shared::Triangulation<dim, spacedim>
1681 std::vector<active_fe_index_type> active_fe_indices(
1682 tr->n_active_cells(), 0u);
1684 if (cell->is_locally_owned())
1685 active_fe_indices[cell->active_cell_index()] =
1686 cell->active_fe_index();
1689 tr->get_communicator(),
1699 if (!cell->is_locally_owned())
1702 active_fe_indices[cell->active_cell_index()];
1704 else if (const ::parallel::
1705 DistributedTriangulationBase<dim, spacedim> *tr =
1708 DistributedTriangulationBase<dim, spacedim> *
>(
1718 [](
const typename ::DoFHandler<dim, spacedim>::
1719 active_cell_iterator &cell) -> active_fe_index_type {
1720 return cell->active_fe_index();
1725 const typename ::DoFHandler<dim, spacedim>::
1726 active_cell_iterator & cell,
1727 const active_fe_index_type active_fe_index) ->
void {
1738 active_fe_index_type,
1746 const ::parallel::TriangulationBase<dim, spacedim> *
>(
1767 template <
int dim,
int spacedim>
1775 using active_fe_index_type =
1776 typename ::DoFHandler<dim, spacedim>::active_fe_index_type;
1778 if (const ::parallel::shared::Triangulation<dim, spacedim> *tr =
1780 const ::parallel::shared::Triangulation<dim, spacedim>
1783 std::vector<active_fe_index_type> future_fe_indices(
1784 tr->n_active_cells(), 0u);
1786 if (cell->is_locally_owned())
1787 future_fe_indices[cell->active_cell_index()] =
1792 tr->get_communicator(),
1796 if (!cell->is_locally_owned())
1799 future_fe_indices[cell->active_cell_index()];
1801 else if (const ::parallel::
1802 DistributedTriangulationBase<dim, spacedim> *tr =
1805 DistributedTriangulationBase<dim, spacedim> *
>(
1810 const typename ::DoFHandler<dim, spacedim>::
1811 active_cell_iterator &cell) -> active_fe_index_type {
1818 const typename ::DoFHandler<dim, spacedim>::
1819 active_cell_iterator & cell,
1820 const active_fe_index_type future_fe_index) ->
void {
1827 active_fe_index_type,
1834 const ::parallel::TriangulationBase<dim, spacedim> *
>(
1862 template <
int dim,
int spacedim>
1870 if (cell->is_locally_owned())
1872 if (cell->refine_flag_set())
1877 fe_transfer->refined_cells_fe_index.insert(
1878 {cell, cell->future_fe_index()});
1880 else if (cell->coarsen_flag_set())
1887 const auto &parent = cell->parent();
1891 if (fe_transfer->coarsened_cells_fe_index.find(parent) ==
1892 fe_transfer->coarsened_cells_fe_index.end())
1899 for (
const auto &child : parent->child_iterators())
1900 Assert(child->is_active() &&
1901 child->coarsen_flag_set(),
1903 dim>::ExcInconsistentCoarseningFlags());
1906 const unsigned int fe_index = ::internal::hp::
1907 DoFHandlerImplementation::Implementation::
1908 dominated_future_fe_on_children<dim, spacedim>(
1911 fe_transfer->coarsened_cells_fe_index.insert(
1912 {parent, fe_index});
1920 if (cell->future_fe_index_set() ==
true)
1921 fe_transfer->persisting_cells_fe_index.insert(
1922 {cell, cell->future_fe_index()});
1933 template <
int dim,
int spacedim>
1941 for (
const auto &persist : fe_transfer->persisting_cells_fe_index)
1943 const auto &cell = persist.first;
1945 if (cell->is_locally_owned())
1948 cell->set_active_fe_index(persist.second);
1954 for (
const auto &
refine : fe_transfer->refined_cells_fe_index)
1956 const auto &parent =
refine.first;
1958 for (
const auto &child : parent->child_iterators())
1959 if (child->is_locally_owned())
1962 child->set_active_fe_index(
refine.second);
1968 for (
const auto &
coarsen : fe_transfer->coarsened_cells_fe_index)
1970 const auto &cell =
coarsen.first;
1972 if (cell->is_locally_owned())
1975 cell->set_active_fe_index(
coarsen.second);
1991 template <
int dim,
int spacedim>
1995 const std::vector<unsigned int> & children_fe_indices,
1996 const ::hp::FECollection<dim, spacedim> &fe_collection)
2001 const std::set<unsigned int> children_fe_indices_set(
2002 children_fe_indices.begin(), children_fe_indices.end());
2004 const unsigned int dominated_fe_index =
2005 fe_collection.find_dominated_fe_extended(children_fe_indices_set,
2011 return dominated_fe_index;
2022 template <
int dim,
int spacedim>
2028 !parent->is_active(),
2030 "You ask for information on children of this cell which is only "
2031 "available for active cells. This cell has no children."));
2033 const auto &dof_handler = parent->get_dof_handler();
2035 dof_handler.has_hp_capabilities(),
2038 std::set<unsigned int> future_fe_indices_children;
2039 for (
const auto &child : parent->child_iterators())
2044 "You ask for information on children of this cell which is only "
2045 "available for active cells. One of its children is not active."));
2053 const unsigned int future_fe_index_child =
2054 ::internal::DoFCellAccessorImplementation::
2055 Implementation::future_fe_index<dim, spacedim, false>(*child);
2057 future_fe_indices_children.insert(future_fe_index_child);
2061 const unsigned int future_fe_index =
2062 dof_handler.fe_collection.find_dominated_fe_extended(
2063 future_fe_indices_children,
2069 return future_fe_index;
2078 template <
int dim,
int spacedim>
2082 Implementation::communicate_future_fe_indices<dim, spacedim>(
2091 template <
int dim,
int spacedim>
2096 return Implementation::dominated_future_fe_on_children<dim, spacedim>(
2105template <
int dim,
int spacedim>
2107 : hp_capability_enabled(true)
2108 , tria(nullptr, typeid(*this).name())
2114template <
int dim,
int spacedim>
2123template <
int dim,
int spacedim>
2127 for (
auto &connection : this->tria_listeners)
2128 connection.disconnect();
2129 this->tria_listeners.clear();
2131 for (
auto &connection : this->tria_listeners_for_transfer)
2132 connection.disconnect();
2133 this->tria_listeners_for_transfer.clear();
2144 this->policy.reset();
2149template <
int dim,
int spacedim>
2159template <
int dim,
int spacedim>
2165 this->distribute_dofs(fe);
2170template <
int dim,
int spacedim>
2178 for (
auto &connection : this->tria_listeners)
2179 connection.disconnect();
2180 this->tria_listeners.clear();
2182 for (
auto &connection : this->tria_listeners_for_transfer)
2183 connection.disconnect();
2184 this->tria_listeners_for_transfer.clear();
2188 this->policy.reset();
2198 this->setup_policy();
2201 hp_capability_enabled =
true;
2202 this->connect_to_triangulation_signals();
2203 this->create_active_fe_table();
2210template <
int dim,
int spacedim>
2216 if (cell == this->get_triangulation().
end(
level))
2218 return cell_iterator(*cell,
this);
2223template <
int dim,
int spacedim>
2231 while (i->has_children())
2239template <
int dim,
int spacedim>
2243 return cell_iterator(&this->get_triangulation(), -1, -1,
this);
2248template <
int dim,
int spacedim>
2253 this->get_triangulation().
end(
level);
2256 return cell_iterator(*cell,
this);
2261template <
int dim,
int spacedim>
2268 return active_cell_iterator(
end());
2269 return active_cell_iterator(*cell,
this);
2274template <
int dim,
int spacedim>
2278 Assert(this->has_level_dofs(),
2280 "levels if mg dofs got distributed."));
2283 if (cell == this->get_triangulation().
end(
level))
2284 return end_mg(
level);
2285 return level_cell_iterator(*cell,
this);
2290template <
int dim,
int spacedim>
2294 Assert(this->has_level_dofs(),
2296 "levels if mg dofs got distributed."));
2298 this->get_triangulation().
end(
level);
2301 return level_cell_iterator(*cell,
this);
2306template <
int dim,
int spacedim>
2310 return level_cell_iterator(&this->get_triangulation(), -1, -1,
this);
2315template <
int dim,
int spacedim>
2325template <
int dim,
int spacedim>
2336template <
int dim,
int spacedim>
2341 begin_mg(), end_mg());
2346template <
int dim,
int spacedim>
2349 const unsigned int level)
const
2357template <
int dim,
int spacedim>
2360 const unsigned int level)
const
2369template <
int dim,
int spacedim>
2372 const unsigned int level)
const
2384template <
int dim,
int spacedim>
2388 Assert(!(dim == 2 && spacedim == 3) || hp_capability_enabled ==
false,
2389 ExcNotImplementedWithHP());
2393 std::unordered_set<types::global_dof_index> boundary_dofs;
2394 std::vector<types::global_dof_index> dofs_on_face;
2395 dofs_on_face.reserve(this->get_fe_collection().max_dofs_per_face());
2397 const IndexSet &owned_dofs = locally_owned_dofs();
2404 for (
const auto &cell : this->active_cell_iterators())
2405 if (cell->is_locally_owned() && cell->at_boundary())
2407 for (
const auto iface : cell->face_indices())
2409 const auto face = cell->face(iface);
2410 if (face->at_boundary())
2412 const unsigned int dofs_per_face =
2413 cell->get_fe().n_dofs_per_face(iface);
2414 dofs_on_face.resize(dofs_per_face);
2416 face->get_dof_indices(dofs_on_face, cell->active_fe_index());
2417 for (
unsigned int i = 0; i < dofs_per_face; ++i)
2419 const unsigned int global_idof_index = dofs_on_face[i];
2420 if (owned_dofs.
is_element(global_idof_index))
2422 boundary_dofs.insert(global_idof_index);
2428 return boundary_dofs.size();
2433template <
int dim,
int spacedim>
2436 const std::set<types::boundary_id> &boundary_ids)
const
2438 Assert(!(dim == 2 && spacedim == 3) || hp_capability_enabled ==
false,
2439 ExcNotImplementedWithHP());
2448 std::unordered_set<types::global_dof_index> boundary_dofs;
2449 std::vector<types::global_dof_index> dofs_on_face;
2450 dofs_on_face.reserve(this->get_fe_collection().max_dofs_per_face());
2452 const IndexSet &owned_dofs = locally_owned_dofs();
2454 for (
const auto &cell : this->active_cell_iterators())
2455 if (cell->is_locally_owned() && cell->at_boundary())
2457 for (
const auto iface : cell->face_indices())
2459 const auto face = cell->face(iface);
2460 const unsigned int boundary_id = face->boundary_id();
2461 if (face->at_boundary() &&
2462 (boundary_ids.find(
boundary_id) != boundary_ids.end()))
2464 const unsigned int dofs_per_face =
2465 cell->get_fe().n_dofs_per_face(iface);
2466 dofs_on_face.resize(dofs_per_face);
2468 face->get_dof_indices(dofs_on_face, cell->active_fe_index());
2469 for (
unsigned int i = 0; i < dofs_per_face; ++i)
2471 const unsigned int global_idof_index = dofs_on_face[i];
2472 if (owned_dofs.
is_element(global_idof_index))
2474 boundary_dofs.insert(global_idof_index);
2480 return boundary_dofs.size();
2485template <
int dim,
int spacedim>
2503 if (hp_capability_enabled)
2516 if (this->mg_faces !=
nullptr)
2519 for (
unsigned int i = 0; i < this->mg_vertex_dofs.size(); ++i)
2520 mem +=
sizeof(MGVertexDoFs) +
2521 (1 + this->mg_vertex_dofs[i].get_finest_level() -
2522 this->mg_vertex_dofs[i].get_coarsest_level()) *
2531template <
int dim,
int spacedim>
2540template <
int dim,
int spacedim>
2545 this->tria !=
nullptr,
2547 "You need to set the Triangulation in the DoFHandler using reinit() or "
2548 "in the constructor before you can distribute DoFs."));
2550 ExcMessage(
"The Triangulation you are using is empty!"));
2554 if (this->fe_collection != ff)
2558 const bool contains_multiple_fes = (this->fe_collection.size() > 1);
2561 if (hp_capability_enabled && !contains_multiple_fes)
2563 hp_capability_enabled =
false;
2567 for (
auto &connection : this->tria_listeners_for_transfer)
2568 connection.disconnect();
2569 this->tria_listeners_for_transfer.clear();
2572 this->hp_cell_active_fe_indices.clear();
2573 this->hp_cell_active_fe_indices.shrink_to_fit();
2574 this->hp_cell_future_fe_indices.clear();
2575 this->hp_cell_future_fe_indices.shrink_to_fit();
2581 hp_capability_enabled || !contains_multiple_fes,
2583 "You cannot re-enable hp-capabilities after you registered a single "
2584 "finite element. Please create a new DoFHandler object instead."));
2587 if (hp_capability_enabled)
2596 for (
const auto &cell : this->active_cell_iterators())
2597 if (!cell->is_artificial())
2598 Assert(cell->active_fe_index() < this->fe_collection.size(),
2599 ExcInvalidFEIndex(cell->active_fe_index(),
2600 this->fe_collection.size()));
2606template <
int dim,
int spacedim>
2616template <
int dim,
int spacedim>
2622 this->tria !=
nullptr,
2624 "You need to set the Triangulation in the DoFHandler using reinit() or "
2625 "in the constructor before you can distribute DoFs."));
2627 ExcMessage(
"The Triangulation you are using is empty!"));
2634 if (this->fe_collection != ff)
2638 const bool contains_multiple_fes = (this->fe_collection.size() > 1);
2641 if (hp_capability_enabled && !contains_multiple_fes)
2643 hp_capability_enabled =
false;
2647 for (
auto &connection : this->tria_listeners_for_transfer)
2648 connection.disconnect();
2649 this->tria_listeners_for_transfer.clear();
2652 this->hp_cell_active_fe_indices.clear();
2653 this->hp_cell_active_fe_indices.shrink_to_fit();
2654 this->hp_cell_future_fe_indices.clear();
2655 this->hp_cell_future_fe_indices.shrink_to_fit();
2661 hp_capability_enabled || !contains_multiple_fes,
2663 "You cannot re-enable hp-capabilities after you registered a single "
2664 "finite element. Please call reinit() or create a new DoFHandler "
2665 "object instead."));
2671 if (hp_capability_enabled)
2681 for (
const auto &cell : this->active_cell_iterators())
2683 if (!cell->is_artificial())
2684 Assert(cell->active_fe_index() < this->fe_collection.size(),
2685 ExcInvalidFEIndex(cell->active_fe_index(),
2686 this->fe_collection.size()));
2687 if (cell->is_locally_owned())
2688 Assert(cell->future_fe_index() < this->fe_collection.size(),
2689 ExcInvalidFEIndex(cell->future_fe_index(),
2690 this->fe_collection.size()));
2705 subdomain_modifier(this->get_triangulation());
2714 if (hp_capability_enabled)
2722 this->number_cache = this->policy->distribute_dofs();
2739 if (!hp_capability_enabled &&
2741 *
>(&*this->tria) ==
nullptr)
2742 this->block_info_object.initialize(*
this,
false,
true);
2747template <
int dim,
int spacedim>
2751 AssertThrow(hp_capability_enabled ==
false, ExcNotImplementedWithHP());
2754 this->object_dof_indices.size() > 0,
2756 "Distribute active DoFs using distribute_dofs() before calling distribute_mg_dofs()."));
2763 "The mesh smoothing requirement 'limit_level_difference_at_vertices' has to be set for using multigrid!"));
2765 this->clear_mg_space();
2768 this->mg_number_cache = this->policy->distribute_mg_dofs();
2773 &*this->tria) ==
nullptr)
2774 this->block_info_object.initialize(*
this,
true,
false);
2779template <
int dim,
int spacedim>
2783 AssertThrow(hp_capability_enabled ==
false, ExcNotImplementedWithHP());
2785 this->block_info_object.initialize_local(*
this);
2790template <
int dim,
int spacedim>
2795 if (
dynamic_cast<const ::parallel::shared::Triangulation<dim, spacedim>
2796 *
>(&this->get_triangulation()) !=
nullptr)
2797 this->policy = std::make_unique<internal::DoFHandlerImplementation::Policy::
2798 ParallelShared<dim, spacedim>>(*this);
2799 else if (
dynamic_cast<
2800 const ::parallel::DistributedTriangulationBase<dim, spacedim>
2801 *
>(&this->get_triangulation()) ==
nullptr)
2802 this->policy = std::make_unique<
2807 std::make_unique<internal::DoFHandlerImplementation::Policy::
2808 ParallelDistributed<dim, spacedim>>(*this);
2813template <
int dim,
int spacedim>
2818 this->clear_space();
2819 this->clear_mg_space();
2824template <
int dim,
int spacedim>
2828 cell_dof_cache_indices.clear();
2830 cell_dof_cache_ptr.clear();
2832 object_dof_indices.clear();
2834 object_dof_ptr.clear();
2836 this->number_cache.clear();
2838 this->hp_cell_active_fe_indices.clear();
2839 this->hp_cell_future_fe_indices.clear();
2844template <
int dim,
int spacedim>
2848 this->mg_levels.clear();
2849 this->mg_faces.reset();
2851 std::vector<MGVertexDoFs> tmp;
2855 this->mg_number_cache.clear();
2860template <
int dim,
int spacedim>
2863 const std::vector<types::global_dof_index> &new_numbers)
2865 if (hp_capability_enabled)
2867 Assert(this->hp_cell_future_fe_indices.size() > 0,
2869 "You need to distribute DoFs before you can renumber them."));
2878 if (this->n_locally_owned_dofs() == this->n_dofs())
2880 std::vector<types::global_dof_index> tmp(new_numbers);
2881 std::sort(tmp.begin(), tmp.end());
2882 std::vector<types::global_dof_index>::const_iterator p = tmp.begin();
2884 for (; p != tmp.end(); ++p, ++i)
2885 Assert(*p == i, ExcNewNumbersNotConsecutive(i));
2888 for (
const auto new_number : new_numbers)
2889 Assert(new_number < this->n_dofs(),
2891 "New DoF index is not less than the total number of dofs."));
2908 this->number_cache = this->policy->renumber_dofs(new_numbers);
2923 Assert(this->object_dof_indices.size() > 0,
2925 "You need to distribute DoFs before you can renumber them."));
2929 &*this->tria) !=
nullptr)
2931 Assert(new_numbers.size() == this->n_dofs() ||
2932 new_numbers.size() == this->n_locally_owned_dofs(),
2933 ExcMessage(
"Incorrect size of the input array."));
2935 else if (
dynamic_cast<
2937 &*this->tria) !=
nullptr)
2950 if (this->n_locally_owned_dofs() == this->n_dofs())
2952 std::vector<types::global_dof_index> tmp(new_numbers);
2953 std::sort(tmp.begin(), tmp.end());
2954 std::vector<types::global_dof_index>::const_iterator p = tmp.begin();
2956 for (; p != tmp.end(); ++p, ++i)
2957 Assert(*p == i, ExcNewNumbersNotConsecutive(i));
2960 for (
const auto new_number : new_numbers)
2961 Assert(new_number < this->n_dofs(),
2963 "New DoF index is not less than the total number of dofs."));
2966 this->number_cache = this->policy->renumber_dofs(new_numbers);
2972template <
int dim,
int spacedim>
2975 const unsigned int level,
2976 const std::vector<types::global_dof_index> &new_numbers)
2978 AssertThrow(hp_capability_enabled ==
false, ExcNotImplementedWithHP());
2981 this->mg_levels.size() > 0 && this->object_dof_indices.size() > 0,
2983 "You need to distribute active and level DoFs before you can renumber level DoFs."));
2986 this->locally_owned_mg_dofs(
level).n_elements());
2993 if (this->n_locally_owned_dofs() == this->n_dofs())
2995 std::vector<types::global_dof_index> tmp(new_numbers);
2996 std::sort(tmp.begin(), tmp.end());
2997 std::vector<types::global_dof_index>::const_iterator p = tmp.begin();
2999 for (; p != tmp.end(); ++p, ++i)
3000 Assert(*p == i, ExcNewNumbersNotConsecutive(i));
3003 for (
const auto new_number : new_numbers)
3006 "New DoF index is not less than the total number of dofs."));
3009 this->mg_number_cache[
level] =
3010 this->policy->renumber_mg_dofs(
level, new_numbers);
3015template <
int dim,
int spacedim>
3024 return this->fe_collection.max_dofs_per_vertex();
3026 return (3 * this->fe_collection.max_dofs_per_vertex() +
3027 2 * this->fe_collection.max_dofs_per_line());
3038 return (19 * this->fe_collection.max_dofs_per_vertex() +
3039 28 * this->fe_collection.max_dofs_per_line() +
3040 8 * this->fe_collection.max_dofs_per_quad());
3049template <
int dim,
int spacedim>
3060template <
int dim,
int spacedim>
3061template <
int structdim>
3064 const unsigned int obj_index,
3065 const unsigned int fe_index,
3066 const unsigned int local_index)
const
3068 if (hp_capability_enabled)
3077 this->mg_levels[obj_level],
3082 std::integral_constant<int, structdim>());
3088template <
int dim,
int spacedim>
3089template <
int structdim>
3092 const unsigned int obj_level,
3093 const unsigned int obj_index,
3094 const unsigned int fe_index,
3095 const unsigned int local_index,
3098 if (hp_capability_enabled)
3107 this->mg_levels[obj_level],
3113 std::integral_constant<int, structdim>());
3119template <
int dim,
int spacedim>
3122 const std::vector<unsigned int> &active_fe_indices)
3124 Assert(active_fe_indices.size() == this->get_triangulation().n_active_cells(),
3126 this->get_triangulation().n_active_cells()));
3128 this->create_active_fe_table();
3133 for (
const auto &cell : this->active_cell_iterators())
3134 if (cell->is_locally_owned())
3135 cell->set_active_fe_index(active_fe_indices[cell->active_cell_index()]);
3140template <
int dim,
int spacedim>
3143 std::vector<unsigned int> &active_fe_indices)
const
3145 active_fe_indices.resize(this->get_triangulation().
n_active_cells());
3150 for (
const auto &cell : this->active_cell_iterators())
3151 if (!cell->is_artificial())
3152 active_fe_indices[cell->active_cell_index()] = cell->active_fe_index();
3157template <
int dim,
int spacedim>
3162 Assert(hp_capability_enabled, ExcOnlyAvailableWithHP());
3165 this->tria_listeners.push_back(this->tria->
signals.create.connect(
3166 [
this]() { this->reinit(*(this->tria)); }));
3167 this->tria_listeners.push_back(
3168 this->tria->
signals.clear.connect([
this]() { this->clear(); }));
3173 const ::parallel::fullydistributed::Triangulation<dim, spacedim>
3174 *
>(&this->get_triangulation()))
3178 else if (
dynamic_cast<
3179 const ::parallel::distributed::Triangulation<dim, spacedim>
3180 *
>(&this->get_triangulation()))
3183 this->tria_listeners_for_transfer.push_back(
3184 this->tria->
signals.pre_distributed_repartition.connect([
this]() {
3185 internal::hp::DoFHandlerImplementation::Implementation::
3186 ensure_absence_of_future_fe_indices<dim, spacedim>(*this);
3188 this->tria_listeners_for_transfer.push_back(
3189 this->tria->
signals.pre_distributed_repartition.connect(
3190 [
this]() { this->pre_distributed_transfer_action(); }));
3191 this->tria_listeners_for_transfer.push_back(
3192 this->tria->
signals.post_distributed_repartition.connect(
3193 [
this] { this->post_distributed_transfer_action(); }));
3196 this->tria_listeners_for_transfer.push_back(
3197 this->tria->
signals.post_p4est_refinement.connect(
3198 [
this]() { this->pre_distributed_transfer_action(); }));
3199 this->tria_listeners_for_transfer.push_back(
3200 this->tria->
signals.post_distributed_refinement.connect(
3201 [
this]() { this->post_distributed_transfer_action(); }));
3204 this->tria_listeners_for_transfer.push_back(
3205 this->tria->
signals.post_distributed_save.connect(
3206 [
this]() { this->active_fe_index_transfer.reset(); }));
3207 this->tria_listeners_for_transfer.push_back(
3208 this->tria->
signals.post_distributed_load.connect(
3209 [
this]() { this->update_active_fe_table(); }));
3211 else if (
dynamic_cast<
3212 const ::parallel::shared::Triangulation<dim, spacedim> *
>(
3213 &this->get_triangulation()) !=
nullptr)
3216 this->tria_listeners_for_transfer.push_back(
3217 this->tria->
signals.pre_partition.connect([
this]() {
3218 internal::hp::DoFHandlerImplementation::Implementation::
3219 ensure_absence_of_future_fe_indices(*this);
3223 this->tria_listeners_for_transfer.push_back(
3224 this->tria->
signals.pre_refinement.connect([
this]() {
3225 internal::hp::DoFHandlerImplementation::Implementation::
3226 communicate_future_fe_indices(*this);
3228 this->tria_listeners_for_transfer.push_back(
3229 this->tria->
signals.pre_refinement.connect(
3230 [
this] { this->pre_transfer_action(); }));
3231 this->tria_listeners_for_transfer.push_back(
3232 this->tria->
signals.post_refinement.connect(
3233 [
this] { this->post_transfer_action(); }));
3238 this->tria_listeners_for_transfer.push_back(
3239 this->tria->
signals.pre_refinement.connect(
3240 [
this] { this->pre_transfer_action(); }));
3241 this->tria_listeners_for_transfer.push_back(
3242 this->tria->
signals.post_refinement.connect(
3243 [
this] { this->post_transfer_action(); }));
3249template <
int dim,
int spacedim>
3253 AssertThrow(hp_capability_enabled ==
true, ExcOnlyAvailableWithHP());
3260 this->hp_cell_active_fe_indices.resize(this->tria->
n_levels());
3261 this->hp_cell_future_fe_indices.resize(this->tria->
n_levels());
3265 for (
unsigned int level = 0;
level < this->hp_cell_future_fe_indices.size();
3268 if (this->hp_cell_active_fe_indices[
level].size() == 0 &&
3269 this->hp_cell_future_fe_indices[
level].size() == 0)
3271 this->hp_cell_active_fe_indices[
level].resize(
3273 this->hp_cell_future_fe_indices[
level].resize(
3281 Assert(this->hp_cell_active_fe_indices[
level].size() ==
3283 this->hp_cell_future_fe_indices[
level].size() ==
3284 this->tria->n_raw_cells(
level),
3300template <
int dim,
int spacedim>
3316 this->hp_cell_active_fe_indices.resize(this->tria->
n_levels());
3317 this->hp_cell_active_fe_indices.shrink_to_fit();
3319 this->hp_cell_future_fe_indices.resize(this->tria->
n_levels());
3320 this->hp_cell_future_fe_indices.shrink_to_fit();
3322 for (
unsigned int i = 0; i < this->hp_cell_future_fe_indices.size(); ++i)
3325 this->hp_cell_active_fe_indices[i].resize(this->tria->
n_raw_cells(i), 0);
3332 this->hp_cell_future_fe_indices[i].assign(this->tria->
n_raw_cells(i),
3333 invalid_active_fe_index);
3338template <
int dim,
int spacedim>
3344 this->active_fe_index_transfer = std::make_unique<ActiveFEIndexTransfer>();
3352template <
int dim,
int spacedim>
3356#ifndef DEAL_II_WITH_P4EST
3359 "You are attempting to use a functionality that is only available "
3360 "if deal.II was configured to use p4est, but cmake did not find a "
3361 "valid p4est library."));
3366 &this->get_triangulation()) !=
nullptr),
3371 active_fe_index_transfer = std::make_unique<ActiveFEIndexTransfer>();
3380 active_fe_index_transfer->active_fe_indices.resize(
3383 for (
const auto &cell : active_cell_iterators())
3384 if (cell->is_locally_owned())
3385 active_fe_index_transfer->active_fe_indices[cell->active_cell_index()] =
3386 cell->future_fe_index();
3389 const auto *distributed_tria =
3391 &this->get_triangulation());
3393 active_fe_index_transfer->cell_data_transfer = std::make_unique<
3394 parallel::distributed::
3395 CellDataTransfer<dim, spacedim, std::vector<unsigned int>>>(
3399 &::AdaptationStrategies::Refinement::
3400 preserve<dim, spacedim, unsigned int>,
3403 const std::vector<unsigned int> &children_fe_indices)
3405 return ::internal::hp::DoFHandlerImplementation::Implementation::
3406 determine_fe_from_children<dim, spacedim>(parent,
3407 children_fe_indices,
3411 active_fe_index_transfer->cell_data_transfer
3412 ->prepare_for_coarsening_and_refinement(
3413 active_fe_index_transfer->active_fe_indices);
3419template <
int dim,
int spacedim>
3423 update_active_fe_table();
3437 this->active_fe_index_transfer.reset();
3442template <
int dim,
int spacedim>
3446#ifndef DEAL_II_WITH_P4EST
3449 update_active_fe_table();
3454 this->active_fe_index_transfer->active_fe_indices.resize(
3456 this->active_fe_index_transfer->cell_data_transfer->unpack(
3457 this->active_fe_index_transfer->active_fe_indices);
3460 this->set_active_fe_indices(
3461 this->active_fe_index_transfer->active_fe_indices);
3468 this->active_fe_index_transfer.reset();
3474template <
int dim,
int spacedim>
3478#ifndef DEAL_II_WITH_P4EST
3481 "You are attempting to use a functionality that is only available "
3482 "if deal.II was configured to use p4est, but cmake did not find a "
3483 "valid p4est library."));
3488 &this->get_triangulation()) !=
nullptr),
3493 active_fe_index_transfer = std::make_unique<ActiveFEIndexTransfer>();
3496 const auto *distributed_tria =
3498 &this->get_triangulation());
3500 active_fe_index_transfer->cell_data_transfer = std::make_unique<
3501 parallel::distributed::
3502 CellDataTransfer<dim, spacedim, std::vector<unsigned int>>>(
3506 &::AdaptationStrategies::Refinement::
3507 preserve<dim, spacedim, unsigned int>,
3510 const std::vector<unsigned int> &children_fe_indices)
3512 return ::internal::hp::DoFHandlerImplementation::Implementation::
3513 determine_fe_from_children<dim, spacedim>(parent,
3514 children_fe_indices,
3525 active_fe_index_transfer->cell_data_transfer->prepare_for_serialization(
3526 active_fe_index_transfer->active_fe_indices);
3532template <
int dim,
int spacedim>
3536#ifndef DEAL_II_WITH_P4EST
3539 "You are attempting to use a functionality that is only available "
3540 "if deal.II was configured to use p4est, but cmake did not find a "
3541 "valid p4est library."));
3546 &this->get_triangulation()) !=
nullptr),
3551 active_fe_index_transfer = std::make_unique<ActiveFEIndexTransfer>();
3554 const auto *distributed_tria =
3556 &this->get_triangulation());
3558 active_fe_index_transfer->cell_data_transfer = std::make_unique<
3559 parallel::distributed::
3560 CellDataTransfer<dim, spacedim, std::vector<unsigned int>>>(
3564 &::AdaptationStrategies::Refinement::
3565 preserve<dim, spacedim, unsigned int>,
3568 const std::vector<unsigned int> &children_fe_indices)
3570 return ::internal::hp::DoFHandlerImplementation::Implementation::
3571 determine_fe_from_children<dim, spacedim>(parent,
3572 children_fe_indices,
3577 active_fe_index_transfer->active_fe_indices.resize(
3579 active_fe_index_transfer->cell_data_transfer->deserialize(
3580 active_fe_index_transfer->active_fe_indices);
3583 set_active_fe_indices(active_fe_index_transfer->active_fe_indices);
3590 active_fe_index_transfer.reset();
3596template <
int dim,
int spacedim>
3604template <
int dim,
int spacedim>
3607 const unsigned int cl,
3608 const unsigned int fl,
3609 const unsigned int dofs_per_vertex)
3611 coarsest_level = cl;
3614 if (coarsest_level <= finest_level)
3616 const unsigned int n_levels = finest_level - coarsest_level + 1;
3617 const unsigned int n_indices = n_levels * dofs_per_vertex;
3619 indices = std::make_unique<types::global_dof_index[]>(n_indices);
3620 std::fill(indices.get(),
3621 indices.get() + n_indices,
3630template <
int dim,
int spacedim>
3634 return coarsest_level;
3639template <
int dim,
int spacedim>
3643 return finest_level;
3647#include "dof_handler.inst"
void init(const unsigned int coarsest_level, const unsigned int finest_level, const unsigned int dofs_per_vertex)
unsigned int get_finest_level() const
unsigned int get_coarsest_level() const
cell_iterator end() const
void pre_distributed_transfer_action()
void post_transfer_action()
void set_dof_index(const unsigned int obj_level, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const types::global_dof_index global_index) const
virtual std::size_t memory_consumption() const
std::vector< std::vector< active_fe_index_type > > hp_cell_active_fe_indices
unsigned int max_couplings_between_dofs() const
std::vector< std::unique_ptr<::internal::DoFHandlerImplementation::DoFLevel< dim > > > mg_levels
const FiniteElement< dim, spacedim > & get_fe(const unsigned int index=0) const
std::unique_ptr< ActiveFEIndexTransfer > active_fe_index_transfer
hp::FECollection< dim, spacedim > fe_collection
void create_active_fe_table()
SmartPointer< const Triangulation< dim, spacedim >, DoFHandler< dim, spacedim > > tria
void set_active_fe_indices(const std::vector< unsigned int > &active_fe_indices)
level_cell_iterator end_mg() const
void renumber_dofs(const std::vector< types::global_dof_index > &new_numbers)
level_cell_iterator begin_mg(const unsigned int level=0) const
void distribute_dofs(const FiniteElement< dim, spacedim > &fe)
types::global_dof_index n_boundary_dofs() const
void connect_to_triangulation_signals()
std::vector< std::vector< types::global_dof_index > > cell_dof_cache_indices
std::vector< MGVertexDoFs > mg_vertex_dofs
std::vector< std::vector< active_fe_index_type > > hp_cell_future_fe_indices
void post_distributed_transfer_action()
std::vector< std::array< std::vector< types::global_dof_index >, dim+1 > > object_dof_indices
const Triangulation< dim, spacedim > & get_triangulation() const
types::global_dof_index get_dof_index(const unsigned int obj_level, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index) const
void pre_transfer_action()
std::array< std::vector< active_fe_index_type >, dim+1 > hp_object_fe_indices
void reinit(const Triangulation< dim, spacedim > &tria)
std::vector< std::array< std::vector< offset_type >, dim+1 > > object_dof_ptr
std::unique_ptr<::internal::DoFHandlerImplementation::DoFFaces< dim > > mg_faces
active_cell_iterator begin_active(const unsigned int level=0) const
void distribute_mg_dofs()
active_cell_iterator end_active(const unsigned int level) const
void set_fe(const FiniteElement< dim, spacedim > &fe)
bool hp_capability_enabled
void initialize_local_block_info()
types::global_dof_index n_dofs() const
void update_active_fe_table()
std::vector< std::vector< offset_type > > cell_dof_cache_ptr
void prepare_for_serialization_of_active_fe_indices()
cell_iterator begin(const unsigned int level=0) const
std::array< std::vector< offset_type >, dim+1 > hp_object_fe_ptr
void get_active_fe_indices(std::vector< unsigned int > &active_fe_indices) const
unsigned int max_couplings_between_boundary_dofs() const
void initialize(const Triangulation< dim, spacedim > &tria, const FiniteElement< dim, spacedim > &fe)
void deserialize_active_fe_indices()
virtual ~DoFHandler() override
unsigned int n_dofs_per_vertex() const
unsigned int n_dofs_per_cell() const
unsigned int n_dofs_per_line() const
bool is_element(const size_type index) const
virtual const MeshSmoothing & get_mesh_smoothing() const
cell_iterator begin(const unsigned int level=0) const
unsigned int n_raw_lines() const
unsigned int n_raw_faces() const
unsigned int n_levels() const
cell_iterator end() const
unsigned int n_raw_cells(const unsigned int level) const
unsigned int max_adjacent_cells() const
bool vertex_used(const unsigned int index) const
active_cell_iterator end_active(const unsigned int level) const
unsigned int n_raw_quads() const
unsigned int n_cells() const
unsigned int n_vertices() const
unsigned int size() const
unsigned int max_dofs_per_line() const
unsigned int max_dofs_per_hex() const
unsigned int max_dofs_per_vertex() const
unsigned int max_dofs_per_quad() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
IteratorRange< active_cell_iterator > active_cell_iterators() const
IteratorRange< level_cell_iterator > mg_cell_iterators() const
IteratorRange< cell_iterator > cell_iterators_on_level(const unsigned int level) const
IteratorRange< cell_iterator > cell_iterators() const
IteratorRange< active_cell_iterator > active_cell_iterators_on_level(const unsigned int level) const
IteratorRange< cell_iterator > cell_iterators_on_level(const unsigned int level) const
IteratorRange< cell_iterator > cell_iterators() const
IteratorRange< level_cell_iterator > mg_cell_iterators_on_level(const unsigned int level) const
static ::ExceptionBase & ExcInvalidBoundaryIndicator()
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcNoDominatedFiniteElementOnChildren()
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcNoFESelected()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
void exchange_cell_data_to_ghosts(const MeshType &mesh, const std::function< std_cxx17::optional< DataType >(const typename MeshType::active_cell_iterator &)> &pack, const std::function< void(const typename MeshType::active_cell_iterator &, const DataType &)> &unpack, const std::function< bool(const typename MeshType::active_cell_iterator &)> &cell_filter=always_return< typename MeshType::active_cell_iterator, bool >{true})
Task< RT > new_task(const std::function< RT()> &function)
void refine(Triangulation< dim, spacedim > &tria, const Vector< Number > &criteria, const double threshold, const unsigned int max_to_mark=numbers::invalid_unsigned_int)
void coarsen(Triangulation< dim, spacedim > &tria, const Vector< Number > &criteria, const double threshold)
@ valid
Iterator points to a valid object.
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
void swap(MemorySpaceData< Number, MemorySpace > &, MemorySpaceData< Number, MemorySpace > &)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
VectorType::value_type * end(VectorType &V)
VectorType::value_type * begin(VectorType &V)
TrilinosWrappers::types::int_type global_index(const Epetra_BlockMap &map, const ::types::global_dof_index i)
T sum(const T &t, const MPI_Comm &mpi_communicator)
size_t pack(const T &object, std::vector< char > &dest_buffer, const bool allow_compression=true)
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
T unpack(const std::vector< char > &buffer, const bool allow_compression=true)
unsigned int n_active_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
unsigned int dominated_future_fe_on_children(const typename DoFHandler< dim, spacedim >::cell_iterator &parent)
void communicate_future_fe_indices(DoFHandler< dim, spacedim > &dof_handler)
void reinit(MatrixBlock< MatrixType > &v, const BlockSparsityPattern &p)
std::string policy_to_string(const ::internal::DoFHandlerImplementation::Policy::PolicyBase< dim, spacedim > &policy)
const types::boundary_id internal_face_boundary_id
static const unsigned int invalid_unsigned_int
const types::global_dof_index invalid_dof_index
TriangulationBase< dim, spacedim > Triangulation
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
static types::global_dof_index get_dof_index(const DoFHandler< 3, spacedim > &dof_handler, const std::unique_ptr< internal::DoFHandlerImplementation::DoFLevel< 3 > > &mg_level, const std::unique_ptr< internal::DoFHandlerImplementation::DoFFaces< 3 > > &, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const std::integral_constant< int, 3 >)
static void reserve_space_mg(DoFHandler< 3, spacedim > &dof_handler)
static void set_dof_index(const DoFHandler< 3, spacedim > &dof_handler, const std::unique_ptr< internal::DoFHandlerImplementation::DoFLevel< 3 > > &, const std::unique_ptr< internal::DoFHandlerImplementation::DoFFaces< 3 > > &mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const types::global_dof_index global_index, const std::integral_constant< int, 2 >)
static types::global_dof_index get_dof_index(const DoFHandler< 3, spacedim > &dof_handler, const std::unique_ptr< internal::DoFHandlerImplementation::DoFLevel< 3 > > &, const std::unique_ptr< internal::DoFHandlerImplementation::DoFFaces< 3 > > &mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const std::integral_constant< int, 2 >)
static void reserve_space(DoFHandler< dim, spacedim > &dof_handler)
static types::global_dof_index get_dof_index(const DoFHandler< 3, spacedim > &dof_handler, const std::unique_ptr< internal::DoFHandlerImplementation::DoFLevel< 3 > > &, const std::unique_ptr< internal::DoFHandlerImplementation::DoFFaces< 3 > > &mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const std::integral_constant< int, 1 >)
static void set_dof_index(const DoFHandler< 2, spacedim > &dof_handler, const std::unique_ptr< internal::DoFHandlerImplementation::DoFLevel< 2 > > &, const std::unique_ptr< internal::DoFHandlerImplementation::DoFFaces< 2 > > &mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const types::global_dof_index global_index, const std::integral_constant< int, 1 >)
static void set_dof_index(const DoFHandler< 2, spacedim > &dof_handler, const std::unique_ptr< internal::DoFHandlerImplementation::DoFLevel< 2 > > &mg_level, const std::unique_ptr< internal::DoFHandlerImplementation::DoFFaces< 2 > > &, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const types::global_dof_index global_index, const std::integral_constant< int, 2 >)
static void reserve_subentities(DoFHandler< dim, spacedim > &dof_handler, const unsigned int structdim, const unsigned int n_raw_entities, const T &cell_process)
static types::global_dof_index get_dof_index(const DoFHandler< 2, spacedim > &dof_handler, const std::unique_ptr< internal::DoFHandlerImplementation::DoFLevel< 2 > > &, const std::unique_ptr< internal::DoFHandlerImplementation::DoFFaces< 2 > > &mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const std::integral_constant< int, 1 >)
static void set_dof_index(const DoFHandler< 1, spacedim > &dof_handler, const std::unique_ptr< internal::DoFHandlerImplementation::DoFLevel< 1 > > &mg_level, const std::unique_ptr< internal::DoFHandlerImplementation::DoFFaces< 1 > > &, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const types::global_dof_index global_index, const std::integral_constant< int, 1 >)
static unsigned int max_couplings_between_dofs(const DoFHandler< 2, spacedim > &dof_handler)
static void set_dof_index(const DoFHandler< 3, spacedim > &dof_handler, const std::unique_ptr< internal::DoFHandlerImplementation::DoFLevel< 3 > > &, const std::unique_ptr< internal::DoFHandlerImplementation::DoFFaces< 3 > > &mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const types::global_dof_index global_index, const std::integral_constant< int, 1 >)
static void set_dof_index(const DoFHandler< 3, spacedim > &dof_handler, const std::unique_ptr< internal::DoFHandlerImplementation::DoFLevel< 3 > > &mg_level, const std::unique_ptr< internal::DoFHandlerImplementation::DoFFaces< 3 > > &, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const types::global_dof_index global_index, const std::integral_constant< int, 3 >)
static void reset_to_empty_objects(DoFHandler< dim, spacedim > &dof_handler)
static unsigned int max_couplings_between_dofs(const DoFHandler< 3, spacedim > &dof_handler)
static void reserve_space_mg(DoFHandler< 1, spacedim > &dof_handler)
static types::global_dof_index get_dof_index(const DoFHandler< 2, spacedim > &dof_handler, const std::unique_ptr< internal::DoFHandlerImplementation::DoFLevel< 2 > > &mg_level, const std::unique_ptr< internal::DoFHandlerImplementation::DoFFaces< 2 > > &, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const std::integral_constant< int, 2 >)
static unsigned int max_couplings_between_dofs(const DoFHandler< 1, spacedim > &dof_handler)
static void reserve_space_mg(DoFHandler< 2, spacedim > &dof_handler)
static types::global_dof_index get_dof_index(const DoFHandler< 1, spacedim > &dof_handler, const std::unique_ptr< internal::DoFHandlerImplementation::DoFLevel< 1 > > &mg_level, const std::unique_ptr< internal::DoFHandlerImplementation::DoFFaces< 1 > > &, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const std::integral_constant< int, 1 >)
static void reserve_cells(DoFHandler< dim, spacedim > &dof_handler, const unsigned int n_inner_dofs_per_cell)
static void collect_fe_indices_on_cells_to_be_refined(DoFHandler< dim, spacedim > &dof_handler)
static unsigned int determine_fe_from_children(const typename Triangulation< dim, spacedim >::cell_iterator &, const std::vector< unsigned int > &children_fe_indices, const ::hp::FECollection< dim, spacedim > &fe_collection)
static void reserve_space_cells(DoFHandler< dim, spacedim > &dof_handler)
static unsigned int dominated_future_fe_on_children(const typename DoFHandler< dim, spacedim >::cell_iterator &parent)
static void distribute_fe_indices_on_refined_cells(DoFHandler< dim, spacedim > &dof_handler)
static void ensure_absence_of_future_fe_indices(DoFHandler< dim, spacedim > &dof_handler)
static void reserve_space(::DoFHandler< 1, spacedim > &dof_handler)
static void reserve_space_faces(DoFHandler< dim, spacedim > &dof_handler)
static void communicate_future_fe_indices(DoFHandler< dim, spacedim > &dof_handler)
static void communicate_active_fe_indices(DoFHandler< dim, spacedim > &dof_handler)
static void reserve_space_vertices(DoFHandler< dim, spacedim > &dof_handler)
static void reserve_space(::DoFHandler< 2, spacedim > &dof_handler)
static void reserve_space(::DoFHandler< 3, spacedim > &dof_handler)