60 std::vector<unsigned int> &,
72 std::vector<unsigned int> &,
85 std::vector<unsigned int> &,
96 std::vector<unsigned int> &,
106 template <
int dim,
int spacedim>
109 const unsigned int level,
110 std::vector<unsigned int> &row_lengths,
118 std::fill(row_lengths.begin(), row_lengths.end(), 0);
120 std::vector<bool> face_touched(dim == 2 ?
124 std::vector<types::global_dof_index> cell_indices;
125 std::vector<types::global_dof_index> neighbor_indices;
138 cell->get_mg_dof_indices(cell_indices);
162 const unsigned int face_no = 0;
167 unsigned int increment =
170 row_lengths[cell_indices[i++]] += increment;
187 row_lengths[cell_indices[i++]] += increment;
196 row_lengths[cell_indices[i++]] += increment;
201 row_lengths[cell_indices[i++]] += increment;
216 bool level_boundary = cell->at_boundary(iface);
220 neighbor = cell->neighbor(iface);
221 if (
static_cast<unsigned int>(neighbor->level()) !=
level)
222 level_boundary =
true;
227 for (
unsigned int local_dof = 0;
230 row_lengths[cell_indices[local_dof]] +=
249 const unsigned int dof_increment =
251 for (
unsigned int local_dof = 0;
254 row_lengths[cell_indices[local_dof]] += dof_increment;
259 if (face_touched[face->index()])
261 face_touched[face->index()] =
true;
276 neighbor->get_mg_dof_indices(neighbor_indices);
279 row_lengths[cell_indices[local_dof]] +=
283 row_lengths[neighbor_indices[local_dof]] +=
291 template <
int dim,
int spacedim>
294 const unsigned int level,
295 std::vector<unsigned int> &row_lengths,
304 std::fill(row_lengths.begin(), row_lengths.end(), 0);
306 std::vector<bool> face_touched(dim == 2 ?
310 std::vector<types::global_dof_index> cell_indices;
311 std::vector<types::global_dof_index> neighbor_indices;
317 std::vector<Table<2, DoFTools::Coupling>> couple_cell;
318 std::vector<Table<2, DoFTools::Coupling>> couple_face;
332 const unsigned int fe_index = cell->active_fe_index();
336 const unsigned int face_no = 0;
352 cell->get_mg_dof_indices(cell_indices);
375 unsigned int increment;
388 row_lengths[cell_indices[i]] += increment;
413 ((dim > 1) ? (dim - 1) :
416 row_lengths[cell_indices[i]] += increment;
433 ((dim > 2) ? (dim - 2) :
436 row_lengths[cell_indices[i]] += increment;
455 row_lengths[cell_indices[i]] += increment;
473 bool level_boundary = cell->at_boundary(iface);
477 neighbor = cell->neighbor(iface);
478 if (
static_cast<unsigned int>(neighbor->level()) !=
level)
479 level_boundary =
true;
484 for (
unsigned int local_dof = 0;
487 row_lengths[cell_indices[local_dof]] +=
507 for (
unsigned int local_dof = 0;
510 if (couple_face[fe_index](
514 const unsigned int dof_increment =
517 row_lengths[cell_indices[local_dof]] += dof_increment;
521 if (face_touched[face->index()])
523 face_touched[face->index()] =
true;
546 neighbor->get_mg_dof_indices(neighbor_indices);
550 for (
unsigned int local_dof = 0;
553 if (couple_cell[fe_index](
556 row_lengths[cell_indices[local_dof]] +=
561 for (
unsigned int local_dof = 0;
564 if (couple_cell[fe_index](
567 row_lengths[neighbor_indices[local_dof]] +=
575 template <
int dim,
int spacedim,
typename number>
579 const unsigned int level,
581 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)
620 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
621 std::vector<types::global_dof_index> dofs_on_other_cell(dofs_per_cell);
624 if (!cell->is_locally_owned_on_level())
627 cell->get_mg_dof_indices(dofs_on_this_cell);
631 keep_constrained_dofs);
636 bool use_face =
false;
637 if ((!cell->at_boundary(face)) &&
638 (
static_cast<unsigned int>(cell->neighbor_level(face)) ==
641 else if (cell->has_periodic_neighbor(face) &&
642 (
static_cast<unsigned int>(
643 cell->periodic_neighbor_level(face)) ==
level))
649 cell->neighbor_or_periodic_neighbor(face);
650 neighbor->get_mg_dof_indices(dofs_on_other_cell);
657 keep_constrained_dofs);
659 if (neighbor->is_locally_owned_on_level() ==
false)
662 dofs_on_other_cell, sparsity, keep_constrained_dofs);
668 keep_constrained_dofs);
677 template <
int dim,
int spacedim>
681 const unsigned int level)
696 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
697 std::vector<types::global_dof_index> dofs_on_other_cell(dofs_per_cell);
700 if (!cell->is_locally_owned_on_level())
703 cell->get_mg_dof_indices(dofs_on_this_cell);
708 bool use_face =
false;
709 if ((!cell->at_boundary(face)) &&
710 (
static_cast<unsigned int>(cell->neighbor_level(face)) !=
713 else if (cell->has_periodic_neighbor(face) &&
714 (
static_cast<unsigned int>(
715 cell->periodic_neighbor_level(face)) !=
level))
721 cell->neighbor_or_periodic_neighbor(face);
722 neighbor->get_mg_dof_indices(dofs_on_other_cell);
724 std::sort(dofs_on_this_cell.begin(), dofs_on_this_cell.end());
725 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
736 template <
int dim,
int spacedim>
740 const unsigned int level,
752 Assert(int_mask.n_rows() == n_comp,
754 Assert(int_mask.n_cols() == n_comp,
756 Assert(flux_mask.n_rows() == n_comp,
758 Assert(flux_mask.n_cols() == n_comp,
762 std::vector<types::global_dof_index> dofs_on_this_cell(total_dofs);
763 std::vector<types::global_dof_index> dofs_on_other_cell(total_dofs);
764 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
776 for (
unsigned int i = 0; i < total_dofs; ++i)
780 std::vector<bool> face_touched(dim == 2 ?
786 if (!cell->is_locally_owned_on_level())
789 cell->get_mg_dof_indices(dofs_on_this_cell);
791 for (
unsigned int i = 0; i < total_dofs; ++i)
792 for (
unsigned int j = 0; j < total_dofs; ++j)
794 cell_entries.emplace_back(dofs_on_this_cell[i],
795 dofs_on_this_cell[j]);
802 if (face_touched[cell_face->index()])
805 if (cell->at_boundary(face) && !cell->has_periodic_neighbor(face))
807 for (
unsigned int i = 0; i < total_dofs; ++i)
809 const bool i_non_zero_i = support_on_face(i, face);
810 for (
unsigned int j = 0; j < total_dofs; ++j)
812 const bool j_non_zero_i = support_on_face(j, face);
815 cell_entries.emplace_back(dofs_on_this_cell[i],
816 dofs_on_this_cell[j]);
818 i_non_zero_i && j_non_zero_i)
819 cell_entries.emplace_back(dofs_on_this_cell[i],
820 dofs_on_this_cell[j]);
827 cell->neighbor_or_periodic_neighbor(face);
829 if (neighbor->level() < cell->level())
832 unsigned int neighbor_face =
833 cell->has_periodic_neighbor(face) ?
834 cell->periodic_neighbor_of_periodic_neighbor(face) :
835 cell->neighbor_of_neighbor(face);
837 neighbor->get_mg_dof_indices(dofs_on_other_cell);
838 for (
unsigned int i = 0; i < total_dofs; ++i)
840 const bool i_non_zero_i = support_on_face(i, face);
841 const bool i_non_zero_e = support_on_face(i, neighbor_face);
842 for (
unsigned int j = 0; j < total_dofs; ++j)
844 const bool j_non_zero_i = support_on_face(j, face);
845 const bool j_non_zero_e =
846 support_on_face(j, neighbor_face);
849 cell_entries.emplace_back(dofs_on_this_cell[i],
850 dofs_on_other_cell[j]);
851 cell_entries.emplace_back(dofs_on_other_cell[i],
852 dofs_on_this_cell[j]);
853 cell_entries.emplace_back(dofs_on_this_cell[i],
854 dofs_on_this_cell[j]);
855 cell_entries.emplace_back(dofs_on_other_cell[i],
856 dofs_on_other_cell[j]);
860 if (i_non_zero_i && j_non_zero_e)
861 cell_entries.emplace_back(dofs_on_this_cell[i],
862 dofs_on_other_cell[j]);
863 if (i_non_zero_e && j_non_zero_i)
864 cell_entries.emplace_back(dofs_on_other_cell[i],
865 dofs_on_this_cell[j]);
866 if (i_non_zero_i && j_non_zero_i)
867 cell_entries.emplace_back(dofs_on_this_cell[i],
868 dofs_on_this_cell[j]);
869 if (i_non_zero_e && j_non_zero_e)
870 cell_entries.emplace_back(dofs_on_other_cell[i],
871 dofs_on_other_cell[j]);
876 cell_entries.emplace_back(dofs_on_this_cell[j],
877 dofs_on_other_cell[i]);
878 cell_entries.emplace_back(dofs_on_other_cell[j],
879 dofs_on_this_cell[i]);
880 cell_entries.emplace_back(dofs_on_this_cell[j],
881 dofs_on_this_cell[i]);
882 cell_entries.emplace_back(dofs_on_other_cell[j],
883 dofs_on_other_cell[i]);
887 if (j_non_zero_i && i_non_zero_e)
888 cell_entries.emplace_back(dofs_on_this_cell[j],
889 dofs_on_other_cell[i]);
890 if (j_non_zero_e && i_non_zero_i)
891 cell_entries.emplace_back(dofs_on_other_cell[j],
892 dofs_on_this_cell[i]);
893 if (j_non_zero_i && i_non_zero_i)
894 cell_entries.emplace_back(dofs_on_this_cell[j],
895 dofs_on_this_cell[i]);
896 if (j_non_zero_e && i_non_zero_e)
897 cell_entries.emplace_back(dofs_on_other_cell[j],
898 dofs_on_other_cell[i]);
902 face_touched[neighbor->face(neighbor_face)->index()] =
true;
906 cell_entries.clear();
912 template <
int dim,
int spacedim>
916 const unsigned int level,
934 Assert(flux_mask.n_rows() == n_comp,
936 Assert(flux_mask.n_cols() == n_comp,
940 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
941 std::vector<types::global_dof_index> dofs_on_other_cell(dofs_per_cell);
942 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
951 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
957 if (!cell->is_locally_owned_on_level())
960 cell->get_mg_dof_indices(dofs_on_this_cell);
965 bool use_face =
false;
966 if ((!cell->at_boundary(face)) &&
967 (
static_cast<unsigned int>(cell->neighbor_level(face)) !=
970 else if (cell->has_periodic_neighbor(face) &&
971 (
static_cast<unsigned int>(
972 cell->periodic_neighbor_level(face)) !=
level))
978 cell->neighbor_or_periodic_neighbor(face);
979 neighbor->get_mg_dof_indices(dofs_on_other_cell);
981 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
983 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
987 cell_entries.emplace_back(dofs_on_other_cell[i],
988 dofs_on_this_cell[j]);
989 cell_entries.emplace_back(dofs_on_other_cell[j],
990 dofs_on_this_cell[i]);
997 cell_entries.clear();
1003 template <
int dim,
int spacedim>
1008 const unsigned int level)
1017 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
1018 std::vector<types::global_dof_index> cols;
1019 cols.reserve(dofs_per_cell);
1022 if (cell->is_locally_owned_on_level())
1024 cell->get_mg_dof_indices(dofs_on_this_cell);
1025 std::sort(dofs_on_this_cell.begin(), dofs_on_this_cell.end());
1026 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1028 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
1030 level, dofs_on_this_cell[i], dofs_on_this_cell[j]))
1031 cols.push_back(dofs_on_this_cell[j]);
1042 template <
int dim,
int spacedim>
1046 std::vector<std::vector<types::global_dof_index>> &result,
1048 std::vector<unsigned int> target_component)
1052 const unsigned int nlevels =
1055 Assert(result.size() == nlevels,
1058 if (target_component.empty())
1060 target_component.resize(n_components);
1061 for (
unsigned int i = 0; i < n_components; ++i)
1062 target_component[i] = i;
1065 Assert(target_component.size() == n_components,
1068 for (
unsigned int l = 0; l < nlevels; ++l)
1070 result[l].resize(n_components);
1071 std::fill(result[l].begin(), result[l].end(), 0U);
1077 if (n_components == 1)
1079 result[l][0] = dof_handler.
n_dofs(l);
1086 std::vector<std::vector<bool>> dofs_in_component(
1087 n_components, std::vector<bool>(dof_handler.
n_dofs(l),
false));
1088 std::vector<ComponentMask> component_select(n_components);
1090 for (
unsigned int i = 0; i < n_components; ++i)
1092 void (*fun_ptr)(
const unsigned int level,
1095 std::vector<bool> &) =
1096 &DoFTools::extract_level_dofs<dim, spacedim>;
1098 std::vector<bool> tmp(n_components,
false);
1105 component_select[i],
1106 dofs_in_component[i]);
1111 unsigned int component = 0;
1120 for (
unsigned int dd = 0; dd < d; ++dd)
1123 result[l][target_component[component]] +=
1124 std::count(dofs_in_component[component].begin(),
1125 dofs_in_component[component].end(),
1133 std::accumulate(result[l].begin(),
1144 template <
int dim,
int spacedim>
1148 std::vector<std::vector<types::global_dof_index>> &dofs_per_block,
1149 std::vector<unsigned int> target_block)
1152 const unsigned int n_blocks = fe.
n_blocks();
1153 const unsigned int n_levels =
1158 for (
unsigned int l = 0; l < n_levels; ++l)
1159 std::fill(dofs_per_block[l].begin(), dofs_per_block[l].end(), 0U);
1163 if (target_block.empty())
1165 target_block.resize(n_blocks);
1166 for (
unsigned int i = 0; i < n_blocks; ++i)
1167 target_block[i] = i;
1169 Assert(target_block.size() == n_blocks,
1172 const unsigned int max_block =
1173 *std::max_element(target_block.begin(), target_block.end());
1174 const unsigned int n_target_blocks = max_block + 1;
1175 (void)n_target_blocks;
1177 for (
unsigned int l = 0; l < n_levels; ++l)
1186 for (
unsigned int l = 0; l < n_levels; ++l)
1187 dofs_per_block[l][0] = dof_handler.
n_dofs(l);
1193 for (
unsigned int l = 0; l < n_levels; ++l)
1195 std::vector<std::vector<bool>> dofs_in_block(
1196 n_blocks, std::vector<bool>(dof_handler.
n_dofs(l),
false));
1197 std::vector<BlockMask> block_select(n_blocks);
1199 for (
unsigned int i = 0; i < n_blocks; ++i)
1201 void (*fun_ptr)(
const unsigned int level,
1204 std::vector<bool> &) =
1205 &DoFTools::extract_level_dofs<dim, spacedim>;
1207 std::vector<bool> tmp(n_blocks,
false);
1212 fun_ptr, l, dof_handler, block_select[i], dofs_in_block[i]);
1217 for (
unsigned int block = 0; block < fe.
n_blocks(); ++block)
1218 dofs_per_block[l][target_block[block]] +=
1219 std::count(dofs_in_block[block].begin(),
1220 dofs_in_block[block].end(),
1227 template <
int dim,
int spacedim>
1233 std::vector<std::set<types::global_dof_index>> &boundary_indices,
1240 std::set<types::boundary_id> boundary_ids;
1241 for (
const auto &boundary_function : function_map)
1242 boundary_ids.insert(boundary_function.first);
1244 std::vector<IndexSet> boundary_indexset;
1247 boundary_indices[i].insert(boundary_indexset[i].begin(),
1248 boundary_indexset[i].end());
1252 template <
int dim,
int spacedim>
1257 std::vector<IndexSet> &boundary_indices,
1264 std::set<types::boundary_id> boundary_ids;
1265 for (
const auto &boundary_function : function_map)
1266 boundary_ids.insert(boundary_function.first);
1273 template <
int dim,
int spacedim>
1276 const std::set<types::boundary_id> &boundary_ids,
1277 std::vector<IndexSet> &boundary_indices,
1283 if (boundary_ids.empty())
1287 if (boundary_indices[i].
size() == 0)
1291 const bool fe_is_system = (n_components != 1);
1293 std::vector<types::global_dof_index> local_dofs;
1297 std::vector<std::vector<types::global_dof_index>> dofs_by_level(
1306 if (cell->is_artificial_on_level())
1309 const unsigned int level = cell->level();
1312 if (cell->at_boundary(face_no) ==
true)
1315 cell->face(face_no);
1318 if (boundary_ids.find(bi) != boundary_ids.end())
1321 face->get_mg_dof_indices(
level, local_dofs);
1322 dofs_by_level[
level].insert(dofs_by_level[
level].end(),
1333 "It's probably worthwhile to select at least one component."));
1336 if (!cell->is_artificial_on_level())
1339 if (cell->at_boundary(face_no) ==
false)
1343 const unsigned int level = cell->level();
1346 cell->face(face_no);
1348 face->boundary_id();
1349 if (boundary_ids.find(boundary_component) != boundary_ids.end())
1352 for (
unsigned int i = 0;
1353 i < cell->get_fe().n_dofs_per_cell();
1357 cell->get_fe().get_nonzero_components(i);
1361 bool selected =
false;
1362 for (
unsigned int c = 0; c < n_components; ++c)
1363 if (nonzero_component_array[c] ==
true &&
1364 component_mask[c] ==
true)
1370 for (
unsigned int c = 0; c < n_components; ++c)
1372 nonzero_component_array[c] ==
false ||
1373 component_mask[c] ==
true,
1375 "You are using a non-primitive FiniteElement "
1376 "and try to constrain just some of its components!"));
1382 face->get_mg_dof_indices(
level, local_dofs);
1385 for (
unsigned int i = 0; i < local_dofs.size(); ++i)
1387 unsigned int component =
1399 cell->get_fe().get_nonzero_components(i);
1400 for (
unsigned int c = 0; c < n_components; ++c)
1401 if (nonzero_component_array[c] ==
true)
1409 if (component_mask[component] ==
true)
1410 dofs_by_level[
level].push_back(local_dofs[i]);
1414 dofs_by_level[
level].insert(dofs_by_level[
level].end(),
1423 std::sort(dofs_by_level[
level].begin(), dofs_by_level[
level].end());
1424 boundary_indices[
level].add_indices(dofs_by_level[
level].begin(),
1425 dofs_by_level[
level].end());
1431 template <
int dim,
int spacedim>
1434 std::vector<IndexSet> &interface_dofs)
1436 Assert(interface_dofs.size() ==
1439 interface_dofs.size(),
1442 std::vector<std::vector<types::global_dof_index>> tmp_interface_dofs(
1443 interface_dofs.size());
1449 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
1451 std::vector<bool> cell_dofs(dofs_per_cell,
false);
1457 if (cell->is_artificial_on_level())
1460 bool has_coarser_neighbor =
false;
1462 std::fill(cell_dofs.begin(), cell_dofs.end(),
false);
1467 cell->face(face_nr);
1468 if (!face->at_boundary() || cell->has_periodic_neighbor(face_nr))
1472 cell->neighbor_or_periodic_neighbor(face_nr);
1476 if (neighbor->is_artificial_on_level())
1480 if (neighbor->level() < cell->level())
1486 has_coarser_neighbor =
true;
1491 if (has_coarser_neighbor ==
false)
1494 const unsigned int level = cell->level();
1495 cell->get_mg_dof_indices(local_dof_indices);
1497 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1500 tmp_interface_dofs[
level].push_back(local_dof_indices[i]);
1504 for (
unsigned int l = 0;
1508 interface_dofs[l].clear();
1509 std::sort(tmp_interface_dofs[l].begin(), tmp_interface_dofs[l].end());
1510 interface_dofs[l].add_indices(tmp_interface_dofs[l].begin(),
1511 tmp_interface_dofs[l].end());
1512 interface_dofs[l].compress();
1518 template <
int dim,
int spacedim>
1529 if (cell->is_locally_owned())
1531 min_level = cell->level();
1535 unsigned int global_min = min_level;
1554 const std::vector<types::global_dof_index> &n_cells_on_levels,
1557 std::vector<types::global_dof_index> n_cells_on_levels_max(
1558 n_cells_on_levels.size());
1559 std::vector<types::global_dof_index> n_cells_on_levels_sum(
1560 n_cells_on_levels.size());
1567 const double ideal_work = std::accumulate(n_cells_on_levels_sum.begin(),
1568 n_cells_on_levels_sum.end(),
1570 static_cast<double>(n_proc);
1572 std::accumulate(n_cells_on_levels_max.begin(),
1573 n_cells_on_levels_max.end(),
1585 std::pair<types::global_dof_index, types::global_dof_index>> &cells,
1588 std::vector<types::global_dof_index> cells_local(cells.size());
1589 std::vector<types::global_dof_index> cells_remote(cells.size());
1591 for (
unsigned int i = 0; i < cells.size(); ++i)
1593 cells_local[i] = cells[i].first;
1594 cells_remote[i] = cells[i].second;
1597 std::vector<types::global_dof_index> cells_local_sum(cells_local.size());
1600 std::vector<types::global_dof_index> cells_remote_sum(
1601 cells_remote.size());
1604 const auto n_cells_local =
1605 std::accumulate(cells_local_sum.begin(), cells_local_sum.end(), 0);
1606 const auto n_cells_remote =
1607 std::accumulate(cells_remote_sum.begin(), cells_remote_sum.end(), 0);
1609 return static_cast<double>(n_cells_local) /
1610 (n_cells_local + n_cells_remote);
1616 template <
int dim,
int spacedim>
1617 std::vector<types::global_dof_index>
1624 tr->is_multilevel_hierarchy_constructed(),
1626 "We can only compute the workload imbalance if the multilevel hierarchy has been constructed!"));
1630 std::vector<types::global_dof_index> n_cells_on_levels(n_global_levels);
1632 for (
unsigned int lvl = 0; lvl < n_global_levels; ++lvl)
1634 if (cell->is_locally_owned_on_level())
1635 ++n_cells_on_levels[lvl];
1637 return n_cells_on_levels;
1642 template <
int dim,
int spacedim>
1643 std::vector<types::global_dof_index>
1648 const unsigned int n_global_levels = trias.size();
1650 std::vector<types::global_dof_index> n_cells_on_levels(n_global_levels);
1652 for (
unsigned int lvl = 0; lvl < n_global_levels; ++lvl)
1653 for (
const auto &cell : trias[lvl]->active_cell_iterators())
1654 if (cell->is_locally_owned())
1655 ++n_cells_on_levels[lvl];
1657 return n_cells_on_levels;
1662 template <
int dim,
int spacedim>
1672 template <
int dim,
int spacedim>
1679 trias.back()->get_mpi_communicator());
1684 template <
int dim,
int spacedim>
1685 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
1690 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
1691 cells(n_global_levels);
1697 for (
unsigned int lvl = 0; lvl < n_global_levels - 1; ++lvl)
1699 if (cell->is_locally_owned_on_level() && cell->has_children())
1700 for (
unsigned int i = 0; i < GeometryInfo<dim>::max_children_per_cell;
1703 const auto level_subdomain_id =
1704 cell->child(i)->level_subdomain_id();
1705 if (level_subdomain_id ==
my_rank)
1706 ++cells[lvl + 1].first;
1708 ++cells[lvl + 1].second;
1718 template <
int dim,
int spacedim>
1719 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
1724 const unsigned int n_global_levels = trias.size();
1726 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
1727 cells(n_global_levels);
1729 const MPI_Comm communicator = trias.back()->get_mpi_communicator();
1733 for (
unsigned int lvl = 0; lvl < n_global_levels - 1; ++lvl)
1735 const auto &tria_coarse = *trias[lvl];
1736 const auto &tria_fine = *trias[lvl + 1];
1738 const unsigned int n_coarse_cells = tria_fine.n_global_coarse_cells();
1739 const unsigned int n_global_levels = tria_fine.n_global_levels();
1741 const ::internal::CellIDTranslator<dim> cell_id_translator(
1742 n_coarse_cells, n_global_levels);
1744 IndexSet is_fine_owned(cell_id_translator.size());
1745 IndexSet is_fine_required(cell_id_translator.size());
1747 for (
const auto &cell : tria_fine.active_cell_iterators())
1748 if (!cell->is_artificial() && cell->is_locally_owned())
1749 is_fine_owned.
add_index(cell_id_translator.translate(cell));
1751 for (
const auto &cell : tria_coarse.active_cell_iterators())
1752 if (!cell->is_artificial() && cell->is_locally_owned())
1754 if (cell->level() + 1u == tria_fine.n_global_levels())
1757 for (
unsigned int i = 0;
1758 i < GeometryInfo<dim>::max_children_per_cell;
1761 cell_id_translator.translate(cell, i));
1764 const std::vector<unsigned int> is_fine_required_ranks =
1769 for (
unsigned i = 0; i < is_fine_required.
n_elements(); ++i)
1770 if (is_fine_required_ranks[i] ==
my_rank)
1771 ++cells[lvl + 1].first;
1773 ++cells[lvl + 1].second;
1781 template <
int dim,
int spacedim>
1791 template <
int dim,
int spacedim>
1799 trias.back()->get_mpi_communicator());
1806#include "multigrid/mg_tools.inst"
ArrayView< std::remove_reference_t< typename std::iterator_traits< Iterator >::reference >, 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
std::pair< unsigned int, unsigned int > system_to_component_index(const unsigned int index) const
unsigned int element_multiplicity(const unsigned int index) const
virtual unsigned int face_to_cell_index(const unsigned int face_dof_index, const unsigned int face, const types::geometric_orientation combined_orientation=numbers::default_geometric_orientation) 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_mpi_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
unsigned int max_dofs_per_face() const
unsigned int n_components() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NOT_IMPLEMENTED()
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)
const unsigned int my_rank
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)
std::vector< unsigned int > compute_index_owner(const IndexSet &owned_indices, const IndexSet &indices_to_look_up, const MPI_Comm comm)
unsigned int this_mpi_process(const MPI_Comm mpi_communicator)
constexpr types::global_dof_index invalid_dof_index
constexpr unsigned int invalid_unsigned_int
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > face_indices()