490 is_ghost.add_indices(is_ghost_vector.begin(), is_ghost_vector.end());
492 number_cache.active_cell_index_partitioner =
493 std::make_shared<const Utilities::MPI::Partitioner>(
494 is_local, is_ghost, this->mpi_communicator);
497 if (this->is_multilevel_hierarchy_constructed() ==
true)
500 std::vector<types::global_cell_index> n_cells_level(
501 this->n_global_levels(), 0);
503 for (
auto cell : this->cell_iterators())
504 if (cell->level_subdomain_id() == this->locally_owned_subdomain())
505 n_cells_level[cell->
level()]++;
508 std::vector<types::global_cell_index>
cell_index(
509 this->n_global_levels(), 0);
511 int ierr = MPI_Exscan(
512 n_cells_level.data(),
514 this->n_global_levels(),
517 this->mpi_communicator);
522 this->mpi_communicator,
528 std::pair<types::global_cell_index, types::global_cell_index>>
529 my_ranges(this->n_global_levels());
530 for (
unsigned int l = 0; l < this->n_global_levels(); ++l)
533 for (
auto cell : this->cell_iterators())
534 if (cell->level_subdomain_id() == this->locally_owned_subdomain())
539 for (
unsigned int l = 0; l < this->n_global_levels(); ++l)
543 std::vector<std::vector<types::global_dof_index>> is_ghost_vectors(
544 this->n_global_levels());
549 [](
const auto &cell) {
return cell->global_level_cell_index(); },
550 [&is_ghost_vectors](
const auto &cell,
const auto &id) {
551 cell->set_global_level_cell_index(
id);
552 is_ghost_vectors[cell->level()].push_back(
id);
555 number_cache.level_cell_index_partitioners.resize(
556 this->n_global_levels());
559 for (
unsigned int l = 0; l < this->n_global_levels(); ++l)
561 IndexSet is_local(n_cells_level[l]);
562 is_local.add_range(my_ranges[l].
first, my_ranges[l].
second);
564 IndexSet is_ghost(n_cells_level[l]);
565 std::sort(is_ghost_vectors[l].begin(), is_ghost_vectors[l].end());
566 is_ghost.add_indices(is_ghost_vectors[l].begin(),
567 is_ghost_vectors[l].end());
569 number_cache.level_cell_index_partitioners[l] =
570 std::make_shared<const Utilities::MPI::Partitioner>(
571 is_local, is_ghost, this->mpi_communicator);
580 template <
int dim,
int spacedim>
583 const
std::vector<
bool> &vertex_locally_moved)
588 const std::vector<bool> locally_owned_vertices =
590 for (
unsigned int i = 0; i < locally_owned_vertices.size(); ++i)
591 Assert((vertex_locally_moved[i] ==
false) ||
592 (locally_owned_vertices[i] ==
true),
593 ExcMessage(
"The vertex_locally_moved argument must not "
594 "contain vertices that are not locally owned"));
599 for (
unsigned int d = 0; d < spacedim; ++d)
600 invalid_point[d] = std::numeric_limits<double>::quiet_NaN();
602 const auto pack = [&](
const auto &cell) {
603 std::vector<Point<spacedim>> vertices(cell->n_vertices());
605 for (
const auto v : cell->vertex_indices())
606 if (vertex_locally_moved[cell->vertex_index(v)])
607 vertices[v] = cell->vertex(v);
609 vertices[v] = invalid_point;
614 const auto unpack = [&](
const auto &cell,
const auto &vertices) {
615 for (
const auto v : cell->vertex_indices())
617 cell->vertex(v) = vertices[v];
620 if (this->is_multilevel_hierarchy_constructed())
627 GridTools::exchange_cell_data_to_ghosts<std::vector<Point<spacedim>>>(
635 template <
int dim,
int spacedim>
639 spacedim>::global_active_cell_index_partitioner()
const
641 return number_cache.active_cell_index_partitioner;
646 template <
int dim,
int spacedim>
650 global_level_cell_index_partitioner(
const unsigned int level)
const
655 return number_cache.level_cell_index_partitioners[
level];
660 template <
int dim,
int spacedim>
665 return number_cache.number_of_global_coarse_cells;
670 template <
int dim,
int spacedim>
676 const
bool check_for_distorted_cells)
680 check_for_distorted_cells)
685 template <
int dim,
int spacedim>
696 template <
int dim,
int spacedim>
700 if (this->n_global_levels() <= 1)
709 const bool have_coarser_cell =
710 std::any_of(this->begin_active(this->n_global_levels() - 2),
711 this->end_active(this->n_global_levels() - 2),
718 this->mpi_communicator) != 0;