20#include <deal.II/base/mpi.templates.h>
23#include <deal.II/distributed/cell_data_transfer.templates.h>
41#include <unordered_set>
45template <
int dim,
int spacedim>
52 template <
int dim,
int spacedim>
55 PolicyBase<dim, spacedim> &policy)
58 if (
dynamic_cast<const typename ::internal::DoFHandlerImplementation::
59 Policy::Sequential<dim, spacedim> *
>(&policy) ||
60 dynamic_cast<const typename ::internal::DoFHandlerImplementation::
61 Policy::Sequential<dim, spacedim> *
>(&policy))
63 else if (
dynamic_cast<
64 const typename ::internal::DoFHandlerImplementation::
65 Policy::ParallelDistributed<dim, spacedim> *
>(&policy) ||
67 const typename ::internal::DoFHandlerImplementation::
68 Policy::ParallelDistributed<dim, spacedim> *
>(&policy))
70 else if (
dynamic_cast<
71 const typename ::internal::DoFHandlerImplementation::
72 Policy::ParallelShared<dim, spacedim> *
>(&policy) ||
74 const typename ::internal::DoFHandlerImplementation::
75 Policy::ParallelShared<dim, spacedim> *
>(&policy))
85 namespace DoFHandlerImplementation
97 template <
int spacedim>
102 3 * dof_handler.fe_collection.max_dofs_per_vertex() +
103 2 * dof_handler.fe_collection.max_dofs_per_line()),
104 dof_handler.n_dofs());
107 template <
int spacedim>
133 switch (dof_handler.tria->max_adjacent_cells())
137 19 * dof_handler.fe_collection.max_dofs_per_vertex() +
138 28 * dof_handler.fe_collection.max_dofs_per_line() +
139 8 * dof_handler.fe_collection.max_dofs_per_quad();
143 21 * dof_handler.fe_collection.max_dofs_per_vertex() +
144 31 * dof_handler.fe_collection.max_dofs_per_line() +
145 9 * dof_handler.fe_collection.max_dofs_per_quad();
149 28 * dof_handler.fe_collection.max_dofs_per_vertex() +
150 42 * dof_handler.fe_collection.max_dofs_per_line() +
151 12 * dof_handler.fe_collection.max_dofs_per_quad();
155 30 * dof_handler.fe_collection.max_dofs_per_vertex() +
156 45 * dof_handler.fe_collection.max_dofs_per_line() +
157 13 * dof_handler.fe_collection.max_dofs_per_quad();
161 37 * dof_handler.fe_collection.max_dofs_per_vertex() +
162 56 * dof_handler.fe_collection.max_dofs_per_line() +
163 16 * dof_handler.fe_collection.max_dofs_per_quad();
172 39 * dof_handler.fe_collection.max_dofs_per_vertex() +
173 59 * dof_handler.fe_collection.max_dofs_per_line() +
174 17 * dof_handler.fe_collection.max_dofs_per_quad();
178 46 * dof_handler.fe_collection.max_dofs_per_vertex() +
179 70 * dof_handler.fe_collection.max_dofs_per_line() +
180 20 * dof_handler.fe_collection.max_dofs_per_quad();
184 48 * dof_handler.fe_collection.max_dofs_per_vertex() +
185 73 * dof_handler.fe_collection.max_dofs_per_line() +
186 21 * dof_handler.fe_collection.max_dofs_per_quad();
190 55 * dof_handler.fe_collection.max_dofs_per_vertex() +
191 84 * dof_handler.fe_collection.max_dofs_per_line() +
192 24 * dof_handler.fe_collection.max_dofs_per_quad();
196 57 * dof_handler.fe_collection.max_dofs_per_vertex() +
197 87 * dof_handler.fe_collection.max_dofs_per_line() +
198 25 * dof_handler.fe_collection.max_dofs_per_quad();
202 63 * dof_handler.fe_collection.max_dofs_per_vertex() +
203 98 * dof_handler.fe_collection.max_dofs_per_line() +
204 28 * dof_handler.fe_collection.max_dofs_per_quad();
208 65 * dof_handler.fe_collection.max_dofs_per_vertex() +
209 103 * dof_handler.fe_collection.max_dofs_per_line() +
210 29 * dof_handler.fe_collection.max_dofs_per_quad();
214 72 * dof_handler.fe_collection.max_dofs_per_vertex() +
215 114 * dof_handler.fe_collection.max_dofs_per_line() +
216 32 * dof_handler.fe_collection.max_dofs_per_quad();
226 template <
int spacedim>
239 const unsigned int max_adjacent_cells =
240 dof_handler.tria->max_adjacent_cells();
243 if (max_adjacent_cells <= 8)
245 7 * 7 * 7 * dof_handler.fe_collection.max_dofs_per_vertex() +
246 7 * 6 * 7 * 3 * dof_handler.fe_collection.max_dofs_per_line() +
247 9 * 4 * 7 * 3 * dof_handler.fe_collection.max_dofs_per_quad() +
248 27 * dof_handler.fe_collection.max_dofs_per_hex();
262 template <
int dim,
int spacedim>
266 dof_handler.object_dof_indices.clear();
267 dof_handler.object_dof_indices.resize(dof_handler.tria->n_levels());
268 dof_handler.object_dof_indices.shrink_to_fit();
270 dof_handler.object_dof_ptr.clear();
271 dof_handler.object_dof_ptr.resize(dof_handler.tria->n_levels());
272 dof_handler.object_dof_ptr.shrink_to_fit();
278 template <
int dim,
int spacedim>
283 for (
unsigned int i = 0; i < dof_handler.tria->n_levels(); ++i)
285 dof_handler.object_dof_ptr[i][dim].assign(
286 dof_handler.tria->n_raw_cells(i) + 1, 0);
288 for (
const auto &cell :
289 dof_handler.tria->cell_iterators_on_level(i))
290 if (cell->is_active() && !cell->is_artificial())
291 dof_handler.object_dof_ptr[i][dim][cell->index() + 1] =
294 for (
unsigned int j = 0;
j < dof_handler.tria->n_raw_cells(i); ++
j)
295 dof_handler.object_dof_ptr[i][dim][
j + 1] +=
296 dof_handler.object_dof_ptr[i][dim][
j];
298 dof_handler.object_dof_indices[i][dim].resize(
299 dof_handler.object_dof_ptr[i][dim].back(),
308 template <
int dim,
int spacedim,
typename T>
311 const unsigned int structdim,
315 if (dof_handler.tria->n_cells() == 0)
318 dof_handler.object_dof_ptr[0][structdim].assign(
n_raw_entities + 1, -1);
320 for (
const auto &cell : dof_handler.tria->cell_iterators())
321 if (cell->is_active() && !cell->is_artificial())
325 const unsigned int index) {
327 dof_handler.object_dof_ptr[0][structdim][
index + 1];
342 dof_handler.object_dof_ptr[0][structdim][0] = 0;
345 if (dof_handler.object_dof_ptr[0][structdim][i] ==
348 dof_handler.object_dof_ptr[0][structdim][i] =
349 dof_handler.object_dof_ptr[0][structdim][i - 1];
351 dof_handler.object_dof_ptr[0][structdim][i] +=
352 dof_handler.object_dof_ptr[0][structdim][i - 1];
356 dof_handler.object_dof_indices[0][structdim].resize(
357 dof_handler.object_dof_ptr[0][structdim].back(),
367 template <
int dim,
int spacedim>
373 const auto &fe = dof_handler.get_fe();
377 dim == 1 ? fe.n_dofs_per_line() :
378 (dim == 2 ? fe.n_dofs_per_quad(0) :
379 fe.n_dofs_per_hex()));
384 dof_handler.tria->n_vertices(),
385 [&](
const auto &cell,
const auto &process) {
386 for (const auto vertex_index :
387 cell->vertex_indices())
388 process(fe.n_dofs_per_vertex(),
389 cell->vertex_index(vertex_index));
393 if (dim == 2 || dim == 3)
396 dof_handler.tria->n_raw_lines(),
397 [&](
const auto &cell,
const auto &process) {
398 for (const auto line_index :
399 cell->line_indices())
400 process(fe.n_dofs_per_line(),
401 cell->line(line_index)->index());
408 dof_handler.tria->n_raw_quads(),
409 [&](
const auto &cell,
const auto &process) {
410 for (const auto face_index :
411 cell->face_indices())
412 process(fe.n_dofs_per_quad(face_index),
413 cell->face(face_index)->index());
417 template <
int spacedim>
421 Assert(dof_handler.get_triangulation().n_levels() > 0,
423 dof_handler.clear_mg_space();
425 const ::Triangulation<1, spacedim> &
tria =
426 dof_handler.get_triangulation();
427 const unsigned int dofs_per_line =
428 dof_handler.get_fe().n_dofs_per_line();
429 const unsigned int n_levels =
tria.n_levels();
431 for (
unsigned int i = 0; i < n_levels; ++i)
433 dof_handler.mg_levels.emplace_back(
435 dof_handler.mg_levels.back()->dof_object.dofs =
436 std::vector<types::global_dof_index>(
tria.n_raw_lines(i) *
441 const unsigned int n_vertices =
tria.n_vertices();
443 dof_handler.mg_vertex_dofs.resize(n_vertices);
445 std::vector<unsigned int> max_level(n_vertices, 0);
446 std::vector<unsigned int> min_level(n_vertices, n_levels);
448 for (typename ::Triangulation<1, spacedim>::cell_iterator cell =
453 const unsigned int level = cell->level();
455 for (
const auto vertex : cell->vertex_indices())
457 const unsigned int vertex_index = cell->vertex_index(vertex);
459 if (min_level[vertex_index] >
level)
460 min_level[vertex_index] =
level;
462 if (max_level[vertex_index] <
level)
463 max_level[vertex_index] =
level;
467 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
468 if (
tria.vertex_used(vertex))
471 Assert(max_level[vertex] >= min_level[vertex],
473 dof_handler.mg_vertex_dofs[vertex].init(
476 dof_handler.get_fe().n_dofs_per_vertex());
483 dof_handler.mg_vertex_dofs[vertex].init(1, 0, 0);
487 template <
int spacedim>
491 Assert(dof_handler.get_triangulation().n_levels() > 0,
493 dof_handler.clear_mg_space();
497 dof_handler.get_triangulation();
498 const unsigned int n_levels =
tria.n_levels();
500 for (
unsigned int i = 0; i < n_levels; ++i)
502 dof_handler.mg_levels.emplace_back(
505 dof_handler.mg_levels.back()->dof_object.dofs =
506 std::vector<types::global_dof_index>(
507 tria.n_raw_quads(i) *
508 fe.n_dofs_per_quad(0 ),
512 dof_handler.mg_faces =
513 std::make_unique<internal::DoFHandlerImplementation::DoFFaces<2>>();
514 dof_handler.mg_faces->lines.dofs =
515 std::vector<types::global_dof_index>(
tria.n_raw_lines() *
516 fe.n_dofs_per_line(),
519 const unsigned int n_vertices =
tria.n_vertices();
521 dof_handler.mg_vertex_dofs.resize(n_vertices);
523 std::vector<unsigned int> max_level(n_vertices, 0);
524 std::vector<unsigned int> min_level(n_vertices, n_levels);
526 for (typename ::Triangulation<2, spacedim>::cell_iterator cell =
531 const unsigned int level = cell->level();
533 for (
const auto vertex : cell->vertex_indices())
535 const unsigned int vertex_index = cell->vertex_index(vertex);
537 if (min_level[vertex_index] >
level)
538 min_level[vertex_index] =
level;
540 if (max_level[vertex_index] <
level)
541 max_level[vertex_index] =
level;
545 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
546 if (
tria.vertex_used(vertex))
549 Assert(max_level[vertex] >= min_level[vertex],
551 dof_handler.mg_vertex_dofs[vertex].init(min_level[vertex],
553 fe.n_dofs_per_vertex());
560 dof_handler.mg_vertex_dofs[vertex].init(1, 0, 0);
564 template <
int spacedim>
568 Assert(dof_handler.get_triangulation().n_levels() > 0,
570 dof_handler.clear_mg_space();
574 dof_handler.get_triangulation();
575 const unsigned int n_levels =
tria.n_levels();
577 for (
unsigned int i = 0; i < n_levels; ++i)
579 dof_handler.mg_levels.emplace_back(
582 dof_handler.mg_levels.back()->dof_object.dofs =
583 std::vector<types::global_dof_index>(
tria.n_raw_hexs(i) *
588 dof_handler.mg_faces =
589 std::make_unique<internal::DoFHandlerImplementation::DoFFaces<3>>();
590 dof_handler.mg_faces->lines.dofs =
591 std::vector<types::global_dof_index>(
tria.n_raw_lines() *
592 fe.n_dofs_per_line(),
598 dof_handler.mg_faces->quads.dofs = std::vector<types::global_dof_index>(
599 tria.n_raw_quads() * fe.n_dofs_per_quad(0 ),
602 const unsigned int n_vertices =
tria.n_vertices();
604 dof_handler.mg_vertex_dofs.resize(n_vertices);
606 std::vector<unsigned int> max_level(n_vertices, 0);
607 std::vector<unsigned int> min_level(n_vertices, n_levels);
609 for (typename ::Triangulation<3, spacedim>::cell_iterator cell =
614 const unsigned int level = cell->level();
616 for (
const auto vertex : cell->vertex_indices())
618 const unsigned int vertex_index = cell->vertex_index(vertex);
620 if (min_level[vertex_index] >
level)
621 min_level[vertex_index] =
level;
623 if (max_level[vertex_index] <
level)
624 max_level[vertex_index] =
level;
628 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
629 if (
tria.vertex_used(vertex))
632 Assert(max_level[vertex] >= min_level[vertex],
634 dof_handler.mg_vertex_dofs[vertex].init(min_level[vertex],
636 fe.n_dofs_per_vertex());
643 dof_handler.mg_vertex_dofs[vertex].init(1, 0, 0);
653 namespace DoFHandlerImplementation
666 template <
int dim,
int spacedim>
672 for (
const auto &cell : dof_handler.active_cell_iterators())
673 if (cell->is_locally_owned())
675 !cell->future_fe_index_set(),
677 "There shouldn't be any cells flagged for p-adaptation when partitioning."));
686 template <
int dim,
int spacedim>
703 dof_handler.tria->n_vertices(),
false);
704 for (
const auto &cell : dof_handler.active_cell_iterators())
705 if (!cell->is_artificial())
706 for (
const auto v : cell->vertex_indices())
710 dof_handler.fe_collection.
size(),
711 std::vector<bool>(dof_handler.tria->n_vertices(),
false));
713 for (
const auto &cell : dof_handler.active_cell_iterators())
714 if (!cell->is_artificial())
715 for (
const auto v : cell->vertex_indices())
717 [cell->vertex_index(v)] =
true;
725 for (
unsigned int v = 0; v < dof_handler.tria->n_vertices(); ++v)
727 if (dof_handler.tria->vertex_used(v) ==
true)
730 for (; fe < dof_handler.fe_collection.
size(); ++fe)
733 Assert(fe != dof_handler.fe_collection.
size(),
738 const unsigned int d = 0;
739 const unsigned int l = 0;
741 dof_handler.hp_object_fe_ptr[d].clear();
742 dof_handler.hp_object_fe_indices[d].clear();
743 dof_handler.object_dof_ptr[l][d].clear();
744 dof_handler.object_dof_indices[l][d].clear();
746 dof_handler.hp_object_fe_ptr[d].reserve(
747 dof_handler.tria->n_vertices() + 1);
752 for (
unsigned int v = 0; v < dof_handler.tria->n_vertices(); ++v)
758 for (
unsigned int fe = 0;
759 fe < dof_handler.fe_collection.
size();
765 dof_handler.get_fe(fe).n_dofs_per_vertex();
777 for (
unsigned int v = 0; v < dof_handler.tria->n_vertices(); ++v)
780 for (
unsigned int fe = 0; fe < dof_handler.fe_collection.
size();
784 dof_handler.hp_object_fe_indices[d].push_back(fe);
785 dof_handler.object_dof_ptr[l][d].push_back(
786 dof_handler.object_dof_indices[l][d].
size());
788 for (
unsigned int i = 0;
789 i < dof_handler.get_fe(fe).n_dofs_per_vertex();
791 dof_handler.object_dof_indices[l][d].push_back(
797 dof_handler.object_dof_ptr[l][d].push_back(
798 dof_handler.object_dof_indices[l][d].
size());
801 dof_handler.object_dof_indices[l][d].
size());
803 dof_handler.hp_object_fe_indices[d].
size());
805 dof_handler.object_dof_ptr[l][d].
size());
807 dof_handler.hp_object_fe_ptr[d].
size());
809 dof_handler.object_dof_indices[l][d].assign(
819 template <
int dim,
int spacedim>
832 for (
unsigned int level = 0;
level < dof_handler.tria->n_levels();
835 dof_handler.object_dof_ptr[
level][dim] =
836 std::vector<typename DoFHandler<dim, spacedim>::offset_type>(
837 dof_handler.tria->n_raw_cells(
level),
843 dof_handler.active_cell_iterators_on_level(
level))
844 if (cell->is_active() && !cell->is_artificial())
846 dof_handler.object_dof_ptr[
level][dim][cell->index()] =
852 dof_handler.object_dof_indices[
level][dim] =
853 std::vector<types::global_dof_index>(
864 template <
int dim,
int spacedim>
886 dof_handler.tria->n_raw_lines() :
887 dof_handler.tria->n_raw_quads());
889 const unsigned int d = dim - 1;
890 const unsigned int l = 0;
892 dof_handler.hp_object_fe_ptr[d].clear();
893 dof_handler.hp_object_fe_indices[d].clear();
894 dof_handler.object_dof_ptr[l][d].clear();
895 dof_handler.object_dof_indices[l][d].clear();
897 dof_handler.hp_object_fe_ptr[d].resize(
898 dof_handler.tria->n_raw_faces() + 1);
904 for (
const auto &cell : dof_handler.active_cell_iterators())
905 if (!cell->is_artificial())
906 for (
const auto face : cell->face_indices())
911 if (cell->at_boundary(face) ||
912 cell->face(face)->has_children() ||
913 cell->neighbor_is_coarser(face) ||
914 (!cell->at_boundary(face) &&
915 cell->neighbor(face)->is_artificial()) ||
916 (!cell->at_boundary(face) &&
917 !cell->neighbor(face)->is_artificial() &&
918 (cell->active_fe_index() ==
919 cell->neighbor(face)->active_fe_index())))
923 dof_handler.get_fe(cell->active_fe_index())
930 dof_handler.get_fe(cell->active_fe_index())
933 .get_fe(cell->neighbor(face)->active_fe_index())
935 cell->neighbor_face_no(face));
942 .hp_object_fe_ptr[d][cell->face(face)->index() + 1] =
946 for (
unsigned int i = 1; i < dof_handler.hp_object_fe_ptr[d].
size();
948 dof_handler.hp_object_fe_ptr[d][i] +=
949 dof_handler.hp_object_fe_ptr[d][i - 1];
952 dof_handler.hp_object_fe_indices[d].resize(
953 dof_handler.hp_object_fe_ptr[d].back());
954 dof_handler.object_dof_ptr[l][d].resize(
955 dof_handler.hp_object_fe_ptr[d].back() + 1);
957 dof_handler.object_dof_indices[l][d].reserve(
n_face_slots);
965 for (
const auto &cell : dof_handler.active_cell_iterators())
966 if (!cell->is_artificial())
967 for (
const auto face : cell->face_indices())
971 if (cell->at_boundary(face) ||
972 cell->face(face)->has_children() ||
973 cell->neighbor_is_coarser(face) ||
974 (!cell->at_boundary(face) &&
975 cell->neighbor(face)->is_artificial()) ||
976 (!cell->at_boundary(face) &&
977 !cell->neighbor(face)->is_artificial() &&
978 (cell->active_fe_index() ==
979 cell->neighbor(face)->active_fe_index())))
982 const unsigned int n_dofs =
983 dof_handler.get_fe(fe)
984 .template n_dofs_per_object<dim - 1>(face);
985 const unsigned int offset =
987 .hp_object_fe_ptr[d][cell->face(face)->index()];
989 dof_handler.hp_object_fe_indices[d][offset] = fe;
990 dof_handler.object_dof_ptr[l][d][offset + 1] = n_dofs;
992 for (
unsigned int i = 0; i < n_dofs; ++i)
993 dof_handler.object_dof_indices[l][d].push_back(
1001 cell->neighbor(face)->active_fe_index();
1002 unsigned int face_no_2 = cell->neighbor_face_no(face);
1011 dof_handler.get_fe(
fe_1)
1012 .template n_dofs_per_object<dim - 1>(
face_no_1);
1015 dof_handler.get_fe(
fe_2)
1016 .template n_dofs_per_object<dim - 1>(
face_no_2);
1018 const unsigned int offset =
1020 .hp_object_fe_ptr[d][cell->face(face)->index()];
1022 dof_handler.hp_object_fe_indices[d].push_back(
1023 cell->active_fe_index());
1024 dof_handler.object_dof_ptr[l][d].push_back(
1025 dof_handler.object_dof_indices[l][d].
size());
1027 dof_handler.hp_object_fe_indices[d][offset + 0] =
1029 dof_handler.hp_object_fe_indices[d][offset + 1] =
1031 dof_handler.object_dof_ptr[l][d][offset + 1] =
1033 dof_handler.object_dof_ptr[l][d][offset + 2] =
1038 dof_handler.object_dof_indices[l][d].push_back(
1046 for (
unsigned int i = 1;
1047 i < dof_handler.object_dof_ptr[l][d].
size();
1049 dof_handler.object_dof_ptr[l][d][i] +=
1050 dof_handler.object_dof_ptr[l][d][i - 1];
1062 template <
int spacedim>
1068 Assert(dof_handler.tria->n_levels() > 0,
1069 ExcMessage(
"The current Triangulation must not be empty."));
1070 Assert(dof_handler.tria->n_levels() ==
1071 dof_handler.hp_cell_future_fe_indices.
size(),
1087 template <
int spacedim>
1093 Assert(dof_handler.tria->n_levels() > 0,
1094 ExcMessage(
"The current Triangulation must not be empty."));
1095 Assert(dof_handler.tria->n_levels() ==
1096 dof_handler.hp_cell_future_fe_indices.
size(),
1114 template <
int spacedim>
1120 Assert(dof_handler.tria->n_levels() > 0,
1121 ExcMessage(
"The current Triangulation must not be empty."));
1122 Assert(dof_handler.tria->n_levels() ==
1123 dof_handler.hp_cell_future_fe_indices.
size(),
1151 dof_handler.fe_collection.
size(),
1152 std::vector<bool>(dof_handler.tria->n_raw_lines(),
false));
1154 for (
const auto &cell : dof_handler.active_cell_iterators())
1155 if (!cell->is_artificial())
1156 for (
const auto l : cell->line_indices())
1158 [cell->line_index(l)] =
true;
1164 std::vector<bool>
line_is_used(dof_handler.tria->n_raw_lines(),
1166 for (
unsigned int line = 0; line < dof_handler.tria->n_raw_lines();
1168 for (
unsigned int fe = 0; fe < dof_handler.fe_collection.
size();
1178 const unsigned int d = 1;
1179 const unsigned int l = 0;
1181 dof_handler.hp_object_fe_ptr[d].clear();
1182 dof_handler.hp_object_fe_indices[d].clear();
1183 dof_handler.object_dof_ptr[l][d].clear();
1184 dof_handler.object_dof_indices[l][d].clear();
1186 dof_handler.hp_object_fe_ptr[d].reserve(
1187 dof_handler.tria->n_raw_lines() + 1);
1192 for (
unsigned int line = 0; line < dof_handler.tria->n_raw_lines();
1199 for (
unsigned int fe = 0;
1200 fe < dof_handler.fe_collection.
size();
1206 dof_handler.get_fe(fe).n_dofs_per_line();
1215 dof_handler.tria->n_raw_lines() + 1);
1222 for (
unsigned int line = 0; line < dof_handler.tria->n_raw_lines();
1226 for (
unsigned int fe = 0;
1227 fe < dof_handler.fe_collection.
size();
1231 dof_handler.hp_object_fe_indices[d].push_back(fe);
1232 dof_handler.object_dof_ptr[l][d].push_back(
1233 dof_handler.object_dof_indices[l][d].
size());
1235 for (
unsigned int i = 0;
1236 i < dof_handler.get_fe(fe).n_dofs_per_line();
1238 dof_handler.object_dof_indices[l][d].push_back(
1243 dof_handler.object_dof_ptr[l][d].push_back(
1244 dof_handler.object_dof_indices[l][d].
size());
1272 template <
int dim,
int spacedim>
1277 dof_handler.hp_capability_enabled ==
true,
1280 if (const ::parallel::shared::Triangulation<dim, spacedim> *
tr =
1282 const ::parallel::shared::Triangulation<dim, spacedim>
1283 *
>(&dof_handler.get_triangulation()))
1295 std::vector<types::fe_index> active_fe_indices(
1296 tr->n_active_cells(), 0
u);
1297 for (
const auto &cell : dof_handler.active_cell_iterators())
1298 if (cell->is_locally_owned())
1299 active_fe_indices[cell->active_cell_index()] =
1300 cell->active_fe_index();
1303 tr->get_communicator(),
1312 for (
const auto &cell : dof_handler.active_cell_iterators())
1313 if (!cell->is_locally_owned())
1315 .hp_cell_active_fe_indices[cell->level()][cell->index()] =
1316 active_fe_indices[cell->active_cell_index()];
1318 else if (const ::parallel::
1322 DistributedTriangulationBase<dim, spacedim> *
>(
1323 &dof_handler.get_triangulation()))
1335 return cell->active_fe_index();
1348 .hp_cell_active_fe_indices[cell->level()][cell->index()] =
1361 const ::parallel::TriangulationBase<dim, spacedim> *
>(
1362 &dof_handler.get_triangulation()) ==
nullptr),
1382 template <
int dim,
int spacedim>
1387 dof_handler.hp_capability_enabled ==
true,
1390 if (const ::parallel::shared::Triangulation<dim, spacedim> *
tr =
1392 const ::parallel::shared::Triangulation<dim, spacedim>
1393 *
>(&dof_handler.get_triangulation()))
1396 tr->n_active_cells(), 0
u);
1397 for (
const auto &cell : dof_handler.active_cell_iterators() |
1401 .hp_cell_future_fe_indices[cell->level()][cell->index()];
1404 tr->get_communicator(),
1407 for (
const auto &cell : dof_handler.active_cell_iterators())
1408 if (!cell->is_locally_owned())
1410 .hp_cell_future_fe_indices[cell->level()][cell->index()] =
1413 else if (const ::parallel::
1417 DistributedTriangulationBase<dim, spacedim> *
>(
1418 &dof_handler.get_triangulation()))
1425 .hp_cell_future_fe_indices[cell->level()][cell->index()];
1434 .hp_cell_future_fe_indices[cell->level()][cell->index()] =
1446 const ::parallel::TriangulationBase<dim, spacedim> *
>(
1447 &dof_handler.get_triangulation()) ==
nullptr),
1474 template <
int dim,
int spacedim>
1479 const auto &
fe_transfer = dof_handler.active_fe_index_transfer;
1481 for (
const auto &cell : dof_handler.active_cell_iterators())
1482 if (cell->is_locally_owned())
1484 if (cell->refine_flag_set())
1490 {cell, cell->future_fe_index()});
1492 else if (cell->coarsen_flag_set())
1499 const auto &parent = cell->parent();
1503 if (
fe_transfer->coarsened_cells_fe_index.find(parent) ==
1511 for (
const auto &child : parent->child_iterators())
1512 Assert(child->is_active() &&
1513 child->coarsen_flag_set(),
1514 typename ::Triangulation<
1515 dim>::ExcInconsistentCoarseningFlags());
1519 DoFHandlerImplementation::Implementation::
1520 dominated_future_fe_on_children<dim, spacedim>(
1524 {parent, fe_index});
1532 if (cell->future_fe_index_set() ==
true)
1534 {cell, cell->future_fe_index()});
1545 template <
int dim,
int spacedim>
1550 const auto &
fe_transfer = dof_handler.active_fe_index_transfer;
1555 const auto &cell =
persist.first;
1557 if (cell->is_locally_owned())
1560 cell->set_active_fe_index(
persist.second);
1566 for (
const auto &refine :
fe_transfer->refined_cells_fe_index)
1568 const auto &parent = refine.first;
1570 for (
const auto &child : parent->child_iterators())
1571 if (child->is_locally_owned())
1574 child->set_active_fe_index(refine.second);
1580 for (
const auto &coarsen :
fe_transfer->coarsened_cells_fe_index)
1582 const auto &cell = coarsen.first;
1584 if (cell->is_locally_owned())
1587 cell->set_active_fe_index(coarsen.second);
1603 template <
int dim,
int spacedim>
1608 const ::hp::FECollection<dim, spacedim> &fe_collection)
1635 template <
int dim,
int spacedim>
1641 !parent->is_active(),
1643 "You ask for information on children of this cell which is only "
1644 "available for active cells. This cell has no children."));
1646 const auto &dof_handler = parent->get_dof_handler();
1648 dof_handler.has_hp_capabilities(),
1653 for (
const auto &child : parent->child_iterators())
1658 "You ask for information on children of this cell which is only "
1659 "available for active cells. One of its children is not active."));
1668 ::internal::DoFCellAccessorImplementation::
1669 Implementation::future_fe_index<dim, spacedim, false>(*child);
1676 dof_handler.fe_collection.find_dominated_fe_extended(
1683 return future_fe_index;
1692 template <
int dim,
int spacedim>
1696 Implementation::communicate_future_fe_indices<dim, spacedim>(
1705 template <
int dim,
int spacedim>
1710 return Implementation::dominated_future_fe_on_children<dim, spacedim>(
1719template <
int dim,
int spacedim>
1722 : hp_capability_enabled(
true)
1729template <
int dim,
int spacedim>
1739template <
int dim,
int spacedim>
1744 for (
auto &connection :
this->tria_listeners)
1745 connection.disconnect();
1746 this->tria_listeners.clear();
1748 for (
auto &connection :
this->tria_listeners_for_transfer)
1749 connection.disconnect();
1750 this->tria_listeners_for_transfer.clear();
1761 this->policy.reset();
1766template <
int dim,
int spacedim>
1774 for (
auto &connection :
this->tria_listeners)
1775 connection.disconnect();
1776 this->tria_listeners.clear();
1778 for (
auto &connection :
this->tria_listeners_for_transfer)
1779 connection.disconnect();
1780 this->tria_listeners_for_transfer.clear();
1784 this->policy.reset();
1794 this->setup_policy();
1797 hp_capability_enabled =
true;
1798 this->connect_to_triangulation_signals();
1799 this->create_active_fe_table();
1806template <
int dim,
int spacedim>
1812 this->get_triangulation().begin(
level);
1813 if (cell == this->get_triangulation().
end(
level))
1815 return cell_iterator(*cell,
this);
1820template <
int dim,
int spacedim>
1829 while (i->has_children())
1837template <
int dim,
int spacedim>
1842 return cell_iterator(&this->get_triangulation(), -1, -1,
this);
1847template <
int dim,
int spacedim>
1853 this->get_triangulation().end(
level);
1856 return cell_iterator(*cell,
this);
1861template <
int dim,
int spacedim>
1867 this->get_triangulation().end_active(
level);
1869 return active_cell_iterator(
end());
1870 return active_cell_iterator(*cell,
this);
1875template <
int dim,
int spacedim>
1880 Assert(this->has_level_dofs(),
1882 "levels if mg dofs got distributed."));
1884 this->get_triangulation().begin(
level);
1885 if (cell == this->get_triangulation().
end(
level))
1886 return end_mg(
level);
1887 return level_cell_iterator(*cell,
this);
1892template <
int dim,
int spacedim>
1897 Assert(this->has_level_dofs(),
1899 "levels if mg dofs got distributed."));
1901 this->get_triangulation().end(
level);
1904 return level_cell_iterator(*cell,
this);
1909template <
int dim,
int spacedim>
1914 return level_cell_iterator(&this->get_triangulation(), -1, -1,
this);
1919template <
int dim,
int spacedim>
1923 spacedim>::cell_iterators()
const
1931template <
int dim,
int spacedim>
1944template <
int dim,
int spacedim>
1951 begin_mg(), end_mg());
1956template <
int dim,
int spacedim>
1960 spacedim>::cell_iterators_on_level(
const unsigned int level)
const
1968template <
int dim,
int spacedim>
1981template <
int dim,
int spacedim>
1997template <
int dim,
int spacedim>
2001 Assert(!(dim == 2 && spacedim == 3) || hp_capability_enabled ==
false,
2002 ExcNotImplementedWithHP());
2004 Assert(this->fe_collection.size() > 0, ExcNoFESelected());
2008 dofs_on_face.reserve(this->get_fe_collection().max_dofs_per_face());
2017 for (
const auto &cell :
this->active_cell_iterators())
2018 if (cell->is_locally_owned() && cell->at_boundary())
2020 for (
const auto iface : cell->face_indices())
2022 const auto face = cell->face(
iface);
2023 if (face->at_boundary())
2025 const unsigned int dofs_per_face =
2026 cell->get_fe().n_dofs_per_face(
iface);
2029 face->get_dof_indices(
dofs_on_face, cell->active_fe_index());
2030 for (
unsigned int i = 0; i < dofs_per_face; ++i)
2046template <
int dim,
int spacedim>
2049 const std::set<types::boundary_id> &boundary_ids)
const
2051 Assert(!(dim == 2 && spacedim == 3) || hp_capability_enabled ==
false,
2052 ExcNotImplementedWithHP());
2054 Assert(this->fe_collection.size() > 0, ExcNoFESelected());
2057 ExcInvalidBoundaryIndicator());
2063 dofs_on_face.reserve(this->get_fe_collection().max_dofs_per_face());
2067 for (
const auto &cell :
this->active_cell_iterators())
2068 if (cell->is_locally_owned() && cell->at_boundary())
2070 for (
const auto iface : cell->face_indices())
2072 const auto face = cell->face(
iface);
2073 const unsigned int boundary_id = face->boundary_id();
2074 if (face->at_boundary() &&
2075 (boundary_ids.find(boundary_id) != boundary_ids.end()))
2077 const unsigned int dofs_per_face =
2078 cell->get_fe().n_dofs_per_face(
iface);
2081 face->get_dof_indices(
dofs_on_face, cell->active_fe_index());
2082 for (
unsigned int i = 0; i < dofs_per_face; ++i)
2098template <
int dim,
int spacedim>
2114 if (hp_capability_enabled)
2127 if (this->mg_faces !=
nullptr)
2130 for (
unsigned int i = 0; i < this->mg_vertex_dofs.size(); ++i)
2131 mem +=
sizeof(MGVertexDoFs) +
2132 (1 + this->mg_vertex_dofs[i].get_finest_level() -
2133 this->mg_vertex_dofs[i].get_coarsest_level()) *
2142template <
int dim,
int spacedim>
2152template <
int dim,
int spacedim>
2157 Assert(this->tria !=
nullptr,
2159 "You need to set the Triangulation in the DoFHandler using reinit() "
2160 "or in the constructor before you can distribute DoFs."));
2161 Assert(this->tria->n_levels() > 0,
2162 ExcMessage(
"The Triangulation you are using is empty!"));
2166 Assert((
ff.
size() <= std::numeric_limits<types::fe_index>::max()) &&
2168 ExcMessage(
"The given hp::FECollection contains more finite elements "
2169 "than the DoFHandler can cover with active FE indices."));
2174 if ((hp_cell_active_fe_indices.size() > 0) &&
2175 (hp_cell_future_fe_indices.size() > 0))
2179 for (
const auto &cell :
2183 ExcInvalidFEIndex(cell->active_fe_index(),
ff.
size()));
2185 ExcInvalidFEIndex(cell->future_fe_index(),
ff.
size()));
2194 if (this->fe_collection !=
ff)
2203 hp_capability_enabled =
false;
2207 for (
auto &connection :
this->tria_listeners_for_transfer)
2208 connection.disconnect();
2209 this->tria_listeners_for_transfer.clear();
2212 this->hp_cell_active_fe_indices.clear();
2213 this->hp_cell_active_fe_indices.shrink_to_fit();
2214 this->hp_cell_future_fe_indices.clear();
2215 this->hp_cell_future_fe_indices.shrink_to_fit();
2223 "You cannot re-enable hp-capabilities after you registered a single "
2224 "finite element. Please call reinit() or create a new DoFHandler "
2225 "object instead."));
2231 if (hp_capability_enabled)
2258 if (hp_capability_enabled)
2266 this->number_cache = this->policy->distribute_dofs();
2283 if (!hp_capability_enabled &&
2285 *
>(&*this->tria) ==
nullptr)
2286 this->block_info_object.initialize(*
this,
false,
true);
2291template <
int dim,
int spacedim>
2295 AssertThrow(hp_capability_enabled ==
false, ExcNotImplementedWithHP());
2298 this->object_dof_indices.size() > 0,
2300 "Distribute active DoFs using distribute_dofs() before calling distribute_mg_dofs()."));
2303 ((this->tria->get_mesh_smoothing() &
2307 "The mesh smoothing requirement 'limit_level_difference_at_vertices' has to be set for using multigrid!"));
2309 this->clear_mg_space();
2312 this->mg_number_cache = this->policy->distribute_mg_dofs();
2317 &*this->tria) ==
nullptr)
2318 this->block_info_object.initialize(*
this,
true,
false);
2323template <
int dim,
int spacedim>
2327 AssertThrow(hp_capability_enabled ==
false, ExcNotImplementedWithHP());
2329 this->block_info_object.initialize_local(*
this);
2334template <
int dim,
int spacedim>
2339 if (
dynamic_cast<const ::parallel::shared::Triangulation<dim, spacedim>
2340 *
>(&this->get_triangulation()) !=
nullptr)
2341 this->policy = std::make_unique<internal::DoFHandlerImplementation::Policy::
2342 ParallelShared<dim, spacedim>>(*this);
2343 else if (
dynamic_cast<
2344 const ::parallel::DistributedTriangulationBase<dim, spacedim>
2345 *
>(&this->get_triangulation()) ==
nullptr)
2346 this->policy = std::make_unique<
2351 std::make_unique<internal::DoFHandlerImplementation::Policy::
2352 ParallelDistributed<dim, spacedim>>(*this);
2357template <
int dim,
int spacedim>
2362 this->clear_space();
2363 this->clear_mg_space();
2368template <
int dim,
int spacedim>
2372 object_dof_indices.clear();
2374 object_dof_ptr.clear();
2376 this->number_cache.clear();
2378 this->hp_cell_active_fe_indices.clear();
2379 this->hp_cell_future_fe_indices.clear();
2384template <
int dim,
int spacedim>
2388 this->mg_levels.clear();
2389 this->mg_faces.reset();
2391 std::vector<MGVertexDoFs> tmp;
2393 std::swap(this->mg_vertex_dofs, tmp);
2395 this->mg_number_cache.clear();
2400template <
int dim,
int spacedim>
2403 const std::vector<types::global_dof_index> &
new_numbers)
2405 if (hp_capability_enabled)
2407 Assert(this->hp_cell_future_fe_indices.size() > 0,
2409 "You need to distribute DoFs before you can renumber them."));
2418 if (this->n_locally_owned_dofs() == this->n_dofs())
2420 std::vector<types::global_dof_index> tmp(
new_numbers);
2421 std::sort(tmp.begin(), tmp.end());
2422 std::vector<types::global_dof_index>::const_iterator p = tmp.begin();
2424 for (; p != tmp.end(); ++p, ++i)
2425 Assert(*p == i, ExcNewNumbersNotConsecutive(i));
2431 "New DoF index is not less than the total number of dofs."));
2448 this->number_cache = this->policy->renumber_dofs(
new_numbers);
2463 Assert(this->object_dof_indices.size() > 0,
2465 "You need to distribute DoFs before you can renumber them."));
2469 &*this->tria) !=
nullptr)
2473 ExcMessage(
"Incorrect size of the input array."));
2475 else if (
dynamic_cast<
2477 &*this->tria) !=
nullptr)
2490 if (this->n_locally_owned_dofs() == this->n_dofs())
2492 std::vector<types::global_dof_index> tmp(
new_numbers);
2493 std::sort(tmp.begin(), tmp.end());
2494 std::vector<types::global_dof_index>::const_iterator p = tmp.begin();
2496 for (; p != tmp.end(); ++p, ++i)
2497 Assert(*p == i, ExcNewNumbersNotConsecutive(i));
2503 "New DoF index is not less than the total number of dofs."));
2506 this->number_cache = this->policy->renumber_dofs(
new_numbers);
2512template <
int dim,
int spacedim>
2515 const unsigned int level,
2516 const std::vector<types::global_dof_index> &
new_numbers)
2518 AssertThrow(hp_capability_enabled ==
false, ExcNotImplementedWithHP());
2521 this->mg_levels.size() > 0 &&
this->object_dof_indices.
size() > 0,
2523 "You need to distribute active and level DoFs before you can renumber level DoFs."));
2533 if (this->n_locally_owned_dofs() == this->n_dofs())
2535 std::vector<types::global_dof_index> tmp(
new_numbers);
2536 std::sort(tmp.begin(), tmp.end());
2537 std::vector<types::global_dof_index>::const_iterator p = tmp.begin();
2539 for (; p != tmp.end(); ++p, ++i)
2540 Assert(*p == i, ExcNewNumbersNotConsecutive(i));
2546 "New DoF index is not less than the total number of dofs."));
2549 this->mg_number_cache[
level] =
2555template <
int dim,
int spacedim>
2560 Assert(this->fe_collection.size() > 0, ExcNoFESelected());
2565 return this->fe_collection.max_dofs_per_vertex();
2567 return (3 * this->fe_collection.max_dofs_per_vertex() +
2568 2 *
this->fe_collection.max_dofs_per_line());
2579 return (19 * this->fe_collection.max_dofs_per_vertex() +
2580 28 *
this->fe_collection.max_dofs_per_line() +
2581 8 *
this->fe_collection.max_dofs_per_quad());
2590template <
int dim,
int spacedim>
2594 Assert(this->fe_collection.size() > 0, ExcNoFESelected());
2601template <
int dim,
int spacedim>
2604 const std::vector<types::fe_index> &active_fe_indices)
2606 Assert(active_fe_indices.size() ==
this->get_triangulation().n_active_cells(),
2608 this->get_triangulation().n_active_cells()));
2610 this->create_active_fe_table();
2615 for (
const auto &cell :
this->active_cell_iterators())
2616 if (cell->is_locally_owned())
2617 cell->set_active_fe_index(active_fe_indices[cell->active_cell_index()]);
2622template <
int dim,
int spacedim>
2625 const std::vector<unsigned int> &active_fe_indices)
2627 set_active_fe_indices(std::vector<types::fe_index>(active_fe_indices.begin(),
2628 active_fe_indices.end()));
2633template <
int dim,
int spacedim>
2638 std::vector<types::fe_index> active_fe_indices(
2644 for (
const auto &cell :
this->active_cell_iterators())
2645 if (!cell->is_artificial())
2646 active_fe_indices[cell->active_cell_index()] = cell->active_fe_index();
2648 return active_fe_indices;
2653template <
int dim,
int spacedim>
2656 std::vector<unsigned int> &active_fe_indices)
const
2660 active_fe_indices.assign(indices.begin(), indices.end());
2665template <
int dim,
int spacedim>
2672 this->get_triangulation().n_active_cells()));
2674 this->create_active_fe_table();
2679 for (
const auto &cell :
this->active_cell_iterators())
2680 if (cell->is_locally_owned() &&
2688template <
int dim,
int spacedim>
2699 for (
const auto &cell :
this->active_cell_iterators())
2700 if (cell->is_locally_owned() && cell->future_fe_index_set())
2708template <
int dim,
int spacedim>
2713 Assert(hp_capability_enabled, ExcOnlyAvailableWithHP());
2716 this->tria_listeners.push_back(this->tria->signals.create.connect(
2717 [
this]() { this->reinit(*(this->tria)); }));
2718 this->tria_listeners.push_back(
2719 this->tria->signals.clear.connect([
this]() { this->clear(); }));
2724 const ::parallel::fullydistributed::Triangulation<dim, spacedim>
2725 *
>(&this->get_triangulation()))
2729 else if (
dynamic_cast<
2730 const ::parallel::distributed::Triangulation<dim, spacedim>
2731 *
>(&this->get_triangulation()))
2734 this->tria_listeners_for_transfer.push_back(
2735 this->tria->signals.pre_distributed_repartition.connect([
this]() {
2736 internal::hp::DoFHandlerImplementation::Implementation::
2737 ensure_absence_of_future_fe_indices<dim, spacedim>(*this);
2739 this->tria_listeners_for_transfer.push_back(
2740 this->tria->signals.pre_distributed_repartition.connect(
2741 [
this]() { this->pre_distributed_transfer_action(); }));
2742 this->tria_listeners_for_transfer.push_back(
2743 this->tria->signals.post_distributed_repartition.connect(
2744 [
this] { this->post_distributed_transfer_action(); }));
2747 this->tria_listeners_for_transfer.push_back(
2748 this->tria->signals.post_p4est_refinement.connect(
2749 [
this]() { this->pre_distributed_transfer_action(); }));
2750 this->tria_listeners_for_transfer.push_back(
2751 this->tria->signals.post_distributed_refinement.connect(
2752 [
this]() { this->post_distributed_transfer_action(); }));
2755 this->tria_listeners_for_transfer.push_back(
2756 this->tria->signals.post_distributed_save.connect(
2757 [
this]() { this->active_fe_index_transfer.reset(); }));
2758 this->tria_listeners_for_transfer.push_back(
2759 this->tria->signals.post_distributed_load.connect(
2760 [
this]() { this->update_active_fe_table(); }));
2762 else if (
dynamic_cast<
2763 const ::parallel::shared::Triangulation<dim, spacedim> *
>(
2764 &this->get_triangulation()) !=
nullptr)
2767 this->tria_listeners_for_transfer.push_back(
2768 this->tria->signals.pre_partition.connect([
this]() {
2769 internal::hp::DoFHandlerImplementation::Implementation::
2770 ensure_absence_of_future_fe_indices(*this);
2774 this->tria_listeners_for_transfer.push_back(
2775 this->tria->signals.pre_refinement.connect([
this]() {
2776 internal::hp::DoFHandlerImplementation::Implementation::
2777 communicate_future_fe_indices(*this);
2779 this->tria_listeners_for_transfer.push_back(
2780 this->tria->signals.pre_refinement.connect(
2781 [
this] { this->pre_transfer_action(); }));
2782 this->tria_listeners_for_transfer.push_back(
2783 this->tria->signals.post_refinement.connect(
2784 [
this] { this->post_transfer_action(); }));
2789 this->tria_listeners_for_transfer.push_back(
2790 this->tria->signals.pre_refinement.connect(
2791 [
this] { this->pre_transfer_action(); }));
2792 this->tria_listeners_for_transfer.push_back(
2793 this->tria->signals.post_refinement.connect(
2794 [
this] { this->post_transfer_action(); }));
2800template <
int dim,
int spacedim>
2804 AssertThrow(hp_capability_enabled ==
true, ExcOnlyAvailableWithHP());
2811 this->hp_cell_active_fe_indices.resize(this->tria->n_levels());
2812 this->hp_cell_future_fe_indices.resize(this->tria->n_levels());
2816 for (
unsigned int level = 0;
level < this->hp_cell_future_fe_indices.size();
2819 if (this->hp_cell_active_fe_indices[
level].size() == 0 &&
2820 this->hp_cell_future_fe_indices[
level].size() == 0)
2822 this->hp_cell_active_fe_indices[
level].resize(
2823 this->tria->n_raw_cells(
level), 0);
2824 this->hp_cell_future_fe_indices[
level].resize(
2832 Assert(this->hp_cell_active_fe_indices[
level].size() ==
2833 this->tria->n_raw_cells(
level) &&
2851template <
int dim,
int spacedim>
2867 this->hp_cell_active_fe_indices.resize(this->tria->n_levels());
2868 this->hp_cell_active_fe_indices.shrink_to_fit();
2870 this->hp_cell_future_fe_indices.resize(this->tria->n_levels());
2871 this->hp_cell_future_fe_indices.shrink_to_fit();
2873 for (
unsigned int i = 0; i < this->hp_cell_future_fe_indices.size(); ++i)
2876 this->hp_cell_active_fe_indices[i].resize(this->tria->n_raw_cells(i), 0);
2883 this->hp_cell_future_fe_indices[i].assign(this->tria->n_raw_cells(i),
2889template <
int dim,
int spacedim>
2895 this->active_fe_index_transfer = std::make_unique<ActiveFEIndexTransfer>();
2903template <
int dim,
int spacedim>
2907#ifndef DEAL_II_WITH_P4EST
2910 "You are attempting to use a functionality that is only available "
2911 "if deal.II was configured to use p4est, but cmake did not find a "
2912 "valid p4est library."));
2917 &this->get_triangulation()) !=
nullptr),
2922 active_fe_index_transfer = std::make_unique<ActiveFEIndexTransfer>();
2931 active_fe_index_transfer->active_fe_indices.resize(
2934 for (
const auto &cell : active_cell_iterators())
2935 if (cell->is_locally_owned())
2936 active_fe_index_transfer->active_fe_indices[cell->active_cell_index()] =
2937 cell->future_fe_index();
2940 const auto *distributed_tria =
2942 &this->get_triangulation());
2944 active_fe_index_transfer->cell_data_transfer = std::make_unique<
2945 parallel::distributed::
2946 CellDataTransfer<dim, spacedim, std::vector<types::fe_index>>>(
2950 &::AdaptationStrategies::Refinement::
2951 preserve<dim, spacedim, types::fe_index>,
2956 return ::internal::hp::DoFHandlerImplementation::Implementation::
2957 determine_fe_from_children<dim, spacedim>(parent,
2962 active_fe_index_transfer->cell_data_transfer
2963 ->prepare_for_coarsening_and_refinement(
2964 active_fe_index_transfer->active_fe_indices);
2970template <
int dim,
int spacedim>
2974 update_active_fe_table();
2988 this->active_fe_index_transfer.reset();
2993template <
int dim,
int spacedim>
2997#ifndef DEAL_II_WITH_P4EST
3000 update_active_fe_table();
3005 this->active_fe_index_transfer->active_fe_indices.resize(
3007 this->active_fe_index_transfer->cell_data_transfer->unpack(
3008 this->active_fe_index_transfer->active_fe_indices);
3011 this->set_active_fe_indices(
3012 this->active_fe_index_transfer->active_fe_indices);
3019 this->active_fe_index_transfer.reset();
3025template <
int dim,
int spacedim>
3029#ifndef DEAL_II_WITH_P4EST
3032 "You are attempting to use a functionality that is only available "
3033 "if deal.II was configured to use p4est, but cmake did not find a "
3034 "valid p4est library."));
3039 &this->get_triangulation()) !=
nullptr),
3044 active_fe_index_transfer = std::make_unique<ActiveFEIndexTransfer>();
3047 const auto *distributed_tria =
3049 &this->get_triangulation());
3051 active_fe_index_transfer->cell_data_transfer = std::make_unique<
3052 parallel::distributed::
3053 CellDataTransfer<dim, spacedim, std::vector<types::fe_index>>>(
3057 &::AdaptationStrategies::Refinement::
3058 preserve<dim, spacedim, types::fe_index>,
3063 return ::internal::hp::DoFHandlerImplementation::Implementation::
3064 determine_fe_from_children<dim, spacedim>(parent,
3076 active_fe_index_transfer->cell_data_transfer->prepare_for_serialization(
3077 active_fe_index_transfer->active_fe_indices);
3083template <
int dim,
int spacedim>
3087#ifndef DEAL_II_WITH_P4EST
3090 "You are attempting to use a functionality that is only available "
3091 "if deal.II was configured to use p4est, but cmake did not find a "
3092 "valid p4est library."));
3097 &this->get_triangulation()) !=
nullptr),
3102 active_fe_index_transfer = std::make_unique<ActiveFEIndexTransfer>();
3105 const auto *distributed_tria =
3107 &this->get_triangulation());
3109 active_fe_index_transfer->cell_data_transfer = std::make_unique<
3110 parallel::distributed::
3111 CellDataTransfer<dim, spacedim, std::vector<types::fe_index>>>(
3115 &::AdaptationStrategies::Refinement::
3116 preserve<dim, spacedim, types::fe_index>,
3121 return ::internal::hp::DoFHandlerImplementation::Implementation::
3122 determine_fe_from_children<dim, spacedim>(parent,
3128 active_fe_index_transfer->active_fe_indices.resize(
3130 active_fe_index_transfer->cell_data_transfer->deserialize(
3131 active_fe_index_transfer->active_fe_indices);
3134 set_active_fe_indices(active_fe_index_transfer->active_fe_indices);
3141 active_fe_index_transfer.reset();
3147template <
int dim,
int spacedim>
3150 : coarsest_level(
numbers::invalid_unsigned_int)
3156template <
int dim,
int spacedim>
3159 const unsigned int cl,
3160 const unsigned int fl,
3161 const unsigned int dofs_per_vertex)
3163 coarsest_level =
cl;
3166 if (coarsest_level <= finest_level)
3168 const unsigned int n_levels = finest_level - coarsest_level + 1;
3169 const unsigned int n_indices = n_levels * dofs_per_vertex;
3171 indices = std::make_unique<types::global_dof_index[]>(
n_indices);
3172 std::fill(indices.get(),
3182template <
int dim,
int spacedim>
3186 return coarsest_level;
3191template <
int dim,
int spacedim>
3195 return finest_level;
3199#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()
virtual std::size_t memory_consumption() const
std::vector< types::fe_index > get_future_fe_indices() const
unsigned int max_couplings_between_dofs() const
void create_active_fe_table()
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()
void post_distributed_transfer_action()
void pre_transfer_action()
void reinit(const Triangulation< dim, spacedim > &tria)
active_cell_iterator begin_active(const unsigned int level=0) const
std::vector< types::fe_index > get_active_fe_indices() const
void distribute_mg_dofs()
active_cell_iterator end_active(const unsigned int level) const
void initialize_local_block_info()
void update_active_fe_table()
typename LevelSelector::cell_iterator level_cell_iterator
void prepare_for_serialization_of_active_fe_indices()
cell_iterator begin(const unsigned int level=0) const
void set_active_fe_indices(const std::vector< types::fe_index > &active_fe_indices)
unsigned int max_couplings_between_boundary_dofs() const
void deserialize_active_fe_indices()
void set_future_fe_indices(const std::vector< types::fe_index > &future_fe_indices)
virtual ~DoFHandler() override
IteratorState::IteratorStates state() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_CXX20_REQUIRES(condition)
#define DEAL_II_NAMESPACE_CLOSE
IteratorRange< active_cell_iterator > active_cell_iterators() const
IteratorRange< level_cell_iterator > mg_cell_iterators() const
IteratorRange< active_cell_iterator > active_cell_iterators_on_level(const unsigned int level) const
IteratorRange< level_cell_iterator > mg_cell_iterators_on_level(const unsigned int level) const
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 & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
typename ActiveSelector::cell_iterator cell_iterator
typename ActiveSelector::active_cell_iterator active_cell_iterator
Task< RT > new_task(const std::function< RT()> &function)
@ valid
Iterator points to a valid object.
std::enable_if_t< std::is_fundamental< T >::value, std::size_t > memory_consumption(const T &t)
VectorType::value_type * end(VectorType &V)
VectorType::value_type * begin(VectorType &V)
T sum(const T &t, const MPI_Comm mpi_communicator)
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
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
const types::fe_index invalid_fe_index
const types::global_dof_index invalid_dof_index
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
unsigned short int fe_index
static void reserve_space_mg(DoFHandler< 3, spacedim > &dof_handler)
static void reserve_space(DoFHandler< dim, spacedim > &dof_handler)
static void reserve_subentities(DoFHandler< dim, spacedim > &dof_handler, const unsigned int structdim, const unsigned int n_raw_entities, const T &cell_process)
static unsigned int max_couplings_between_dofs(const DoFHandler< 2, spacedim > &dof_handler)
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 unsigned int max_couplings_between_dofs(const DoFHandler< 1, spacedim > &dof_handler)
static void reserve_space_mg(DoFHandler< 2, spacedim > &dof_handler)
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 void reserve_space(DoFHandler< 2, spacedim > &dof_handler)
static void reserve_space_cells(DoFHandler< dim, spacedim > &dof_handler)
static types::fe_index 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 reserve_space(DoFHandler< 3, spacedim > &dof_handler)
static void ensure_absence_of_future_fe_indices(DoFHandler< dim, 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 types::fe_index determine_fe_from_children(const typename Triangulation< dim, spacedim >::cell_iterator &, const std::vector< types::fe_index > &children_fe_indices, const ::hp::FECollection< dim, spacedim > &fe_collection)
static void reserve_space_vertices(DoFHandler< dim, spacedim > &dof_handler)
static void reserve_space(DoFHandler< 1, spacedim > &dof_handler)
const ::Triangulation< dim, spacedim > & tria