From: Peter Munch Date: Wed, 24 Feb 2021 23:49:12 +0000 (+0100) Subject: Simplify code of create_geometric_coarsening_sequence() X-Git-Tag: v9.3.0-rc1~408^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0dde4997f0a3c4d6eea4f75a3be1be02bf929b3;p=dealii.git Simplify code of create_geometric_coarsening_sequence() --- diff --git a/include/deal.II/multigrid/mg_transfer_global_coarsening.h b/include/deal.II/multigrid/mg_transfer_global_coarsening.h index 5d2d276bb2..228f1ab2d3 100644 --- a/include/deal.II/multigrid/mg_transfer_global_coarsening.h +++ b/include/deal.II/multigrid/mg_transfer_global_coarsening.h @@ -96,7 +96,7 @@ namespace MGTransferGlobalCoarseningTools * @note Currently, only implemented for parallel::distributed::Triangulation. */ template - std::vector>> + std::vector>> create_geometric_coarsening_sequence( const Triangulation &tria); diff --git a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h index 034dff589e..933f550cbc 100644 --- a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h +++ b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h @@ -1873,15 +1873,23 @@ namespace MGTransferGlobalCoarseningTools } // namespace internal template - std::vector>> + std::vector>> create_geometric_coarsening_sequence( const Triangulation &fine_triangulation_in) { - std::vector>> - coarse_grid_triangulations; + std::vector>> + coarse_grid_triangulations(fine_triangulation_in.n_global_levels()); + + coarse_grid_triangulations.back().reset(&fine_triangulation_in, [](auto &) { + // empty deleter, since fine_triangulation_in is an external field + // and its destructor is called somewhere else + }); + + // for a single level nothing has to be done + if (fine_triangulation_in.n_global_levels() == 1) + return coarse_grid_triangulations; #ifndef DEAL_II_WITH_P4EST - (void)fine_triangulation_in; Assert(false, ExcNotImplemented()); #else const auto fine_triangulation = @@ -1895,15 +1903,6 @@ namespace MGTransferGlobalCoarseningTools const auto coarse_mesh_description = GridTools::get_coarse_mesh_description(*fine_triangulation); - coarse_grid_triangulations.resize(fine_triangulation->n_global_levels()); - - coarse_grid_triangulations[max_level].reset( - const_cast *>(&fine_triangulation_in), - [](auto &) { - // empty deleter, since fine_triangulation_in is an external field - // and its destructor is called somewhere else - }); - // create coarse meshes for (unsigned int l = max_level; l > 0; --l) { diff --git a/source/multigrid/mg_transfer_global_coarsening.inst.in b/source/multigrid/mg_transfer_global_coarsening.inst.in index 458227c55b..65365814f9 100644 --- a/source/multigrid/mg_transfer_global_coarsening.inst.in +++ b/source/multigrid/mg_transfer_global_coarsening.inst.in @@ -25,7 +25,7 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) { #if deal_II_dimension <= deal_II_space_dimension template std::vector>> + const Triangulation>> MGTransferGlobalCoarseningTools::create_geometric_coarsening_sequence( const Triangulation &fine_triangulation_in);