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;
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;
555 row_lengths[cell_indices[local_dof]] +=
560 for (
unsigned int local_dof = 0;
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.empty())
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(), 0
U);
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)
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(), 0
U);
1174 if (target_block.empty())
1177 for (
unsigned int i = 0; i <
n_blocks; ++i)
1178 target_block[i] = i;
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(
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);
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.empty())
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);
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]);
1442 template <
int dim,
int spacedim>
1445 std::vector<IndexSet> &interface_dofs)
1447 Assert(interface_dofs.size() ==
1450 interface_dofs.size(),
1453 std::vector<std::vector<types::global_dof_index>> tmp_interface_dofs(
1454 interface_dofs.size());
1460 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
1462 std::vector<bool> cell_dofs(dofs_per_cell,
false);
1468 if (cell->is_artificial_on_level())
1471 bool has_coarser_neighbor =
false;
1473 std::fill(cell_dofs.begin(), cell_dofs.end(),
false);
1478 cell->face(face_nr);
1479 if (!face->at_boundary() || cell->has_periodic_neighbor(face_nr))
1483 cell->neighbor_or_periodic_neighbor(face_nr);
1487 if (neighbor->is_artificial_on_level())
1491 if (neighbor->level() < cell->level())
1497 has_coarser_neighbor =
true;
1502 if (has_coarser_neighbor ==
false)
1505 const unsigned int level = cell->level();
1506 cell->get_mg_dof_indices(local_dof_indices);
1508 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1511 tmp_interface_dofs[
level].push_back(local_dof_indices[i]);
1515 for (
unsigned int l = 0;
1519 interface_dofs[
l].clear();
1520 std::sort(tmp_interface_dofs[
l].
begin(), tmp_interface_dofs[
l].
end());
1521 interface_dofs[
l].add_indices(tmp_interface_dofs[
l].
begin(),
1522 tmp_interface_dofs[
l].
end());
1523 interface_dofs[
l].compress();
1529 template <
int dim,
int spacedim>
1540 if (cell->is_locally_owned())
1542 min_level = cell->level();
1546 unsigned int global_min = min_level;
1565 const std::vector<types::global_dof_index> &n_cells_on_levels,
1566 const MPI_Comm
comm)
1568 std::vector<types::global_dof_index> n_cells_on_levels_max(
1569 n_cells_on_levels.size());
1570 std::vector<types::global_dof_index> n_cells_on_levels_sum(
1571 n_cells_on_levels.size());
1578 const double ideal_work = std::accumulate(n_cells_on_levels_sum.begin(),
1579 n_cells_on_levels_sum.end(),
1581 static_cast<double>(n_proc);
1583 std::accumulate(n_cells_on_levels_max.begin(),
1584 n_cells_on_levels_max.end(),
1596 std::pair<types::global_dof_index, types::global_dof_index>> &cells,
1597 const MPI_Comm
comm)
1599 std::vector<types::global_dof_index> cells_local(cells.size());
1600 std::vector<types::global_dof_index> cells_remote(cells.size());
1602 for (
unsigned int i = 0; i < cells.size(); ++i)
1604 cells_local[i] = cells[i].first;
1605 cells_remote[i] = cells[i].second;
1608 std::vector<types::global_dof_index> cells_local_sum(cells_local.size());
1611 std::vector<types::global_dof_index> cells_remote_sum(
1612 cells_remote.size());
1615 const auto n_cells_local =
1616 std::accumulate(cells_local_sum.begin(), cells_local_sum.end(), 0);
1617 const auto n_cells_remote =
1618 std::accumulate(cells_remote_sum.begin(), cells_remote_sum.end(), 0);
1620 return static_cast<double>(n_cells_local) /
1621 (n_cells_local + n_cells_remote);
1627 template <
int dim,
int spacedim>
1628 std::vector<types::global_dof_index>
1635 tr->is_multilevel_hierarchy_constructed(),
1637 "We can only compute the workload imbalance if the multilevel hierarchy has been constructed!"));
1641 std::vector<types::global_dof_index> n_cells_on_levels(n_global_levels);
1643 for (
unsigned int lvl = 0; lvl < n_global_levels; ++lvl)
1645 if (cell->is_locally_owned_on_level())
1646 ++n_cells_on_levels[lvl];
1648 return n_cells_on_levels;
1653 template <
int dim,
int spacedim>
1654 std::vector<types::global_dof_index>
1659 const unsigned int n_global_levels = trias.size();
1661 std::vector<types::global_dof_index> n_cells_on_levels(n_global_levels);
1663 for (
unsigned int lvl = 0; lvl < n_global_levels; ++lvl)
1664 for (
const auto &cell : trias[lvl]->active_cell_iterators())
1665 if (cell->is_locally_owned())
1666 ++n_cells_on_levels[lvl];
1668 return n_cells_on_levels;
1673 template <
int dim,
int spacedim>
1683 template <
int dim,
int spacedim>
1690 trias.back()->get_communicator());
1695 template <
int dim,
int spacedim>
1696 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
1701 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
1702 cells(n_global_levels);
1708 for (
unsigned int lvl = 0; lvl < n_global_levels - 1; ++lvl)
1710 if (cell->is_locally_owned_on_level() && cell->has_children())
1711 for (
unsigned int i = 0; i < GeometryInfo<dim>::max_children_per_cell;
1714 const auto level_subdomain_id =
1715 cell->child(i)->level_subdomain_id();
1716 if (level_subdomain_id == my_rank)
1717 ++cells[lvl + 1].first;
1719 ++cells[lvl + 1].second;
1729 template <
int dim,
int spacedim>
1730 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
1735 const unsigned int n_global_levels = trias.size();
1737 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>
1738 cells(n_global_levels);
1740 const MPI_Comm communicator = trias.back()->get_communicator();
1744 for (
unsigned int lvl = 0; lvl < n_global_levels - 1; ++lvl)
1746 const auto &tria_coarse = *trias[lvl];
1747 const auto &tria_fine = *trias[lvl + 1];
1749 const unsigned int n_coarse_cells = tria_fine.n_global_coarse_cells();
1750 const unsigned int n_global_levels = tria_fine.n_global_levels();
1752 const ::internal::CellIDTranslator<dim> cell_id_translator(
1753 n_coarse_cells, n_global_levels);
1755 IndexSet is_fine_owned(cell_id_translator.size());
1756 IndexSet is_fine_required(cell_id_translator.size());
1758 for (
const auto &cell : tria_fine.active_cell_iterators())
1759 if (!cell->is_artificial() && cell->is_locally_owned())
1760 is_fine_owned.
add_index(cell_id_translator.translate(cell));
1762 for (
const auto &cell : tria_coarse.active_cell_iterators())
1763 if (!cell->is_artificial() && cell->is_locally_owned())
1765 if (cell->level() + 1u == tria_fine.n_global_levels())
1768 for (
unsigned int i = 0;
1769 i < GeometryInfo<dim>::max_children_per_cell;
1772 cell_id_translator.translate(cell, i));
1775 std::vector<unsigned int> is_fine_required_ranks(
1779 process(is_fine_owned,
1782 is_fine_required_ranks,
1787 std::pair<types::global_cell_index, types::global_cell_index>>,
1788 std::vector<unsigned int>>
1789 consensus_algorithm;
1790 consensus_algorithm.
run(process, communicator);
1792 for (
unsigned i = 0; i < is_fine_required.
n_elements(); ++i)
1793 if (is_fine_required_ranks[i] == my_rank)
1794 ++cells[lvl + 1].first;
1796 ++cells[lvl + 1].second;
1804 template <
int dim,
int spacedim>
1814 template <
int dim,
int spacedim>
1822 trias.back()->get_communicator());
1829 #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 Triangulation< dim, spacedim > & get_triangulation() const
types::global_dof_index n_dofs() const
const FiniteElement< dim, spacedim > & get_fe(const types::fe_index index=0) const
const hp::FECollection< dim, spacedim > & get_fe_collection() 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, unsigned int > system_to_component_index(const unsigned int index) const
std::pair< unsigned int, types::global_dof_index > system_to_block_index(const unsigned int component) 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
virtual const FiniteElement< dim, spacedim > & base_element(const unsigned int index) const
unsigned int element_multiplicity(const unsigned int index) const
std::pair< unsigned int, unsigned int > face_system_to_component_index(const unsigned int index, const unsigned int face_no=0) const
unsigned int n_base_elements() 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< active_cell_iterator > active_cell_iterators() const
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 & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
#define Assert(cond, exc)
static ::ExceptionBase & ExcNotImplemented()
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcIndexRange(std::size_t arg1, std::size_t arg2, std::size_t arg3)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
typename ActiveSelector::cell_iterator cell_iterator
Task< RT > new_task(const std::function< RT()> &function)
std::enable_if_t< IsBlockVector< VectorType >::value, unsigned int > n_blocks(const VectorType &vector)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
VectorType::value_type * begin(VectorType &V)
VectorType::value_type * end(VectorType &V)
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
unsigned int global_dof_index
unsigned short int fe_index
const ::Triangulation< dim, spacedim > & tria