From: Martin Kronbichler Date: Tue, 22 Aug 2023 13:19:24 +0000 (+0200) Subject: Merge pull request #15807 from peterrum/FineDoFHandlerViewBase X-Git-Tag: relicensing~569 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3b4ff4147fac613da3b1ab607c9689182491c47;p=dealii.git Merge pull request #15807 from peterrum/FineDoFHandlerViewBase MGTwoLevelTransfer: specialize setup for FCP and p-mg --- e3b4ff4147fac613da3b1ab607c9689182491c47 diff --cc include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h index 169ed71000,fcf2c8f5e5..09d0f53ced --- a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h +++ b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h @@@ -999,75 -1404,15 +1408,79 @@@ namespace interna is_dst_remote, is_src_locally_owned, true); + + // check if meshes are compatible + if (mg_level_coarse == numbers::invalid_unsigned_int) + { + std::vector not_found_cells_local; + + const auto coarse_operation_check = [&](const auto &cell) { + bool flag = false; + + const auto index = this->cell_id_translator.translate(cell); + + flag |= this->is_dst_remote.is_element(index) || + this->is_dst_locally_owned.is_element(index); + + if (cell->level() + 1u != tria_dst.n_global_levels()) + { + for (unsigned int i = 0; + i < GeometryInfo::max_children_per_cell; + ++i) + { + const auto index = + this->cell_id_translator.translate(cell, i); + + flag |= this->is_dst_remote.is_element(index) || + this->is_dst_locally_owned.is_element(index); + } + } + + if (!flag) + not_found_cells_local.emplace_back(cell->id().to_string()); + }; + + loop_over_active_or_level_cells(tria_src, + mg_level_coarse, + coarse_operation_check); + + auto not_found_cells = + Utilities::MPI::reduce>( + not_found_cells_local, + this->communicator, + [](const auto &a, const auto &b) { + auto result = a; + result.insert(result.end(), b.begin(), b.end()); + return result; + }, + 0); + + if (Utilities::MPI::this_mpi_process(this->communicator) == 0 && + !not_found_cells.empty()) + { + std::sort(not_found_cells.begin(), not_found_cells.end()); + + const std::string str = + boost::algorithm::join(not_found_cells, ", "); + + AssertThrow( + false, + ExcMessage( + "Problem setting up two-level transfer operator, since coarse triangulation " + "seems to be obtainable by simple coarsening. Following coarse cells " + "or children cells could not be found in the fine mesh: " + + str + ".")); + } + } } + + virtual ~GlobalCoarseningFineDoFHandlerView() = default; }; + + template - class PermutationFineDoFHandlerView : public internal::FineDoFHandlerView + class PermutationFineDoFHandlerView : public BlackBoxFineDoFHandlerView { public: PermutationFineDoFHandlerView(const DoFHandler &dof_handler_dst,