59 std::vector<unsigned int> &,
71 std::vector<unsigned int> &,
84 std::vector<unsigned int> &,
95 std::vector<unsigned int> &,
105 template <
int dim,
int spacedim>
108 const unsigned int level,
109 std::vector<unsigned int> & row_lengths,
117 std::fill(row_lengths.begin(), row_lengths.end(), 0);
119 std::vector<bool> face_touched(dim == 2 ?
123 std::vector<types::global_dof_index> cell_indices;
124 std::vector<types::global_dof_index> neighbor_indices;
137 cell->get_mg_dof_indices(cell_indices);
161 const unsigned int face_no = 0;
166 unsigned int increment =
169 row_lengths[cell_indices[i++]] += increment;
186 row_lengths[cell_indices[i++]] += increment;
195 row_lengths[cell_indices[i++]] += increment;
200 row_lengths[cell_indices[i++]] += increment;
215 bool level_boundary = cell->at_boundary(iface);
219 neighbor = cell->neighbor(iface);
220 if (
static_cast<unsigned int>(neighbor->level()) !=
level)
221 level_boundary =
true;
226 for (
unsigned int local_dof = 0;
229 row_lengths[cell_indices[local_dof]] +=
248 const unsigned int dof_increment =
250 for (
unsigned int local_dof = 0;
253 row_lengths[cell_indices[local_dof]] += dof_increment;
258 if (face_touched[face->index()])
260 face_touched[face->index()] =
true;
275 neighbor->get_mg_dof_indices(neighbor_indices);
278 row_lengths[cell_indices[local_dof]] +=
282 row_lengths[neighbor_indices[local_dof]] +=
290 template <
int dim,
int spacedim>
293 const unsigned int level,
294 std::vector<unsigned int> & row_lengths,
303 std::fill(row_lengths.begin(), row_lengths.end(), 0);
305 std::vector<bool> face_touched(dim == 2 ?
309 std::vector<types::global_dof_index> cell_indices;
310 std::vector<types::global_dof_index> neighbor_indices;
316 std::vector<Table<2, DoFTools::Coupling>> couple_cell;
317 std::vector<Table<2, DoFTools::Coupling>> couple_face;
331 const unsigned int fe_index = cell->active_fe_index();
335 const unsigned int face_no = 0;
351 cell->get_mg_dof_indices(cell_indices);
374 unsigned int increment;
387 row_lengths[cell_indices[i]] += increment;
412 ((dim > 1) ? (dim - 1) :
415 row_lengths[cell_indices[i]] += increment;
432 ((dim > 2) ? (dim - 2) :
435 row_lengths[cell_indices[i]] += increment;
454 row_lengths[cell_indices[i]] += increment;
472 bool level_boundary = cell->at_boundary(iface);
476 neighbor = cell->neighbor(iface);
477 if (
static_cast<unsigned int>(neighbor->level()) !=
level)
478 level_boundary =
true;
483 for (
unsigned int local_dof = 0;
486 row_lengths[cell_indices[local_dof]] +=
506 for (
unsigned int local_dof = 0;
509 if (couple_face[fe_index](
513 const unsigned int dof_increment =
516 row_lengths[cell_indices[local_dof]] += dof_increment;
520 if (face_touched[face->index()])
522 face_touched[face->index()] =
true;
545 neighbor->get_mg_dof_indices(neighbor_indices);
549 for (
unsigned int local_dof = 0;
552 if (couple_cell[fe_index](
555 row_lengths[cell_indices[local_dof]] +=
560 for (
unsigned int local_dof = 0;
563 if (couple_cell[fe_index](
566 row_lengths[neighbor_indices[local_dof]] +=
574 template <
int dim,
int spacedim,
typename number>
578 const unsigned int level,
580 const bool keep_constrained_dofs)
591 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
593 if (cell->is_locally_owned_on_level())
595 cell->get_mg_dof_indices(dofs_on_this_cell);
598 keep_constrained_dofs);
604 template <
int dim,
int spacedim,
typename number>
608 const unsigned int level,
610 const bool keep_constrained_dofs)
621 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
622 std::vector<types::global_dof_index> dofs_on_other_cell(dofs_per_cell);
625 if (!cell->is_locally_owned_on_level())
628 cell->get_mg_dof_indices(dofs_on_this_cell);
632 keep_constrained_dofs);
637 bool use_face =
false;
638 if ((!cell->at_boundary(face)) &&
639 (
static_cast<unsigned int>(cell->neighbor_level(face)) ==
642 else if (cell->has_periodic_neighbor(face) &&
643 (
static_cast<unsigned int>(
644 cell->periodic_neighbor_level(face)) ==
level))
650 cell->neighbor_or_periodic_neighbor(face);
651 neighbor->get_mg_dof_indices(dofs_on_other_cell);
658 keep_constrained_dofs);
660 if (neighbor->is_locally_owned_on_level() ==
false)
663 dofs_on_other_cell, sparsity, keep_constrained_dofs);
669 keep_constrained_dofs);
678 template <
int dim,
int spacedim>
682 const unsigned int level)
700 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
701 std::vector<types::global_dof_index> dofs_on_other_cell(dofs_per_cell);
704 if (!cell->is_locally_owned_on_level())
707 cell->get_mg_dof_indices(dofs_on_this_cell);
712 bool use_face =
false;
713 if ((!cell->at_boundary(face)) &&
714 (
static_cast<unsigned int>(cell->neighbor_level(face)) !=
717 else if (cell->has_periodic_neighbor(face) &&
718 (
static_cast<unsigned int>(
719 cell->periodic_neighbor_level(face)) !=
level))
725 cell->neighbor_or_periodic_neighbor(face);
726 neighbor->get_mg_dof_indices(dofs_on_other_cell);
728 std::sort(dofs_on_this_cell.begin(), dofs_on_this_cell.end());
729 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
740 template <
int dim,
int spacedim>
744 const unsigned int level,
758 Assert(int_mask.n_rows() == n_comp,
760 Assert(int_mask.n_cols() == n_comp,
762 Assert(flux_mask.n_rows() == n_comp,
764 Assert(flux_mask.n_cols() == n_comp,
768 std::vector<types::global_dof_index> dofs_on_this_cell(total_dofs);
769 std::vector<types::global_dof_index> dofs_on_other_cell(total_dofs);
770 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
782 for (
unsigned int i = 0; i < total_dofs; ++i)
786 std::vector<bool> face_touched(dim == 2 ?
792 if (!cell->is_locally_owned_on_level())
795 cell->get_mg_dof_indices(dofs_on_this_cell);
797 for (
unsigned int i = 0; i < total_dofs; ++i)
798 for (
unsigned int j = 0; j < total_dofs; ++j)
800 cell_entries.emplace_back(dofs_on_this_cell[i],
801 dofs_on_this_cell[j]);
808 if (face_touched[cell_face->index()])
811 if (cell->at_boundary(face) && !cell->has_periodic_neighbor(face))
813 for (
unsigned int i = 0; i < total_dofs; ++i)
815 const bool i_non_zero_i = support_on_face(i, face);
816 for (
unsigned int j = 0; j < total_dofs; ++j)
818 const bool j_non_zero_i = support_on_face(j, face);
821 cell_entries.emplace_back(dofs_on_this_cell[i],
822 dofs_on_this_cell[j]);
824 i_non_zero_i && j_non_zero_i)
825 cell_entries.emplace_back(dofs_on_this_cell[i],
826 dofs_on_this_cell[j]);
833 cell->neighbor_or_periodic_neighbor(face);
835 if (neighbor->level() < cell->level())
838 unsigned int neighbor_face =
839 cell->has_periodic_neighbor(face) ?
840 cell->periodic_neighbor_of_periodic_neighbor(face) :
841 cell->neighbor_of_neighbor(face);
843 neighbor->get_mg_dof_indices(dofs_on_other_cell);
844 for (
unsigned int i = 0; i < total_dofs; ++i)
846 const bool i_non_zero_i = support_on_face(i, face);
847 const bool i_non_zero_e = support_on_face(i, neighbor_face);
848 for (
unsigned int j = 0; j < total_dofs; ++j)
850 const bool j_non_zero_i = support_on_face(j, face);
851 const bool j_non_zero_e =
852 support_on_face(j, neighbor_face);
855 cell_entries.emplace_back(dofs_on_this_cell[i],
856 dofs_on_other_cell[j]);
857 cell_entries.emplace_back(dofs_on_other_cell[i],
858 dofs_on_this_cell[j]);
859 cell_entries.emplace_back(dofs_on_this_cell[i],
860 dofs_on_this_cell[j]);
861 cell_entries.emplace_back(dofs_on_other_cell[i],
862 dofs_on_other_cell[j]);
866 if (i_non_zero_i && j_non_zero_e)
867 cell_entries.emplace_back(dofs_on_this_cell[i],
868 dofs_on_other_cell[j]);
869 if (i_non_zero_e && j_non_zero_i)
870 cell_entries.emplace_back(dofs_on_other_cell[i],
871 dofs_on_this_cell[j]);
872 if (i_non_zero_i && j_non_zero_i)
873 cell_entries.emplace_back(dofs_on_this_cell[i],
874 dofs_on_this_cell[j]);
875 if (i_non_zero_e && j_non_zero_e)
876 cell_entries.emplace_back(dofs_on_other_cell[i],
877 dofs_on_other_cell[j]);
882 cell_entries.emplace_back(dofs_on_this_cell[j],
883 dofs_on_other_cell[i]);
884 cell_entries.emplace_back(dofs_on_other_cell[j],
885 dofs_on_this_cell[i]);
886 cell_entries.emplace_back(dofs_on_this_cell[j],
887 dofs_on_this_cell[i]);
888 cell_entries.emplace_back(dofs_on_other_cell[j],
889 dofs_on_other_cell[i]);
893 if (j_non_zero_i && i_non_zero_e)
894 cell_entries.emplace_back(dofs_on_this_cell[j],
895 dofs_on_other_cell[i]);
896 if (j_non_zero_e && i_non_zero_i)
897 cell_entries.emplace_back(dofs_on_other_cell[j],
898 dofs_on_this_cell[i]);
899 if (j_non_zero_i && i_non_zero_i)
900 cell_entries.emplace_back(dofs_on_this_cell[j],
901 dofs_on_this_cell[i]);
902 if (j_non_zero_e && i_non_zero_e)
903 cell_entries.emplace_back(dofs_on_other_cell[j],
904 dofs_on_other_cell[i]);
908 face_touched[neighbor->face(neighbor_face)->index()] =
true;
912 cell_entries.clear();
918 template <
int dim,
int spacedim>
922 const unsigned int level,
943 Assert(flux_mask.n_rows() == n_comp,
945 Assert(flux_mask.n_cols() == n_comp,
949 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
950 std::vector<types::global_dof_index> dofs_on_other_cell(dofs_per_cell);
951 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
960 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
966 if (!cell->is_locally_owned_on_level())
969 cell->get_mg_dof_indices(dofs_on_this_cell);
974 bool use_face =
false;
975 if ((!cell->at_boundary(face)) &&
976 (
static_cast<unsigned int>(cell->neighbor_level(face)) !=
979 else if (cell->has_periodic_neighbor(face) &&
980 (
static_cast<unsigned int>(
981 cell->periodic_neighbor_level(face)) !=
level))
987 cell->neighbor_or_periodic_neighbor(face);
988 neighbor->get_mg_dof_indices(dofs_on_other_cell);
990 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
992 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
996 cell_entries.emplace_back(dofs_on_other_cell[i],
997 dofs_on_this_cell[j]);
998 cell_entries.emplace_back(dofs_on_other_cell[j],
999 dofs_on_this_cell[i]);
1006 cell_entries.clear();
1012 template <
int dim,
int spacedim>
1017 const unsigned int level)
1028 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
1029 std::vector<types::global_dof_index> cols;
1030 cols.reserve(dofs_per_cell);
1033 if (cell->is_locally_owned_on_level())
1035 cell->get_mg_dof_indices(dofs_on_this_cell);
1036 std::sort(dofs_on_this_cell.begin(), dofs_on_this_cell.end());
1037 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1039 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
1041 level, dofs_on_this_cell[i], dofs_on_this_cell[j]))
1042 cols.push_back(dofs_on_this_cell[j]);
1053 template <
int dim,
int spacedim>
1057 std::vector<std::vector<types::global_dof_index>> &result,
1059 std::vector<unsigned int> target_component)
1063 const unsigned int nlevels =
1066 Assert(result.size() == nlevels,
1069 if (target_component.size() == 0)
1071 target_component.resize(n_components);
1072 for (
unsigned int i = 0; i < n_components; ++i)
1073 target_component[i] = i;
1076 Assert(target_component.size() == n_components,
1079 for (
unsigned int l = 0; l < nlevels; ++l)
1081 result[l].resize(n_components);
1082 std::fill(result[l].begin(), result[l].end(), 0U);
1088 if (n_components == 1)
1090 result[l][0] = dof_handler.
n_dofs(l);
1097 std::vector<std::vector<bool>> dofs_in_component(
1098 n_components, std::vector<bool>(dof_handler.
n_dofs(l),
false));
1099 std::vector<ComponentMask> component_select(n_components);
1101 for (
unsigned int i = 0; i < n_components; ++i)
1103 void (*fun_ptr)(
const unsigned int level,
1106 std::vector<bool> &) =
1107 &DoFTools::extract_level_dofs<dim, spacedim>;
1109 std::vector<bool> tmp(n_components,
false);
1116 component_select[i],
1117 dofs_in_component[i]);
1122 unsigned int component = 0;
1131 for (
unsigned int dd = 0; dd < d; ++dd)
1134 result[l][target_component[component]] +=
1135 std::count(dofs_in_component[component].begin(),
1136 dofs_in_component[component].end(),
1144 std::accumulate(result[l].begin(),
1155 template <
int dim,
int spacedim>
1159 std::vector<std::vector<types::global_dof_index>> &dofs_per_block,
1160 std::vector<unsigned int> target_block)
1163 const unsigned int n_blocks = fe.
n_blocks();
1164 const unsigned int n_levels =
1169 for (
unsigned int l = 0; l < n_levels; ++l)
1170 std::fill(dofs_per_block[l].begin(), dofs_per_block[l].end(), 0U);
1174 if (target_block.size() == 0)
1176 target_block.resize(n_blocks);
1177 for (
unsigned int i = 0; i < n_blocks; ++i)
1178 target_block[i] = i;
1180 Assert(target_block.size() == n_blocks,
1183 const unsigned int max_block =
1184 *std::max_element(target_block.begin(), target_block.end());
1185 const unsigned int n_target_blocks = max_block + 1;
1186 (void)n_target_blocks;
1188 for (
unsigned int l = 0; l < n_levels; ++l)
1197 for (
unsigned int l = 0; l < n_levels; ++l)
1198 dofs_per_block[l][0] = dof_handler.
n_dofs(l);
1204 for (
unsigned int l = 0; l < n_levels; ++l)
1206 std::vector<std::vector<bool>> dofs_in_block(
1207 n_blocks, std::vector<bool>(dof_handler.
n_dofs(l),
false));
1208 std::vector<BlockMask> block_select(n_blocks);
1210 for (
unsigned int i = 0; i < n_blocks; ++i)
1212 void (*fun_ptr)(
const unsigned int level,
1215 std::vector<bool> &) =
1216 &DoFTools::extract_level_dofs<dim, spacedim>;
1218 std::vector<bool> tmp(n_blocks,
false);
1220 block_select[i] = tmp;
1223 fun_ptr, l, dof_handler, block_select[i], dofs_in_block[i]);
1228 for (
unsigned int block = 0; block < fe.
n_blocks(); ++block)
1229 dofs_per_block[l][target_block[block]] +=
1230 std::count(dofs_in_block[block].begin(),
1231 dofs_in_block[block].end(),
1238 template <
int dim,
int spacedim>
1244 std::vector<std::set<types::global_dof_index>> &boundary_indices,
1251 std::set<types::boundary_id> boundary_ids;
1252 for (
const auto &boundary_function : function_map)
1253 boundary_ids.insert(boundary_function.first);
1255 std::vector<IndexSet> boundary_indexset;
1258 boundary_indices[i].insert(boundary_indexset[i].begin(),
1259 boundary_indexset[i].end());
1263 template <
int dim,
int spacedim>
1268 std::vector<IndexSet> &boundary_indices,
1275 std::set<types::boundary_id> boundary_ids;
1276 for (
const auto &boundary_function : function_map)
1277 boundary_ids.insert(boundary_function.first);
1284 template <
int dim,
int spacedim>
1287 const std::set<types::boundary_id> &boundary_ids,
1288 std::vector<IndexSet> & boundary_indices,
1294 if (boundary_ids.size() == 0)
1298 if (boundary_indices[i].size() == 0)
1302 const bool fe_is_system = (n_components != 1);
1304 std::vector<types::global_dof_index> local_dofs;
1308 std::vector<std::vector<types::global_dof_index>> dofs_by_level(
1317 if (cell->is_artificial_on_level())
1320 const unsigned int level = cell->level();
1323 if (cell->at_boundary(face_no) ==
true)
1326 cell->face(face_no);
1329 if (boundary_ids.find(bi) != boundary_ids.end())
1332 face->get_mg_dof_indices(
level, local_dofs);
1333 dofs_by_level[
level].insert(dofs_by_level[
level].end(),
1344 "It's probably worthwhile to select at least one component."));
1347 if (!cell->is_artificial_on_level())
1350 if (cell->at_boundary(face_no) ==
false)
1354 const unsigned int level = cell->level();
1357 cell->face(face_no);
1359 face->boundary_id();
1360 if (boundary_ids.find(boundary_component) != boundary_ids.end())
1363 for (
unsigned int i = 0;
1364 i < cell->get_fe().n_dofs_per_cell();
1368 cell->get_fe().get_nonzero_components(i);
1372 bool selected =
false;
1373 for (
unsigned int c = 0; c < n_components; ++c)
1374 if (nonzero_component_array[c] ==
true &&
1375 component_mask[c] ==
true)
1381 for (
unsigned int c = 0; c < n_components; ++c)
1383 nonzero_component_array[c] ==
false ||
1384 component_mask[c] ==
true,
1386 "You are using a non-primitive FiniteElement "
1387 "and try to constrain just some of its components!"));
1393 face->get_mg_dof_indices(
level, local_dofs);
1396 for (
unsigned int i = 0; i < local_dofs.size(); ++i)
1398 unsigned int component =
1410 cell->get_fe().get_nonzero_components(i);
1411 for (
unsigned int c = 0; c < n_components; ++c)
1412 if (nonzero_component_array[c] ==
true)
1420 if (component_mask[component] ==
true)
1421 dofs_by_level[
level].push_back(local_dofs[i]);
1425 dofs_by_level[
level].insert(dofs_by_level[
level].end(),
1434 std::sort(dofs_by_level[
level].begin(), dofs_by_level[
level].end());
1435 boundary_indices[
level].add_indices(
1436 dofs_by_level[
level].begin(),
1437 std::unique(dofs_by_level[
level].begin(),
1438 dofs_by_level[
level].end()));
1444 template <
int dim,
int spacedim>
1447 std::vector<IndexSet> & interface_dofs)
1449 Assert(interface_dofs.size() ==
1452 interface_dofs.size(),
1455 std::vector<std::vector<types::global_dof_index>> tmp_interface_dofs(
1456 interface_dofs.size());
1462 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
1464 std::vector<bool> cell_dofs(dofs_per_cell,
false);
1470 if (cell->is_artificial_on_level())
1473 bool has_coarser_neighbor =
false;
1475 std::fill(cell_dofs.begin(), cell_dofs.end(),
false);
1480 cell->face(face_nr);
1481 if (!face->at_boundary() || cell->has_periodic_neighbor(face_nr))
1485 cell->neighbor_or_periodic_neighbor(face_nr);
1489 if (neighbor->is_artificial_on_level())
1493 if (neighbor->level() < cell->level())
1499 has_coarser_neighbor =
true;
1504 if (has_coarser_neighbor ==
false)
1507 const unsigned int level = cell->level();
1508 cell->get_mg_dof_indices(local_dof_indices);
1510 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1513 tmp_interface_dofs[
level].push_back(local_dof_indices[i]);
1517 for (
unsigned int l = 0;
1521 interface_dofs[l].clear();
1522 std::sort(tmp_interface_dofs[l].begin(), tmp_interface_dofs[l].end());
1523 interface_dofs[l].add_indices(tmp_interface_dofs[l].begin(),
1524 std::unique(tmp_interface_dofs[l].begin(),
1525 tmp_interface_dofs[l].end()));
1526 interface_dofs[l].compress();
1532 template <
int dim,
int spacedim>
1543 if (cell->is_locally_owned())
1545 min_level = cell->level();
1549 unsigned int global_min = min_level;
1568 const std::vector<types::global_dof_index> &n_cells_on_levels,
1571 std::vector<types::global_dof_index> n_cells_on_levels_max(
1572 n_cells_on_levels.size());
1573 std::vector<types::global_dof_index> n_cells_on_levels_sum(
1574 n_cells_on_levels.size());
1581 const double ideal_work = std::accumulate(n_cells_on_levels_sum.begin(),
1582 n_cells_on_levels_sum.end(),
1584 static_cast<double>(n_proc);
1586 std::accumulate(n_cells_on_levels_max.begin(),
1587 n_cells_on_levels_max.end(),
1599 std::pair<types::global_dof_index, types::global_dof_index>> &cells,
1602 std::vector<types::global_dof_index> cells_local(cells.size());
1603 std::vector<types::global_dof_index> cells_remote(cells.size());
1605 for (
unsigned int i = 0; i < cells.size(); ++i)
1607 cells_local[i] = cells[i].first;
1608 cells_remote[i] = cells[i].second;
1611 std::vector<types::global_dof_index> cells_local_sum(cells_local.size());
1614 std::vector<types::global_dof_index> cells_remote_sum(
1615 cells_remote.size());
1618 const auto n_cells_local =
1619 std::accumulate(cells_local_sum.begin(), cells_local_sum.end(), 0);
1620 const auto n_cells_remote =
1621 std::accumulate(cells_remote_sum.begin(), cells_remote_sum.end(), 0);
1623 return static_cast<double>(n_cells_local) /
1624 (n_cells_local + n_cells_remote);
1630 template <
int dim,
int spacedim>
1631 std::vector<types::global_dof_index>
1638 tr->is_multilevel_hierarchy_constructed(),
1640 "We can only compute the workload imbalance if the multilevel hierarchy has been constructed!"));
1644 std::vector<types::global_dof_index> n_cells_on_levels(n_global_levels);
1646 for (
unsigned int lvl = 0; lvl < n_global_levels; ++lvl)
1648 if (cell->is_locally_owned_on_level())
1649 ++n_cells_on_levels[lvl];
1651 return n_cells_on_levels;
1656 template <
int dim,
int spacedim>
1657 std::vector<types::global_dof_index>
1662 const unsigned int n_global_levels = trias.size();
1664 std::vector<types::global_dof_index> n_cells_on_levels(n_global_levels);
1666 for (
unsigned int lvl = 0; lvl < n_global_levels; ++lvl)
1667 for (
const auto &cell : trias[lvl]->active_cell_iterators())
1668 if (cell->is_locally_owned())
1669 ++n_cells_on_levels[lvl];
1671 return n_cells_on_levels;
1676 template <
int dim,
int spacedim>
1686 template <
int dim,
int spacedim>
1693 trias.back()->get_communicator());
1698 template <
int dim,
int spacedim>
1699 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
1704 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
1705 cells(n_global_levels);
1711 for (
unsigned int lvl = 0; lvl < n_global_levels - 1; ++lvl)
1713 if (cell->is_locally_owned_on_level() && cell->has_children())
1714 for (
unsigned int i = 0; i < GeometryInfo<dim>::max_children_per_cell;
1717 const auto level_subdomain_id =
1718 cell->child(i)->level_subdomain_id();
1719 if (level_subdomain_id == my_rank)
1720 ++cells[lvl + 1].first;
1722 ++cells[lvl + 1].second;
1732 template <
int dim,
int spacedim>
1733 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
1738 const unsigned int n_global_levels = trias.size();
1740 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
1741 cells(n_global_levels);
1743 const MPI_Comm communicator = trias.back()->get_communicator();
1747 for (
unsigned int lvl = 0; lvl < n_global_levels - 1; ++lvl)
1749 const auto &tria_coarse = *trias[lvl];
1750 const auto &tria_fine = *trias[lvl + 1];
1752 const unsigned int n_coarse_cells = tria_fine.n_global_coarse_cells();
1753 const unsigned int n_global_levels = tria_fine.n_global_levels();
1755 const ::internal::CellIDTranslator<dim> cell_id_translator(
1756 n_coarse_cells, n_global_levels);
1758 IndexSet is_fine_owned(cell_id_translator.size());
1759 IndexSet is_fine_required(cell_id_translator.size());
1761 for (
const auto &cell : tria_fine.active_cell_iterators())
1762 if (!cell->is_artificial() && cell->is_locally_owned())
1763 is_fine_owned.
add_index(cell_id_translator.translate(cell));
1765 for (
const auto &cell : tria_coarse.active_cell_iterators())
1766 if (!cell->is_artificial() && cell->is_locally_owned())
1768 if (cell->level() + 1u == tria_fine.n_global_levels())
1771 for (
unsigned int i = 0;
1772 i < GeometryInfo<dim>::max_children_per_cell;
1775 cell_id_translator.translate(cell, i));
1778 std::vector<unsigned int> is_fine_required_ranks(
1782 process(is_fine_owned,
1785 is_fine_required_ranks,
1790 std::pair<types::global_cell_index, types::global_cell_index>>,
1791 std::vector<unsigned int>>
1792 consensus_algorithm;
1793 consensus_algorithm.
run(process, communicator);
1795 for (
unsigned i = 0; i < is_fine_required.
n_elements(); ++i)
1796 if (is_fine_required_ranks[i] == my_rank)
1797 ++cells[lvl + 1].first;
1799 ++cells[lvl + 1].second;
1807 template <
int dim,
int spacedim>
1817 template <
int dim,
int spacedim>
1825 trias.back()->get_communicator());
1832#include "mg_tools.inst"
ArrayView< typename std::remove_reference< typename std::iterator_traits< Iterator >::reference >::type, MemorySpaceType > make_array_view(const Iterator begin, const Iterator end)
void add_entries_local_to_global(const std::vector< size_type > &local_dof_indices, SparsityPatternBase &sparsity_pattern, const bool keep_constrained_entries=true, const Table< 2, bool > &dof_mask=Table< 2, bool >()) const
unsigned int n_selected_components(const unsigned int overall_number_of_components=numbers::invalid_unsigned_int) const
const hp::FECollection< dim, spacedim > & get_fe_collection() const
const FiniteElement< dim, spacedim > & get_fe(const types::fe_index index=0) const
const Triangulation< dim, spacedim > & get_triangulation() const
types::global_dof_index n_dofs() const
unsigned int get_first_line_index() const
unsigned int n_dofs_per_cell() const
unsigned int get_first_quad_index(const unsigned int quad_no=0) const
unsigned int n_dofs_per_face(unsigned int face_no=0, unsigned int child=0) const
unsigned int n_blocks() const
unsigned int n_components() const
ReferenceCell reference_cell() const
unsigned int get_first_hex_index() const
std::pair< unsigned int, types::global_dof_index > system_to_block_index(const unsigned int component) const
virtual const FiniteElement< dim, spacedim > & base_element(const unsigned int index) const
bool is_primitive() const
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const
virtual unsigned int face_to_cell_index(const unsigned int face_dof_index, const unsigned int face, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false) const
std::pair< unsigned int, unsigned int > system_to_component_index(const unsigned int index) const
unsigned int element_multiplicity(const unsigned int index) const
unsigned int n_base_elements() const
std::pair< unsigned int, unsigned int > face_system_to_component_index(const unsigned int index, const unsigned int face_no=0) const
types::global_dof_index first_block_of_base(const unsigned int b) const
size_type n_elements() const
void add_index(const size_type index)
bool is_interface_matrix_entry(const unsigned int level, const types::global_dof_index i, const types::global_dof_index j) const
virtual void add_entries(const ArrayView< const std::pair< size_type, size_type > > &entries)
virtual void add_row_entries(const size_type &row, const ArrayView< const size_type > &columns, const bool indices_are_sorted=false)=0
virtual MPI_Comm get_communicator() const
unsigned int n_raw_lines() const
unsigned int n_levels() const
virtual unsigned int n_global_levels() const
unsigned int n_raw_quads() const
virtual std::vector< unsigned int > run(const std::vector< unsigned int > &targets, const std::function< RequestType(const unsigned int)> &create_request, const std::function< AnswerType(const unsigned int, const RequestType &)> &answer_request, const std::function< void(const unsigned int, const AnswerType &)> &process_answer, const MPI_Comm comm) override
unsigned int max_dofs_per_face() const
unsigned int n_components() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
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() const
IteratorRange< cell_iterator > 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 & ExcInternalError()
static ::ExceptionBase & ExcIndexRange(std::size_t arg1, std::size_t arg2, std::size_t arg3)
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::face_iterator face_iterator
Task< RT > new_task(const std::function< RT()> &function)
T sum(const T &t, const MPI_Comm mpi_communicator)
unsigned int n_mpi_processes(const MPI_Comm mpi_communicator)
T max(const T &t, const MPI_Comm mpi_communicator)
T min(const T &t, const MPI_Comm mpi_communicator)
unsigned int this_mpi_process(const MPI_Comm mpi_communicator)
static const unsigned int invalid_unsigned_int
const types::global_dof_index invalid_dof_index
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > face_indices()
const ::Triangulation< dim, spacedim > & tria