169 std::map<Point<spacedim>,
182 std::map<unsigned int, unsigned int>
187 for (
const auto &p :
other.coarse_cell_vertices)
203 for (
auto &v : cell.vertices)
213 other.coarse_cells.begin(),
214 other.coarse_cells.end());
217 other.coarse_cell_vertices.begin(),
218 other.coarse_cell_vertices.end());
223 other.coarse_cell_index_to_coarse_cell_id.begin(),
224 other.coarse_cell_index_to_coarse_cell_id.end());
226 for (
unsigned int i = 0; i < this->
cell_infos.size(); ++i)
227 this->cell_infos[i].
insert(this->cell_infos[i].
end(),
228 other.cell_infos[i].begin(),
229 other.cell_infos[i].end());
246 for (
unsigned int i = 0; i < this->
coarse_cells.size(); ++i)
247 temp.emplace_back(
this->coarse_cell_index_to_coarse_cell_id[i],
248 this->coarse_cells[i],
251 std::sort(temp.begin(),
253 [](
const auto &a,
const auto &b) {
254 return std::get<0>(a) < std::get<0>(b);
256 temp.erase(std::unique(temp.begin(),
258 [](
const auto &a,
const auto &b) {
259 return std::get<0>(a) == std::get<0>(b);
262 std::sort(temp.begin(),
264 [](
const auto &a,
const auto &b) {
265 return std::get<2>(a) < std::get<2>(b);
271 for (
unsigned int i = 0; i < temp.size(); ++i)
274 std::get<0>(temp[i]);
282 this->coarse_cell_vertices.end(),
285 return a.first < b.first;
290 this->coarse_cell_vertices.end(),
293 if (a.first == b.first)
295 Assert(a.second.distance(b.second) <=
297 std::max(a.second.norm(), b.second.norm()),
299 "In the process of merging the vertices of "
300 "the coarse meshes used on different processes, "
301 "there were two processes that used the same "
302 "vertex index for points that are not the same. "
303 "This suggests that you are using different "
304 "coarse meshes on different processes. This "
305 "should not happen."));
314 for (
unsigned int i = 0; i < this->
cell_infos.size(); ++i)
316 if (this->cell_infos[i].empty())
319 std::sort(this->cell_infos[i].
begin(),
320 this->cell_infos[i].
end(),
321 [](
const auto &a,
const auto &b) {
325 std::vector<CellData<dim>> temp;
326 temp.push_back(this->cell_infos[i][0]);
328 for (
unsigned int j = 1;
j < this->
cell_infos[i].size(); ++
j)
329 if (temp.back().id == cell_infos[i][
j].id)
331 temp.back().subdomain_id =
333 this->cell_infos[i][
j].subdomain_id);
334 temp.back().level_subdomain_id =
335 std::min(temp.back().level_subdomain_id,
336 this->cell_infos[i][
j].level_subdomain_id);
340 temp.push_back(this->cell_infos[i][
j]);
361 description.comm =
comm;
363 description.settings = settings;
368 std::map<unsigned int, unsigned int> map;
372 description.coarse_cell_vertices.push_back(
380 for (unsigned
int v = 0; v < cell.vertices.size(); ++v)
381 cell.vertices[v] = map[cell.vertices[v]];
383 description.coarse_cell_index_to_coarse_cell_id =
392 std::vector<std::pair<unsigned int, Point<spacedim>>>
403 template <
int dim,
int spacedim>
410 if (cell->level() != 0)
419 template <
typename DescriptionType,
int dim,
int spacedim>
422 const ::Triangulation<dim, spacedim> &tria,
424 const typename ::Triangulation<dim, spacedim>::cell_iterator &)>
427 const typename ::Triangulation<dim, spacedim>::cell_iterator &)>
429 const std::map<
unsigned int, std::vector<unsigned int>>
431 const std::map<unsigned int, unsigned int>
438 std::is_same_v<DescriptionType, Description<dim, spacedim>> ||
439 std::is_same_v<DescriptionType, DescriptionTemp<dim, spacedim>>,
440 "Wrong template type.");
444 (tria.get_mesh_smoothing() &
445 Triangulation<dim, spacedim>::limit_level_difference_at_vertices),
447 "Source triangulation has to be set up with "
448 "limit_level_difference_at_vertices if the construction of the "
449 "multigrid hierarchy is requested!"));
472 const typename ::Triangulation<dim, spacedim>::cell_iterator
506 tria.get_vertices()[i]);
512 for (unsigned
int v = 0; v < cell.vertices.size(); ++v)
522 i, tria.get_vertices()[i]);
529 std::vector<std::vector<bool>>
cell_marked(tria.n_levels());
530 for (
unsigned int l = 0;
l < tria.n_levels(); ++
l)
533 for (
int level = tria.get_triangulation().n_global_levels() - 1;
541 for (
const auto &cell : tria.cell_iterators_on_level(
level))
547 for (
const auto &cell : tria.active_cell_iterators())
558 [cell->vertex_index(v)])
564 for (
const auto &cell : tria.cell_iterators_on_level(
level))
574 for (
const auto &cell : tria.cell_iterators_on_level(0))
581 cell_data.material_id = cell->material_id();
582 cell_data.manifold_id = cell->manifold_id();
584 cell_data.vertices[v] = cell->vertex_index(v);
593 cell->id().get_coarse_cell_id());
602 tria.get_triangulation().n_global_levels());
607 for (
const auto &cell : tria.active_cell_iterators())
615 if (cell->is_active())
618 [cell->vertex_index(v)])
623 for (
unsigned int level = 0;
624 level < tria.get_triangulation().n_global_levels();
630 for (
const auto &cell : tria.cell_iterators_on_level(
level))
642 [cell->vertex_index(v)])
648 for (
const auto &cell : tria.cell_iterators_on_level(
level))
660 for (
const auto f : cell->face_indices())
663 cell->face(f)->boundary_id();
671 cell_info.manifold_id = cell->manifold_id();
675 for (
const auto line : cell->line_indices())
681 for (
const auto f : cell->face_indices())
716 template <
int dim,
int spacedim>
719 const ::Triangulation<dim, spacedim> &tria,
724 if (
const auto ptria =
729 ExcMessage(
"MPI communicators do not match."));
733 "For creation from a parallel::Triangulation, "
734 "my_rank has to equal the rank of the current process "
735 "in the given communicator."));
747 const unsigned int n_mpi_processes =
749 for (
const auto &cell : tria.active_cell_iterators())
750 Assert(cell->subdomain_id() < n_mpi_processes,
752 "You can't have a cell with subdomain_id of " +
753 std::to_string(cell->subdomain_id()) +
754 " when splitting the triangulation using an MPI "
755 " communicator with only " +
756 std::to_string(n_mpi_processes) +
" processes."));
768 return cell->subdomain_id();
772 return cell->level_subdomain_id();
775 std::map<unsigned int, std::vector<unsigned int>>
795 template <
int dim,
int spacedim>
808#ifndef DEAL_II_WITH_MPI
833 typename ::Triangulation<dim, spacedim>::MeshSmoothing
>(
836 spacedim>::limit_level_difference_at_vertices) :
898 std::vector<char>
buf(
len);
925 template <
int dim,
int spacedim>
933 (partition.size() > 0) &&
939 (tria.get_mesh_smoothing() &
942 "Source triangulation has to be set up with "
943 "limit_level_difference_at_vertices if the construction of the "
944 "multigrid hierarchy is requested!"));
946 std::vector<LinearAlgebra::distributed::Vector<double>>
partitions_mg;
962 for (
unsigned int l = 0; l < tria.n_global_levels(); ++l)
964 tria_parallel->global_level_cell_index_partitioner(l).lock());
974 partition.update_ghost_values();
977 for (
const auto &cell : tria.cell_iterators_on_level(
level))
979 if (cell->is_locally_owned_on_level())
981 if (cell->is_active())
983 partition[cell->global_active_cell_index()];
988 ->global_level_cell_index()];
1009 template <
int dim,
int spacedim>
1018#ifdef DEAL_II_WITH_MPI
1023 if (partition.size() == 0)
1032 partition.update_ghost_values();
1034 partition.update_ghost_values();
1050 partition.get_mpi_communicator());
1053 for (
unsigned int i = 0; i < partition.locally_owned_size(); ++i)
1055 Assert(
static_cast<unsigned int>(partition.local_element(i)) ==
1056 partition.local_element(i),
1058 "The elements of a partition vector must be integers."));
1062 "The elements of a partition vector must be between zero "
1063 "and the number of processes in the communicator "
1064 "to be used for partitioning the triangulation."));
1066 static_cast<unsigned int>(partition.local_element(i)));
1070 for (
unsigned int i = 0; i < partition.locally_owned_size(); ++i)
1073 static_cast<unsigned int>(partition.local_element(i)) ==
1074 partition.local_element(i),
1076 "The elements of a partition vector must be integers."));
1080 "The elements of a partition vector must be between zero "
1081 "and the number of processes in the communicator "
1082 "to be used for partitioning the triangulation."));
1084 static_cast<unsigned int>(partition.local_element(i)));
1106 if ((cell->is_active() && (cell->is_artificial() ==
false)))
1108 partition[cell->global_active_cell_index()]);
1118 partitions_mg[cell->level()][cell->global_level_cell_index()]);
1131 std::map<unsigned int, std::vector<unsigned int>>
1146 tria.get_mpi_communicator(),
1156 partition.get_mpi_communicator(),
1166 tria.get_mesh_smoothing(),
1176#include "grid/tria_description.inst"