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);
120 std::vector<bool> old_flags;
130 std::vector<types::global_dof_index> cell_indices;
131 std::vector<types::global_dof_index> neighbor_indices;
144 cell->get_mg_dof_indices(cell_indices);
168 const unsigned int face_no = 0;
173 unsigned int increment =
176 row_lengths[cell_indices[i++]] += increment;
193 row_lengths[cell_indices[i++]] += increment;
202 row_lengths[cell_indices[i++]] += increment;
207 row_lengths[cell_indices[i++]] += increment;
222 bool level_boundary = cell->at_boundary(iface);
226 neighbor = cell->neighbor(iface);
227 if (
static_cast<unsigned int>(neighbor->level()) !=
level)
228 level_boundary =
true;
233 for (
unsigned int local_dof = 0;
236 row_lengths[cell_indices[local_dof]] +=
255 const unsigned int dof_increment =
257 for (
unsigned int local_dof = 0;
260 row_lengths[cell_indices[local_dof]] += dof_increment;
265 if (face->user_flag_set())
267 face->set_user_flag();
281 neighbor->get_mg_dof_indices(neighbor_indices);
284 row_lengths[cell_indices[local_dof]] +=
288 row_lengths[neighbor_indices[local_dof]] +=
297 template <
int dim,
int spacedim>
300 const unsigned int level,
301 std::vector<unsigned int> & row_lengths,
310 std::fill(row_lengths.begin(), row_lengths.end(), 0);
313 std::vector<bool> old_flags;
323 std::vector<types::global_dof_index> cell_indices;
324 std::vector<types::global_dof_index> neighbor_indices;
330 std::vector<Table<2, DoFTools::Coupling>> couple_cell;
331 std::vector<Table<2, DoFTools::Coupling>> couple_face;
345 const unsigned int fe_index = cell->active_fe_index();
349 const unsigned int face_no = 0;
365 cell->get_mg_dof_indices(cell_indices);
388 unsigned int increment;
401 row_lengths[cell_indices[i]] += increment;
426 ((dim > 1) ? (dim - 1) :
429 row_lengths[cell_indices[i]] += increment;
446 ((dim > 2) ? (dim - 2) :
449 row_lengths[cell_indices[i]] += increment;
468 row_lengths[cell_indices[i]] += increment;
486 bool level_boundary = cell->at_boundary(iface);
490 neighbor = cell->neighbor(iface);
491 if (
static_cast<unsigned int>(neighbor->level()) !=
level)
492 level_boundary =
true;
497 for (
unsigned int local_dof = 0;
500 row_lengths[cell_indices[local_dof]] +=
520 for (
unsigned int local_dof = 0;
523 if (couple_face[fe_index](
527 const unsigned int dof_increment =
530 row_lengths[cell_indices[local_dof]] += dof_increment;
536 if (face->user_flag_set())
538 face->set_user_flag();
560 neighbor->get_mg_dof_indices(neighbor_indices);
564 for (
unsigned int local_dof = 0;
567 if (couple_cell[fe_index](
570 row_lengths[cell_indices[local_dof]] +=
575 for (
unsigned int local_dof = 0;
578 if (couple_cell[fe_index](
581 row_lengths[neighbor_indices[local_dof]] +=
592 typename SparsityPatternType,
596 SparsityPatternType & sparsity,
597 const unsigned int level,
599 const bool keep_constrained_dofs)
604 Assert(sparsity.n_rows() == n_dofs,
606 Assert(sparsity.n_cols() == n_dofs,
610 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
612 if (cell->is_locally_owned_on_level())
614 cell->get_mg_dof_indices(dofs_on_this_cell);
617 keep_constrained_dofs);
625 typename SparsityPatternType,
629 SparsityPatternType & sparsity,
630 const unsigned int level,
632 const bool keep_constrained_dofs)
637 Assert(sparsity.n_rows() == n_dofs,
639 Assert(sparsity.n_cols() == n_dofs,
643 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
644 std::vector<types::global_dof_index> dofs_on_other_cell(dofs_per_cell);
647 for (; cell != endc; ++cell)
649 if (!cell->is_locally_owned_on_level())
652 cell->get_mg_dof_indices(dofs_on_this_cell);
656 keep_constrained_dofs);
661 bool use_face =
false;
662 if ((!cell->at_boundary(face)) &&
663 (
static_cast<unsigned int>(cell->neighbor_level(face)) ==
666 else if (cell->has_periodic_neighbor(face) &&
667 (
static_cast<unsigned int>(
668 cell->periodic_neighbor_level(face)) ==
level))
674 cell->neighbor_or_periodic_neighbor(face);
675 neighbor->get_mg_dof_indices(dofs_on_other_cell);
682 keep_constrained_dofs);
684 if (neighbor->is_locally_owned_on_level() ==
false)
687 dofs_on_other_cell, sparsity, keep_constrained_dofs);
693 keep_constrained_dofs);
702 template <
int dim,
typename SparsityPatternType,
int spacedim>
705 SparsityPatternType & sparsity,
706 const unsigned int level)
718 Assert(sparsity.n_rows() == coarse_dofs,
720 Assert(sparsity.n_cols() == fine_dofs,
724 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
725 std::vector<types::global_dof_index> dofs_on_other_cell(dofs_per_cell);
728 for (; cell != endc; ++cell)
730 if (!cell->is_locally_owned_on_level())
733 cell->get_mg_dof_indices(dofs_on_this_cell);
738 bool use_face =
false;
739 if ((!cell->at_boundary(face)) &&
740 (
static_cast<unsigned int>(cell->neighbor_level(face)) !=
743 else if (cell->has_periodic_neighbor(face) &&
744 (
static_cast<unsigned int>(
745 cell->periodic_neighbor_level(face)) !=
level))
751 cell->neighbor_or_periodic_neighbor(face);
752 neighbor->get_mg_dof_indices(dofs_on_other_cell);
754 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
756 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
758 sparsity.add(dofs_on_other_cell[i],
759 dofs_on_this_cell[j]);
760 sparsity.add(dofs_on_other_cell[j],
761 dofs_on_this_cell[i]);
771 template <
int dim,
typename SparsityPatternType,
int spacedim>
774 SparsityPatternType & sparsity,
775 const unsigned int level,
785 Assert(sparsity.n_rows() == n_dofs,
787 Assert(sparsity.n_cols() == n_dofs,
789 Assert(int_mask.n_rows() == n_comp,
791 Assert(int_mask.n_cols() == n_comp,
793 Assert(flux_mask.n_rows() == n_comp,
795 Assert(flux_mask.n_cols() == n_comp,
799 std::vector<types::global_dof_index> dofs_on_this_cell(total_dofs);
800 std::vector<types::global_dof_index> dofs_on_other_cell(total_dofs);
813 for (
unsigned int i = 0; i < total_dofs; ++i)
825 std::vector<bool> user_flags;
830 for (; cell != endc; ++cell)
832 if (!cell->is_locally_owned_on_level())
835 cell->get_mg_dof_indices(dofs_on_this_cell);
837 for (
unsigned int i = 0; i < total_dofs; ++i)
838 for (
unsigned int j = 0; j < total_dofs; ++j)
840 sparsity.add(dofs_on_this_cell[i], dofs_on_this_cell[j]);
847 if (cell_face->user_flag_set())
850 if (cell->at_boundary(face) && !cell->has_periodic_neighbor(face))
852 for (
unsigned int i = 0; i < total_dofs; ++i)
854 const bool i_non_zero_i = support_on_face(i, face);
855 for (
unsigned int j = 0; j < total_dofs; ++j)
857 const bool j_non_zero_i = support_on_face(j, face);
860 sparsity.add(dofs_on_this_cell[i],
861 dofs_on_this_cell[j]);
863 i_non_zero_i && j_non_zero_i)
864 sparsity.add(dofs_on_this_cell[i],
865 dofs_on_this_cell[j]);
872 cell->neighbor_or_periodic_neighbor(face);
874 if (neighbor->level() < cell->level())
877 unsigned int neighbor_face =
878 cell->has_periodic_neighbor(face) ?
879 cell->periodic_neighbor_of_periodic_neighbor(face) :
880 cell->neighbor_of_neighbor(face);
882 neighbor->get_mg_dof_indices(dofs_on_other_cell);
883 for (
unsigned int i = 0; i < total_dofs; ++i)
885 const bool i_non_zero_i = support_on_face(i, face);
886 const bool i_non_zero_e = support_on_face(i, neighbor_face);
887 for (
unsigned int j = 0; j < total_dofs; ++j)
889 const bool j_non_zero_i = support_on_face(j, face);
890 const bool j_non_zero_e =
891 support_on_face(j, neighbor_face);
894 sparsity.add(dofs_on_this_cell[i],
895 dofs_on_other_cell[j]);
896 sparsity.add(dofs_on_other_cell[i],
897 dofs_on_this_cell[j]);
898 sparsity.add(dofs_on_this_cell[i],
899 dofs_on_this_cell[j]);
900 sparsity.add(dofs_on_other_cell[i],
901 dofs_on_other_cell[j]);
905 if (i_non_zero_i && j_non_zero_e)
906 sparsity.add(dofs_on_this_cell[i],
907 dofs_on_other_cell[j]);
908 if (i_non_zero_e && j_non_zero_i)
909 sparsity.add(dofs_on_other_cell[i],
910 dofs_on_this_cell[j]);
911 if (i_non_zero_i && j_non_zero_i)
912 sparsity.add(dofs_on_this_cell[i],
913 dofs_on_this_cell[j]);
914 if (i_non_zero_e && j_non_zero_e)
915 sparsity.add(dofs_on_other_cell[i],
916 dofs_on_other_cell[j]);
921 sparsity.add(dofs_on_this_cell[j],
922 dofs_on_other_cell[i]);
923 sparsity.add(dofs_on_other_cell[j],
924 dofs_on_this_cell[i]);
925 sparsity.add(dofs_on_this_cell[j],
926 dofs_on_this_cell[i]);
927 sparsity.add(dofs_on_other_cell[j],
928 dofs_on_other_cell[i]);
932 if (j_non_zero_i && i_non_zero_e)
933 sparsity.add(dofs_on_this_cell[j],
934 dofs_on_other_cell[i]);
935 if (j_non_zero_e && i_non_zero_i)
936 sparsity.add(dofs_on_other_cell[j],
937 dofs_on_this_cell[i]);
938 if (j_non_zero_i && i_non_zero_i)
939 sparsity.add(dofs_on_this_cell[j],
940 dofs_on_this_cell[i]);
941 if (j_non_zero_e && i_non_zero_e)
942 sparsity.add(dofs_on_other_cell[j],
943 dofs_on_other_cell[i]);
947 neighbor->face(neighbor_face)->set_user_flag();
954 .load_user_flags(user_flags);
959 template <
int dim,
typename SparsityPatternType,
int spacedim>
962 SparsityPatternType & sparsity,
963 const unsigned int level,
980 Assert(sparsity.n_rows() == coarse_dofs,
982 Assert(sparsity.n_cols() == fine_dofs,
984 Assert(flux_mask.n_rows() == n_comp,
986 Assert(flux_mask.n_cols() == n_comp,
990 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
991 std::vector<types::global_dof_index> dofs_on_other_cell(dofs_per_cell);
1001 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1005 for (; cell != endc; ++cell)
1007 if (!cell->is_locally_owned_on_level())
1010 cell->get_mg_dof_indices(dofs_on_this_cell);
1015 bool use_face =
false;
1016 if ((!cell->at_boundary(face)) &&
1017 (
static_cast<unsigned int>(cell->neighbor_level(face)) !=
1020 else if (cell->has_periodic_neighbor(face) &&
1021 (
static_cast<unsigned int>(
1022 cell->periodic_neighbor_level(face)) !=
level))
1028 cell->neighbor_or_periodic_neighbor(face);
1029 neighbor->get_mg_dof_indices(dofs_on_other_cell);
1031 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1033 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
1037 sparsity.add(dofs_on_other_cell[i],
1038 dofs_on_this_cell[j]);
1039 sparsity.add(dofs_on_other_cell[j],
1040 dofs_on_this_cell[i]);
1051 template <
int dim,
int spacedim,
typename SparsityPatternType>
1055 SparsityPatternType & sparsity,
1056 const unsigned int level)
1061 Assert(sparsity.n_rows() == n_dofs,
1063 Assert(sparsity.n_cols() == n_dofs,
1067 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
1070 for (; cell != endc; ++cell)
1071 if (cell->is_locally_owned_on_level())
1073 cell->get_mg_dof_indices(dofs_on_this_cell);
1074 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1075 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
1077 level, dofs_on_this_cell[i], dofs_on_this_cell[j]))
1078 sparsity.add(dofs_on_this_cell[i], dofs_on_this_cell[j]);
1084 template <
int dim,
int spacedim>
1088 std::vector<std::vector<types::global_dof_index>> &result,
1090 std::vector<unsigned int> target_component)
1094 const unsigned int nlevels =
1097 Assert(result.size() == nlevels,
1100 if (target_component.size() == 0)
1102 target_component.resize(n_components);
1103 for (
unsigned int i = 0; i < n_components; ++i)
1104 target_component[i] = i;
1107 Assert(target_component.size() == n_components,
1110 for (
unsigned int l = 0; l < nlevels; ++l)
1112 result[l].resize(n_components);
1113 std::fill(result[l].begin(), result[l].end(), 0U);
1119 if (n_components == 1)
1121 result[l][0] = dof_handler.
n_dofs(l);
1128 std::vector<std::vector<bool>> dofs_in_component(
1129 n_components, std::vector<bool>(dof_handler.
n_dofs(l),
false));
1130 std::vector<ComponentMask> component_select(n_components);
1132 for (
unsigned int i = 0; i < n_components; ++i)
1134 void (*fun_ptr)(
const unsigned int level,
1137 std::vector<bool> &) =
1138 &DoFTools::extract_level_dofs<dim, spacedim>;
1140 std::vector<bool> tmp(n_components,
false);
1147 component_select[i],
1148 dofs_in_component[i]);
1153 unsigned int component = 0;
1162 for (
unsigned int dd = 0; dd < d; ++dd)
1165 result[l][target_component[component]] +=
1166 std::count(dofs_in_component[component].begin(),
1167 dofs_in_component[component].end(),
1175 std::accumulate(result[l].begin(),
1186 template <
int dim,
int spacedim>
1190 std::vector<std::vector<types::global_dof_index>> &dofs_per_block,
1191 std::vector<unsigned int> target_block)
1194 const unsigned int n_blocks = fe.
n_blocks();
1195 const unsigned int n_levels =
1200 for (
unsigned int l = 0; l < n_levels; ++l)
1201 std::fill(dofs_per_block[l].begin(), dofs_per_block[l].end(), 0U);
1205 if (target_block.size() == 0)
1207 target_block.resize(n_blocks);
1208 for (
unsigned int i = 0; i < n_blocks; ++i)
1209 target_block[i] = i;
1211 Assert(target_block.size() == n_blocks,
1214 const unsigned int max_block =
1215 *std::max_element(target_block.begin(), target_block.end());
1216 const unsigned int n_target_blocks = max_block + 1;
1217 (void)n_target_blocks;
1219 for (
unsigned int l = 0; l < n_levels; ++l)
1228 for (
unsigned int l = 0; l < n_levels; ++l)
1229 dofs_per_block[l][0] = dof_handler.
n_dofs(l);
1235 for (
unsigned int l = 0; l < n_levels; ++l)
1237 std::vector<std::vector<bool>> dofs_in_block(
1238 n_blocks, std::vector<bool>(dof_handler.
n_dofs(l),
false));
1239 std::vector<BlockMask> block_select(n_blocks);
1241 for (
unsigned int i = 0; i < n_blocks; ++i)
1243 void (*fun_ptr)(
const unsigned int level,
1246 std::vector<bool> &) =
1247 &DoFTools::extract_level_dofs<dim, spacedim>;
1249 std::vector<bool> tmp(n_blocks,
false);
1251 block_select[i] = tmp;
1254 fun_ptr, l, dof_handler, block_select[i], dofs_in_block[i]);
1259 for (
unsigned int block = 0; block < fe.
n_blocks(); ++block)
1260 dofs_per_block[l][target_block[block]] +=
1261 std::count(dofs_in_block[block].begin(),
1262 dofs_in_block[block].end(),
1269 template <
int dim,
int spacedim>
1275 std::vector<std::set<types::global_dof_index>> &boundary_indices,
1282 std::set<types::boundary_id> boundary_ids;
1283 for (
const auto &boundary_function : function_map)
1284 boundary_ids.insert(boundary_function.first);
1286 std::vector<IndexSet> boundary_indexset;
1289 boundary_indices[i].insert(boundary_indexset[i].begin(),
1290 boundary_indexset[i].end());
1294 template <
int dim,
int spacedim>
1299 std::vector<IndexSet> &boundary_indices,
1306 std::set<types::boundary_id> boundary_ids;
1307 for (
const auto &boundary_function : function_map)
1308 boundary_ids.insert(boundary_function.first);
1315 template <
int dim,
int spacedim>
1318 const std::set<types::boundary_id> &boundary_ids,
1319 std::vector<IndexSet> & boundary_indices,
1325 if (boundary_ids.size() == 0)
1329 if (boundary_indices[i].size() == 0)
1333 const bool fe_is_system = (n_components != 1);
1335 std::vector<types::global_dof_index> local_dofs;
1339 std::vector<std::vector<types::global_dof_index>> dofs_by_level(
1348 if (cell->is_artificial_on_level())
1351 const unsigned int level = cell->level();
1354 if (cell->at_boundary(face_no) ==
true)
1357 cell->face(face_no);
1360 if (boundary_ids.find(bi) != boundary_ids.end())
1363 face->get_mg_dof_indices(
level, local_dofs);
1364 dofs_by_level[
level].insert(dofs_by_level[
level].end(),
1375 "It's probably worthwhile to select at least one component."));
1378 if (!cell->is_artificial_on_level())
1381 if (cell->at_boundary(face_no) ==
false)
1385 const unsigned int level = cell->level();
1388 cell->face(face_no);
1390 face->boundary_id();
1391 if (boundary_ids.find(boundary_component) != boundary_ids.end())
1394 for (
unsigned int i = 0;
1395 i < cell->get_fe().n_dofs_per_cell();
1399 cell->get_fe().get_nonzero_components(i);
1403 bool selected =
false;
1404 for (
unsigned int c = 0; c < n_components; ++c)
1405 if (nonzero_component_array[c] ==
true &&
1406 component_mask[c] ==
true)
1412 for (
unsigned int c = 0; c < n_components; ++c)
1414 nonzero_component_array[c] ==
false ||
1415 component_mask[c] ==
true,
1417 "You are using a non-primitive FiniteElement "
1418 "and try to constrain just some of its components!"));
1424 face->get_mg_dof_indices(
level, local_dofs);
1427 for (
unsigned int i = 0; i < local_dofs.size(); ++i)
1429 unsigned int component =
1441 cell->get_fe().get_nonzero_components(i);
1442 for (
unsigned int c = 0; c < n_components; ++c)
1443 if (nonzero_component_array[c] ==
true)
1451 if (component_mask[component] ==
true)
1452 dofs_by_level[
level].push_back(local_dofs[i]);
1456 dofs_by_level[
level].insert(dofs_by_level[
level].end(),
1465 std::sort(dofs_by_level[
level].begin(), dofs_by_level[
level].end());
1466 boundary_indices[
level].add_indices(
1467 dofs_by_level[
level].begin(),
1468 std::unique(dofs_by_level[
level].begin(),
1469 dofs_by_level[
level].end()));
1475 template <
int dim,
int spacedim>
1478 std::vector<IndexSet> & interface_dofs)
1480 Assert(interface_dofs.size() ==
1483 interface_dofs.size(),
1486 std::vector<std::vector<types::global_dof_index>> tmp_interface_dofs(
1487 interface_dofs.size());
1493 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
1495 std::vector<bool> cell_dofs(dofs_per_cell,
false);
1498 endc = mg_dof_handler.
end();
1500 for (; cell != endc; ++cell)
1504 if (cell->is_artificial_on_level())
1507 bool has_coarser_neighbor =
false;
1509 std::fill(cell_dofs.begin(), cell_dofs.end(),
false);
1514 cell->face(face_nr);
1515 if (!face->at_boundary() || cell->has_periodic_neighbor(face_nr))
1519 cell->neighbor_or_periodic_neighbor(face_nr);
1523 if (neighbor->is_artificial_on_level())
1527 if (neighbor->level() < cell->level())
1533 has_coarser_neighbor =
true;
1538 if (has_coarser_neighbor ==
false)
1541 const unsigned int level = cell->level();
1542 cell->get_mg_dof_indices(local_dof_indices);
1544 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1547 tmp_interface_dofs[
level].push_back(local_dof_indices[i]);
1551 for (
unsigned int l = 0;
1555 interface_dofs[l].
clear();
1556 std::sort(tmp_interface_dofs[l].begin(), tmp_interface_dofs[l].end());
1557 interface_dofs[l].add_indices(tmp_interface_dofs[l].begin(),
1558 std::unique(tmp_interface_dofs[l].begin(),
1559 tmp_interface_dofs[l].end()));
1560 interface_dofs[l].compress();
1566 template <
int dim,
int spacedim>
1579 for (; cell != endc; ++cell)
1580 if (cell->is_locally_owned())
1582 min_level = cell->level();
1586 unsigned int global_min = min_level;
1605 const std::vector<types::global_dof_index> &n_cells_on_levels,
1608 std::vector<types::global_dof_index> n_cells_on_leves_max(
1609 n_cells_on_levels.size());
1610 std::vector<types::global_dof_index> n_cells_on_leves_sum(
1611 n_cells_on_levels.size());
1618 const double ideal_work = std::accumulate(n_cells_on_leves_sum.begin(),
1619 n_cells_on_leves_sum.end(),
1621 static_cast<double>(n_proc);
1623 std::accumulate(n_cells_on_leves_max.begin(),
1624 n_cells_on_leves_max.end(),
1636 std::pair<types::global_dof_index, types::global_dof_index>> &cells,
1639 std::vector<types::global_dof_index> cells_local(cells.size());
1640 std::vector<types::global_dof_index> cells_remote(cells.size());
1642 for (
unsigned int i = 0; i < cells.size(); ++i)
1644 cells_local[i] = cells[i].first;
1645 cells_remote[i] = cells[i].second;
1648 std::vector<types::global_dof_index> cells_local_sum(cells_local.size());
1651 std::vector<types::global_dof_index> cells_remote_sum(
1652 cells_remote.size());
1655 const auto n_cells_local =
1656 std::accumulate(cells_local_sum.begin(), cells_local_sum.end(), 0);
1657 const auto n_cells_remote =
1658 std::accumulate(cells_remote_sum.begin(), cells_remote_sum.end(), 0);
1660 return static_cast<double>(n_cells_local) /
1661 (n_cells_local + n_cells_remote);
1667 template <
int dim,
int spacedim>
1668 std::vector<types::global_dof_index>
1675 tr->is_multilevel_hierarchy_constructed(),
1677 "We can only compute the workload imbalance if the multilevel hierarchy has been constructed!"));
1681 std::vector<types::global_dof_index> n_cells_on_levels(n_global_levels);
1683 for (
unsigned int lvl = 0; lvl < n_global_levels; ++lvl)
1685 if (cell->is_locally_owned_on_level())
1686 ++n_cells_on_levels[lvl];
1688 return n_cells_on_levels;
1693 template <
int dim,
int spacedim>
1694 std::vector<types::global_dof_index>
1699 const unsigned int n_global_levels = trias.size();
1701 std::vector<types::global_dof_index> n_cells_on_levels(n_global_levels);
1703 for (
unsigned int lvl = 0; lvl < n_global_levels; ++lvl)
1704 for (
const auto &cell : trias[lvl]->active_cell_iterators())
1705 if (cell->is_locally_owned())
1706 ++n_cells_on_levels[lvl];
1708 return n_cells_on_levels;
1713 template <
int dim,
int spacedim>
1723 template <
int dim,
int spacedim>
1730 trias.back()->get_communicator());
1735 template <
int dim,
int spacedim>
1736 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
1741 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
1742 cells(n_global_levels);
1748 for (
unsigned int lvl = 0; lvl < n_global_levels - 1; ++lvl)
1750 if (cell->is_locally_owned_on_level() && cell->has_children())
1751 for (
unsigned int i = 0; i < GeometryInfo<dim>::max_children_per_cell;
1754 const auto level_subdomain_id =
1755 cell->child(i)->level_subdomain_id();
1756 if (level_subdomain_id == my_rank)
1757 ++cells[lvl + 1].first;
1759 ++cells[lvl + 1].second;
1769 template <
int dim,
int spacedim>
1770 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
1775 const unsigned int n_global_levels = trias.size();
1777 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
1778 cells(n_global_levels);
1780 const MPI_Comm communicator = trias.back()->get_communicator();
1784 for (
unsigned int lvl = 0; lvl < n_global_levels - 1; ++lvl)
1786 const auto &tria_coarse = *trias[lvl];
1787 const auto &tria_fine = *trias[lvl + 1];
1789 const unsigned int n_coarse_cells = tria_fine.n_global_coarse_cells();
1790 const unsigned int n_global_levels = tria_fine.n_global_levels();
1792 const ::internal::CellIDTranslator<dim> cell_id_translator(
1793 n_coarse_cells, n_global_levels);
1795 IndexSet is_fine_owned(cell_id_translator.size());
1796 IndexSet is_fine_required(cell_id_translator.size());
1798 for (
const auto &cell : tria_fine.active_cell_iterators())
1799 if (!cell->is_artificial() && cell->is_locally_owned())
1800 is_fine_owned.
add_index(cell_id_translator.translate(cell));
1802 for (
const auto &cell : tria_coarse.active_cell_iterators())
1803 if (!cell->is_artificial() && cell->is_locally_owned())
1805 if (cell->level() + 1u == tria_fine.n_global_levels())
1808 for (
unsigned int i = 0;
1809 i < GeometryInfo<dim>::max_children_per_cell;
1812 cell_id_translator.translate(cell, i));
1815 std::vector<unsigned int> is_fine_required_ranks(
1819 process(is_fine_owned,
1822 is_fine_required_ranks,
1827 std::pair<types::global_cell_index, types::global_cell_index>>,
1828 std::vector<unsigned int>>
1829 consensus_algorithm;
1830 consensus_algorithm.
run(process, communicator);
1832 for (
unsigned i = 0; i < is_fine_required.
n_elements(); ++i)
1833 if (is_fine_required_ranks[i] == my_rank)
1834 ++cells[lvl + 1].first;
1836 ++cells[lvl + 1].second;
1844 template <
int dim,
int spacedim>
1854 template <
int dim,
int spacedim>
1862 trias.back()->get_communicator());
1869#include "mg_tools.inst"
void add_entries_local_to_global(const std::vector< size_type > &local_dof_indices, SparsityPatternType &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
cell_iterator end() const
const FiniteElement< dim, spacedim > & get_fe(const unsigned int index=0) const
const hp::FECollection< dim, spacedim > & get_fe_collection() const
const Triangulation< dim, spacedim > & get_triangulation() const
types::global_dof_index n_dofs() const
cell_iterator begin(const unsigned int level=0) 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 MPI_Comm get_communicator() const
void save_user_flags(std::ostream &out) const
unsigned int n_levels() const
cell_iterator end() const
virtual unsigned int n_global_levels() const
void load_user_flags(std::istream &in)
active_cell_iterator begin_active(const unsigned int level=0) 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< 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)
unsigned int this_mpi_process(const MPI_Comm &mpi_communicator)
T min(const T &t, const MPI_Comm &mpi_communicator)
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)
static const unsigned int invalid_unsigned_int
const types::global_dof_index invalid_dof_index
const ::Triangulation< dim, spacedim > & tria