From ad46017978ba0f3128663380133dcab927d30cd3 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 6 Sep 2018 14:58:03 -0600 Subject: [PATCH] Extend DoFRenumbering::hierarchical(). In particular, make it work for dim!=spacedim and for hp::DoFHandler objects. --- include/deal.II/dofs/dof_renumbering.h | 4 ++-- source/dofs/dof_renumbering.cc | 24 +++++++++++++----------- source/dofs/dof_renumbering.inst.in | 9 ++++++--- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/include/deal.II/dofs/dof_renumbering.h b/include/deal.II/dofs/dof_renumbering.h index 0b317cb18f..d94420c66e 100644 --- a/include/deal.II/dofs/dof_renumbering.h +++ b/include/deal.II/dofs/dof_renumbering.h @@ -832,9 +832,9 @@ namespace DoFRenumbering * have been produced by a previous call to a renumbering function is * ignored. */ - template + template void - hierarchical(DoFHandler &dof_handler); + hierarchical(DoFHandlerType &dof_handler); /** * Renumber degrees of freedom by cell. The function takes a vector of cell diff --git a/source/dofs/dof_renumbering.cc b/source/dofs/dof_renumbering.cc index 1e5ae0e447..6f1616d58f 100644 --- a/source/dofs/dof_renumbering.cc +++ b/source/dofs/dof_renumbering.cc @@ -1246,7 +1246,7 @@ namespace DoFRenumbering namespace { - // Helper function for DoFRenumbering::hierarchical(). this function + // Helper function for DoFRenumbering::hierarchical(). This function // recurses into the given cell or, if that should be an active (terminal) // cell, renumbers DoF indices on it. The function starts renumbering with // 'next_free_dof_index' and returns the first still unused DoF index at the @@ -1341,10 +1341,13 @@ namespace DoFRenumbering - template + template void - hierarchical(DoFHandler &dof_handler) + hierarchical(DoFHandlerType &dof_handler) { + const int dim = DoFHandlerType::dimension; + const int spacedim = DoFHandlerType::space_dimension; + std::vector renumbering( dof_handler.n_locally_owned_dofs(), numbers::invalid_dof_index); @@ -1364,8 +1367,8 @@ namespace DoFRenumbering // DoFs for all previous processes types::global_dof_index my_starting_index = 0; - if (const parallel::Triangulation *tria = - dynamic_cast *>( + if (const parallel::Triangulation *tria = + dynamic_cast *>( &dof_handler.get_triangulation())) { const std::vector @@ -1378,9 +1381,9 @@ namespace DoFRenumbering types::global_dof_index(0)); } - if (const parallel::distributed::Triangulation *tria = - dynamic_cast *>( - &dof_handler.get_triangulation())) + if (const parallel::distributed::Triangulation *tria = + dynamic_cast + *>(&dof_handler.get_triangulation())) { #ifdef DEAL_II_WITH_P4EST // this is a distributed Triangulation. we need to traverse the coarse @@ -1392,7 +1395,7 @@ namespace DoFRenumbering const unsigned int coarse_cell_index = tria->get_p4est_tree_to_coarse_cell_permutation()[c]; - const typename DoFHandler::level_cell_iterator this_cell( + const typename DoFHandlerType::level_cell_iterator this_cell( tria, 0, coarse_cell_index, &dof_handler); next_free_dof_offset = @@ -1410,8 +1413,7 @@ namespace DoFRenumbering { // this is not a distributed Triangulation, so we can traverse coarse // cells in the normal order - for (typename DoFHandler::cell_iterator cell = - dof_handler.begin(0); + for (typename DoFHandlerType::cell_iterator cell = dof_handler.begin(0); cell != dof_handler.end(0); ++cell) next_free_dof_offset = diff --git a/source/dofs/dof_renumbering.inst.in b/source/dofs/dof_renumbering.inst.in index 1422db062a..f7667f4b83 100644 --- a/source/dofs/dof_renumbering.inst.in +++ b/source/dofs/dof_renumbering.inst.in @@ -67,6 +67,12 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) const DoFHandler &dof_handler); + template void + hierarchical(DoFHandler &); + + template void + hierarchical( + hp::DoFHandler &); \} #endif } @@ -168,9 +174,6 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) block_wise(DoFHandler &, unsigned int); - template void - hierarchical(DoFHandler &); - template void cell_wise>( DoFHandler &, -- 2.39.5